[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 11/17] qapi: centralize the built-in module name definition
From: |
John Snow |
Subject: |
[PATCH v3 11/17] qapi: centralize the built-in module name definition |
Date: |
Tue, 19 Jan 2021 13:02:36 -0500 |
Use a constant to make it obvious we're referring to a very specific thing.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/schema.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index c519c18a5ec..887a1c82c6f 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -68,7 +68,7 @@ def check_doc(self):
def _set_module(self, schema, info):
assert self._checked
- fname = info.fname if info else './builtin'
+ fname = info.fname if info else QAPISchemaModule.BUILTIN_MODULE_NAME
self._module = schema.module_by_fname(fname)
self._module.add_entity(self)
@@ -138,6 +138,9 @@ def visit_event(self, name, info, ifcond, features,
arg_type, boxed):
class QAPISchemaModule:
+
+ BUILTIN_MODULE_NAME = './builtin'
+
def __init__(self, name):
self.name = name
self._entity_list = []
@@ -152,7 +155,7 @@ def is_user_module(cls, name: str) -> bool:
@classmethod
def is_builtin_module(cls, name: str) -> bool:
- return name == './builtin'
+ return name == cls.BUILTIN_MODULE_NAME
@property
def system_module(self) -> bool:
@@ -850,7 +853,7 @@ def __init__(self, fname):
self._entity_dict = {}
self._module_dict = OrderedDict()
self._schema_dir = os.path.dirname(fname)
- self._make_module('./builtin') # built-ins
+ self._make_module(QAPISchemaModule.BUILTIN_MODULE_NAME) # built-ins
self._make_module(fname)
self._predefining = True
self._def_predefineds()
--
2.26.2
- Re: [PATCH v3 06/17] qapi: centralize is_[user|system|builtin]_module methods, (continued)
[PATCH v3 07/17] qapi/gen: Replace ._begin_system_module(), John Snow, 2021/01/19
[PATCH v3 11/17] qapi: centralize the built-in module name definition,
John Snow <=
[PATCH v3 04/17] qapi/gen: inline _wrap_ifcond into end_if(), John Snow, 2021/01/19
[PATCH v3 12/17] qapi/gen: write _genc/_genh access shims, John Snow, 2021/01/19
[PATCH v3 16/17] qapi: type 'info' as Optional[QAPISourceInfo], John Snow, 2021/01/19
[PATCH v3 10/17] qapi/gen: Combine ._add_[user|system]_module, John Snow, 2021/01/19
[PATCH v3 02/17] qapi/events: fix visit_event typing, John Snow, 2021/01/19
[PATCH v3 09/17] qapi: use './builtin' as the built-in module name, John Snow, 2021/01/19