diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2011-09-02 18:39:51 -0400 |
---|---|---|
committer | John (J5) Palmieri <johnp@redhat.com> | 2011-09-12 13:05:22 -0400 |
commit | a4e4318b50a24a688e32579273fbcfa51d1b422a (patch) | |
tree | 8a748c7da58cc60715ac0fb0d15925309ea04b66 | |
parent | 45b0fcff9e948c65a3903c32a3957802034c5e47 (diff) | |
download | pygobject-a4e4318b50a24a688e32579273fbcfa51d1b422a.tar.gz |
refactor in/out marshalling to be to_py/from_py
* in/out make sense from a C perspective but when you get to the
python layers it makes more sense to label them as to_py and
from_py to denote which way we are marshalling
* this helps clear up the difference between callbacks which
call into python and invoked functions which call into C
* in the callback case we marshal in values to Python objects
and out values to C types but in the invoke case we do the
reverse. Dealing with to_py/from_py makes the code much more
resuable and consistant
https://bugzilla.gnome.org/show_bug.cgi?id=658362
-rw-r--r-- | gi/Makefile.am | 8 | ||||
-rw-r--r-- | gi/pygi-cache.c | 673 | ||||
-rw-r--r-- | gi/pygi-cache.h | 62 | ||||
-rw-r--r-- | gi/pygi-invoke.c | 144 | ||||
-rw-r--r-- | gi/pygi-marshal-cleanup.c | 168 | ||||
-rw-r--r-- | gi/pygi-marshal-cleanup.h | 128 | ||||
-rw-r--r-- | gi/pygi-marshal-from-py.c (renamed from gi/pygi-marshal-in.c) | 372 | ||||
-rw-r--r-- | gi/pygi-marshal-from-py.h | 186 | ||||
-rw-r--r-- | gi/pygi-marshal-in.h | 186 | ||||
-rw-r--r-- | gi/pygi-marshal-out.h | 144 | ||||
-rw-r--r-- | gi/pygi-marshal-to-py.c (renamed from gi/pygi-marshal-out.c) | 278 | ||||
-rw-r--r-- | gi/pygi-marshal-to-py.h | 144 |
12 files changed, 1267 insertions, 1226 deletions
diff --git a/gi/Makefile.am b/gi/Makefile.am index 4cc1d2fc..93bb4f8f 100644 --- a/gi/Makefile.am +++ b/gi/Makefile.am @@ -65,10 +65,10 @@ _gi_la_SOURCES = \ pygi-invoke-state-struct.h \ pygi-cache.h \ pygi-cache.c \ - pygi-marshal-in.c \ - pygi-marshal-in.h \ - pygi-marshal-out.c \ - pygi-marshal-out.h \ + pygi-marshal-from-py.c \ + pygi-marshal-from-py.h \ + pygi-marshal-to-py.c \ + pygi-marshal-to-py.h \ pygi-marshal-cleanup.c \ pygi-marshal-cleanup.h _gi_la_CFLAGS = \ diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c index a3764435..50248998 100644 --- a/gi/pygi-cache.c +++ b/gi/pygi-cache.c @@ -21,8 +21,8 @@ #include "pygi-info.h" #include "pygi-cache.h" -#include "pygi-marshal-in.h" -#include "pygi-marshal-out.h" +#include "pygi-marshal-to-py.h" +#include "pygi-marshal-from-py.h" #include "pygi-marshal-cleanup.h" #include "pygi-type.h" #include <girepository.h> @@ -31,7 +31,7 @@ PyGIArgCache * _arg_cache_new (GITypeInfo *type_info, PyGICallableCache *callable_cache, GIArgInfo *arg_info, GITransfer transfer, - GIDirection direction, + PyGIDirection direction, gssize c_arg_index, gssize py_arg_index); @@ -39,7 +39,7 @@ PyGIArgCache * _arg_cache_new_for_interface (GIInterfaceInfo *iface_info, PyGICallableCache *callable_cache, GIArgInfo *arg_info, GITransfer transfer, - GIDirection direction, + PyGIDirection direction, gssize c_arg_index, gssize py_arg_index); /* cleanup */ @@ -108,7 +108,7 @@ _pygi_callable_cache_free (PyGICallableCache *cache) if (cache == NULL) return; - g_slist_free (cache->out_args); + g_slist_free (cache->to_py_args); g_slist_free (cache->arg_name_list); g_hash_table_destroy (cache->arg_name_hash); @@ -262,219 +262,219 @@ _arg_cache_alloc (void) } static void -_arg_cache_in_void_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_void_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_void; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_void; } static void -_arg_cache_out_void_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_void_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_void; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_void; } static void -_arg_cache_in_boolean_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_boolean_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_boolean; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_boolean; } static void -_arg_cache_out_boolean_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_boolean_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_boolean; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_boolean; } static void -_arg_cache_in_int8_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_int8_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_int8; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_int8; } static void -_arg_cache_out_int8_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_int8_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_int8; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_int8; } static void -_arg_cache_in_uint8_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_uint8_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_uint8; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_uint8; } static void -_arg_cache_out_uint8_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_uint8_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_uint8; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_uint8; } static void -_arg_cache_in_int16_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_int16_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_int16; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_int16; } static void -_arg_cache_out_int16_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_int16_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_int16; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_int16; } static void -_arg_cache_in_uint16_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_uint16_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_uint16; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_uint16; } static void -_arg_cache_out_uint16_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_uint16_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_uint16; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_uint16; } static void -_arg_cache_in_int32_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_int32_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_int32; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_int32; } static void -_arg_cache_out_int32_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_int32_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_int32; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_int32; } static void -_arg_cache_in_uint32_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_uint32_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_uint32; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_uint32; } static void -_arg_cache_out_uint32_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_uint32_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_uint32; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_uint32; } static void -_arg_cache_in_int64_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_int64_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_int64; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_int64; } static void -_arg_cache_out_int64_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_int64_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_int64; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_int64; } static void -_arg_cache_in_uint64_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_uint64_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_uint64; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_uint64; } static void -_arg_cache_out_uint64_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_uint64_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_uint64; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_uint64; } static void -_arg_cache_in_float_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_float_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_float; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_float; } static void -_arg_cache_out_float_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_float_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_float; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_float; } static void -_arg_cache_in_double_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_double_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_double; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_double; } static void -_arg_cache_out_double_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_double_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_double; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_double; } static void -_arg_cache_in_unichar_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_unichar_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_unichar; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_unichar; } static void -_arg_cache_out_unichar_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_unichar_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_unichar; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_unichar; } static void -_arg_cache_in_gtype_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_gtype_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_gtype; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_gtype; } static void -_arg_cache_out_gtype_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_gtype_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_gtype; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_gtype; } static void -_arg_cache_in_utf8_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_utf8_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_utf8; - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_utf8; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_utf8; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_utf8; } static void -_arg_cache_out_utf8_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_utf8_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_utf8; - arg_cache->out_cleanup = _pygi_marshal_cleanup_out_utf8; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_utf8; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_utf8; } static void -_arg_cache_in_filename_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_filename_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_filename; - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_utf8; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_filename; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_utf8; } static void -_arg_cache_out_filename_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_filename_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_filename; - arg_cache->out_cleanup = _pygi_marshal_cleanup_out_utf8; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_filename; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_utf8; } static gboolean -_arg_cache_in_array_setup (PyGIArgCache *arg_cache, - PyGICallableCache *callable_cache, - GITypeInfo *type_info, - GITransfer transfer, - GIDirection direction) +_arg_cache_from_py_array_setup (PyGIArgCache *arg_cache, + PyGICallableCache *callable_cache, + GITypeInfo *type_info, + GITransfer transfer, + PyGIDirection direction) { PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache; seq_cache->array_type = g_type_info_get_array_type (type_info); - arg_cache->in_marshaller = _pygi_marshal_in_array; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_array; if (seq_cache->len_arg_index >= 0 && - direction == GI_DIRECTION_IN) { + direction == PYGI_DIRECTION_FROM_PYTHON) { PyGIArgCache *child_cache = callable_cache->args_cache[seq_cache->len_arg_index]; @@ -486,50 +486,50 @@ _arg_cache_in_array_setup (PyGIArgCache *arg_cache, child_cache->meta_type = PYGI_META_ARG_TYPE_CHILD; child_cache->direction = direction; - child_cache->in_marshaller = NULL; - child_cache->out_marshaller = NULL; + child_cache->to_py_marshaller = NULL; + child_cache->from_py_marshaller = NULL; callable_cache->args_cache[seq_cache->len_arg_index] = child_cache; } - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_array; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_to_py_array; return TRUE; } static gboolean -_arg_cache_out_array_setup (PyGIArgCache *arg_cache, - PyGICallableCache *callable_cache, - GITypeInfo *type_info, - GITransfer transfer, - GIDirection direction, - gssize arg_index) +_arg_cache_to_py_array_setup (PyGIArgCache *arg_cache, + PyGICallableCache *callable_cache, + GITypeInfo *type_info, + GITransfer transfer, + PyGIDirection direction, + gssize arg_index) { PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache; - arg_cache->out_marshaller = _pygi_marshal_out_array; - arg_cache->out_cleanup = _pygi_marshal_cleanup_out_array; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_array; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_array; seq_cache->array_type = g_type_info_get_array_type (type_info); if (seq_cache->len_arg_index >= 0) { PyGIArgCache *child_cache = callable_cache->args_cache[seq_cache->len_arg_index]; if (seq_cache->len_arg_index < arg_index) - callable_cache->n_out_child_args++; + callable_cache->n_to_py_child_args++; if (child_cache != NULL) { if (child_cache->meta_type == PYGI_META_ARG_TYPE_CHILD) return TRUE; - callable_cache->out_args = - g_slist_remove (callable_cache->out_args, child_cache); + callable_cache->to_py_args = + g_slist_remove (callable_cache->to_py_args, child_cache); } else { child_cache = _arg_cache_alloc (); } child_cache->meta_type = PYGI_META_ARG_TYPE_CHILD; child_cache->direction = direction; - child_cache->in_marshaller = NULL; - child_cache->out_marshaller = NULL; + child_cache->to_py_marshaller = NULL; + child_cache->from_py_marshaller = NULL; callable_cache->args_cache[seq_cache->len_arg_index] = child_cache; } @@ -538,175 +538,177 @@ _arg_cache_out_array_setup (PyGIArgCache *arg_cache, } static void -_arg_cache_in_glist_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_glist_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_glist; - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_glist; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_glist; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_glist; } static void -_arg_cache_out_glist_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_glist_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_glist; - arg_cache->in_cleanup = _pygi_marshal_cleanup_out_glist; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_glist; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_glist; } static void -_arg_cache_in_gslist_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_gslist_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_gslist; - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_glist; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_gslist; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_glist; } static void -_arg_cache_out_gslist_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_gslist_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_gslist; - arg_cache->out_cleanup = _pygi_marshal_cleanup_out_glist; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_gslist; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_glist; } static void -_arg_cache_in_ghash_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_ghash_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_ghash; - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_ghash; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_ghash; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_ghash; } static void -_arg_cache_out_ghash_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_ghash_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_ghash; - arg_cache->out_cleanup = _pygi_marshal_cleanup_out_ghash; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_ghash; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_ghash; } static void -_arg_cache_in_gerror_setup (PyGIArgCache *arg_cache) +_arg_cache_from_py_gerror_setup (PyGIArgCache *arg_cache) { - arg_cache->in_marshaller = _pygi_marshal_in_gerror; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_gerror; arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD; } static void -_arg_cache_out_gerror_setup (PyGIArgCache *arg_cache) +_arg_cache_to_py_gerror_setup (PyGIArgCache *arg_cache) { - arg_cache->out_marshaller = _pygi_marshal_out_gerror; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_gerror; arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD; } static void -_arg_cache_in_interface_union_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_interface_union_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_interface_struct; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_struct; } static void -_arg_cache_out_interface_union_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_interface_union_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_interface_struct; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_interface_struct; } static void -_arg_cache_in_interface_struct_setup (PyGIArgCache *arg_cache, - GIInterfaceInfo *iface_info, - GITransfer transfer) +_arg_cache_from_py_interface_struct_setup (PyGIArgCache *arg_cache, + GIInterfaceInfo *iface_info, + GITransfer transfer) { PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; iface_cache->is_foreign = g_struct_info_is_foreign ( (GIStructInfo*)iface_info); - arg_cache->in_marshaller = _pygi_marshal_in_interface_struct; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_struct; if (iface_cache->g_type == G_TYPE_VALUE) - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_interface_struct_gvalue; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_interface_struct_gvalue; else if (iface_cache->is_foreign) - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_interface_struct_foreign; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_interface_struct_foreign; } static void -_arg_cache_out_interface_struct_setup (PyGIArgCache *arg_cache, - GIInterfaceInfo *iface_info, - GITransfer transfer) +_arg_cache_to_py_interface_struct_setup (PyGIArgCache *arg_cache, + GIInterfaceInfo *iface_info, + GITransfer transfer) { PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; iface_cache->is_foreign = g_struct_info_is_foreign ( (GIStructInfo*)iface_info); - arg_cache->out_marshaller = _pygi_marshal_out_interface_struct; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_interface_struct; if (iface_cache->is_foreign) - arg_cache->in_cleanup = _pygi_marshal_cleanup_out_interface_struct_foreign; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_interface_struct_foreign; } static void -_arg_cache_in_interface_object_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_interface_object_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_interface_object; - arg_cache->in_cleanup = _pygi_marshal_cleanup_in_interface_object; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_object; + arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_interface_object; } static void -_arg_cache_out_interface_object_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_interface_object_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_interface_object; - arg_cache->out_cleanup = _pygi_marshal_cleanup_out_interface_object; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_interface_object; + arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_interface_object; } static void -_arg_cache_in_interface_callback_setup (PyGIArgCache *arg_cache, - PyGICallableCache *callable_cache) +_arg_cache_from_py_interface_callback_setup (PyGIArgCache *arg_cache, + PyGICallableCache *callable_cache) { PyGICallbackCache *callback_cache = (PyGICallbackCache *)arg_cache; if (callback_cache->user_data_index >= 0) { PyGIArgCache *user_data_arg_cache = _arg_cache_alloc (); user_data_arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD_WITH_PYARG; + user_data_arg_cache->direction = PYGI_DIRECTION_FROM_PYTHON; callable_cache->args_cache[callback_cache->user_data_index] = user_data_arg_cache; } if (callback_cache->destroy_notify_index >= 0) { PyGIArgCache *destroy_arg_cache = _arg_cache_alloc (); destroy_arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD; + destroy_arg_cache->direction = PYGI_DIRECTION_FROM_PYTHON; callable_cache->args_cache[callback_cache->destroy_notify_index] = destroy_arg_cache; } - arg_cache->in_marshaller = _pygi_marshal_in_interface_callback; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_callback; } static void -_arg_cache_out_interface_callback_setup (void) +_arg_cache_to_py_interface_callback_setup (void) { PyErr_Format(PyExc_NotImplementedError, "Callback returns are not supported"); } static void -_arg_cache_in_interface_enum_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_interface_enum_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_interface_enum; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_enum; } static void -_arg_cache_out_interface_enum_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_interface_enum_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_interface_enum; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_interface_enum; } static void -_arg_cache_in_interface_flags_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_from_py_interface_flags_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->in_marshaller = _pygi_marshal_in_interface_flags; + arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_flags; } static void -_arg_cache_out_interface_flags_setup (PyGIArgCache *arg_cache, - GITransfer transfer) +_arg_cache_to_py_interface_flags_setup (PyGIArgCache *arg_cache, + GITransfer transfer) { - arg_cache->out_marshaller = _pygi_marshal_out_interface_flags; + arg_cache->to_py_marshaller = _pygi_marshal_to_py_interface_flags; } PyGIArgCache * @@ -714,7 +716,7 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info, PyGICallableCache *callable_cache, GIArgInfo *arg_info, GITransfer transfer, - GIDirection direction, + PyGIDirection direction, gssize c_arg_index, gssize py_arg_index) { @@ -743,52 +745,50 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info, switch (info_type) { case GI_INFO_TYPE_UNION: - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_union_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_union_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_interface_union_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_interface_union_setup (arg_cache, transfer); break; case GI_INFO_TYPE_STRUCT: - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_struct_setup (arg_cache, - iface_info, - transfer); - - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_interface_struct_setup (arg_cache, - iface_info, - transfer); - + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_struct_setup (arg_cache, + iface_info, + transfer); + + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_interface_struct_setup (arg_cache, + iface_info, + transfer); break; case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_object_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_object_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_interface_object_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_interface_object_setup (arg_cache, transfer); break; case GI_INFO_TYPE_BOXED: - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_struct_setup (arg_cache, - iface_info, - transfer); - - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_interface_struct_setup (arg_cache, + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_struct_setup (arg_cache, iface_info, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_interface_struct_setup (arg_cache, + iface_info, + transfer); break; case GI_INFO_TYPE_CALLBACK: { PyGICallbackCache *callback_cache; - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { - _arg_cache_out_interface_callback_setup (); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) { + _arg_cache_to_py_interface_callback_setup (); return NULL; } @@ -801,25 +801,25 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info, if (arg_cache == NULL) return NULL; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_callback_setup (arg_cache, callable_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_callback_setup (arg_cache, callable_cache); break; } case GI_INFO_TYPE_ENUM: - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_enum_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_enum_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_interface_enum_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_interface_enum_setup (arg_cache, transfer); break; case GI_INFO_TYPE_FLAGS: - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_interface_flags_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_interface_flags_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_interface_flags_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_interface_flags_setup (arg_cache, transfer); break; default: @@ -847,14 +847,14 @@ _arg_cache_new (GITypeInfo *type_info, PyGICallableCache *callable_cache, GIArgInfo *arg_info, GITransfer transfer, - GIDirection direction, + PyGIDirection direction, gssize c_arg_index, gssize py_arg_index) { PyGIArgCache *arg_cache = NULL; gssize child_offset = 0; GITypeTag type_tag; - + GI_IS_TYPE_INFO (type_info); type_tag = g_type_info_get_tag (type_info); @@ -870,22 +870,23 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_void_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_void_setup (arg_cache); + + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_void_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_void_setup (arg_cache); break; case GI_TYPE_TAG_BOOLEAN: arg_cache = _arg_cache_alloc (); if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_boolean_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_boolean_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_boolean_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_boolean_setup (arg_cache); break; case GI_TYPE_TAG_INT8: @@ -893,11 +894,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_int8_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_int8_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_int8_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_int8_setup (arg_cache); break; case GI_TYPE_TAG_UINT8: @@ -905,11 +906,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_uint8_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_uint8_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_uint8_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_uint8_setup (arg_cache); break; case GI_TYPE_TAG_INT16: @@ -917,11 +918,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_int16_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_int16_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_int16_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_int16_setup (arg_cache); break; case GI_TYPE_TAG_UINT16: @@ -929,23 +930,22 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_uint16_setup (arg_cache); - - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_uint16_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_uint16_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_uint16_setup (arg_cache); break; case GI_TYPE_TAG_INT32: arg_cache = _arg_cache_alloc (); if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_int32_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_int32_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_int32_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_int32_setup (arg_cache); break; case GI_TYPE_TAG_UINT32: @@ -953,11 +953,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_uint32_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_uint32_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_uint32_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_uint32_setup (arg_cache); break; case GI_TYPE_TAG_INT64: @@ -965,11 +965,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_int64_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_int64_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_int64_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_int64_setup (arg_cache); break; case GI_TYPE_TAG_UINT64: @@ -977,11 +977,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_uint64_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_uint64_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_uint64_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_uint64_setup (arg_cache); break; case GI_TYPE_TAG_FLOAT: @@ -989,11 +989,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_float_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_float_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_float_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_float_setup (arg_cache); break; case GI_TYPE_TAG_DOUBLE: @@ -1001,11 +1001,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_double_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_double_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_double_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_double_setup (arg_cache); break; case GI_TYPE_TAG_UNICHAR: @@ -1013,11 +1013,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_unichar_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_unichar_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_unichar_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_unichar_setup (arg_cache); break; case GI_TYPE_TAG_GTYPE: @@ -1025,11 +1025,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_gtype_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_gtype_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_gtype_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_gtype_setup (arg_cache); break; case GI_TYPE_TAG_UTF8: @@ -1037,11 +1037,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_utf8_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_utf8_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_utf8_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_utf8_setup (arg_cache, transfer); break; case GI_TYPE_TAG_FILENAME: @@ -1049,11 +1049,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_filename_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_filename_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_filename_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_filename_setup (arg_cache, transfer); break; case GI_TYPE_TAG_ARRAY: @@ -1068,20 +1068,20 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_array_setup (arg_cache, - callable_cache, - type_info, - transfer, - direction); - - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_array_setup (arg_cache, - callable_cache, - type_info, - transfer, - direction, - c_arg_index); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_array_setup (arg_cache, + callable_cache, + type_info, + transfer, + direction); + + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_array_setup (arg_cache, + callable_cache, + type_info, + transfer, + direction, + c_arg_index); /* ugly edge case code: * @@ -1120,11 +1120,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_glist_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_glist_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_glist_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_glist_setup (arg_cache, transfer); break; @@ -1141,11 +1141,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_gslist_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_gslist_setup (arg_cache, transfer); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_gslist_setup (arg_cache, transfer); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_gslist_setup (arg_cache, transfer); break; } @@ -1158,11 +1158,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_ghash_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_ghash_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { - _arg_cache_out_ghash_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) { + _arg_cache_to_py_ghash_setup (arg_cache); } break; @@ -1185,11 +1185,11 @@ _arg_cache_new (GITypeInfo *type_info, if (arg_cache == NULL) break; - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - _arg_cache_in_gerror_setup (arg_cache); + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_from_py_gerror_setup (arg_cache); - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) - _arg_cache_out_gerror_setup (arg_cache); + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) + _arg_cache_to_py_gerror_setup (arg_cache); break; } @@ -1225,8 +1225,8 @@ _arg_name_list_generate (PyGICallableCache *callable_cache) arg_cache = callable_cache->args_cache[i]; if (arg_cache->meta_type != PYGI_META_ARG_TYPE_CHILD && - (arg_cache->direction == GI_DIRECTION_IN || - arg_cache->direction == GI_DIRECTION_INOUT)) { + (arg_cache->direction == PYGI_DIRECTION_FROM_PYTHON || + arg_cache->direction == PYGI_DIRECTION_BIDIRECTIONAL)) { gpointer arg_name = (gpointer)arg_cache->arg_name; @@ -1250,6 +1250,13 @@ _args_cache_generate (GICallableInfo *callable_info, GITypeInfo *return_info; GITransfer return_transfer; PyGIArgCache *return_cache; + PyGIDirection return_direction; + + /* determine if we are marshalling the return to or from python */ + if (callable_cache->function_type == PYGI_FUNCTION_TYPE_CALLBACK) + return_direction = PYGI_DIRECTION_FROM_PYTHON; + else + return_direction = PYGI_DIRECTION_TO_PYTHON; /* cache the return arg */ return_info = @@ -1261,7 +1268,7 @@ _args_cache_generate (GICallableInfo *callable_info, callable_cache, NULL, return_transfer, - GI_DIRECTION_OUT, + return_direction, -1, -1); @@ -1274,6 +1281,10 @@ _args_cache_generate (GICallableInfo *callable_info, callable_cache->function_type == PYGI_FUNCTION_TYPE_VFUNC) { GIInterfaceInfo *interface_info; PyGIArgCache *instance_cache; + PyGIDirection instance_direction; + + instance_direction = PYGI_DIRECTION_FROM_PYTHON; + interface_info = g_base_info_get_container ( (GIBaseInfo *)callable_info); @@ -1282,11 +1293,12 @@ _args_cache_generate (GICallableInfo *callable_info, callable_cache, NULL, GI_TRANSFER_NOTHING, - GI_DIRECTION_IN, + instance_direction, arg_index, 0); - instance_cache->in_marshaller = _pygi_marshal_in_interface_instance; + /* FIXME: marshal interfaces from_py */ + instance_cache->from_py_marshaller = _pygi_marshal_from_py_interface_instance; g_base_info_unref ( (GIBaseInfo *)interface_info); if (instance_cache == NULL) @@ -1295,7 +1307,7 @@ _args_cache_generate (GICallableInfo *callable_info, callable_cache->args_cache[arg_index] = instance_cache; arg_index++; - callable_cache->n_in_args++; + callable_cache->n_from_py_args++; callable_cache->n_py_args++; } @@ -1304,7 +1316,8 @@ _args_cache_generate (GICallableInfo *callable_info, PyGIArgCache *arg_cache = NULL; GIArgInfo *arg_info; GITypeInfo *type_info; - GIDirection direction; + GIDirection gi_direction; + PyGIDirection direction; GITransfer transfer; GITypeTag type_tag; gboolean is_caller_allocates = FALSE; @@ -1313,7 +1326,21 @@ _args_cache_generate (GICallableInfo *callable_info, arg_info = g_callable_info_get_arg (callable_info, i); - direction = g_arg_info_get_direction (arg_info); + /* For vfuncs and callbacks our marshalling directions + are reversed */ + gi_direction = g_arg_info_get_direction (arg_info); + if (gi_direction == GI_DIRECTION_INOUT) { + direction = PYGI_DIRECTION_BIDIRECTIONAL; + } else if (gi_direction == GI_DIRECTION_IN) { + direction = PYGI_DIRECTION_FROM_PYTHON; + if (callable_cache->function_type == PYGI_FUNCTION_TYPE_CALLBACK) + direction = PYGI_DIRECTION_TO_PYTHON; + } else { + direction = PYGI_DIRECTION_TO_PYTHON; + if (callable_cache->function_type == PYGI_FUNCTION_TYPE_CALLBACK) + direction = PYGI_DIRECTION_FROM_PYTHON; + } + transfer = g_arg_info_get_ownership_transfer (arg_info); type_info = g_arg_info_get_type (arg_info); type_tag = g_type_info_get_tag (type_info); @@ -1322,8 +1349,8 @@ _args_cache_generate (GICallableInfo *callable_info, is_caller_allocates = g_arg_info_is_caller_allocates (arg_info); /* must be an child arg filled in by its owner - * fill in it's c_arg_index, add to the in count * and continue + * fill in it's c_arg_index, add to the in count */ if (callable_cache->args_cache[arg_index] != NULL) { arg_cache = callable_cache->args_cache[arg_index]; @@ -1332,23 +1359,23 @@ _args_cache_generate (GICallableInfo *callable_info, callable_cache->n_py_args++; } - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) { - arg_cache->c_arg_index = callable_cache->n_in_args; - callable_cache->n_in_args++; + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) { + arg_cache->c_arg_index = callable_cache->n_from_py_args; + callable_cache->n_from_py_args++; } - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { - callable_cache->n_out_args++; - callable_cache->n_out_child_args++; + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) { + callable_cache->n_to_py_args++; + callable_cache->n_to_py_child_args++; } g_base_info_unref ( (GIBaseInfo *)arg_info); continue; } - if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) { + if (direction == PYGI_DIRECTION_FROM_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) { py_arg_index = callable_cache->n_py_args; - callable_cache->n_in_args++; + callable_cache->n_from_py_args++; callable_cache->n_py_args++; } @@ -1368,14 +1395,14 @@ _args_cache_generate (GICallableInfo *callable_info, arg_cache->allow_none = g_arg_info_may_be_null(arg_info); arg_cache->is_caller_allocates = is_caller_allocates; - if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { - callable_cache->n_out_args++; + if (direction == PYGI_DIRECTION_TO_PYTHON || direction == PYGI_DIRECTION_BIDIRECTIONAL) { + callable_cache->n_to_py_args++; if (arg_cache == NULL) goto arg_err; - callable_cache->out_args = - g_slist_append (callable_cache->out_args, arg_cache); + callable_cache->to_py_args = + g_slist_append (callable_cache->to_py_args, arg_cache); } callable_cache->args_cache[arg_index] = arg_cache; diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h index a0e6e4f2..162c6e25 100644 --- a/gi/pygi-cache.h +++ b/gi/pygi-cache.h @@ -32,16 +32,16 @@ G_BEGIN_DECLS typedef struct _PyGICallableCache PyGICallableCache; typedef struct _PyGIArgCache PyGIArgCache; -typedef gboolean (*PyGIMarshalInFunc) (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); +typedef gboolean (*PyGIMarshalFromPyFunc) (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); -typedef PyObject *(*PyGIMarshalOutFunc) (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); +typedef PyObject *(*PyGIMarshalToPyFunc) (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); typedef void (*PyGIMarshalCleanupFunc) (PyGIInvokeState *state, PyGIArgCache *arg_cache, @@ -72,14 +72,28 @@ typedef enum { * PyGIFunctionType enum consolidates them into one enumeration for ease of * branching and debugging. */ - typedef enum { - PYGI_FUNCTION_TYPE_FUNCTION, - PYGI_FUNCTION_TYPE_METHOD, - PYGI_FUNCTION_TYPE_CONSTRUCTOR, - PYGI_FUNCTION_TYPE_VFUNC, - PYGI_FUNCTION_TYPE_CALLBACK +typedef enum { + PYGI_FUNCTION_TYPE_FUNCTION, + PYGI_FUNCTION_TYPE_METHOD, + PYGI_FUNCTION_TYPE_CONSTRUCTOR, + PYGI_FUNCTION_TYPE_VFUNC, + PYGI_FUNCTION_TYPE_CALLBACK } PyGIFunctionType; +/* + * In PyGI IN and OUT arguments mean different things depending on the context + * of the callable (e.g. is it a callback that is being called from C or a + * function that is being called from python). We don't as much care if the + * parameter is an IN or OUT C parameter, than we do if the parameter is being + * marshalled into Python or from Python. + */ +typedef enum { + PYGI_DIRECTION_TO_PYTHON, + PYGI_DIRECTION_FROM_PYTHON, + PYGI_DIRECTION_BIDIRECTIONAL + } PyGIDirection; + + struct _PyGIArgCache { const gchar *arg_name; @@ -90,16 +104,16 @@ struct _PyGIArgCache gboolean is_skipped; gboolean allow_none; - GIDirection direction; + PyGIDirection direction; GITransfer transfer; GITypeTag type_tag; GITypeInfo *type_info; - PyGIMarshalInFunc in_marshaller; - PyGIMarshalOutFunc out_marshaller; + PyGIMarshalFromPyFunc from_py_marshaller; + PyGIMarshalToPyFunc to_py_marshaller; - PyGIMarshalCleanupFunc in_cleanup; - PyGIMarshalCleanupFunc out_cleanup; + PyGIMarshalCleanupFunc from_py_cleanup; + PyGIMarshalCleanupFunc to_py_cleanup; GDestroyNotify destroy_notify; @@ -152,14 +166,14 @@ struct _PyGICallableCache PyGIArgCache *return_cache; PyGIArgCache **args_cache; - GSList *out_args; + GSList *to_py_args; GSList *arg_name_list; /* for keyword arg matching */ GHashTable *arg_name_hash; /* counts */ - gssize n_in_args; - gssize n_out_args; - gssize n_out_child_args; + gssize n_from_py_args; + gssize n_to_py_args; + gssize n_to_py_child_args; gssize n_args; gssize n_py_args; diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index 4a7366c2..f669c2e9 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -43,17 +43,17 @@ _invoke_callable (PyGIInvokeState *state, retval = g_vfunc_info_invoke ( callable_info, state->implementor_gtype, state->in_args, - cache->n_in_args, + cache->n_from_py_args, state->out_args, - cache->n_out_args, + cache->n_to_py_args, &state->return_arg, &error); else retval = g_function_info_invoke ( callable_info, state->in_args, - cache->n_in_args, + cache->n_from_py_args, state->out_args, - cache->n_out_args, + cache->n_to_py_args, &state->return_arg, &error); pyg_end_allow_threads; @@ -67,7 +67,7 @@ _invoke_callable (PyGIInvokeState *state, * We eventually should marshal directly to FFI so we no longer * have to use the reference implementation */ - pygi_marshal_cleanup_args_in_marshal_success (state, cache); + pygi_marshal_cleanup_args_from_py_marshal_success (state, cache); return FALSE; } @@ -76,7 +76,7 @@ _invoke_callable (PyGIInvokeState *state, if (pyglib_error_check (&(state->error))) { /* even though we errored out, the call itself was successful, so we assume the call processed all of the parameters */ - pygi_marshal_cleanup_args_in_marshal_success (state, cache); + pygi_marshal_cleanup_args_from_py_marshal_success (state, cache); return FALSE; } } @@ -299,20 +299,20 @@ _invoke_state_init_from_callable_cache (PyGIInvokeState *state, return FALSE; } - state->in_args = g_slice_alloc0 (cache->n_in_args * sizeof(GIArgument)); - if (state->in_args == NULL && cache->n_in_args != 0) { + state->in_args = g_slice_alloc0 (cache->n_from_py_args * sizeof(GIArgument)); + if (state->in_args == NULL && cache->n_from_py_args != 0) { PyErr_NoMemory (); return FALSE; } - state->out_values = g_slice_alloc0 (cache->n_out_args * sizeof(GIArgument)); - if (state->out_values == NULL && cache->n_out_args != 0) { + state->out_values = g_slice_alloc0 (cache->n_to_py_args * sizeof(GIArgument)); + if (state->out_values == NULL && cache->n_to_py_args != 0) { PyErr_NoMemory (); return FALSE; } - state->out_args = g_slice_alloc0 (cache->n_out_args * sizeof(GIArgument)); - if (state->out_args == NULL && cache->n_out_args != 0) { + state->out_args = g_slice_alloc0 (cache->n_to_py_args * sizeof(GIArgument)); + if (state->out_args == NULL && cache->n_to_py_args != 0) { PyErr_NoMemory (); return FALSE; } @@ -326,9 +326,9 @@ static inline void _invoke_state_clear (PyGIInvokeState *state, PyGICallableCache *cache) { g_slice_free1 (cache->n_args * sizeof(GIArgument *), state->args); - g_slice_free1 (cache->n_in_args * sizeof(GIArgument), state->in_args); - g_slice_free1 (cache->n_out_args * sizeof(GIArgument), state->out_args); - g_slice_free1 (cache->n_out_args * sizeof(GIArgument), state->out_values); + g_slice_free1 (cache->n_from_py_args * sizeof(GIArgument), state->in_args); + g_slice_free1 (cache->n_to_py_args * sizeof(GIArgument), state->out_args); + g_slice_free1 (cache->n_to_py_args * sizeof(GIArgument), state->out_values); Py_XDECREF (state->py_in_args); } @@ -396,7 +396,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache) PyObject *py_arg = NULL; switch (arg_cache->direction) { - case GI_DIRECTION_IN: + case PYGI_DIRECTION_FROM_PYTHON: state->args[i] = &(state->in_args[in_count]); in_count++; @@ -413,9 +413,9 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache) /* clean up all of the args we have already marshalled, * since invoke will not be called */ - pygi_marshal_cleanup_args_in_parameter_fail (state, - cache, - i - 1); + pygi_marshal_cleanup_args_from_py_parameter_fail (state, + cache, + i - 1); return FALSE; } @@ -424,7 +424,7 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache) arg_cache->py_arg_index); break; - case GI_DIRECTION_INOUT: + case PYGI_DIRECTION_BIDIRECTIONAL: /* this will be filled in if it is an child value */ if (state->in_args[in_count].v_pointer != NULL) state->out_values[out_count] = state->in_args[in_count]; @@ -439,9 +439,9 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache) cache->name, cache->n_py_args, state->n_py_in_args); - pygi_marshal_cleanup_args_in_parameter_fail (state, - cache, - i - 1); + pygi_marshal_cleanup_args_from_py_parameter_fail (state, + cache, + i - 1); return FALSE; } @@ -449,15 +449,15 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache) PyTuple_GET_ITEM (state->py_in_args, arg_cache->py_arg_index); } - case GI_DIRECTION_OUT: + case PYGI_DIRECTION_TO_PYTHON: if (arg_cache->is_caller_allocates) { if (!_caller_alloc (state, arg_cache, i, out_count)) { PyErr_Format (PyExc_TypeError, "Could not caller allocate argument %zd of callable %s", i, cache->name); - pygi_marshal_cleanup_args_in_parameter_fail (state, - cache, - i - 1); + pygi_marshal_cleanup_args_from_py_parameter_fail (state, + cache, + i - 1); return FALSE; } } else { @@ -469,26 +469,26 @@ _invoke_marshal_in_args (PyGIInvokeState *state, PyGICallableCache *cache) } c_arg = state->args[i]; - if (arg_cache->in_marshaller != NULL) { + if (arg_cache->from_py_marshaller != NULL) { if (!arg_cache->allow_none && py_arg == Py_None) { PyErr_Format (PyExc_TypeError, "Argument %i does not allow None as a value", i); - pygi_marshal_cleanup_args_in_parameter_fail (state, - cache, - i - 1); + pygi_marshal_cleanup_args_from_py_parameter_fail (state, + cache, + i - 1); return FALSE; } - gboolean success = arg_cache->in_marshaller (state, - cache, - arg_cache, - py_arg, - c_arg); - if (!success) { - pygi_marshal_cleanup_args_in_parameter_fail (state, + gboolean success = arg_cache->from_py_marshaller (state, cache, - i - 1); + arg_cache, + py_arg, + c_arg); + if (!success) { + pygi_marshal_cleanup_args_from_py_parameter_fail (state, + cache, + i - 1); return FALSE; } @@ -504,7 +504,7 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGICallableCache *cache) { PyObject *py_out = NULL; PyObject *py_return = NULL; - gssize total_out_args = cache->n_out_args; + gssize total_out_args = cache->n_to_py_args; gboolean has_return = FALSE; if (cache->return_cache) { @@ -518,10 +518,10 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGICallableCache *cache) } } - py_return = cache->return_cache->out_marshaller ( state, - cache, - cache->return_cache, - &state->return_arg); + py_return = cache->return_cache->to_py_marshaller ( state, + cache, + cache->return_cache, + &state->return_arg); if (py_return == NULL) { pygi_marshal_cleanup_args_return_fail (state, cache); @@ -535,39 +535,39 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGICallableCache *cache) } } else { if (cache->return_cache->transfer == GI_TRANSFER_EVERYTHING) { - PyGIMarshalCleanupFunc out_cleanup = - cache->return_cache->out_cleanup; - - if (out_cleanup != NULL) - out_cleanup ( state, - cache->return_cache, - &state->return_arg, - FALSE); + PyGIMarshalCleanupFunc to_py_cleanup = + cache->return_cache->to_py_cleanup; + + if (to_py_cleanup != NULL) + to_py_cleanup ( state, + cache->return_cache, + &state->return_arg, + FALSE); } } } - total_out_args -= cache->n_out_child_args; + total_out_args -= cache->n_to_py_child_args; - if (cache->n_out_args - cache->n_out_child_args == 0) { + if (cache->n_to_py_args - cache->n_to_py_child_args == 0) { py_out = py_return; } else if (total_out_args == 1) { /* if we get here there is one out arg an no return */ - PyGIArgCache *arg_cache = (PyGIArgCache *)cache->out_args->data; - py_out = arg_cache->out_marshaller (state, - cache, - arg_cache, - state->args[arg_cache->c_arg_index]); + PyGIArgCache *arg_cache = (PyGIArgCache *)cache->to_py_args->data; + py_out = arg_cache->to_py_marshaller (state, + cache, + arg_cache, + state->args[arg_cache->c_arg_index]); if (py_out == NULL) { - pygi_marshal_cleanup_args_out_parameter_fail (state, - cache, - 0); + pygi_marshal_cleanup_args_to_py_parameter_fail (state, + cache, + 0); return NULL; } } else { gssize py_arg_index = 0; - GSList *cache_item = cache->out_args; + GSList *cache_item = cache->to_py_args; /* return a tuple */ py_out = PyTuple_New (total_out_args); if (has_return) { @@ -577,18 +577,18 @@ _invoke_marshal_out_args (PyGIInvokeState *state, PyGICallableCache *cache) for(; py_arg_index < total_out_args; py_arg_index++) { PyGIArgCache *arg_cache = (PyGIArgCache *)cache_item->data; - PyObject *py_obj = arg_cache->out_marshaller (state, - cache, - arg_cache, - state->args[arg_cache->c_arg_index]); + PyObject *py_obj = arg_cache->to_py_marshaller (state, + cache, + arg_cache, + state->args[arg_cache->c_arg_index]); if (py_obj == NULL) { if (has_return) py_arg_index--; - pygi_marshal_cleanup_args_out_parameter_fail (state, - cache, - py_arg_index); + pygi_marshal_cleanup_args_to_py_parameter_fail (state, + cache, + py_arg_index); Py_DECREF (py_out); return NULL; } @@ -623,11 +623,11 @@ _wrap_g_callable_info_invoke (PyGIBaseInfo *self, if (!_invoke_callable (&state, self->cache, self->info)) goto err; - pygi_marshal_cleanup_args_in_marshal_success (&state, self->cache); + pygi_marshal_cleanup_args_from_py_marshal_success (&state, self->cache); ret = _invoke_marshal_out_args (&state, self->cache); if (ret) - pygi_marshal_cleanup_args_out_marshal_success (&state, self->cache); + pygi_marshal_cleanup_args_to_py_marshal_success (&state, self->cache); err: _invoke_state_clear (&state, self->cache); return ret; diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c index cd072f42..8ed9bdb2 100644 --- a/gi/pygi-marshal-cleanup.c +++ b/gi/pygi-marshal-cleanup.c @@ -66,42 +66,42 @@ _cleanup_caller_allocates (PyGIInvokeState *state, * stage (either success or failure) * * The in stage must call one of these cleanup functions: - * - pygi_marshal_cleanup_args_in_marshal_success + * - pygi_marshal_cleanup_args_from_py_marshal_success * (continue to out stage) - * - pygi_marshal_cleanup_args_in_parameter_fail + * - pygi_marshal_cleanup_args_from_py_parameter_fail * (final, exit from invoke) * * The out stage must call one of these cleanup functions which are all final: - * - pygi_marshal_cleanup_args_out_marshal_success + * - pygi_marshal_cleanup_args_to_py_marshal_success * - pygi_marshal_cleanup_args_return_fail - * - pygi_marshal_cleanup_args_out_parameter_fail + * - pygi_marshal_cleanup_args_to_py_parameter_fail * **/ void -pygi_marshal_cleanup_args_in_marshal_success (PyGIInvokeState *state, - PyGICallableCache *cache) +pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state, + PyGICallableCache *cache) { gssize i; /* For in success, call cleanup for all GI_DIRECTION_IN values only. */ for (i = 0; i < cache->n_args; i++) { PyGIArgCache *arg_cache = cache->args_cache[i]; - PyGIMarshalCleanupFunc cleanup_func = arg_cache->in_cleanup; + PyGIMarshalCleanupFunc cleanup_func = arg_cache->from_py_cleanup; if (cleanup_func && - arg_cache->direction == GI_DIRECTION_IN && + arg_cache->direction == PYGI_DIRECTION_FROM_PYTHON && state->args[i]->v_pointer != NULL) cleanup_func (state, arg_cache, state->args[i]->v_pointer, TRUE); } } void -pygi_marshal_cleanup_args_out_marshal_success (PyGIInvokeState *state, - PyGICallableCache *cache) +pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState *state, + PyGICallableCache *cache) { /* clean up the return if available */ if (cache->return_cache != NULL) { - PyGIMarshalCleanupFunc cleanup_func = cache->return_cache->out_cleanup; + PyGIMarshalCleanupFunc cleanup_func = cache->return_cache->to_py_cleanup; if (cleanup_func && state->return_arg.v_pointer != NULL) cleanup_func (state, cache->return_cache, @@ -110,10 +110,10 @@ pygi_marshal_cleanup_args_out_marshal_success (PyGIInvokeState *state, } /* Now clean up args */ - GSList *cache_item = cache->out_args; + GSList *cache_item = cache->to_py_args; while (cache_item) { PyGIArgCache *arg_cache = (PyGIArgCache *) cache_item->data; - PyGIMarshalCleanupFunc cleanup_func = arg_cache->out_cleanup; + PyGIMarshalCleanupFunc cleanup_func = arg_cache->to_py_cleanup; gpointer data = state->args[arg_cache->c_arg_index]->v_pointer; if (cleanup_func != NULL && data != NULL) @@ -127,9 +127,9 @@ pygi_marshal_cleanup_args_out_marshal_success (PyGIInvokeState *state, } void -pygi_marshal_cleanup_args_in_parameter_fail (PyGIInvokeState *state, - PyGICallableCache *cache, - gssize failed_arg_index) +pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state, + PyGICallableCache *cache, + gssize failed_arg_index) { gssize i; @@ -137,11 +137,11 @@ pygi_marshal_cleanup_args_in_parameter_fail (PyGIInvokeState *state, for (i = 0; i < cache->n_args && i <= failed_arg_index; i++) { PyGIArgCache *arg_cache = cache->args_cache[i]; - PyGIMarshalCleanupFunc cleanup_func = arg_cache->in_cleanup; + PyGIMarshalCleanupFunc cleanup_func = arg_cache->from_py_cleanup; gpointer data = state->args[i]->v_pointer; if (cleanup_func && - arg_cache->direction == GI_DIRECTION_IN && + arg_cache->direction == PYGI_DIRECTION_FROM_PYTHON && data != NULL) { cleanup_func (state, arg_cache, @@ -164,9 +164,9 @@ pygi_marshal_cleanup_args_return_fail (PyGIInvokeState *state, } void -pygi_marshal_cleanup_args_out_parameter_fail (PyGIInvokeState *state, +pygi_marshal_cleanup_args_to_py_parameter_fail (PyGIInvokeState *state, PyGICallableCache *cache, - gssize failed_out_arg_index) + gssize failed_to_py_arg_index) { state->failed = TRUE; } @@ -181,10 +181,10 @@ _pygi_marshal_cleanup_closure_unref (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_utf8 (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_utf8 (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { /* We strdup strings so always free if we have processed this parameter for input */ @@ -193,10 +193,10 @@ _pygi_marshal_cleanup_in_utf8 (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_out_utf8 (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_to_py_utf8 (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { /* Python copies the string so we need to free it if the interface is transfering ownership, @@ -206,10 +206,10 @@ _pygi_marshal_cleanup_out_utf8 (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_interface_object (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_interface_object (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { /* If we processed the parameter but fail before invoking the method, we need to remove the ref we added */ @@ -219,10 +219,10 @@ _pygi_marshal_cleanup_in_interface_object (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_out_interface_object (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_to_py_interface_object (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { /* If we error out and the object is not marshalled into a PyGObject we must take care of removing the ref */ @@ -231,10 +231,10 @@ _pygi_marshal_cleanup_out_interface_object (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_interface_struct_gvalue (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_interface_struct_gvalue (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (was_processed) { PyObject *py_arg = PyTuple_GET_ITEM (state->py_in_args, @@ -250,10 +250,10 @@ _pygi_marshal_cleanup_in_interface_struct_gvalue (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_interface_struct_foreign (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_interface_struct_foreign (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (state->failed && was_processed) pygi_struct_foreign_release ( @@ -262,10 +262,10 @@ _pygi_marshal_cleanup_in_interface_struct_foreign (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_out_interface_struct_foreign (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_to_py_interface_struct_foreign (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (!was_processed && arg_cache->transfer == GI_TRANSFER_EVERYTHING) pygi_struct_foreign_release ( @@ -274,10 +274,10 @@ _pygi_marshal_cleanup_out_interface_struct_foreign (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_array (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_array (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (was_processed) { GArray *array_; @@ -311,10 +311,10 @@ _pygi_marshal_cleanup_in_array (PyGIInvokeState *state, } /* clean up items first */ - if (sequence_cache->item_cache->in_cleanup != NULL) { + if (sequence_cache->item_cache->from_py_cleanup != NULL) { gsize i; PyGIMarshalCleanupFunc cleanup_func = - sequence_cache->item_cache->in_cleanup; + sequence_cache->item_cache->from_py_cleanup; for(i = 0; i < array_->len; i++) { cleanup_func (state, @@ -335,10 +335,10 @@ _pygi_marshal_cleanup_in_array (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_out_array (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_to_py_array (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache; @@ -351,10 +351,10 @@ _pygi_marshal_cleanup_out_array (PyGIInvokeState *state, return; } - if (sequence_cache->item_cache->out_cleanup != NULL) { + if (sequence_cache->item_cache->to_py_cleanup != NULL) { gsize i; - PyGIMarshalCleanupFunc cleanup_func = sequence_cache->item_cache->out_cleanup; + PyGIMarshalCleanupFunc cleanup_func = sequence_cache->item_cache->to_py_cleanup; for (i = 0; i < array_->len; i++) { cleanup_func (state, sequence_cache->item_cache, @@ -369,10 +369,10 @@ _pygi_marshal_cleanup_out_array (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_glist (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_glist (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (was_processed) { GSList *list_; @@ -381,9 +381,9 @@ _pygi_marshal_cleanup_in_glist (PyGIInvokeState *state, list_ = (GSList *)data; /* clean up items first */ - if (sequence_cache->item_cache->in_cleanup != NULL) { + if (sequence_cache->item_cache->from_py_cleanup != NULL) { PyGIMarshalCleanupFunc cleanup_func = - sequence_cache->item_cache->in_cleanup; + sequence_cache->item_cache->from_py_cleanup; GSList *node = list_; while (node != NULL) { cleanup_func (state, @@ -412,10 +412,10 @@ _pygi_marshal_cleanup_in_glist (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_out_glist (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_to_py_glist (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache; @@ -423,9 +423,9 @@ _pygi_marshal_cleanup_out_glist (PyGIInvokeState *state, arg_cache->transfer == GI_TRANSFER_CONTAINER) { GSList *list_ = (GSList *)data; - if (sequence_cache->item_cache->out_cleanup != NULL) { + if (sequence_cache->item_cache->to_py_cleanup != NULL) { PyGIMarshalCleanupFunc cleanup_func = - sequence_cache->item_cache->out_cleanup; + sequence_cache->item_cache->to_py_cleanup; GSList *node = list_; while (node != NULL) { @@ -453,10 +453,10 @@ _pygi_marshal_cleanup_out_glist (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_in_ghash (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_from_py_ghash (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (data == NULL) return; @@ -468,16 +468,16 @@ _pygi_marshal_cleanup_in_ghash (PyGIInvokeState *state, hash_ = (GHashTable *)data; /* clean up keys and values first */ - if (hash_cache->key_cache->in_cleanup != NULL || - hash_cache->value_cache->in_cleanup != NULL) { + if (hash_cache->key_cache->from_py_cleanup != NULL || + hash_cache->value_cache->from_py_cleanup != NULL) { GHashTableIter hiter; gpointer key; gpointer value; PyGIMarshalCleanupFunc key_cleanup_func = - hash_cache->key_cache->in_cleanup; + hash_cache->key_cache->from_py_cleanup; PyGIMarshalCleanupFunc value_cleanup_func = - hash_cache->value_cache->in_cleanup; + hash_cache->value_cache->from_py_cleanup; g_hash_table_iter_init (&hiter, hash_); while (g_hash_table_iter_next (&hiter, &key, &value)) { @@ -503,10 +503,10 @@ _pygi_marshal_cleanup_in_ghash (PyGIInvokeState *state, } void -_pygi_marshal_cleanup_out_ghash (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed) +_pygi_marshal_cleanup_to_py_ghash (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed) { if (data == NULL) return; diff --git a/gi/pygi-marshal-cleanup.h b/gi/pygi-marshal-cleanup.h index 3aff8fa1..92027bef 100644 --- a/gi/pygi-marshal-cleanup.h +++ b/gi/pygi-marshal-cleanup.h @@ -26,72 +26,72 @@ G_BEGIN_DECLS -void pygi_marshal_cleanup_args_in_marshal_success (PyGIInvokeState *state, - PyGICallableCache *cache); -void pygi_marshal_cleanup_args_in_parameter_fail (PyGIInvokeState *state, - PyGICallableCache *cache, - gssize failed_arg_index); +void pygi_marshal_cleanup_args_from_py_marshal_success (PyGIInvokeState *state, + PyGICallableCache *cache); +void pygi_marshal_cleanup_args_from_py_parameter_fail (PyGIInvokeState *state, + PyGICallableCache *cache, + gssize failed_arg_index); -void pygi_marshal_cleanup_args_out_marshal_success (PyGIInvokeState *state, - PyGICallableCache *cache); -void pygi_marshal_cleanup_args_return_fail (PyGIInvokeState *state, - PyGICallableCache *cache); -void pygi_marshal_cleanup_args_out_parameter_fail (PyGIInvokeState *state, - PyGICallableCache *cache, - gssize failed_out_arg_index); +void pygi_marshal_cleanup_args_to_py_marshal_success (PyGIInvokeState *state, + PyGICallableCache *cache); +void pygi_marshal_cleanup_args_return_fail (PyGIInvokeState *state, + PyGICallableCache *cache); +void pygi_marshal_cleanup_args_to_py_parameter_fail (PyGIInvokeState *state, + PyGICallableCache *cache, + gssize failed_to_py_arg_index); -void _pygi_marshal_cleanup_in_utf8 (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_out_utf8 (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_in_interface_struct_gvalue (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_in_interface_struct_foreign (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_out_interface_struct_foreign (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_in_interface_object (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_out_interface_object (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_in_array (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_out_array (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_in_glist (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_out_glist (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_in_ghash (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); -void _pygi_marshal_cleanup_out_ghash (PyGIInvokeState *state, - PyGIArgCache *arg_cache, - gpointer data, - gboolean was_processed); +void _pygi_marshal_cleanup_from_py_utf8 (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_to_py_utf8 (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_from_py_interface_struct_gvalue (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_from_py_interface_struct_foreign (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_to_py_interface_struct_foreign (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_from_py_interface_object (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_to_py_interface_object (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_from_py_array (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_to_py_array (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_from_py_glist (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_to_py_glist (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_from_py_ghash (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); +void _pygi_marshal_cleanup_to_py_ghash (PyGIInvokeState *state, + PyGIArgCache *arg_cache, + gpointer data, + gboolean was_processed); G_END_DECLS #endif /* __PYGI_MARSHAL_CLEANUP_H__ */ diff --git a/gi/pygi-marshal-in.c b/gi/pygi-marshal-from-py.c index 9ae7def8..03244918 100644 --- a/gi/pygi-marshal-in.c +++ b/gi/pygi-marshal-from-py.c @@ -3,7 +3,7 @@ * * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>, Red Hat, Inc. * - * pygi-marshal-in.c: PyObject conversion functions for in parameters. + * pygi-marshal-from-py.c: Functions to convert PyObjects to C types. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,14 +32,14 @@ #include "pygi-cache.h" #include "pygi-marshal-cleanup.h" -#include "pygi-marshal-in.h" +#include "pygi-marshal-from-py.h" gboolean -_pygi_marshal_in_void (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_void (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { g_warn_if_fail (arg_cache->transfer == GI_TRANSFER_NOTHING); @@ -49,11 +49,11 @@ _pygi_marshal_in_void (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_boolean (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_boolean (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { arg->v_boolean = PyObject_IsTrue (py_arg); @@ -61,11 +61,11 @@ _pygi_marshal_in_boolean (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_int8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_int8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; long long_; @@ -100,11 +100,11 @@ _pygi_marshal_in_int8 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_uint8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_uint8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { unsigned long long_; @@ -149,11 +149,11 @@ _pygi_marshal_in_uint8 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_int16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_int16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; long long_; @@ -188,11 +188,11 @@ _pygi_marshal_in_int16 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_uint16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_uint16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; long long_; @@ -227,11 +227,11 @@ _pygi_marshal_in_uint16 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_int32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_int32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; long long_; @@ -266,11 +266,11 @@ _pygi_marshal_in_int32 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_uint32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_uint32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; long long long_; @@ -311,11 +311,11 @@ _pygi_marshal_in_uint32 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_int64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_int64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; long long long_; @@ -383,11 +383,11 @@ _pygi_marshal_in_int64 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_uint64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_uint64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_long; guint64 ulong_; @@ -462,11 +462,11 @@ _pygi_marshal_in_uint64 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_float (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_float (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_float; double double_; @@ -501,11 +501,11 @@ _pygi_marshal_in_float (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_double (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_double (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *py_float; double double_; @@ -540,11 +540,11 @@ _pygi_marshal_in_double (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_unichar (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_unichar (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { Py_ssize_t size; gchar *string_; @@ -586,11 +586,11 @@ _pygi_marshal_in_unichar (PyGIInvokeState *state, return TRUE; } gboolean -_pygi_marshal_in_gtype (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_gtype (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { long type_ = pyg_type_from_object (py_arg); @@ -604,11 +604,11 @@ _pygi_marshal_in_gtype (PyGIInvokeState *state, return TRUE; } gboolean -_pygi_marshal_in_utf8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_utf8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { gchar *string_; @@ -641,11 +641,11 @@ _pygi_marshal_in_utf8 (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_filename (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_filename (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { gchar *string_; GError *error = NULL; @@ -683,13 +683,13 @@ _pygi_marshal_in_filename (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_array (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_array (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { - PyGIMarshalInFunc in_marshaller; + PyGIMarshalFromPyFunc from_py_marshaller; int i; Py_ssize_t length; gboolean is_ptr_array; @@ -742,18 +742,18 @@ _pygi_marshal_in_array (PyGIInvokeState *state, goto array_success; } - in_marshaller = sequence_cache->item_cache->in_marshaller; + from_py_marshaller = sequence_cache->item_cache->from_py_marshaller; for (i = 0; i < length; i++) { GIArgument item; PyObject *py_item = PySequence_GetItem (py_arg, i); if (py_item == NULL) goto err; - if (!in_marshaller ( state, - callable_cache, - sequence_cache->item_cache, - py_item, - &item)) + if (!from_py_marshaller ( state, + callable_cache, + sequence_cache->item_cache, + py_item, + &item)) goto err; /* FIXME: it is much more efficent to have seperate marshaller @@ -766,10 +766,10 @@ _pygi_marshal_in_array (PyGIInvokeState *state, g_array_insert_val (array_, i, item); continue; err: - if (sequence_cache->item_cache->in_cleanup != NULL) { + if (sequence_cache->item_cache->from_py_cleanup != NULL) { gsize j; PyGIMarshalCleanupFunc cleanup_func = - sequence_cache->item_cache->in_cleanup; + sequence_cache->item_cache->from_py_cleanup; for(j = 0; j < i; j++) { cleanup_func (state, @@ -780,7 +780,7 @@ err: } if (is_ptr_array) - g_ptr_array_free (array_, TRUE); + g_ptr_array_free ( ( GPtrArray *)array_, TRUE); else g_array_free (array_, TRUE); _PyGI_ERROR_PREFIX ("Item %i: ", i); @@ -793,7 +793,7 @@ array_success: PyGIArgCache *child_cache = callable_cache->args_cache[sequence_cache->len_arg_index]; - if (child_cache->direction == GI_DIRECTION_INOUT) { + if (child_cache->direction == PYGI_DIRECTION_BIDIRECTIONAL) { gint *len_arg = (gint *)state->in_args[child_cache->c_arg_index].v_pointer; /* if we are not setup yet just set the in arg */ if (len_arg == NULL) @@ -816,13 +816,13 @@ array_success: } gboolean -_pygi_marshal_in_glist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_glist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { - PyGIMarshalInFunc in_marshaller; + PyGIMarshalFromPyFunc from_py_marshaller; int i; Py_ssize_t length; GList *list_ = NULL; @@ -852,25 +852,25 @@ _pygi_marshal_in_glist (PyGIInvokeState *state, return FALSE; } - in_marshaller = sequence_cache->item_cache->in_marshaller; + from_py_marshaller = sequence_cache->item_cache->from_py_marshaller; for (i = 0; i < length; i++) { GIArgument item; PyObject *py_item = PySequence_GetItem (py_arg, i); if (py_item == NULL) goto err; - if (!in_marshaller ( state, - callable_cache, - sequence_cache->item_cache, - py_item, - &item)) + if (!from_py_marshaller ( state, + callable_cache, + sequence_cache->item_cache, + py_item, + &item)) goto err; list_ = g_list_append (list_, item.v_pointer); continue; err: - if (sequence_cache->item_cache->in_cleanup != NULL) { - GDestroyNotify cleanup = sequence_cache->item_cache->in_cleanup; + if (sequence_cache->item_cache->from_py_cleanup != NULL) { + PyGIMarshalCleanupFunc cleanup = sequence_cache->item_cache->from_py_cleanup; } g_list_free (list_); @@ -883,13 +883,13 @@ err: } gboolean -_pygi_marshal_in_gslist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_gslist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { - PyGIMarshalInFunc in_marshaller; + PyGIMarshalFromPyFunc from_py_marshaller; int i; Py_ssize_t length; GSList *list_ = NULL; @@ -918,14 +918,14 @@ _pygi_marshal_in_gslist (PyGIInvokeState *state, return FALSE; } - in_marshaller = sequence_cache->item_cache->in_marshaller; + from_py_marshaller = sequence_cache->item_cache->from_py_marshaller; for (i = 0; i < length; i++) { GIArgument item; PyObject *py_item = PySequence_GetItem (py_arg, i); if (py_item == NULL) goto err; - if (!in_marshaller ( state, + if (!from_py_marshaller ( state, callable_cache, sequence_cache->item_cache, py_item, @@ -935,8 +935,8 @@ _pygi_marshal_in_gslist (PyGIInvokeState *state, list_ = g_slist_append (list_, item.v_pointer); continue; err: - if (sequence_cache->item_cache->in_cleanup != NULL) { - GDestroyNotify cleanup = sequence_cache->item_cache->in_cleanup; + if (sequence_cache->item_cache->from_py_cleanup != NULL) { + PyGIMarshalCleanupFunc cleanup = sequence_cache->item_cache->from_py_cleanup; } g_slist_free (list_); @@ -949,14 +949,14 @@ err: } gboolean -_pygi_marshal_in_ghash (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_ghash (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { - PyGIMarshalInFunc key_in_marshaller; - PyGIMarshalInFunc value_in_marshaller; + PyGIMarshalFromPyFunc key_from_py_marshaller; + PyGIMarshalFromPyFunc value_from_py_marshaller; int i; Py_ssize_t length; @@ -992,8 +992,8 @@ _pygi_marshal_in_ghash (PyGIInvokeState *state, return FALSE; } - key_in_marshaller = hash_cache->key_cache->in_marshaller; - value_in_marshaller = hash_cache->value_cache->in_marshaller; + key_from_py_marshaller = hash_cache->key_cache->from_py_marshaller; + value_from_py_marshaller = hash_cache->value_cache->from_py_marshaller; switch (hash_cache->key_cache->type_tag) { case GI_TYPE_TAG_UTF8: @@ -1021,18 +1021,18 @@ _pygi_marshal_in_ghash (PyGIInvokeState *state, if (py_key == NULL || py_value == NULL) goto err; - if (!key_in_marshaller ( state, - callable_cache, - hash_cache->key_cache, - py_key, - &key)) + if (!key_from_py_marshaller ( state, + callable_cache, + hash_cache->key_cache, + py_key, + &key)) goto err; - if (!value_in_marshaller ( state, - callable_cache, - hash_cache->value_cache, - py_value, - &value)) + if (!value_from_py_marshaller ( state, + callable_cache, + hash_cache->value_cache, + py_value, + &value)) goto err; g_hash_table_insert (hash_, key.v_pointer, value.v_pointer); @@ -1053,11 +1053,11 @@ err: } gboolean -_pygi_marshal_in_gerror (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_gerror (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyErr_Format (PyExc_NotImplementedError, "Marshalling for GErrors is not implemented"); @@ -1065,11 +1065,11 @@ _pygi_marshal_in_gerror (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_interface_callback (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_callback (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { GICallableInfo *callable_info; PyGICClosure *closure; @@ -1134,11 +1134,11 @@ _pygi_marshal_in_interface_callback (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_interface_enum (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_enum (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *int_; gint is_instance; @@ -1186,11 +1186,11 @@ err: } gboolean -_pygi_marshal_in_interface_flags (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_flags (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyObject *int_; gint is_instance; @@ -1221,11 +1221,11 @@ err: } gboolean -_pygi_marshal_in_interface_struct (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_struct (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; @@ -1320,11 +1320,11 @@ _pygi_marshal_in_interface_struct (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_interface_boxed (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_boxed (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyErr_Format (PyExc_NotImplementedError, "Marshalling for this type is not implemented yet"); @@ -1332,11 +1332,11 @@ _pygi_marshal_in_interface_boxed (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_interface_object (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_object (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { if (py_arg == Py_None) { arg->v_pointer = NULL; @@ -1358,22 +1358,22 @@ _pygi_marshal_in_interface_object (PyGIInvokeState *state, } gboolean -_pygi_marshal_in_interface_union (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +_pygi_marshal_from_py_interface_union (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { PyErr_Format(PyExc_NotImplementedError, "Marshalling for this type is not implemented yet"); return FALSE; } -gboolean _pygi_marshal_in_interface_instance (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg) +gboolean _pygi_marshal_from_py_interface_instance (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg) { GIInfoType info_type; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; diff --git a/gi/pygi-marshal-from-py.h b/gi/pygi-marshal-from-py.h new file mode 100644 index 00000000..34511db3 --- /dev/null +++ b/gi/pygi-marshal-from-py.h @@ -0,0 +1,186 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * vim: tabstop=4 shiftwidth=4 expandtab + * + * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>, Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#ifndef __PYGI_MARSHAL_from_py_PY_H__ +#define __PYGI_MARSHAL_from_py_PY_H__ + +#include <Python.h> + +#include <girepository.h> + +#include "pygi-private.h" + +G_BEGIN_DECLS + +gboolean _pygi_marshal_from_py_void (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_boolean (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_int8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_uint8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_int16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_uint16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_int32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_uint32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_int64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_uint64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_float (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_double (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_unichar (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_gtype (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_utf8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_filename (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_array (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_glist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_gslist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_ghash (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_gerror (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_callback (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_enum (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_flags (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_struct (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_interface(PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_boxed (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_object (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_union (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); +gboolean _pygi_marshal_from_py_interface_instance (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + PyObject *py_arg, + GIArgument *arg); + +G_END_DECLS + +#endif /* __PYGI_MARSHAL_from_py_PY__ */ diff --git a/gi/pygi-marshal-in.h b/gi/pygi-marshal-in.h deleted file mode 100644 index 7d948bc9..00000000 --- a/gi/pygi-marshal-in.h +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C; c-basic-offset: 4 -*- - * vim: tabstop=4 shiftwidth=4 expandtab - * - * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef __PYGI_MARSHAL_H__ -#define __PYGI_MARSHAL_H__ - -#include <Python.h> - -#include <girepository.h> - -#include "pygi-private.h" - -G_BEGIN_DECLS - -gboolean _pygi_marshal_in_void (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_boolean (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_int8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_uint8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_int16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_uint16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_int32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_uint32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_int64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_uint64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_float (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_double (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_unichar (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_gtype (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_utf8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_filename (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_array (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_glist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_gslist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_ghash (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_gerror (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_callback (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_enum (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_flags (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_struct (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_interface(PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_boxed (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_object (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_union (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); -gboolean _pygi_marshal_in_interface_instance (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg); - -G_END_DECLS - -#endif /* __PYGI_MARSHAL_H__ */ diff --git a/gi/pygi-marshal-out.h b/gi/pygi-marshal-out.h deleted file mode 100644 index db6bcfed..00000000 --- a/gi/pygi-marshal-out.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C; c-basic-offset: 4 -*- - * vim: tabstop=4 shiftwidth=4 expandtab - * - * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - * USA - */ - -#ifndef __PYGI_MARSHAL_OUT_H__ -#define __PYGI_MARSHAL_OUT_H__ - -PyObject *_pygi_marshal_out_void (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_boolean (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_int8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_uint8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_int16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_uint16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_int32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_uint32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_int64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_uint64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_float (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_double (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_unichar (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_gtype (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_utf8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_filename (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_array (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_glist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_gslist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_ghash (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_gerror (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_callback(PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_enum (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_flags (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_struct (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_interface(PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_boxed (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_object (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); -PyObject *_pygi_marshal_out_interface_union (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg); - -G_END_DECLS - -#endif /* __PYGI_MARSHAL_OUT_H__ */ diff --git a/gi/pygi-marshal-out.c b/gi/pygi-marshal-to-py.c index e72db80c..cb62c49c 100644 --- a/gi/pygi-marshal-out.c +++ b/gi/pygi-marshal-to-py.c @@ -3,7 +3,7 @@ * * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>, Red Hat, Inc. * - * pygi-marshal-out.c: PyObject conversion functions for out parameters. + * pygi-marshal-from-py.c: functions for converting C types to PyObject * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,13 +32,13 @@ #include "pygi-cache.h" #include "pygi-marshal-cleanup.h" -#include "pygi-marshal-out.h" +#include "pygi-marshal-to-py.h" PyObject * -_pygi_marshal_out_void (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_void (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; if (arg_cache->is_pointer) @@ -51,30 +51,30 @@ _pygi_marshal_out_void (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_boolean (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_boolean (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PyBool_FromLong (arg->v_boolean); return py_obj; } PyObject * -_pygi_marshal_out_int8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_int8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PYGLIB_PyLong_FromLong (arg->v_int8); return py_obj; } PyObject * -_pygi_marshal_out_uint8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_uint8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PYGLIB_PyLong_FromLong (arg->v_uint8); @@ -82,10 +82,10 @@ _pygi_marshal_out_uint8 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_int16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_int16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PYGLIB_PyLong_FromLong (arg->v_int16); @@ -93,10 +93,10 @@ _pygi_marshal_out_int16 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_uint16 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_uint16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PYGLIB_PyLong_FromLong (arg->v_uint16); @@ -104,10 +104,10 @@ _pygi_marshal_out_uint16 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_int32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_int32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PYGLIB_PyLong_FromLong (arg->v_int32); @@ -115,10 +115,10 @@ _pygi_marshal_out_int32 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_uint32 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_uint32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PyLong_FromLongLong (arg->v_uint32); @@ -126,10 +126,10 @@ _pygi_marshal_out_uint32 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_int64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_int64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PyLong_FromLongLong (arg->v_int64); @@ -137,10 +137,10 @@ _pygi_marshal_out_int64 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_uint64 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_uint64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PyLong_FromUnsignedLongLong (arg->v_uint64); @@ -148,10 +148,10 @@ _pygi_marshal_out_uint64 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_float (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_float (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PyFloat_FromDouble (arg->v_float); @@ -159,10 +159,10 @@ _pygi_marshal_out_float (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_double (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_double (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = PyFloat_FromDouble (arg->v_double); @@ -170,10 +170,10 @@ _pygi_marshal_out_double (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_unichar (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_unichar (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; @@ -197,10 +197,10 @@ _pygi_marshal_out_unichar (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_gtype (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_gtype (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; @@ -209,10 +209,10 @@ _pygi_marshal_out_gtype (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_utf8 (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_utf8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; if (arg->v_string == NULL) { @@ -226,10 +226,10 @@ _pygi_marshal_out_utf8 (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_filename (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_filename (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { gchar *string; PyObject *py_obj = NULL; @@ -255,10 +255,10 @@ _pygi_marshal_out_filename (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_array (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_array (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { GArray *array_; PyObject *py_obj = NULL; @@ -311,7 +311,7 @@ _pygi_marshal_out_array (PyGIInvokeState *state, int i; gsize item_size; - PyGIMarshalOutFunc item_out_marshaller; + PyGIMarshalToPyFunc item_to_py_marshaller; PyGIArgCache *item_arg_cache; py_obj = PyList_New (array_->len); @@ -320,7 +320,7 @@ _pygi_marshal_out_array (PyGIInvokeState *state, item_arg_cache = seq_cache->item_cache; - item_out_marshaller = item_arg_cache->out_marshaller; + item_to_py_marshaller = item_arg_cache->to_py_marshaller; item_size = g_array_get_element_size (array_); @@ -351,7 +351,7 @@ _pygi_marshal_out_array (PyGIInvokeState *state, memcpy (&item_arg, array_->data + i * item_size, item_size); } - py_item = item_out_marshaller ( state, + py_item = item_to_py_marshaller ( state, callable_cache, item_arg_cache, &item_arg); @@ -380,9 +380,9 @@ err: g_array_free (array_, arg_cache->transfer == GI_TRANSFER_EVERYTHING); } else { /* clean up unprocessed items */ - if (seq_cache->item_cache->out_cleanup != NULL) { + if (seq_cache->item_cache->to_py_cleanup != NULL) { int j; - PyGIMarshalCleanupFunc cleanup_func = seq_cache->item_cache->out_cleanup; + PyGIMarshalCleanupFunc cleanup_func = seq_cache->item_cache->to_py_cleanup; for (j = processed_items; j < array_->len; j++) { cleanup_func (state, seq_cache->item_cache, @@ -399,16 +399,16 @@ err: } PyObject * -_pygi_marshal_out_glist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_glist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { GList *list_; gsize length; gsize i; - PyGIMarshalOutFunc item_out_marshaller; + PyGIMarshalToPyFunc item_to_py_marshaller; PyGIArgCache *item_arg_cache; PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache; @@ -422,14 +422,14 @@ _pygi_marshal_out_glist (PyGIInvokeState *state, return NULL; item_arg_cache = seq_cache->item_cache; - item_out_marshaller = item_arg_cache->out_marshaller; + item_to_py_marshaller = item_arg_cache->to_py_marshaller; for (i = 0; list_ != NULL; list_ = g_list_next (list_), i++) { GIArgument item_arg; PyObject *py_item; item_arg.v_pointer = list_->data; - py_item = item_out_marshaller ( state, + py_item = item_to_py_marshaller ( state, callable_cache, item_arg_cache, &item_arg); @@ -447,16 +447,16 @@ _pygi_marshal_out_glist (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_gslist (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_gslist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { GSList *list_; gsize length; gsize i; - PyGIMarshalOutFunc item_out_marshaller; + PyGIMarshalToPyFunc item_to_py_marshaller; PyGIArgCache *item_arg_cache; PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache; @@ -470,14 +470,14 @@ _pygi_marshal_out_gslist (PyGIInvokeState *state, return NULL; item_arg_cache = seq_cache->item_cache; - item_out_marshaller = item_arg_cache->out_marshaller; + item_to_py_marshaller = item_arg_cache->to_py_marshaller; for (i = 0; list_ != NULL; list_ = g_slist_next (list_), i++) { GIArgument item_arg; PyObject *py_item; item_arg.v_pointer = list_->data; - py_item = item_out_marshaller ( state, + py_item = item_to_py_marshaller ( state, callable_cache, item_arg_cache, &item_arg); @@ -495,16 +495,16 @@ _pygi_marshal_out_gslist (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_ghash (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_ghash (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { GHashTable *hash_; GHashTableIter hash_table_iter; - PyGIMarshalOutFunc key_out_marshaller; - PyGIMarshalOutFunc value_out_marshaller; + PyGIMarshalToPyFunc key_to_py_marshaller; + PyGIMarshalToPyFunc value_to_py_marshaller; PyGIArgCache *key_arg_cache; PyGIArgCache *value_arg_cache; @@ -528,10 +528,10 @@ _pygi_marshal_out_ghash (PyGIInvokeState *state, return NULL; key_arg_cache = hash_cache->key_cache; - key_out_marshaller = key_arg_cache->out_marshaller; + key_to_py_marshaller = key_arg_cache->to_py_marshaller; value_arg_cache = hash_cache->value_cache; - value_out_marshaller = value_arg_cache->out_marshaller; + value_to_py_marshaller = value_arg_cache->to_py_marshaller; g_hash_table_iter_init (&hash_table_iter, hash_); while (g_hash_table_iter_next (&hash_table_iter, @@ -541,7 +541,7 @@ _pygi_marshal_out_ghash (PyGIInvokeState *state, PyObject *py_value; int retval; - py_key = key_out_marshaller ( state, + py_key = key_to_py_marshaller ( state, callable_cache, key_arg_cache, &key_arg); @@ -551,7 +551,7 @@ _pygi_marshal_out_ghash (PyGIInvokeState *state, return NULL; } - py_value = value_out_marshaller ( state, + py_value = value_to_py_marshaller ( state, callable_cache, value_arg_cache, &value_arg); @@ -577,36 +577,36 @@ _pygi_marshal_out_ghash (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_gerror (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_gerror (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; PyErr_Format (PyExc_NotImplementedError, - "Marshalling for gerror out is not implemented"); + "Marshalling for gerror to PyObject is not implemented"); return py_obj; } PyObject * -_pygi_marshal_out_interface_callback (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_callback (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; PyErr_Format (PyExc_NotImplementedError, - "Callback out values are not supported"); + "Marshalling a callback to PyObject is not supported"); return py_obj; } PyObject * -_pygi_marshal_out_interface_enum (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_enum (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; @@ -620,10 +620,10 @@ _pygi_marshal_out_interface_enum (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_interface_flags (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_flags (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; @@ -656,10 +656,10 @@ _pygi_marshal_out_interface_flags (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_interface_struct (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_struct (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; @@ -686,12 +686,12 @@ _pygi_marshal_out_interface_struct (PyGIInvokeState *state, py_obj = pyg_pointer_new (type, arg->v_pointer); } else { py_obj = _pygi_struct_new ( (PyTypeObject *)iface_cache->py_type, arg->v_pointer, - arg_cache->transfer == GI_TRANSFER_EVERYTHING); + arg_cache->transfer == GI_TRANSFER_EVERYTHING); } } else if (g_type_is_a (type, G_TYPE_VARIANT)) { g_variant_ref_sink (arg->v_pointer); py_obj = _pygi_struct_new ( (PyTypeObject *)iface_cache->py_type, arg->v_pointer, - FALSE); + FALSE); } else if (type == G_TYPE_NONE && iface_cache->is_foreign) { py_obj = pygi_struct_foreign_convert_from_g_argument (iface_cache->interface_info, arg->v_pointer); } else if (type == G_TYPE_NONE) { @@ -707,10 +707,10 @@ _pygi_marshal_out_interface_struct (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_interface_interface (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_interface (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; @@ -720,10 +720,10 @@ _pygi_marshal_out_interface_interface (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_interface_boxed (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_boxed (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; @@ -733,10 +733,10 @@ _pygi_marshal_out_interface_boxed (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_interface_object (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_object (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj; @@ -755,10 +755,10 @@ _pygi_marshal_out_interface_object (PyGIInvokeState *state, } PyObject * -_pygi_marshal_out_interface_union (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - GIArgument *arg) +_pygi_marshal_to_py_interface_union (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg) { PyObject *py_obj = NULL; diff --git a/gi/pygi-marshal-to-py.h b/gi/pygi-marshal-to-py.h new file mode 100644 index 00000000..a07a13e8 --- /dev/null +++ b/gi/pygi-marshal-to-py.h @@ -0,0 +1,144 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- + * vim: tabstop=4 shiftwidth=4 expandtab + * + * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>, Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#ifndef __PYGI_MARSHAL_TO_PY_H__ +#define __PYGI_MARSHAL_TO_PY_H__ + +PyObject *_pygi_marshal_to_py_void (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_boolean (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_int8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_uint8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_int16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_uint16 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_int32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_uint32 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_int64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_uint64 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_float (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_double (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_unichar (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_gtype (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_utf8 (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_filename (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_array (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_glist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_gslist (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_ghash (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_gerror (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_callback(PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_enum (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_flags (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_struct (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_interface(PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_boxed (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_object (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); +PyObject *_pygi_marshal_to_py_interface_union (PyGIInvokeState *state, + PyGICallableCache *callable_cache, + PyGIArgCache *arg_cache, + GIArgument *arg); + +G_END_DECLS + +#endif /* __PYGI_MARSHAL_TO_PY_H__ */ |