Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[gi] foreign types now take interface infos instead of type infos

 * this is a prep for the invoke-rewrite branch
 * when marshalling foreign structs we may not have the type info but
   we will always have the interface info to pass
 * this simplifies the code because we were simply converting the
   type info back to an interface info anyway so there is less
   refcounting to keep track of
 * also fixes a bug where we were leaking PyNone ref counts
  • Loading branch information...
commit 01596a9b7cc0ceef3904da5b96939140ee0732fd 1 parent fbabc1f
John (J5) Palmieri authored
View
4 gi/pygi-argument.c
@@ -1092,7 +1092,7 @@ _pygi_argument_from_object (PyObject *object,
} 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);
+ object, 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);
@@ -1564,7 +1564,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;
View
16 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 *interface_info,
+ GITransfer transfer,
GIArgument *arg)
{
cairo_t *cr;
@@ -56,7 +56,7 @@ cairo_context_to_arg (PyObject *value,
}
PyObject *
-cairo_context_from_arg (GITypeInfo *type_info, gpointer data)
+cairo_context_from_arg (GIInterfaceInfo *interface_info, gpointer data)
{
cairo_t *context = (cairo_t*) data;
@@ -75,9 +75,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 *interface_info,
+ GITransfer transfer,
GIArgument *arg)
{
cairo_surface_t *surface;
@@ -95,7 +95,7 @@ cairo_surface_to_arg (PyObject *value,
}
PyObject *
-cairo_surface_from_arg (GITypeInfo *type_info, gpointer data)
+cairo_surface_from_arg (GIInterfaceInfo *interface_info, gpointer data)
{
cairo_surface_t *surface = (cairo_surface_t*) data;
View
12 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 *interface_info,
+ GITransfer transfer,
GIArgument *arg)
{
g_assert (transfer == GI_TRANSFER_NOTHING);
@@ -41,11 +41,11 @@ g_variant_to_arg (PyObject *value,
}
PyObject *
-g_variant_from_arg (GITypeInfo *type_info,
- gpointer data)
+g_variant_from_arg (GIInterfaceInfo *interface_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);
g_variant_ref_sink (variant);
View
32 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 *interface_info,
+ GITransfer transfer,
GIArgument *arg)
{
- GIBaseInfo *base_info = g_type_info_get_interface (type_info);
+ PyObject *result;
+
+ GIBaseInfo *base_info = (GIBaseInfo *) interface_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))
- return NULL;
-
- Py_RETURN_NONE;
+ result = foreign_struct->to_func (value, interface_info, transfer, arg);
+ return result;
}
PyObject *
-pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info,
- GIArgument *arg)
+pygi_struct_foreign_convert_from_g_argument (GIInterfaceInfo *interface_info,
+ GIArgument *arg)
{
- GIBaseInfo *base_info = g_type_info_get_interface (type_info);
+ GIBaseInfo *base_info = (GIBaseInfo *) interface_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 (interface_info, arg);
}
PyObject *
@@ -152,10 +149,7 @@ pygi_struct_foreign_release (GIBaseInfo *base_info,
if (!foreign_struct->release_func)
Py_RETURN_NONE;
- if (!foreign_struct->release_func (base_info, struct_))
- return NULL;
-
- Py_RETURN_NONE;
+ return foreign_struct->release_func (base_info, struct_);
}
void
View
8 gi/pygi-foreign.h
@@ -31,11 +31,11 @@
#include "pygi.h"
PyObject *pygi_struct_foreign_convert_to_g_argument (PyObject *value,
- GITypeInfo *type_info,
+ GIInterfaceInfo *interface_info,
GITransfer transfer,
- GIArgument *arg);
-PyObject *pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info,
- GIArgument *arg);
+ GIArgument *arg);
+PyObject *pygi_struct_foreign_convert_from_g_argument (GIInterfaceInfo *interface_info,
+ GIArgument *arg);
PyObject *pygi_struct_foreign_release (GITypeInfo *type_info,
gpointer struct_);
View
6 gi/pygi-invoke.c
@@ -382,11 +382,11 @@ _prepare_invocation_state (struct invocation_state *state,
state->args[i]->v_pointer = _pygi_boxed_alloc (info, NULL);
} else 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]);
@@ -694,7 +694,7 @@ _process_invocation_state (struct invocation_state *state,
} else if (type == G_TYPE_NONE && 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_POINTER) || type == G_TYPE_NONE) {
if (transfer != GI_TRANSFER_NOTHING)
g_warning ("Return argument in %s returns a struct "
View
12 gi/pygi.h
@@ -55,12 +55,12 @@ typedef struct {
gsize size;
} PyGIBoxed;
-typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
- GIArgument *arg);
-typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GITypeInfo *type_info,
- gpointer data);
+typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
+ GIArgument *arg);
+typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
+ gpointer data);
typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
gpointer struct_);
Please sign in to comment.
Something went wrong with that request. Please try again.