summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2011-04-09 08:52:17 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2011-04-09 08:52:17 +0200
commit73a8fcdbc9bff32edac2b17a31a4143369dc3c4f (patch)
tree176686b4f7de6fa73d53aea24cdab1fb0f9be8d6
parent725b7d63651936ac04dc79b42ffd75ed4cc82452 (diff)
parentcc0e8423f36486d15f751bd3c14351edda28538d (diff)
downloadpygobject-windows.tar.gz
Merge branch 'pygobject-2-28' into windowsPYGOBJECT_2_28_3_WINDOWSwindows
-rw-r--r--gi/pygi-argument.c25
-rw-r--r--gi/types.py9
-rw-r--r--gobject/__init__.py16
3 files changed, 40 insertions, 10 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 6519e5ca..ee14b49b 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1316,6 +1316,23 @@ hash_table_release:
return arg;
}
+static glong
+_pygi_glong_from_argument (GIArgument *arg,
+ GITypeInfo *type_info)
+{
+ gsize item_size = _pygi_g_type_info_size (type_info);
+
+ if (item_size == sizeof (glong))
+ return arg->v_long;
+ else if (item_size == sizeof (gint))
+ return arg->v_int;
+ else
+ {
+ g_warning ("pygi: unsupported item size %ld", item_size);
+ return arg->v_long;
+ }
+}
+
PyObject *
_pygi_argument_to_object (GIArgument *arg,
GITypeInfo *type_info,
@@ -1621,24 +1638,26 @@ _pygi_argument_to_object (GIArgument *arg,
/* An enum with a GType of None is an enum without GType */
PyObject *py_type = _pygi_type_import_by_gi_info (info);
PyObject *py_args = NULL;
+ glong val = _pygi_glong_from_argument (arg, type_info);
if (!py_type)
return NULL;
py_args = PyTuple_New (1);
- if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (arg->v_long)) != 0) {
+ if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (val)) != 0) {
Py_DECREF (py_args);
Py_DECREF (py_type);
return NULL;
}
- object = PyObject_CallFunction (py_type, "l", arg->v_long);
+ object = PyObject_CallFunction (py_type, "l", val);
Py_DECREF (py_args);
Py_DECREF (py_type);
} else if (info_type == GI_INFO_TYPE_ENUM) {
- object = pyg_enum_from_gtype (type, arg->v_long);
+ glong val = _pygi_glong_from_argument (arg, type_info);
+ object = pyg_enum_from_gtype (type, val);
} else {
object = pyg_flags_from_gtype (type, arg->v_long);
}
diff --git a/gi/types.py b/gi/types.py
index 9b250b16..210fdc1c 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -232,6 +232,15 @@ class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
def mro(cls):
return mro(cls)
+ def _must_register_type(cls, namespace):
+ ## don't register the class if already registered
+ if '__gtype__' in namespace:
+ return False
+
+ # Do not register a new GType for the overrides, as this would sort of
+ # defeat the purpose of overrides...
+ return not cls.__module__.startswith('gi.overrides.')
+
def mro(C):
"""Compute the class precedence list (mro) according to C3
diff --git a/gobject/__init__.py b/gobject/__init__.py
index 1858d188..a9522a63 100644
--- a/gobject/__init__.py
+++ b/gobject/__init__.py
@@ -101,17 +101,19 @@ class GObjectMeta(type):
prop.setter(self, value)
cls.do_set_property = obj_set_property
- def _type_register(cls, namespace):
+ def _must_register_type(cls, namespace):
## don't register the class if already registered
if '__gtype__' in namespace:
- return
+ return False
- # Do not register a new GType for the overrides, as this would sort of
- # defeat the purpose of overrides...
- if cls.__module__.startswith('gi.overrides.'):
- return
+ return ('__gproperties__' in namespace or
+ '__gsignals__' in namespace or
+ '__gtype_name__' in namespace)
+
+ def _type_register(cls, namespace):
+ if cls._must_register_type(namespace):
+ type_register(cls, namespace.get('__gtype_name__'))
- type_register(cls, namespace.get('__gtype_name__'))
_gobject._install_metaclass(GObjectMeta)
del _gobject