public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: gdbarch.py: spell out parameters of _Component.__init__
@ 2023-02-27 18:29 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2023-02-27 18:29 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c4e1b10cc2e84eaf574842907e4c35ad51eb5792

commit c4e1b10cc2e84eaf574842907e4c35ad51eb5792
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Sun Feb 26 20:13:56 2023 -0500

    gdb: gdbarch.py: spell out parameters of _Component.__init__
    
    The way _Component uses kwargs is handy to save a few characters, but it
    doesn't play well with static analysis.  When editing gdbarch.py, my
    editor (which uses pylance under the hood) knows nothing about the
    properties of components.  So it's full of squiggly lines, and typing
    analysis (which I find really helpful) doesn't work.  I therefore think
    it would be better to spell out the parameters.
    
    Change-Id: Iaf561beb0d0fbe170ce1c79252a291e0945e1830
    Reviewed-By: Tom Tromey <tom@tromey.com>
    Reviewed-By: Andrew Burgess <aburgess@redhat.com>

Diff:
---
 gdb/gdbarch.py | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index 68c7bbae661..63c3aee1dc0 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -49,9 +49,34 @@ def join_params(params):
 class _Component:
     "Base class for all components."
 
-    def __init__(self, **kwargs):
-        for key in kwargs:
-            setattr(self, key, kwargs[key])
+    def __init__(
+        self,
+        name,
+        type,
+        printer,
+        comment=None,
+        predicate=False,
+        predefault=None,
+        postdefault=None,
+        invalid=None,
+        params=None,
+        param_checks=None,
+        result_checks=None,
+        implement=True,
+    ):
+        self.name = name
+        self.type = type
+        self.printer = printer
+        self.comment = comment
+        self.predicate = predicate
+        self.predefault = predefault
+        self.postdefault = postdefault
+        self.invalid = invalid
+        self.params = params
+        self.param_checks = param_checks
+        self.result_checks = result_checks
+        self.implement = implement
+
         components.append(self)
 
         # It doesn't make sense to have a check of the result value
@@ -87,7 +112,7 @@ class Value(_Component):
         name,
         type,
         comment=None,
-        predicate=None,
+        predicate=False,
         predefault=None,
         postdefault=None,
         invalid=None,
@@ -115,7 +140,7 @@ class Function(_Component):
         type,
         params,
         comment=None,
-        predicate=None,
+        predicate=False,
         predefault=None,
         postdefault=None,
         invalid=None,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-27 18:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27 18:29 [binutils-gdb] gdb: gdbarch.py: spell out parameters of _Component.__init__ Simon Marchi

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).