diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-10-12 20:00:12 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-02-02 16:02:57 -0800 |
commit | 1d0f120d77582509b4e75d83f500a1ace7ed6421 (patch) | |
tree | 60a470165153f02d97b7b37c15d3371f07aa26b5 /gi/pygi-cache.c | |
parent | 4dcaa2b988239e01224994098c3e7cbe8b455fe0 (diff) | |
download | pygobject-1d0f120d77582509b4e75d83f500a1ace7ed6421.tar.gz |
cache refactoring: Move various struct arg setup and marshaling to new file
Move struct (boxed, union, gvalue, gclosure, variant, and pointer) argument
cache setup and marshaling fragments into isolated file:
pygi-struct-marshal.c.
Remove redundant and dead code related to boxed and union marshaling.
https://bugzilla.gnome.org/show_bug.cgi?id=709700
Diffstat (limited to 'gi/pygi-cache.c')
-rw-r--r-- | gi/pygi-cache.c | 72 |
1 files changed, 10 insertions, 62 deletions
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c index f26df8c6..aab25348 100644 --- a/gi/pygi-cache.c +++ b/gi/pygi-cache.c @@ -2,6 +2,7 @@ * vim: tabstop=4 shiftwidth=4 expandtab * * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com> + * Copyright (C) 2013 Simon Feltman <sfeltman@gnome.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -34,6 +35,7 @@ #include "pygi-closure.h" #include "pygi-error.h" #include "pygi-object.h" +#include "pygi-struct-marshal.h" /* _arg_info_default_value @@ -251,48 +253,6 @@ _arg_cache_alloc (void) } static void -_arg_cache_from_py_interface_union_setup (PyGIArgCache *arg_cache, - GITransfer transfer) -{ - arg_cache->from_py_marshaller = _pygi_marshal_from_py_interface_struct_cache_adapter; -} - -static void -_arg_cache_to_py_interface_union_setup (PyGIArgCache *arg_cache, - GITransfer transfer) -{ - arg_cache->to_py_marshaller = _pygi_marshal_to_py_interface_struct_cache_adapter; -} - -static void -_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->from_py_marshaller = _pygi_marshal_from_py_interface_struct_cache_adapter; - - if (iface_cache->g_type == G_TYPE_VALUE) - arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_interface_struct_gvalue; - else if (iface_cache->is_foreign) - arg_cache->from_py_cleanup = _pygi_marshal_cleanup_from_py_interface_struct_foreign; -} - -static void -_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->to_py_marshaller = _pygi_marshal_to_py_interface_struct_cache_adapter; - - if (iface_cache->is_foreign) - arg_cache->to_py_cleanup = _pygi_marshal_cleanup_to_py_interface_struct_foreign; -} - -static void _arg_cache_from_py_interface_enum_setup (PyGIArgCache *arg_cache, GITransfer transfer) { @@ -351,6 +311,14 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info, transfer, direction, iface_info); + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_STRUCT: + case GI_INFO_TYPE_UNION: + return pygi_arg_struct_new_from_info (type_info, + arg_info, + transfer, + direction, + iface_info); default: ; /* pass through to old model of setup */ } @@ -364,26 +332,6 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info, return NULL; switch (info_type) { - case GI_INFO_TYPE_UNION: - if (direction & PYGI_DIRECTION_FROM_PYTHON) - _arg_cache_from_py_interface_union_setup (arg_cache, transfer); - - if (direction & PYGI_DIRECTION_TO_PYTHON) - _arg_cache_to_py_interface_union_setup (arg_cache, transfer); - - break; - case GI_INFO_TYPE_BOXED: - case GI_INFO_TYPE_STRUCT: - if (direction & PYGI_DIRECTION_FROM_PYTHON) - _arg_cache_from_py_interface_struct_setup (arg_cache, - iface_info, - transfer); - - if (direction & PYGI_DIRECTION_TO_PYTHON) - _arg_cache_to_py_interface_struct_setup (arg_cache, - iface_info, - transfer); - break; case GI_INFO_TYPE_ENUM: if (direction & PYGI_DIRECTION_FROM_PYTHON) _arg_cache_from_py_interface_enum_setup (arg_cache, transfer); |