diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-07-13 23:10:31 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2013-07-25 21:15:22 -0700 |
commit | ea194404843a16555f9a475cc973872a4428bfe1 (patch) | |
tree | a8b15025ef8c35f096daec5f8b42b96781f09f71 | |
parent | 6b36fbe904d19f515578f447daa7657d3a9a859c (diff) | |
download | pygobject-ea194404843a16555f9a475cc973872a4428bfe1.tar.gz |
Merge method and constructor setup
Merge _setup_constructors into _setup_methods as they contain same
basic logic. This removes an unnecessary call with additional
filtering of GIObjectInfo.get_methods() which can be large for
objects with many methods.
https://bugzilla.gnome.org/show_bug.cgi?id=704037
-rw-r--r-- | gi/types.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/gi/types.py b/gi/types.py index 54e38a17..85eecf18 100644 --- a/gi/types.py +++ b/gi/types.py @@ -91,21 +91,16 @@ def Constructor(info): class MetaClassHelper(object): - - def _setup_constructors(cls): - for method_info in cls.__info__.get_methods(): - if method_info.is_constructor(): - constructor = Constructor(method_info) - setattr(cls, constructor.__name__, classmethod(constructor)) - def _setup_methods(cls): for method_info in cls.__info__.get_methods(): - function = Function(method_info) if method_info.is_method(): + function = Function(method_info) method = function elif method_info.is_constructor(): - continue + function = Constructor(method_info) + method = classmethod(function) else: + function = Function(method_info) method = staticmethod(function) setattr(cls, function.__name__, method) @@ -250,7 +245,6 @@ class GObjectMeta(_gobject.GObjectMeta, MetaClassHelper): if isinstance(cls.__info__, ObjectInfo): cls._setup_fields() - cls._setup_constructors() elif isinstance(cls.__info__, InterfaceInfo): register_interface_info(cls.__info__.get_g_type()) @@ -330,7 +324,6 @@ class StructMeta(type, MetaClassHelper): cls._setup_fields() cls._setup_methods() - cls._setup_constructors() for method_info in cls.__info__.get_methods(): if method_info.is_constructor() and \ |