diff options
author | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:46 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:46 +0000 |
commit | aaee65aea29ac8f7317e866d5dbef9f96cfdb253 (patch) | |
tree | 57f18e9d5f250a7c7b8f974850dcd8676705fdae /gdb/compile/compile-internal.h | |
parent | 3d8b0d9483f6eabc2c1739ac3dd64c30061a6a72 (diff) | |
download | binutils-aaee65aea29ac8f7317e866d5dbef9f96cfdb253.zip binutils-aaee65aea29ac8f7317e866d5dbef9f96cfdb253.tar.gz binutils-aaee65aea29ac8f7317e866d5dbef9f96cfdb253.tar.bz2 |
Use ui_file_as_string in gdb/compile/
Using ui_file_as_string would imply changing a few prototypes to pass
around source and object file names as std::string. Instead of that,
wrap those two in a new class. This ends up eliminating a small
wrinkle: get_new_file_names and compile_object_load have swapped
parameters. The former takes "source, objfile", while the latter
takes "objfile, source".
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* c-lang.h (c_compute_program): Now returns std::string.
* compile/compile-internal.h (class compile_file_names): New
class.
* compile/compile-object-load.c (compile_object_load): Replace
object_file and source_file parameters with a compile_file_names
parameter. Adjust.
* compile-object-load.h: Include "compile-internal.h".
(compile_object_load): Replace object_file and source_file
parameters with a compile_file_names parameter.
* compile/compile-c-support.c (c_compute_program): Now returns a
std::string. Use ui_file_as_string.
* compile/compile.c (get_new_file_names): Remove parameters and
return a compile_file_names instead.
(compile_to_object): Now returns a compile_file_names. Use
ui_file_as_string.
(eval_compile_command): Use compile_file_names.
* language.h (struct language_defn) <la_compute_program>: Now
returns std::string.
Diffstat (limited to 'gdb/compile/compile-internal.h')
-rw-r--r-- | gdb/compile/compile-internal.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/compile/compile-internal.h b/gdb/compile/compile-internal.h index 66ea864..5a7bf14 100644 --- a/gdb/compile/compile-internal.h +++ b/gdb/compile/compile-internal.h @@ -152,4 +152,29 @@ extern const char *c_get_mode_for_size (int size); struct dynamic_prop; extern char *c_get_range_decl_name (const struct dynamic_prop *prop); +/* Type used to hold and pass around the source and object file names + to use for compilation. */ +class compile_file_names +{ +public: + compile_file_names (std::string source_file, std::string object_file) + : m_source_file (source_file), m_object_file (object_file) + {} + + /* Provide read-only views only. Return 'const char *' instead of + std::string to avoid having to use c_str() everywhere in client + code. */ + + const char *source_file () const + { return m_source_file.c_str (); } + + const char *object_file () const + { return m_object_file.c_str (); } + +private: + /* Storage for the file names. */ + std::string m_source_file; + std::string m_object_file; +}; + #endif /* GDB_COMPILE_INTERNAL_H */ |