From 4895cde29761f6c39fdb6c319ff4666ee39f5d28 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 18 Apr 2017 21:39:25 +0100 Subject: gdb_xml_parser: make data fields private and make more functions methods This patch makes the data fields of gdb_xml_parser private, and makes more functions be gdb_xml_parser methods. This is mostly for better encapsulation. Some free functions have their parsing-related guts converted to methods, while the free functions remain, as they're used as expat callbacks. Now their only job is to be small shims that restore back the gdb_xml_parser type, defer work to the corresponding method, and make sure C++ exceptions don't cross expat. More C++-fycation of the XML parsers built on top of gdb_xml_parser could follow, but this was my stopping point. gdb/ChangeLog: 2017-04-18 Pedro Alves * xml-support.c (gdb_xml_parser) : New methods. : Make private and add m_ prefix. (gdb_xml_parser::body_text): New method, based on ... (gdb_xml_body_text): ... this. Adjust. (gdb_xml_parser::vdebug): New method, based on ... (gdb_xml_debug): ... this. Adjust. (gdb_xml_parser::verror): New method, based on ... (gdb_xml_error): ... this. Adjust. (gdb_xml_parser::start_element): New method, based on ... (gdb_xml_start_element): ... this. Adjust. (gdb_xml_start_element_wrapper): Defer to gdb_xml_parser::start_element and gdb_xml_parser::set_error. (gdb_xml_parser::end_element): New method, based on ... (gdb_xml_end_element_wrapper): ... this. Adjust. (gdb_xml_parser::~gdb_xml_parser): Adjust. (gdb_xml_parser::gdb_xml_parser): Adjust to field renames. (gdb_xml_parser::use_dtd): New method, based on ... (gdb_xml_use_dtd): ... this. Adjust. (gdb_xml_parser::parse): New method, based on ... (gdb_xml_parse): ... this. Adjust. (gdb_xml_parse_quick): Adjust to call the parser's parse method. (xinclude_start_include): Adjust to call the parser's name method. (xml_xinclude_default, xml_xinclude_start_doctype) (xml_xinclude_end_doctype): Adjust to call the parser's user_data method. (xml_process_xincludes): Adjust to call parser methods. * xml-support.h (gdb_xml_use_dtd, gdb_xml_parse): Delete declarations. --- gdb/xml-support.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'gdb/xml-support.h') diff --git a/gdb/xml-support.h b/gdb/xml-support.h index 8248a32..f9ea64d 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -172,20 +172,6 @@ struct gdb_xml_element gdb_xml_element_end_handler *end_handler; }; -/* Associate DTD_NAME, which must be the name of a compiled-in DTD, - with PARSER. */ - -void gdb_xml_use_dtd (struct gdb_xml_parser *parser, const char *dtd_name); - -/* Invoke PARSER on BUFFER. BUFFER is the data to parse, which - should be NUL-terminated. - - The return value is 0 for success or -1 for error. It may throw, - but only if something unexpected goes wrong during parsing; parse - errors will be caught, warned about, and reported as failure. */ - -int gdb_xml_parse (struct gdb_xml_parser *parser, const char *buffer); - /* Parse a XML document. DOCUMENT is the data to parse, which should be NUL-terminated. If non-NULL, use the compiled-in DTD named DTD_NAME to drive the parsing. -- cgit v1.1