Commit ea194404 authored by Simon Feltman's avatar Simon Feltman
Browse files

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
parent 6b36fbe9
......@@ -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 \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment