summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:36:42 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:36:42 +0900
commitdd20fe51cd566c8c20bcbb96901c766a385d0a11 (patch)
treeb73c8ec2b2f9aa4fd0aaed9467d076c3a3602fe1 /gi
parent637e88b9e8a5847acbc571d34b1f1bceceb74372 (diff)
downloadpygobject2-dd20fe51cd566c8c20bcbb96901c766a385d0a11.tar.gz
pygobject2-dd20fe51cd566c8c20bcbb96901c766a385d0a11.tar.bz2
pygobject2-dd20fe51cd566c8c20bcbb96901c766a385d0a11.zip
Imported Upstream version 2.28.4
Change-Id: I26f0b6fb519c0878c69b3aabfa3ec8752b5a9af5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi')
-rw-r--r--gi/overrides/GLib.py16
-rw-r--r--gi/pygi-argument.c27
-rw-r--r--gi/types.py9
3 files changed, 35 insertions, 17 deletions
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index ac783be..ad9f235 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -25,17 +25,6 @@ GLib = modules['GLib']._introspection_module
__all__ = []
-def _create_variant(value):
- '''Create a variant containing the variant "value".
-
- This is usually done with the GLib.Variant.new_variant() leaf
- constructor, but this is currently broken, see GNOME#639952.
- '''
- builder = GLib.VariantBuilder()
- builder.init(variant_type_from_string('v'))
- builder.add_value(value)
- return builder.end()
-
class _VariantCreator(object):
_LEAF_CONSTRUCTORS = {
@@ -52,8 +41,7 @@ class _VariantCreator(object):
's': GLib.Variant.new_string,
'o': GLib.Variant.new_object_path,
'g': GLib.Variant.new_signature,
- #'v': GLib.Variant.new_variant,
- 'v': _create_variant,
+ 'v': GLib.Variant.new_variant,
}
def _create(self, format, args):
@@ -77,7 +65,7 @@ class _VariantCreator(object):
if not args:
raise TypeError('not enough arguments for GVariant format string')
v = constructor(args[0])
- return (constructor(args[0]), format[1:], args[1:])
+ return (v, format[1:], args[1:])
else:
return (None, format[1:], None)
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 6519e5c..ad02ff7 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);
}
@@ -1844,6 +1863,8 @@ _pygi_argument_from_g_value(const GValue *value,
case GI_INFO_TYPE_UNION:
if (G_VALUE_HOLDS(value, G_TYPE_BOXED)) {
arg.v_pointer = g_value_get_boxed (value);
+ } else if (G_VALUE_HOLDS(value, G_TYPE_VARIANT)) {
+ arg.v_pointer = g_value_get_variant (value);
} else {
arg.v_pointer = g_value_get_pointer (value);
}
diff --git a/gi/types.py b/gi/types.py
index 9b250b1..210fdc1 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