[pygobject/pygobject-2-28] [gi] backport of "GVariant has a GType" fe386a
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-2-28] [gi] backport of "GVariant has a GType" fe386a
- Date: Fri, 10 Jun 2011 20:53:07 +0000 (UTC)
commit 78366697d8f7fc53f20d9f52f9f39552c5e99bd1
Author: John (J5) Palmieri <johnp redhat com>
Date: Fri Jun 10 16:48:28 2011 -0400
[gi] backport of "GVariant has a GType" fe386a
* backport the switch to using GIInterfaceInfo instead of GITypeInfo
for foreign types to support this patch - 01596a
gi/pygi-argument.c | 10 +++++-----
gi/pygi-foreign-cairo.c | 18 ++++++++++--------
gi/pygi-foreign-gvariant.c | 15 +++++++--------
gi/pygi-foreign-gvariant.h | 14 ++++++--------
gi/pygi-foreign.c | 21 +++++++++------------
gi/pygi-foreign.h | 16 ++++++++--------
gi/pygi-invoke.c | 26 ++++++++++++++++----------
7 files changed, 61 insertions(+), 59 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index ad02ff7..a9b5b60 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1084,15 +1084,15 @@ array_success:
}
arg.v_pointer = closure;
+ } else if (g_struct_info_is_foreign (info)) {
+ PyObject *result;
+ result = pygi_struct_foreign_convert_to_g_argument (
+ object, info, transfer, &arg);
} else if (g_type_is_a (type, G_TYPE_BOXED)) {
arg.v_pointer = pyg_boxed_get (object, void);
if (transfer == GI_TRANSFER_EVERYTHING) {
arg.v_pointer = g_boxed_copy (type, arg.v_pointer);
}
- } else if ( (type == G_TYPE_NONE) && (g_struct_info_is_foreign (info))) {
- PyObject *result;
- result = pygi_struct_foreign_convert_to_g_argument (
- object, type_info, transfer, &arg);
} else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) {
g_warn_if_fail (!g_type_info_is_pointer (type_info) || transfer == GI_TRANSFER_NOTHING);
arg.v_pointer = pyg_pointer_get (object, void);
@@ -1581,7 +1581,7 @@ _pygi_argument_to_object (GIArgument *arg,
if (g_type_is_a (type, G_TYPE_VALUE)) {
object = pyg_value_as_pyobject (arg->v_pointer, FALSE);
} else if (g_struct_info_is_foreign (info)) {
- object = pygi_struct_foreign_convert_from_g_argument (type_info, arg->v_pointer);
+ object = pygi_struct_foreign_convert_from_g_argument (info, arg->v_pointer);
} else if (g_type_is_a (type, G_TYPE_BOXED)) {
PyObject *py_type;
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index 0264b71..e332a22 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -37,9 +37,9 @@ Pycairo_CAPI_t *Pycairo_CAPI;
#include <pyglib-python-compat.h>
PyObject *
-cairo_context_to_arg (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
+cairo_context_to_arg (PyObject *value,
+ GIInterfaceInfo *iface_info,
+ GITransfer transfer,
GIArgument *arg)
{
cairo_t *cr;
@@ -56,7 +56,8 @@ cairo_context_to_arg (PyObject *value,
}
PyObject *
-cairo_context_from_arg (GITypeInfo *type_info, gpointer data)
+cairo_context_from_arg (GIInterfaceInfo *iface_info,
+ gpointer data)
{
cairo_t *context = (cairo_t*) data;
@@ -75,9 +76,9 @@ cairo_context_release (GIBaseInfo *base_info,
PyObject *
-cairo_surface_to_arg (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
+cairo_surface_to_arg (PyObject *value,
+ GIInterfaceInfo *iface_info,
+ GITransfer transfer,
GIArgument *arg)
{
cairo_surface_t *surface;
@@ -95,7 +96,8 @@ cairo_surface_to_arg (PyObject *value,
}
PyObject *
-cairo_surface_from_arg (GITypeInfo *type_info, gpointer data)
+cairo_surface_from_arg (GIInterfaceInfo *iface_info,
+ gpointer data)
{
cairo_surface_t *surface = (cairo_surface_t*) data;
diff --git a/gi/pygi-foreign-gvariant.c b/gi/pygi-foreign-gvariant.c
index 3c8ae8d..9249d44 100644
--- a/gi/pygi-foreign-gvariant.c
+++ b/gi/pygi-foreign-gvariant.c
@@ -27,9 +27,9 @@
#include "pygi-foreign-gvariant.h"
PyObject *
-g_variant_to_arg (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
+g_variant_to_arg (PyObject *value,
+ GIInterfaceInfo *type_info,
+ GITransfer transfer,
GIArgument *arg)
{
g_assert (transfer == GI_TRANSFER_NOTHING);
@@ -41,12 +41,11 @@ g_variant_to_arg (PyObject *value,
}
PyObject *
-g_variant_from_arg (GITypeInfo *type_info,
- gpointer data)
+g_variant_from_arg (GIInterfaceInfo *iface_info,
+ gpointer data)
{
GVariant *variant = (GVariant *) data;
- GITypeInfo *interface_info = g_type_info_get_interface (type_info);
- PyObject *type = _pygi_type_import_by_gi_info (interface_info);
+ PyObject *type = _pygi_type_import_by_gi_info (iface_info);
g_variant_ref_sink (variant);
@@ -55,7 +54,7 @@ g_variant_from_arg (GITypeInfo *type_info,
PyObject *
g_variant_release_foreign (GIBaseInfo *base_info,
- gpointer struct_)
+ gpointer struct_)
{
g_variant_unref ( (GVariant *) struct_);
Py_RETURN_NONE;
diff --git a/gi/pygi-foreign-gvariant.h b/gi/pygi-foreign-gvariant.h
index b0c9781..8ebc4cd 100644
--- a/gi/pygi-foreign-gvariant.h
+++ b/gi/pygi-foreign-gvariant.h
@@ -26,14 +26,12 @@
#include "pygi-foreign.h"
-PyObject *g_variant_to_arg(PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
- GIArgument *arg);
-
-PyObject *g_variant_from_arg(GITypeInfo *type_info,
- gpointer data);
-
+PyObject *g_variant_to_arg (PyObject *value,
+ GIInterfaceInfo *iface_info,
+ GITransfer transfer,
+ GIArgument *arg);
+PyObject *g_variant_from_arg (GIInterfaceInfo *iface_info,
+ gpointer data);
PyObject *g_variant_release_foreign (GIBaseInfo *base_info,
gpointer struct_);
diff --git a/gi/pygi-foreign.c b/gi/pygi-foreign.c
index 5c9a88a..eafaca3 100644
--- a/gi/pygi-foreign.c
+++ b/gi/pygi-foreign.c
@@ -107,37 +107,34 @@ pygi_struct_foreign_lookup (GIBaseInfo *base_info)
}
PyObject *
-pygi_struct_foreign_convert_to_g_argument (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
+pygi_struct_foreign_convert_to_g_argument (PyObject *value,
+ GIInterfaceInfo *iface_info,
+ GITransfer transfer,
GIArgument *arg)
{
- GIBaseInfo *base_info = g_type_info_get_interface (type_info);
+ GIBaseInfo *base_info = (GIBaseInfo *) iface_info;
PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (base_info);
- g_base_info_unref (base_info);
if (foreign_struct == NULL)
return NULL;
- if (!foreign_struct->to_func (value, type_info, transfer, arg))
+ if (!foreign_struct->to_func (value, iface_info, transfer, arg))
return NULL;
Py_RETURN_NONE;
}
PyObject *
-pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info,
- GIArgument *arg)
+pygi_struct_foreign_convert_from_g_argument (GIInterfaceInfo *iface_info,
+ GIArgument *arg)
{
- GIBaseInfo *base_info = g_type_info_get_interface (type_info);
+ GIBaseInfo *base_info = (GIBaseInfo *) iface_info;
PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (base_info);
- g_base_info_unref (base_info);
-
if (foreign_struct == NULL)
return NULL;
- return foreign_struct->from_func (type_info, arg);
+ return foreign_struct->from_func (iface_info, arg);
}
PyObject *
diff --git a/gi/pygi-foreign.h b/gi/pygi-foreign.h
index b57f892..b07f682 100644
--- a/gi/pygi-foreign.h
+++ b/gi/pygi-foreign.h
@@ -30,14 +30,14 @@
#include "pygi.h"
-PyObject *pygi_struct_foreign_convert_to_g_argument (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
- GIArgument *arg);
-PyObject *pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info,
- GIArgument *arg);
-PyObject *pygi_struct_foreign_release (GITypeInfo *type_info,
- gpointer struct_);
+PyObject *pygi_struct_foreign_convert_to_g_argument (PyObject *value,
+ GIInterfaceInfo *iface_info,
+ GITransfer transfer,
+ GIArgument *arg);
+PyObject *pygi_struct_foreign_convert_from_g_argument (GIInterfaceInfo *iface_info,
+ GIArgument *arg);
+PyObject *pygi_struct_foreign_release (GIBaseInfo *base_info,
+ gpointer struct_);
void pygi_register_foreign_struct_real (const char* namespace_,
const char* name,
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 78984e5..f9e09bb 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -378,19 +378,19 @@ _prepare_invocation_state (struct invocation_state *state,
/* if caller allocates only use one level of indirection */
state->out_args[out_args_pos].v_pointer = NULL;
state->args[i] = &state->out_args[out_args_pos];
- if (g_type_is_a (g_registered_type_info_get_g_type (info), G_TYPE_BOXED)) {
- state->args[i]->v_pointer = _pygi_boxed_alloc (info, NULL);
- } else if (g_struct_info_is_foreign((GIStructInfo *) info) ) {
+ if (g_struct_info_is_foreign((GIStructInfo *) info) ) {
PyObject *foreign_struct =
- pygi_struct_foreign_convert_from_g_argument(state->arg_type_infos[i], NULL);
+ pygi_struct_foreign_convert_from_g_argument(info, NULL);
pygi_struct_foreign_convert_to_g_argument(
foreign_struct,
- state->arg_type_infos[i],
+ info,
GI_TRANSFER_EVERYTHING,
state->args[i]);
Py_DECREF(foreign_struct);
+ } else if (g_type_is_a (g_registered_type_info_get_g_type (info), G_TYPE_BOXED)) {
+ state->args[i]->v_pointer = _pygi_boxed_alloc (info, NULL);
} else {
gssize size = g_struct_info_get_size ( (GIStructInfo *) info);
state->args[i]->v_pointer = g_malloc0 (size);
@@ -457,6 +457,12 @@ _prepare_invocation_state (struct invocation_state *state,
if (g_type_is_a (type, G_TYPE_BOXED)) {
g_assert (state->n_in_args > 0);
state->in_args[0].v_pointer = pyg_boxed_get (py_arg, void);
+ } else if (g_struct_info_is_foreign (container_info)) {
+ PyObject *result;
+ result = pygi_struct_foreign_convert_to_g_argument (
+ py_arg, container_info,
+ GI_TRANSFER_NOTHING,
+ &state->in_args[0]);
} else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) {
g_assert (state->n_in_args > 0);
state->in_args[0].v_pointer = pyg_pointer_get (py_arg, void);
@@ -688,13 +694,13 @@ _process_invocation_state (struct invocation_state *state,
type = g_registered_type_info_get_g_type ( (GIRegisteredTypeInfo *) info);
- if (g_type_is_a (type, G_TYPE_BOXED)) {
- g_warn_if_fail (transfer == GI_TRANSFER_EVERYTHING);
- state->return_value = _pygi_boxed_new (py_type, state->return_arg.v_pointer, transfer == GI_TRANSFER_EVERYTHING);
- } else if (type == G_TYPE_NONE && g_struct_info_is_foreign (info)) {
+ if (g_struct_info_is_foreign (info)) {
state->return_value =
pygi_struct_foreign_convert_from_g_argument (
- state->return_type_info, state->return_arg.v_pointer);
+ info, state->return_arg.v_pointer);
+ } else if (g_type_is_a (type, G_TYPE_BOXED)) {
+ g_warn_if_fail (transfer == GI_TRANSFER_EVERYTHING);
+ state->return_value = _pygi_boxed_new (py_type, state->return_arg.v_pointer, transfer == GI_TRANSFER_EVERYTHING);
} else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) {
if (transfer != GI_TRANSFER_NOTHING)
g_warning ("Return argument in %s returns a struct "
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]