summaryrefslogtreecommitdiffstats
path: root/gi
diff options
context:
space:
mode:
authorSimon van der Linden <svdlinden@src.gnome.org>2010-01-08 20:33:44 +0100
committerSimon van der Linden <svdlinden@src.gnome.org>2010-01-08 20:33:44 +0100
commitb4189be2b2d3c350fdf33e27309bee5a72e4f72a (patch)
tree4647888a92fe7584ac99946ce343d2d88b5c3986 /gi
parent4db68b958ea11bd2c3a88067cae03fd6bdd1d24b (diff)
downloadpygi-b4189be2b2d3c350fdf33e27309bee5a72e4f72a.tar.gz
pygi-b4189be2b2d3c350fdf33e27309bee5a72e4f72a.tar.xz
pygi-b4189be2b2d3c350fdf33e27309bee5a72e4f72a.zip
Don't set a default constructor for structures.
Update tests accordingly. The reason for this change is that setting __new__ in the metaclass doesn't let one overrides it afterwards, in a subclass (in my experience, at least, even though it seems weird). https://bugzilla.gnome.org/show_bug.cgi?id=603536
Diffstat (limited to 'gi')
-rw-r--r--gi/types.py35
1 files changed, 7 insertions, 28 deletions
diff --git a/gi/types.py b/gi/types.py
index 5212fef..e4d7c5f 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -61,6 +61,13 @@ def Constructor(info):
class MetaClassHelper(object):
+ def _setup_constructors(cls):
+ for method_info in cls.__info__.get_methods():
+ if method_info.is_constructor():
+ name = method_info.get_name()
+ constructor = classmethod(Constructor(method_info))
+ setattr(cls, name, constructor)
+
def _setup_methods(cls):
for method_info in cls.__info__.get_methods():
name = method_info.get_name()
@@ -87,13 +94,6 @@ class MetaClassHelper(object):
class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
- def _setup_constructors(cls):
- for method_info in cls.__info__.get_methods():
- if method_info.is_constructor():
- name = method_info.get_name()
- constructor = classmethod(Constructor(method_info))
- setattr(cls, name, constructor)
-
def __init__(cls, name, bases, dict_):
super(GObjectMeta, cls).__init__(name, bases, dict_)
@@ -114,27 +114,6 @@ class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
class StructMeta(type, MetaClassHelper):
- def _setup_constructors(cls):
- constructor_infos = []
- default_constructor_info = None
-
- for method_info in cls.__info__.get_methods():
- if method_info.is_constructor():
- name = method_info.get_name()
- constructor = classmethod(Function(method_info))
-
- setattr(cls, name, constructor)
-
- constructor_infos.append(method_info)
- if name == "new":
- default_constructor_info = method_info
-
- if default_constructor_info is None and constructor_infos:
- default_constructor_info = constructor_infos[0]
-
- if default_constructor_info is not None:
- cls.__new__ = staticmethod(Function(default_constructor_info))
-
def __init__(cls, name, bases, dict_):
super(StructMeta, cls).__init__(name, bases, dict_)