aboutsummaryrefslogtreecommitdiff
path: root/gdb/xml-support.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-09-14 11:12:55 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-09-14 11:30:58 -0400
commit8400a90d19c5c53f7100421c688fb896789048b9 (patch)
treedbf3aff829ab551c14a040ac7717e187d7417300 /gdb/xml-support.h
parentb1766e7ce88647c8002928aeb8a9f04048c494ae (diff)
downloadgdb-8400a90d19c5c53f7100421c688fb896789048b9.zip
gdb-8400a90d19c5c53f7100421c688fb896789048b9.tar.gz
gdb-8400a90d19c5c53f7100421c688fb896789048b9.tar.bz2
gdb: change xml_fetch_another a function_view
The xml_fetch_another is currently a plain function pointer type, with a `void *` baton parameter. To improve type-safety, change this to a function_view. Any required data is captured by a lambda at the call site. gdb/ChangeLog: * xml-support.h (xml_fetch_another): Change type to be a function_view. (xml_process_xincludes): Remove baton parameter. (xml_fetch_content_from_file): Change baton parameter to dirname. * xml-support.c (struct xinclude_parsing_data) <xinclude_parsing_data>: Remove baton parameter. <fetcher_baton>: Remove. (xinclude_start_include): Adjust. (xml_process_xincludes): Adjust. (xml_fetch_content_from_file): Replace baton parameter with dirname. * xml-syscall.c (syscall_parse_xml): Remove baton parameter. (xml_init_syscalls_info): Use a lambda. * xml-tdesc.c (tdesc_parse_xml): Remove baton parameter. (file_read_description_xml): Use a lambda. (fetch_available_features_from_target): Change baton parameter to target_ops. (target_read_description_xml): Use a lambda. (target_fetch_description_xml): Use a lambda. (string_read_description_xml): Update. Change-Id: I7ba4b8f5e97fc6a952c6c20ccc3be92a06cc2bd2
Diffstat (limited to 'gdb/xml-support.h')
-rw-r--r--gdb/xml-support.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index 7880aaa..429d9ca 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -25,6 +25,7 @@
#include "gdbsupport/xml-utils.h"
#include "gdbsupport/byte-vector.h"
#include "gdbsupport/gdb_optional.h"
+#include "gdbsupport/function-view.h"
struct gdb_xml_parser;
struct gdb_xml_element;
@@ -48,12 +49,12 @@ LONGEST xml_builtin_xfer_partial (const char *filename,
/* Callback to fetch a new XML file, based on the provided HREF. */
-typedef gdb::optional<gdb::char_vector> (*xml_fetch_another) (const char *href,
- void *baton);
+using xml_fetch_another = gdb::function_view<gdb::optional<gdb::char_vector>
+ (const char * /* href */)>;
/* Append the expansion of TEXT after processing <xi:include> tags in
- RESULT. FETCHER will be called (with FETCHER_BATON) to retrieve
- any new files. DEPTH should be zero on the initial call.
+ RESULT. FETCHER will be called to retrieve any new files. DEPTH
+ should be zero on the initial call.
On failure, this function uses NAME in a warning and returns false.
It may throw an exception, but does not for XML parsing
@@ -61,8 +62,7 @@ typedef gdb::optional<gdb::char_vector> (*xml_fetch_another) (const char *href,
bool xml_process_xincludes (std::string &result,
const char *name, const char *text,
- xml_fetch_another fetcher, void *fetcher_baton,
- int depth);
+ xml_fetch_another fetcher, int depth);
/* Simplified XML parser infrastructure. */
@@ -231,6 +231,6 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
and warn. */
extern gdb::optional<gdb::char_vector> xml_fetch_content_from_file
- (const char *filename, void *baton);
+ (const char *filename, const char *dirname);
#endif