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 <palves@redhat.com>
* xml-support.c (gdb_xml_parser) <use_dtd, dtd_name, parse,
vdebug, verror, body_text, start_element, end_element, name,
user_data, set_is_xinclude, set_error, expat_parser>: New methods.
<name, user_data, expat_parser, scopes, error, last_line, dtd_name,
is_xinclude>: 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.