aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/shibokenmodule/files.dir
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-09-21 18:34:13 +0200
committerChristian Tismer <tismer@stackless.com>2019-09-28 00:15:57 +0200
commitb4989b9c2b33772f23dd5f9763622e6fd3cf41a8 (patch)
treefee1717e5d8bdb1267ed7f7432fc09be67c6b024 /sources/shiboken2/shibokenmodule/files.dir
parent94023741a3d0377b5a39914646bc06b06f6fa548 (diff)
Enable the Function Registry for 5.14
The function registry was not enabled for versions greater than 5.12 . This is now needed, since the function registry will be used in the tests for the improved NumPy support. There were new cases of Python keywords touched by enums which had to be renamed. This was moved into the code generator instead of the runtime overhead. The formatting of the enums was rewritten and reports all enums now that can be found (also those which are copied into the parent class). The formatting of the function registry had not been used for a long time and had entries that showed the wrong number of subclasses. The usage of the registry was also simplified by using the full names of functions. They can now directly be accessed. Task-number: PYSIDE-795 Change-Id: I734f6811205f3c3528a911975677eb677fedd2dd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/shibokenmodule/files.dir')
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py63
1 files changed, 34 insertions, 29 deletions
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
index b84a20e16..2e4d67186 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
@@ -84,6 +84,7 @@ class ExactEnumerator(object):
def module(self, mod_name):
__import__(mod_name)
+ self.fmt.mod_name = mod_name
with self.fmt.module(mod_name):
module = sys.modules[mod_name]
members = inspect.getmembers(module, inspect.isclass)
@@ -93,7 +94,7 @@ class ExactEnumerator(object):
for class_name, klass in members:
ret.update(self.klass(class_name, klass))
if isinstance(klass, EnumType):
- self.enum(klass)
+ raise SystemError("implement enum instances at module level")
for func_name, func in functions:
ret.update(self.function(func_name, func))
return ret
@@ -114,26 +115,41 @@ class ExactEnumerator(object):
name = modname + "." + base.__name__
bases_list.append(name)
class_str = "{}({})".format(class_name, ", ".join(bases_list))
- with self.fmt.klass(class_name, class_str):
- ret = self.result_type()
- # class_members = inspect.getmembers(klass)
- # gives us also the inherited things.
- class_members = sorted(list(klass.__dict__.items()))
- subclasses = []
- functions = []
- for thing_name, thing in class_members:
- if inspect.isclass(thing):
- subclass_name = ".".join((class_name, thing_name))
- subclasses.append((subclass_name, thing))
- elif inspect.isroutine(thing):
- func_name = thing_name.split(".")[0] # remove ".overload"
+ ret = self.result_type()
+ # class_members = inspect.getmembers(klass)
+ # gives us also the inherited things.
+ class_members = sorted(list(klass.__dict__.items()))
+ subclasses = []
+ functions = []
+ enums = []
+
+ for thing_name, thing in class_members:
+ if inspect.isclass(thing):
+ subclass_name = ".".join((class_name, thing_name))
+ subclasses.append((subclass_name, thing))
+ elif inspect.isroutine(thing):
+ func_name = thing_name.split(".")[0] # remove ".overload"
+ signature = getattr(thing, "__signature__", None)
+ if signature is not None:
functions.append((func_name, thing))
+ elif type(type(thing)) is EnumType:
+ enums.append((thing_name, thing))
+ init_signature = getattr(klass, "__signature__", None)
+ enums.sort(key=lambda tup: tup[1]) # sort by enum value
+ self.fmt.have_body = bool(subclasses or functions or enums or init_signature)
+
+ with self.fmt.klass(class_name, class_str):
self.fmt.level += 1
+ self.fmt.class_name = class_name
+ if hasattr(self.fmt, "enum"):
+ # this is an optional feature
+ for enum_name, value in enums:
+ with self.fmt.enum(class_name, enum_name, int(value)):
+ pass
for subclass_name, subclass in subclasses:
ret.update(self.klass(subclass_name, subclass))
- if isinstance(subclass, EnumType):
- self.enum(subclass)
- ret = self.function("__init__", klass)
+ self.fmt.class_name = class_name
+ ret.update(self.function("__init__", klass))
for func_name, func in functions:
func_kind = get_signature(func, "__func_kind__")
modifier = func_kind if func_kind in (
@@ -145,24 +161,13 @@ class ExactEnumerator(object):
def function(self, func_name, func, modifier=None):
self.fmt.level += 1
ret = self.result_type()
- signature = getattr(func, '__signature__', None)
+ signature = func.__signature__
if signature is not None:
with self.fmt.function(func_name, signature, modifier) as key:
ret[key] = signature
self.fmt.level -= 1
return ret
- def enum(self, subclass):
- if not hasattr(self.fmt, "enum"):
- # this is an optional feature
- return
- class_name = subclass.__name__
- for enum_name, value in subclass.__dict__.items():
- if type(type(value)) is EnumType:
- with self.fmt.enum(class_name, enum_name, int(value)):
- pass
- self._after_enum = True
-
def stringify(signature):
if isinstance(signature, list):