Commit c5c149be authored by John (J5) Palmieri's avatar John (J5) Palmieri

[gi] implemented return marshalling and started on out marshalling

parent 4fcca851
......@@ -2718,10 +2718,10 @@ _pygi_marshal_in_interface_struct (PyGIInvokeState *state,
PyObject *py_arg,
GIArgument *arg)
{
PyGIIntefaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
if (py_arg == Py_None) {
arg.v_pointer = NULL;
arg->v_pointer = NULL;
return TRUE;
}
......@@ -2739,8 +2739,8 @@ _pygi_marshal_in_interface_struct (PyGIInvokeState *state,
return FALSE;
}
(*argv).v_pointer = closure;
} else if (iface_cache->g_type == G_VALUE) {
(*arg).v_pointer = closure;
} else if (iface_cache->g_type == G_TYPE_VALUE) {
GValue *value;
GType object_type;
......@@ -2752,7 +2752,7 @@ _pygi_marshal_in_interface_struct (PyGIInvokeState *state,
value = g_slice_new0 (GValue);
g_value_init (value, object_type);
if (pyg_value_from_pyobject (value, object) < 0) {
if (pyg_value_from_pyobject (value, py_arg) < 0) {
g_slice_free (GValue, value);
PyErr_SetString (PyExc_RuntimeError, "PyObject conversion to GValue failed");
return FALSE;
......@@ -2824,3 +2824,380 @@ _pygi_marshal_in_interface_union (PyGIInvokeState *state,
return FALSE;
}
PyObject *
_pygi_marshal_out_void (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
if (arg_cache->is_pointer)
py_obj = arg->v_pointer;
else
py_obj = Py_None;
Py_XINCREF(py_obj);
return py_obj;
}
PyObject *
_pygi_marshal_out_boolean (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = PyBool_FromLong(arg->v_boolean);
return py_obj;
}
PyObject *
_pygi_marshal_out_int8 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_uint8 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_int16 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_uint16 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_int32 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_uint32 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_int64 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_uint64 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_float (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_double (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_unichar (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_gtype (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_utf8 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_filename (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_array (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_glist (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_gslist (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_ghash (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_gerror (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_callback(PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_enum (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_flags (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_struct (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_interface (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_boxed (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_object (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
PyObject *
_pygi_marshal_out_interface_union (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg)
{
PyObject *py_obj = NULL;
PyErr_Format(PyExc_NotImplementedError,
"Marshalling for this type is not implemented yet");
return py_obj;
}
......@@ -212,6 +212,123 @@ gboolean _pygi_marshal_in_interface_union (PyGIInvokeState *state,
PyObject *py_arg,
GIArgument *arg);
PyObject *_pygi_marshal_out_void (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_boolean (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_int8 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_uint8 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_int16 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_uint16 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_int32 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_uint32 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_int64 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_uint64 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_float (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_double (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_unichar (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_gtype (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_utf8 (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_filename (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_array (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_glist (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_gslist (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_ghash (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_gerror (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_callback(PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_enum (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_flags (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_struct (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_interface(PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_boxed (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_object (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
PyObject *_pygi_marshal_out_interface_union (PyGIInvokeState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
GIArgument *arg);
G_END_DECLS
#endif /* __PYGI_ARGUMENT_H__ */
......@@ -93,6 +93,9 @@ _pygi_function_cache_free (PyGIFunctionCache *cache)
PyGIArgCache *tmp = cache->args_cache[i];
_pygi_arg_cache_free(tmp);
}
if (cache->return_cache != NULL)
_pygi_arg_cache_free(cache->return_cache);
g_slice_free1(cache->n_args * sizeof(PyGIArgCache *), cache->args_cache);
g_slice_free(PyGIFunctionCache, cache);
}
......@@ -394,7 +397,7 @@ _arg_cache_new_for_in_interface_struct(GIInterfaceInfo *iface_info,
GITransfer transfer)
{
PyGIInterfaceCache *iface_cache = _interface_cache_new_from_interface_info(iface_info);
PyGIArgCache *arg_cache = (PyGIArgCache *)iface_cache);
PyGIArgCache *arg_cache = (PyGIArgCache *)iface_cache;
iface_cache->is_foreign = g_struct_info_is_foreign( (GIStructInfo*)iface_info);
arg_cache->in_marshaller = _pygi_marshal_in_interface_struct;
if (iface_cache->g_type == G_TYPE_VALUE)
......@@ -472,7 +475,8 @@ _arg_cache_in_new_from_interface_info (GIInterfaceInfo *iface_info,
arg_cache = _arg_cache_new_for_in_interface_union();
break;
case GI_INFO_TYPE_STRUCT:
arg_cache = _arg_cache_new_for_in_interface_struct();
arg_cache = _arg_cache_new_for_in_interface_struct(iface_info,
transfer);
break;
case GI_INFO_TYPE_OBJECT:
case GI_INFO_TYPE_INTERFACE:
......@@ -507,6 +511,297 @@ _arg_cache_in_new_from_interface_info (GIInterfaceInfo *iface_info,
return arg_cache;
}
/* process out args */
static inline PyGIArgCache *
_arg_cache_new_for_out_void(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_void;
return arg_cache;
}
static inline PyGIArgCache *
_arg_cache_new_for_out_boolean(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_boolean;
return arg_cache;
}
static inline PyGIArgCache *
_arg_cache_new_for_out_int8(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_int8;
return arg_cache;
}
static inline PyGIArgCache *
_arg_cache_new_for_out_uint8(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_uint8;
return arg_cache;
}
static inline PyGIArgCache *
_arg_cache_new_for_out_int16(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_int16;
return arg_cache;
}
static inline PyGIArgCache *
_arg_cache_new_for_out_uint16(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_uint16;
return arg_cache;
}
static inline PyGIArgCache *
_arg_cache_new_for_out_int32(void)
{
PyGIArgCache *arg_cache = _arg_cache_new();
arg_cache->out_marshaller = _pygi_marshal_out_int32;