gdb: Convert language la_word_break_characters field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 1 Jun 2020 13:40:22 +0000 (14:40 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 17 Jun 2020 08:25:10 +0000 (09:25 +0100)
This commit changes the language_data::la_word_break_characters
function pointer member variable into a member function of
language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_get_gdb_completer_word_break_characters): Delete.
(ada_language_data): Delete la_word_break_characters initializer.
(ada_language::word_break_characters): New member function.
* c-lang.c (c_language_data): Delete la_word_break_characters
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* completer.c: Update global comment.
(advance_to_expression_complete_word_point): Update call to
word_break_characters.
(complete_files_symbols): Likewise.
(complete_line_internal_1): Likewise.
(default_completer_handle_brkchars): Likewise.
(skip_quoted_chars): Likewise.
* d-lang.c (d_language_data): Delete la_word_break_characters
initializer.
* f-lang.c (f_word_break_characters): Delete.
(f_language_data): Delete la_word_break_characters initializer.
(f_language::word_break_characters): New member function.
* go-lang.c (go_language_data): Delete la_word_break_characters
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (default_word_break_characters): Move declaration to
earlier in the file.
(language_data): Delete la_word_break_characters field.
(language_defn::word_break_characters): New member function.
* m2-lang.c (m2_language_data): Delete la_word_break_characters
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.

14 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/completer.c
gdb/d-lang.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c

index 0cb660fa812d09de33d2ef317322a9afd52cf787..18c608b03c2bdadba98c2f51ebab0cd4f48987de 100644 (file)
@@ -1,3 +1,40 @@
+2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_get_gdb_completer_word_break_characters): Delete.
+       (ada_language_data): Delete la_word_break_characters initializer.
+       (ada_language::word_break_characters): New member function.
+       * c-lang.c (c_language_data): Delete la_word_break_characters
+       initializer.
+       (cplus_language_data): Likewise.
+       (asm_language_data): Likewise.
+       (minimal_language_data): Likewise.
+       * completer.c: Update global comment.
+       (advance_to_expression_complete_word_point): Update call to
+       word_break_characters.
+       (complete_files_symbols): Likewise.
+       (complete_line_internal_1): Likewise.
+       (default_completer_handle_brkchars): Likewise.
+       (skip_quoted_chars): Likewise.
+       * d-lang.c (d_language_data): Delete la_word_break_characters
+       initializer.
+       * f-lang.c (f_word_break_characters): Delete.
+       (f_language_data): Delete la_word_break_characters initializer.
+       (f_language::word_break_characters): New member function.
+       * go-lang.c (go_language_data): Delete la_word_break_characters
+       initializer.
+       * language.c (unknown_language_data): Likewise.
+       (auto_language_data): Likewise.
+       * language.h (default_word_break_characters): Move declaration to
+       earlier in the file.
+       (language_data): Delete la_word_break_characters field.
+       (language_defn::word_break_characters): New member function.
+       * m2-lang.c (m2_language_data): Delete la_word_break_characters
+       initializer.
+       * objc-lang.c (objc_language_data): Likewise.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       * rust-lang.c (rust_language_data): Likewise.
+
 2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_get_symbol_name_matcher): Update header comment.
index c91597e6406607ac45d3ec40fd3ef4c57d2b05fa..137f4a9b5bdc3e62e008be9fc6680cc62a2b5b2c 100644 (file)
@@ -488,12 +488,6 @@ add_angle_brackets (const char *str)
   return string_printf ("<%s>", str);
 }
 
-static const char *
-ada_get_gdb_completer_word_break_characters (void)
-{
-  return ada_completer_word_break_characters;
-}
-
 /* la_watch_location_expression for Ada.  */
 
 static gdb::unique_xmalloc_ptr<char>
@@ -13917,7 +13911,6 @@ extern const struct language_data ada_language_data =
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
-  ada_get_gdb_completer_word_break_characters,
   ada_collect_symbol_completion_matches,
   ada_watch_location_expression,
   &ada_varobj_ops,
@@ -14105,6 +14098,13 @@ public:
     ada_print_type (type, varstring, stream, show, level, flags);
   }
 
+  /* See language.h.  */
+
+  const char *word_break_characters (void) const override
+  {
+    return ada_completer_word_break_characters;
+  }
+
 protected:
   /* See language.h.  */
 
index 8edab0779e81fb65c7ed27c81510fb02d0f3b627..79c4839bd9614edb253810690fa2782bc7fe3c84 100644 (file)
@@ -914,7 +914,6 @@ extern const struct language_data c_language_data =
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &c_varobj_ops,
@@ -1028,7 +1027,6 @@ extern const struct language_data cplus_language_data =
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &cplus_varobj_ops,
@@ -1230,7 +1228,6 @@ extern const struct language_data asm_language_data =
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
@@ -1299,7 +1296,6 @@ extern const struct language_data minimal_language_data =
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 1ec0a0ed4f1f79c8488e0a6e324ab2756fdebd2b..ea07096210f441336175b1b00d7f60ef3b06ac49 100644 (file)
@@ -155,7 +155,7 @@ enum explicit_location_match_type
    but it does affect how much stuff M-? lists.
    (2) If one of the matches contains a word break character, readline
    will quote it.  That's why we switch between
-   current_language->la_word_break_characters() and
+   current_language->word_break_characters () and
    gdb_completer_command_word_break_characters.  I'm not sure when
    we need this behavior (perhaps for funky characters in C++ 
    symbols?).  */
@@ -448,7 +448,7 @@ const char *
 advance_to_expression_complete_word_point (completion_tracker &tracker,
                                           const char *text)
 {
-  const char *brk_chars = current_language->la_word_break_characters ();
+  const char *brk_chars = current_language->word_break_characters ();
   return advance_to_completion_word (tracker, brk_chars, text);
 }
 
@@ -573,7 +573,7 @@ complete_files_symbols (completion_tracker &tracker,
          colon = p;
          symbol_start = p + 1;
        }
-      else if (strchr (current_language->la_word_break_characters(), *p))
+      else if (strchr (current_language->word_break_characters (), *p))
        symbol_start = p + 1;
     }
 
@@ -1348,7 +1348,7 @@ complete_line_internal_1 (completion_tracker &tracker,
      strings, which leaves out the '-' and '.' character used in some
      commands.  */
   set_rl_completer_word_break_characters
-    (current_language->la_word_break_characters());
+    (current_language->word_break_characters ());
 
   /* Decide whether to complete on a list of gdb commands or on
      symbols.  */
@@ -1964,7 +1964,7 @@ default_completer_handle_brkchars (struct cmd_list_element *ignore,
                                   const char *text, const char *word)
 {
   set_rl_completer_word_break_characters
-    (current_language->la_word_break_characters ());
+    (current_language->word_break_characters ());
 }
 
 /* See definition in completer.h.  */
@@ -2473,7 +2473,7 @@ skip_quoted_chars (const char *str, const char *quotechars,
     quotechars = gdb_completer_quote_characters;
 
   if (breakchars == NULL)
-    breakchars = current_language->la_word_break_characters();
+    breakchars = current_language->word_break_characters ();
 
   for (scan = str; *scan != '\0'; scan++)
     {
index 4842d4b9d6923e77703c479a4494e89da7c9d1cb..56feda1268f63e2bf668f21138a07830c06d68cb 100644 (file)
@@ -157,7 +157,6 @@ extern const struct language_data d_language_data =
   d_op_print_tab,              /* Expression operators for printing.  */
   1,                           /* C-style arrays.  */
   0,                           /* String lower bound.  */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 42e6c988f3d96d3fd79f8ddfe1ab6a6dba8c0ec6..27495cf63f109171bcd5e0049740ddb65aa41a61 100644 (file)
@@ -165,30 +165,6 @@ enum f_primitive_types {
   nr_f_primitive_types
 };
 
-/* Remove the modules separator :: from the default break list.  */
-
-static const char *
-f_word_break_characters (void)
-{
-  static char *retval;
-
-  if (!retval)
-    {
-      char *s;
-
-      retval = xstrdup (default_word_break_characters ());
-      s = strchr (retval, ':');
-      if (s)
-       {
-         char *last_char = &s[strlen (s) - 1];
-
-         *s = *last_char;
-         *last_char = 0;
-       }
-    }
-  return retval;
-}
-
 /* Consider the modules separator :: as a valid symbol name character
    class.  */
 
@@ -617,7 +593,6 @@ extern const struct language_data f_language_data =
   f_op_print_tab,              /* expression operators for printing */
   0,                           /* arrays are first-class (not c-style) */
   1,                           /* String lower bound */
-  f_word_break_characters,
   f_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
@@ -699,6 +674,30 @@ public:
     f_print_type (type, varstring, stream, show, level, flags);
   }
 
+  /* See language.h.  This just returns default set of word break
+     characters but with the modules separator `::' removed.  */
+
+  const char *word_break_characters (void) const override
+  {
+    static char *retval;
+
+    if (!retval)
+      {
+       char *s;
+
+       retval = xstrdup (language_defn::word_break_characters ());
+       s = strchr (retval, ':');
+       if (s)
+         {
+           char *last_char = &s[strlen (s) - 1];
+
+           *s = *last_char;
+           *last_char = 0;
+         }
+      }
+    return retval;
+  }
+
 protected:
 
   /* See language.h.  */
index 661cabbe54cd0adb88cc0b26b40857fea03e63eb..1b3372a774afa1aa61241435119df79e5fe97425 100644 (file)
@@ -542,7 +542,6 @@ extern const struct language_data go_language_data =
   go_op_print_tab,             /* Expression operators for printing.  */
   1,                           /* C-style arrays.  */
   0,                           /* String lower bound.  */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 363481bc9d50feadb1ecd6714a1a3f1fecbd7f90..167a68c920338db438f655b57b4b8d6bd3a7d297 100644 (file)
@@ -779,7 +779,6 @@ extern const struct language_data unknown_language_data =
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
@@ -852,7 +851,6 @@ extern const struct language_data auto_language_data =
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 7e5837fdef37a908c93fb0a015031bf08f0b9f4c..8c6f7e3fb13c4315fd60063e5ad0f037c9ce6ba9 100644 (file)
@@ -169,6 +169,9 @@ struct language_pass_by_ref_info
   bool destructible = true;
 };
 
+/* Splitting strings into words.  */
+extern const char *default_word_break_characters (void);
+
 /* Structure tying together assorted information about a language.
 
    As we move over from the old structure based languages to a class
@@ -316,9 +319,6 @@ struct language_data
     /* Index to use for extracting the first element of a string.  */
     char string_lower_bound;
 
-    /* The list of characters forming word boundaries.  */
-    const char *(*la_word_break_characters) (void);
-
     /* Add to the completion tracker all symbols which are possible
        completions for TEXT.  WORD is the entire command on which the
        completion is being made.  If CODE is TYPE_CODE_UNDEF, then all
@@ -529,6 +529,12 @@ struct language_defn : language_data
     return nullptr;
   }
 
+  /* The list of characters forming word boundaries.  */
+  virtual const char *word_break_characters (void) const
+  {
+    return default_word_break_characters ();
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 
@@ -691,9 +697,6 @@ extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc);
 extern char *language_demangle (const struct language_defn *current_language, 
                                const char *mangled, int options);
 
-/* Splitting strings into words.  */
-extern const char *default_word_break_characters (void);
-
 /* Return information about whether TYPE should be passed
    (and returned) by reference at the language level.  */
 struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
index 9245ebbeeae9cc2606ed3b97415f414dddc0be2b..331ad5a3e6ee8349fc65a4867f969bb39b395374 100644 (file)
@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
   m2_op_print_tab,             /* expression operators for printing */
   0,                           /* arrays are first-class (not c-style) */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 9a77f6cb96d8b8d3b503e00ca2491a5f85be11e5..3bd71896aef96047e725d256ec9b34835edaffce 100644 (file)
@@ -351,7 +351,6 @@ extern const struct language_data objc_language_data =
   objc_op_print_tab,           /* Expression operators for printing */
   1,                           /* C-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 377c550d5a68c9c3b00dcd514115b37c283c80b9..3f0fb1fa9484c0cf4f7e6728cfc71853af52b63b 100644 (file)
@@ -1030,7 +1030,6 @@ extern const struct language_data opencl_language_data =
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 189617afc06da60b5d5178919e3ea3e49ee5198e..22ed912c6f5df9f8045fa37e64e4c8d9d747d711 100644 (file)
@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
   pascal_op_print_tab,         /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_watch_location_expression,
   &default_varobj_ops,
index 3f187bdea50579eef530c0bb0d5a026eb387eb36..53d1ee2bc8456c0725c43d2fbcd33ca67643b4ee 100644 (file)
@@ -2062,7 +2062,6 @@ extern const struct language_data rust_language_data =
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
-  default_word_break_characters,
   default_collect_symbol_completion_matches,
   rust_watch_location_expression,
   &default_varobj_ops,