summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2011-01-21 04:22:06 -0500
committerJohn (J5) Palmieri <johnp@redhat.com>2011-01-21 04:22:06 -0500
commit3133dc595adf44279397d30712c0f8595f0e1acc (patch)
treee9713b5b3404b524daa59f56c351399f72c51dcd /gi
parent1239f3709ba257c404dda72b7067b77b19c240fa (diff)
downloadpygobject-3133dc595adf44279397d30712c0f8595f0e1acc.tar.gz
[gi] move to using type_info and interface_info instead of arg_info
* only arguments have arg_infos, not return types and instances so type_info is much better to pass. In fact most API that took an arg_info simply converted it to a type_info * In the case of instances for methods we don't even have a type_info. Since all instances are interfaces, we also attach the interface_info to the interface cache
Diffstat (limited to 'gi')
-rw-r--r--gi/pygi-argument.c20
-rw-r--r--gi/pygi-cache.c43
-rw-r--r--gi/pygi-cache.h4
-rw-r--r--gi/pygi-foreign-cairo.c24
-rw-r--r--gi/pygi-foreign-gvariant.c11
-rw-r--r--gi/pygi-foreign-gvariant.h10
-rw-r--r--gi/pygi-foreign.c21
-rw-r--r--gi/pygi-foreign.h6
-rw-r--r--gi/pygi.h8
9 files changed, 77 insertions, 70 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 87d5a450..13c576cb 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -3015,13 +3015,9 @@ _pygi_marshal_in_interface_callback (PyGIInvokeState *state,
if (callback_cache->destroy_notify_index > 0)
destroy_cache = function_cache->args_cache[callback_cache->destroy_notify_index];
- type_info = g_arg_info_get_type(arg_cache->arg_info);
- callable_info = (GICallableInfo *)g_type_info_get_interface(type_info);
+ callable_info = (GICallableInfo *)callback_cache->interface_info;
closure = _pygi_make_native_closure (callable_info, callback_cache->scope, py_arg, py_user_data);
- g_base_info_unref((GIBaseInfo *)callable_info);
- g_base_info_unref((GIBaseInfo *)type_info);
-
arg->v_pointer = closure->closure;
if (user_data_cache != NULL) {
state->in_args[user_data_cache->c_arg_index].v_pointer = closure;
@@ -3063,13 +3059,10 @@ _pygi_marshal_in_interface_enum (PyGIInvokeState *state,
if (!is_instance) {
int i;
gboolean is_found = FALSE;
- GITypeInfo *type_info = g_arg_info_get_type(arg_cache->arg_info);
- GIInterfaceInfo *iface_info =
- g_type_info_get_interface (type_info);
- for (i = 0; i < g_enum_info_get_n_values(iface_info); i++) {
+ for (i = 0; i < g_enum_info_get_n_values(iface_cache->interface_info); i++) {
GIValueInfo *value_info =
- g_enum_info_get_value(iface_info, i);
+ g_enum_info_get_value(iface_cache->interface_info, i);
glong enum_value = g_value_info_get_value(value_info);
g_base_info_unref( (GIBaseInfo *)value_info);
if (arg->v_long == enum_value) {
@@ -3078,9 +3071,6 @@ _pygi_marshal_in_interface_enum (PyGIInvokeState *state,
}
}
- g_base_info_unref( (GIBaseInfo *)iface_info);
- g_base_info_unref( (GIBaseInfo *)type_info);
-
if (!is_found)
goto err;
}
@@ -3184,12 +3174,10 @@ _pygi_marshal_in_interface_struct (PyGIInvokeState *state,
return TRUE;
} else if (iface_cache->is_foreign) {
gboolean success;
- GITypeInfo *type_info = g_arg_info_get_type(arg_cache->arg_info);
success = pygi_struct_foreign_convert_to_g_argument(py_arg,
- type_info,
+ iface_cache->interface_info,
arg_cache->transfer,
arg);
- g_base_info_unref((GIBaseInfo *)type_info);
return success;
} else if (!PyObject_IsInstance(py_arg, iface_cache->py_type)) {
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 556e3b84..1be0323b 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -40,8 +40,8 @@ _pygi_arg_cache_free(PyGIArgCache *cache)
if (cache == NULL)
return;
- if (cache->arg_info != NULL)
- g_base_info_unref(cache->arg_info);
+ if (cache->type_info != NULL)
+ g_base_info_unref( (GIBaseInfo *)cache->type_info);
if (cache->destroy_notify)
cache->destroy_notify(cache);
else
@@ -53,9 +53,11 @@ _interface_cache_free_func (PyGIInterfaceCache *cache)
{
if (cache != NULL) {
Py_XDECREF(cache->py_type);
- g_slice_free(PyGIInterfaceCache, cache);
if (cache->type_name != NULL)
g_free(cache->type_name);
+ if (cache->interface_info != NULL)
+ g_base_info_unref( (GIBaseInfo *)cache->interface_info);
+ g_slice_free(PyGIInterfaceCache, cache);
}
}
@@ -81,8 +83,12 @@ _sequence_cache_free_func(PyGISequenceCache *cache)
static void
_callback_cache_free_func(PyGICallbackCache *cache)
{
- if (cache != NULL)
+ if (cache != NULL) {
+ if (cache->interface_info != NULL)
+ g_base_info_unref( (GIBaseInfo *)cache->interface_info);
+
g_slice_free(PyGICallbackCache, cache);
+ }
}
void
@@ -243,6 +249,7 @@ _hash_cache_new_from_type_info(GITypeInfo *type_info)
static inline PyGICallbackCache *
_callback_cache_new_from_arg_info(GIArgInfo *arg_info,
+ GIInterfaceInfo *iface_info,
gint aux_offset)
{
PyGICallbackCache *cc;
@@ -251,7 +258,8 @@ _callback_cache_new_from_arg_info(GIArgInfo *arg_info,
cc->user_data_index = g_arg_info_get_closure(arg_info) + aux_offset;
cc->destroy_notify_index = g_arg_info_get_destroy(arg_info) + aux_offset;
cc->scope = g_arg_info_get_scope(arg_info);
-
+ g_base_info_ref( (GIBaseInfo *)iface_info);
+ cc->interface_info = iface_info;
return cc;
}
@@ -523,9 +531,10 @@ _arg_cache_new_for_in_interface_boxed(GIInterfaceInfo *iface_info,
static inline PyGIArgCache *
_arg_cache_new_for_in_interface_callback(PyGIFunctionCache *function_cache,
- GIArgInfo *arg_info)
+ GIArgInfo *arg_info,
+ GIInterfaceInfo *iface_info)
{
- PyGICallbackCache *callback_cache = _callback_cache_new_from_arg_info(arg_info, function_cache->is_method ? 1: 0);
+ PyGICallbackCache *callback_cache = _callback_cache_new_from_arg_info(arg_info, iface_info, function_cache->is_method ? 1: 0);
PyGIArgCache *arg_cache = (PyGIArgCache *)callback_cache;
if (callback_cache->user_data_index >= 0) {
PyGIArgCache *user_data_arg_cache = _arg_cache_new();
@@ -593,7 +602,8 @@ _arg_cache_in_new_from_interface_info (GIInterfaceInfo *iface_info,
break;
case GI_INFO_TYPE_CALLBACK:
arg_cache = _arg_cache_new_for_in_interface_callback(function_cache,
- arg_info);
+ arg_info,
+ iface_info);
break;
case GI_INFO_TYPE_ENUM:
arg_cache = _arg_cache_new_for_in_interface_enum(iface_info);
@@ -611,6 +621,9 @@ _arg_cache_in_new_from_interface_info (GIInterfaceInfo *iface_info,
arg_cache->type_tag = GI_TYPE_TAG_INTERFACE;
arg_cache->py_arg_index = py_arg_index;
arg_cache->c_arg_index = c_arg_index;
+
+ g_base_info_ref( (GIBaseInfo *)iface_info);
+ ((PyGIInterfaceCache *)arg_cache)->interface_info = iface_info;
}
return arg_cache;
@@ -926,6 +939,9 @@ _arg_cache_out_new_from_interface_info (GIInterfaceInfo *iface_info,
arg_cache->transfer = transfer;
arg_cache->type_tag = GI_TYPE_TAG_INTERFACE;
arg_cache->c_arg_index = c_arg_index;
+
+ g_base_info_ref( (GIBaseInfo *)iface_info);
+ ((PyGIInterfaceCache *)arg_cache)->interface_info = iface_info;
}
return arg_cache;
@@ -1006,7 +1022,8 @@ _arg_cache_out_new_from_type_info (GITypeInfo *type_info,
c_arg_index);
g_base_info_unref( (GIBaseInfo *) interface_info);
- return arg_cache;
+
+ break;
}
case GI_TYPE_TAG_GLIST:
arg_cache = _arg_cache_new_for_out_glist(type_info,
@@ -1030,6 +1047,8 @@ _arg_cache_out_new_from_type_info (GITypeInfo *type_info,
arg_cache->type_tag = type_tag;
arg_cache->c_arg_index = c_arg_index;
arg_cache->is_pointer = g_type_info_is_pointer(type_info);
+ g_base_info_ref( (GIBaseInfo *) type_info);
+ arg_cache->type_info = type_info;
}
return arg_cache;
@@ -1115,7 +1134,7 @@ _arg_cache_in_new_from_type_info (GITypeInfo *type_info,
py_arg_index);
g_base_info_unref( (GIBaseInfo *) interface_info);
- return arg_cache;
+ break;
}
case GI_TYPE_TAG_GLIST:
arg_cache = _arg_cache_new_for_in_glist(type_info,
@@ -1140,6 +1159,8 @@ _arg_cache_in_new_from_type_info (GITypeInfo *type_info,
arg_cache->py_arg_index = py_arg_index;
arg_cache->c_arg_index = c_arg_index;
arg_cache->is_pointer = g_type_info_is_pointer(type_info);
+ g_base_info_ref( (GIBaseInfo *) type_info);
+ arg_cache->type_info = type_info;
}
return arg_cache;
@@ -1167,6 +1188,7 @@ _args_cache_generate(GIFunctionInfo *function_info,
return_type_tag,
return_transfer,
GI_DIRECTION_OUT,
+ FALSE,
-1);
function_cache->return_cache = return_cache;
@@ -1283,7 +1305,6 @@ _args_cache_generate(GIFunctionInfo *function_info,
}
- arg_cache->arg_info = arg_info;
function_cache->args_cache[arg_index] = arg_cache;
g_base_info_unref( (GIBaseInfo *) type_info);
continue;
diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h
index 8141932c..3b18d413 100644
--- a/gi/pygi-cache.h
+++ b/gi/pygi-cache.h
@@ -62,7 +62,7 @@ struct _PyGIArgCache
GIDirection direction;
GITransfer transfer;
GITypeTag type_tag;
- GIArgInfo *arg_info;
+ GITypeInfo *type_info;
GIArgument *default_value;
PyGIMarshalInFunc in_marshaller;
@@ -92,6 +92,7 @@ typedef struct _PyGIInterfaceCache
gboolean is_foreign;
GType g_type;
PyObject *py_type;
+ GIInterfaceInfo *interface_info;
gchar *type_name;
} PyGIInterfaceCache;
@@ -108,6 +109,7 @@ typedef struct _PyGICallbackCache
gint user_data_index;
gint destroy_notify_index;
GIScopeType scope;
+ GIInterfaceInfo *interface_info;
} PyGICallbackCache;
struct _PyGIFunctionCache
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index babe8b4b..228cefbd 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 *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, GIArgument *arg)
+cairo_context_from_arg (GIInterfaceInfo *interface_info, GIArgument *arg)
{
cairo_t *context = (cairo_t*) arg;
@@ -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, GIArgument *arg)
+cairo_surface_from_arg (GIInterfaceInfo *interface_info, GIArgument *arg)
{
cairo_surface_t *surface = (cairo_surface_t*) arg;
@@ -143,9 +143,9 @@ cairo_surface_release (GIBaseInfo *base_info,
}
PyObject *
-cairo_rectangle_int_to_arg (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
+cairo_rectangle_int_to_arg (PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
GIArgument *arg)
{
cairo_rectangle_int_t *rect;
@@ -173,7 +173,7 @@ err:
}
PyObject *
-cairo_rectangle_int_from_arg (GITypeInfo *type_info, GIArgument *arg)
+cairo_rectangle_int_from_arg (GIInterfaceInfo *interface_info, GIArgument *arg)
{
PyObject *result;
cairo_rectangle_int_t *rect = (cairo_rectangle_int_t*) arg;
diff --git a/gi/pygi-foreign-gvariant.c b/gi/pygi-foreign-gvariant.c
index ac163950..3b6a1f1a 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 *interface_info,
+ GITransfer transfer,
GIArgument *arg)
{
g_assert (transfer == GI_TRANSFER_NOTHING);
@@ -41,11 +41,10 @@ g_variant_to_arg (PyObject *value,
}
PyObject *
-g_variant_from_arg (GITypeInfo *type_info,
- GIArgument *arg)
+g_variant_from_arg (GIInterfaceInfo *interface_info,
+ GIArgument *arg)
{
GVariant *variant = (GVariant *) arg;
- 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);
diff --git a/gi/pygi-foreign-gvariant.h b/gi/pygi-foreign-gvariant.h
index 6de8c57a..a9fa351b 100644
--- a/gi/pygi-foreign-gvariant.h
+++ b/gi/pygi-foreign-gvariant.h
@@ -26,13 +26,13 @@
#include "pygi-foreign.h"
-PyObject *g_variant_to_arg(PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
+PyObject *g_variant_to_arg(PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
GIArgument *arg);
-PyObject *g_variant_from_arg(GITypeInfo *type_info,
- GIArgument *arg);
+PyObject *g_variant_from_arg(GIInterfaceInfo *interface_info,
+ GIArgument *arg);
PyObject *g_variant_release_foreign (GIBaseInfo *base_info,
gpointer struct_);
diff --git a/gi/pygi-foreign.c b/gi/pygi-foreign.c
index fa43005a..b7a9b990 100644
--- a/gi/pygi-foreign.c
+++ b/gi/pygi-foreign.c
@@ -107,15 +107,14 @@ pygi_struct_foreign_lookup (GIBaseInfo *base_info)
}
gboolean
-pygi_struct_foreign_convert_to_g_argument (PyObject *value,
- GITypeInfo *type_info,
- GITransfer transfer,
- GIArgument *arg)
+pygi_struct_foreign_convert_to_g_argument (PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
+ GIArgument *arg)
{
PyObject *result;
- GIBaseInfo *base_info = g_type_info_get_interface (type_info);
+ PyGIBaseInfo *base_info = (PyGIBaseInfo *)interface_info;
PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (base_info);
- g_base_info_unref (base_info);
if (foreign_struct == NULL) {
PyErr_Format(PyExc_KeyError, "could not find foreign type %s",
@@ -123,7 +122,7 @@ pygi_struct_foreign_convert_to_g_argument (PyObject *value,
return FALSE;
}
- result = foreign_struct->to_func (value, type_info, transfer, arg);
+ result = foreign_struct->to_func (value, interface_info, transfer, arg);
if (result == NULL)
return FALSE;
@@ -132,18 +131,16 @@ pygi_struct_foreign_convert_to_g_argument (PyObject *value,
}
PyObject *
-pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info,
+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 *
diff --git a/gi/pygi-foreign.h b/gi/pygi-foreign.h
index 3e206638..9f55eb97 100644
--- a/gi/pygi-foreign.h
+++ b/gi/pygi-foreign.h
@@ -31,12 +31,12 @@
#include "pygi.h"
gboolean 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,
+PyObject *pygi_struct_foreign_convert_from_g_argument (GIInterfaceInfo *interface_info,
GIArgument *arg);
-PyObject *pygi_struct_foreign_release (GITypeInfo *type_info,
+PyObject *pygi_struct_foreign_release (GIInterfaceInfo *interface_info,
gpointer struct_);
void pygi_register_foreign_struct_real (const char* namespace_,
diff --git a/gi/pygi.h b/gi/pygi.h
index a87b6fc5..92334695 100644
--- a/gi/pygi.h
+++ b/gi/pygi.h
@@ -58,12 +58,12 @@ typedef struct {
} PyGIBoxed;
typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
- GITypeInfo *type_info,
+ GIInterfaceInfo *interface_info,
GITransfer transfer,
GIArgument *arg);
-typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GITypeInfo *type_info,
- GIArgument *arg);
-typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
+typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
+ GIArgument *arg);
+typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *interface_info,
gpointer struct_);
struct PyGI_API {