public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/7] gdb: Convert language la_printchar field to a method
Date: Thu, 18 Jun 2020 23:31:51 +0100	[thread overview]
Message-ID: <146e5696e117eb31b24f0fb89c8ae6165685e6d5.1592519094.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1592519094.git.andrew.burgess@embecosm.com>

This commit changes the language_data::la_printchar 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_language_data): Delete la_printchar initializer.
	(ada_language::printchar): New member function.
	* c-lang.c (c_language_data): Delete la_printchar initializer.
	(cplus_language_data): Likewise.
	(asm_language_data): Likewise.
	(minimal_language_data): Likewise.
	* d-lang.c (d_language_data): Likewise.
	* f-lang.c (f_printchar): Rename to f_language::printchar.
	(f_language_data): Delete la_printchar initializer.
	(f_language::printchar): New member function, implementation from
	f_printchar.
	* go-lang.c (go_language_data): Delete la_printchar initializer.
	* language.c (unk_lang_printchar): Delete.
	(language_defn::printchar): Define new member function.
	(unknown_language_data): Delete la_printchar initializer.
	(unknown_language::printchar): New member function.
	(auto_language_data): Delete la_printchar initializer.
	(auto_language::printchar): New member function.
	* language.h (language_data): Delete la_printchar field.
	(language_defn::printchar): Declare new member function.
	(LA_PRINT_CHAR): Update call to printchar.
	* m2-lang.c (m2_language_data): Delete la_printchar initializer.
	(m2_language::printchar): New member function.
	* objc-lang.c (objc_language_data): Delete la_printchar
	initializer.
	* opencl-lang.c (opencl_language_data): Likewise.
	* p-lang.c (pascal_language_data): Delete la_printchar
	initializer.
	(pascal_language::printchar): New member function.
	* rust-lang.c (rust_printchar): Rename to
	rust_language::printchar.
	(rust_language_data): Delete la_printchar initializer.
	(rust_language::printchar): New member function, implementation
	from rust_printchar.
---
 gdb/ChangeLog     | 37 +++++++++++++++++++++++++++++++++++++
 gdb/ada-lang.c    |  9 ++++++++-
 gdb/c-lang.c      |  4 ----
 gdb/d-lang.c      |  1 -
 gdb/f-lang.c      | 23 ++++++++++-------------
 gdb/go-lang.c     |  1 -
 gdb/language.c    | 37 +++++++++++++++++++++++++------------
 gdb/language.h    |  8 ++++----
 gdb/m2-lang.c     |  9 ++++++++-
 gdb/objc-lang.c   |  1 -
 gdb/opencl-lang.c |  1 -
 gdb/p-lang.c      | 10 +++++++++-
 gdb/rust-lang.c   | 21 ++++++++++-----------
 13 files changed, 111 insertions(+), 51 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7858679f5bc..e69c3cbf50c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13681,7 +13681,6 @@ extern const struct language_data ada_language_data =
   macro_expansion_no,
   ada_extensions,
   &ada_exp_descriptor,
-  ada_printchar,                /* Print a character constant */
   ada_printstr,                 /* Function to print string constant */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   NULL,                         /* name_of_this */
@@ -14115,6 +14114,14 @@ class ada_language : public language_defn
     ada_emit_char (ch, chtype, stream, quoter, 1);
   }
 
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    ada_printchar (ch, chtype, stream);
+  }
+
 protected:
   /* See language.h.  */
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index fbd564d0415..f7b1b80cd56 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -889,7 +889,6 @@ extern const struct language_data c_language_data =
   macro_expansion_c,
   c_extensions,
   &exp_descriptor_c,
-  c_printchar,			/* Print a character constant */
   c_printstr,			/* Function to print string constant */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
@@ -994,7 +993,6 @@ extern const struct language_data cplus_language_data =
   macro_expansion_c,
   cplus_extensions,
   &exp_descriptor_c,
-  c_printchar,			/* Print a character constant */
   c_printstr,			/* Function to print string constant */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   "this",                       /* name_of_this */
@@ -1196,7 +1194,6 @@ extern const struct language_data asm_language_data =
   macro_expansion_c,
   asm_extensions,
   &exp_descriptor_c,
-  c_printchar,			/* Print a character constant */
   c_printstr,			/* Function to print string constant */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
@@ -1256,7 +1253,6 @@ extern const struct language_data minimal_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_c,
-  c_printchar,			/* Print a character constant */
   c_printstr,			/* Function to print string constant */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index fa6df337389..f76b74f18b4 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -142,7 +142,6 @@ extern const struct language_data d_language_data =
   macro_expansion_no,
   d_extensions,
   &exp_descriptor_c,
-  c_printchar,			/* Print a character constant.  */
   c_printstr,			/* Function to print string constant.  */
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 90b2e861286..68d0a4e6d0c 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -41,8 +41,6 @@
 
 /* Local functions */
 
-static void f_printchar (int c, struct type *type, struct ui_file * stream);
-
 /* Return the encoding that should be used for the character type
    TYPE.  */
 
@@ -70,16 +68,6 @@ f_get_encoding (struct type *type)
   return encoding;
 }
 
-/* Implementation of la_printchar.  */
-
-static void
-f_printchar (int c, struct type *type, struct ui_file *stream)
-{
-  fputs_filtered ("'", stream);
-  LA_EMIT_CHAR (c, type, stream, '\'');
-  fputs_filtered ("'", stream);
-}
-
 /* Print the character string STRING, printing at most LENGTH characters.
    Printing stops early if the number hits print_max; repeat counts
    are printed as appropriate.  Print ellipses at the end if we
@@ -548,7 +536,6 @@ extern const struct language_data f_language_data =
   macro_expansion_no,
   f_extensions,
   &exp_descriptor_f,
-  f_printchar,			/* Print character constant */
   f_printstr,			/* function to print string constant */
   f_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,                    	/* name_of_this */
@@ -710,6 +697,16 @@ class f_language : public language_defn
     generic_emit_char (ch, chtype, stream, quoter, encoding);
   }
 
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    fputs_filtered ("'", stream);
+    LA_EMIT_CHAR (ch, chtype, stream, '\'');
+    fputs_filtered ("'", stream);
+  }
+
 protected:
 
   /* See language.h.  */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index f167543278a..819780bc30e 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -527,7 +527,6 @@ extern const struct language_data go_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_c,
-  c_printchar,			/* Print a character constant.  */
   c_printstr,			/* Function to print string constant.  */
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
diff --git a/gdb/language.c b/gdb/language.c
index 6778646becd..34990e040cd 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -49,9 +49,6 @@
 
 static void set_range_case (void);
 
-static void unk_lang_printchar (int c, struct type *type,
-				struct ui_file *stream);
-
 /* The current (default at startup) state of type and range checking.
    (If the modes are set to "auto", though, these are changed based
    on the default language at startup, and then again based on the
@@ -663,6 +660,15 @@ language_defn::emitchar (int ch, struct type *chtype,
   c_emit_char (ch, chtype, stream, quoter);
 }
 
+/* See language.h.  */
+
+void
+language_defn::printchar (int ch, struct type *chtype,
+			  struct ui_file * stream) const
+{
+  c_printchar (ch, chtype, stream);
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -728,13 +734,6 @@ default_is_string_type_p (struct type *type)
   return (type->code ()  == TYPE_CODE_STRING);
 }
 
-static void
-unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
-{
-  error (_("internal error - unimplemented "
-	   "function unk_lang_printchar called."));
-}
-
 static void
 unk_lang_printstr (struct ui_file *stream, struct type *type,
 		   const gdb_byte *string, unsigned int length,
@@ -773,7 +772,6 @@ extern const struct language_data unknown_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  unk_lang_printchar,		/* Print character constant */
   unk_lang_printstr,
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   "this",        	    	/* name_of_this */
@@ -851,6 +849,14 @@ class unknown_language : public language_defn
   {
     error (_("unimplemented unknown_language::emitchar called"));
   }
+
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    error (_("unimplemented unknown_language::printchar called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -870,7 +876,6 @@ extern const struct language_data auto_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  unk_lang_printchar,		/* Print character constant */
   unk_lang_printstr,
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   "this",		        /* name_of_this */
@@ -948,6 +953,14 @@ class auto_language : public language_defn
   {
     error (_("unimplemented auto_language::emitchar called"));
   }
+
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    error (_("unimplemented auto_language::printchar called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
diff --git a/gdb/language.h b/gdb/language.h
index 612afb3c5f1..fc9efd89939 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -225,9 +225,6 @@ struct language_data
 
     const struct exp_descriptor *la_exp_desc;
 
-    void (*la_printchar) (int ch, struct type *chtype,
-			  struct ui_file * stream);
-
     void (*la_printstr) (struct ui_file * stream, struct type *elttype,
 			 const gdb_byte *string, unsigned int length,
 			 const char *encoding, int force_ellipses,
@@ -547,6 +544,9 @@ struct language_defn : language_data
   virtual void emitchar (int ch, struct type *chtype,
 			 struct ui_file *stream, int quoter) const;
 
+  virtual void printchar (int ch, struct type *chtype,
+			  struct ui_file * stream) const;
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
@@ -649,7 +649,7 @@ extern enum language set_language (enum language);
   (current_language->value_print (val,stream,options))
 
 #define LA_PRINT_CHAR(ch, type, stream) \
-  (current_language->la_printchar(ch, type, stream))
+  (current_language->printchar (ch, type, stream))
 #define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses, options) \
   (current_language->la_printstr(stream, elttype, string, length, \
 				 encoding, force_ellipses,options))
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index d8f7f005280..bdb1a460aea 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -309,7 +309,6 @@ extern const struct language_data m2_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_modula2,
-  m2_printchar,			/* Print character constant */
   m2_printstr,			/* function to print string constant */
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,		                /* name_of_this */
@@ -426,6 +425,14 @@ class m2_language : public language_defn
 	  }
       }
   }
+
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    m2_printchar (ch, chtype, stream);
+  }
 };
 
 /* Single instance of the M2 language.  */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index ffde14a97aa..736c8684523 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -337,7 +337,6 @@ extern const struct language_data objc_language_data =
   macro_expansion_c,
   objc_extensions,
   &exp_descriptor_standard,
-  c_printchar,		       /* Print a character constant */
   c_printstr,		       /* Function to print string constant */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   "self",		        /* name_of_this */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 3789c211ca0..d66f3f8aec3 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1016,7 +1016,6 @@ extern const struct language_data opencl_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_opencl,
-  c_printchar,			/* Print a character constant */
   c_printstr,			/* Function to print string constant */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,                         /* name_of_this */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index b0465f4a355..b8c99c4650f 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -376,7 +376,6 @@ extern const struct language_data pascal_language_data =
   macro_expansion_no,
   p_extensions,
   &exp_descriptor_standard,
-  pascal_printchar,		/* Print a character constant */
   pascal_printstr,		/* Function to print string constant */
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
   "this",		        /* name_of_this */
@@ -491,6 +490,15 @@ class pascal_language : public language_defn
     if (in_quotes)
       fputs_filtered ("'", stream);
   }
+
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    pascal_printchar (ch, chtype, stream);
+  }
+
 };
 
 /* Single instance of the Pascal language class.  */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 2d6cb8bf0b1..36e26179f34 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -281,16 +281,6 @@ rust_get_trait_object_pointer (struct value *value)
 
 \f
 
-/* la_printchar implementation for Rust.  */
-
-static void
-rust_printchar (int c, struct type *type, struct ui_file *stream)
-{
-  fputs_filtered ("'", stream);
-  LA_EMIT_CHAR (c, type, stream, '\'');
-  fputs_filtered ("'", stream);
-}
-
 /* la_printstr implementation for Rust.  */
 
 static void
@@ -1963,7 +1953,6 @@ extern const struct language_data rust_language_data =
   macro_expansion_no,
   rust_extensions,
   &exp_descriptor_rust,
-  rust_printchar,		/* Print a character constant */
   rust_printstr,		/* Function to print string constant */
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
   NULL,				/* name_of_this */
@@ -2146,6 +2135,16 @@ class rust_language : public language_defn
     else
       fprintf_filtered (stream, "\\u{%06x}", ch);
   }
+
+  /* See language.h.  */
+
+  void printchar (int ch, struct type *chtype,
+		  struct ui_file *stream) const override
+  {
+    fputs_filtered ("'", stream);
+    LA_EMIT_CHAR (ch, chtype, stream, '\'');
+    fputs_filtered ("'", stream);
+  }
 };
 
 /* Single instance of the Rust language class.  */
-- 
2.25.4


  parent reply	other threads:[~2020-06-18 22:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 22:31 [PATCH 0/7] Language Class Hierarchy Conversion (Prt 3) Andrew Burgess
2020-06-18 22:31 ` [PATCH 1/7] gdb: Convert language la_parser field to a method Andrew Burgess
2020-06-18 22:31 ` [PATCH 2/7] gdb: Convert language la_post_parser " Andrew Burgess
2020-06-18 22:31 ` [PATCH 3/7] gdb: Convert language la_emitchar " Andrew Burgess
2020-06-18 22:31 ` Andrew Burgess [this message]
2020-06-18 22:31 ` [PATCH 5/7] gdb: Convert language la_printstr " Andrew Burgess
2020-06-18 22:31 ` [PATCH 6/7] gdb: Convert language la_print_typedef " Andrew Burgess
2020-06-18 22:31 ` [PATCH 7/7] gdb: Convert language la_is_string_type_p " Andrew Burgess
2020-06-19 14:25 ` [PATCH 0/7] Language Class Hierarchy Conversion (Prt 3) Tom Tromey
2020-06-19 16:18   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=146e5696e117eb31b24f0fb89c8ae6165685e6d5.1592519094.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).