Commit 8b5b3d2b authored by John (J5) Palmieri's avatar John (J5) Palmieri
Browse files

add marshalling for basic types and add more skeleton code

* still doesn't compile
parent f554cf62
This diff is collapsed.
......@@ -26,8 +26,9 @@
#include <girepository.h>
G_BEGIN_DECLS
#include "pygi-cache.h"
G_BEGIN_DECLS
/* Private */
gint _pygi_g_type_interface_check_object (GIBaseInfo *info,
......@@ -63,6 +64,38 @@ void _pygi_argument_release (GIArgument *arg,
void _pygi_argument_init (void);
/*** argument marshaling and validating routines ***/
PyGIMarshalInFunc _pygi_marshal_in_void;
PyGIMarshalInFunc _pygi_marshal_in_int8;
PyGIMarshalInFunc _pygi_marshal_in_uint8;
PyGIMarshalInFunc _pygi_marshal_in_int16;
PyGIMarshalInFunc _pygi_marshal_in_uint16;
PyGIMarshalInFunc _pygi_marshal_in_int32;
PyGIMarshalInFunc _pygi_marshal_in_uint32;
PyGIMarshalInFunc _pygi_marshal_in_int64;
PyGIMarshalInFunc _pygi_marshal_in_float;
PyGIMarshalInFunc _pygi_marshal_in_double;
PyGIMarshalInFunc _pygi_marshal_in_unichar;
PyGIMarshalInFunc _pygi_marshal_in_gtype;
PyGIMarshalInFunc _pygi_marshal_in_utf8;
PyGIMarshalInFunc _pygi_marshal_in_filename;
PyGIMarshalInFunc _pygi_marshal_in_array;
PyGIMarshalInFunc _pygi_marshal_in_glist;
PyGIMarshalInFunc _pygi_marshal_in_gslist;
PyGIMarshalInFunc _pygi_marshal_in_ghash;
PyGIMarshalInFunc _pygi_marshal_in_gerror;
PyGIMarshalInFunc _pygi_marshal_in_interface_callback;
PyGIMarshalInFunc _pygi_marshal_in_interface_enum;
PyGIMarshalInFunc _pygi_marshal_in_interface_flags;
PyGIMarshalInFunc _pygi_marshal_in_interface_struct;
PyGIMarshalInFunc _pygi_marshal_in_interface_interface;
PyGIMarshalInFunc _pygi_marshal_in_interface_boxed;
PyGIMarshalInFunc _pygi_marshal_in_interface_object;
PyGIMarshalInFunc _pygi_marshal_in_interface_union;
G_END_DECLS
#endif /* __PYGI_ARGUMENT_H__ */
......@@ -117,9 +117,7 @@ _arg_cache_generate_metadata_in_void(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
ac->in_validator = <type validation function pointer>
ac->in_marshaler = <type marshaling function pointer>
ac->cleanup = <type cleanup function pointer>
arg_cache->in_marshaler = _pygi_marshal_in_void;
return TRUE;
}
......@@ -129,6 +127,7 @@ _arg_cache_generate_metadata_in_boolean(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_boolean;
return TRUE;
}
......@@ -137,6 +136,7 @@ _arg_cache_generate_metadata_in_int8(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_int8;
return TRUE;
}
......@@ -145,6 +145,7 @@ _arg_cache_generate_metadata_in_uint8(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_uint8;
return TRUE;
}
......@@ -153,6 +154,7 @@ _arg_cache_generate_metadata_in_int16(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_int16;
return TRUE;
}
......@@ -161,6 +163,7 @@ _arg_cache_generate_metadata_in_uint16(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_uint16;
return TRUE;
}
......@@ -169,6 +172,7 @@ _arg_cache_generate_metadata_in_int32(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_int32;
return TRUE;
}
......@@ -177,6 +181,7 @@ _arg_cache_generate_metadata_in_uint32(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_uint32;
return TRUE;
}
......@@ -185,6 +190,7 @@ _arg_cache_generate_metadata_in_int64(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_int64;
return TRUE;
}
......@@ -193,6 +199,7 @@ _arg_cache_generate_metadata_in_uint64(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_uint64;
return TRUE;
}
......@@ -201,6 +208,7 @@ _arg_cache_generate_metadata_in_float(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_float;
return TRUE;
}
......@@ -209,6 +217,7 @@ _arg_cache_generate_metadata_in_double(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_double;
return TRUE;
}
......@@ -217,6 +226,8 @@ _arg_cache_generate_metadata_in_unichar(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_unichar;
return TRUE;
}
......@@ -225,6 +236,7 @@ _arg_cache_generate_metadata_in_gtype(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_gtype;
return TRUE;
}
......@@ -233,6 +245,10 @@ _arg_cache_generate_metadata_in_utf8(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_utf8;
if (arg_cache->transfer == GI_TRANSFER_NOTHING)
arg_cache->cleanup = g_free;
return TRUE;
}
......@@ -241,6 +257,10 @@ _arg_cache_generate_metadata_in_filename(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
arg_cache->in_marshaler = _pygi_marshal_in_filename;
if (arg_cache->transfer == GI_TRANSFER_NOTHING)
arg_cache->cleanup = g_free;
return TRUE;
}
......@@ -249,7 +269,10 @@ _arg_cache_generate_metadata_in_array(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
return TRUE;
arg_cache->in_marshaler = _pygi_marshal_in_array;
PyErr_Format(PyExc_NotImplementedError,
"Caching for this type is not fully implemented yet");
return FALSE;
}
static inline boolean
......@@ -257,7 +280,10 @@ _arg_cache_generate_metadata_in_interface(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
return TRUE;
/* TODO: Switch on GI_INFO_TYPE_ to determine caching */
PyErr_Format(PyExc_NotImplementedError,
"Caching for this type is not fully implemented yet");
return FALSE;
}
static inline boolean
......@@ -265,7 +291,10 @@ _arg_cache_generate_metadata_in_glist(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
return TRUE;
arg_cache->in_marshaler = _pygi_marshal_in_glist;
PyErr_Format(PyExc_NotImplementedError,
"Caching for this type is not fully implemented yet");
return FALSE;
}
static inline boolean
......@@ -273,7 +302,10 @@ _arg_cache_generate_metadata_in_gslist(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
return TRUE;
arg_cache->in_marshaler = _pygi_marshal_in_gslist;
PyErr_Format(PyExc_NotImplementedError,
"Caching for this type is not fully implemented yet");
return FALSE;
}
static inline boolean
......@@ -281,7 +313,10 @@ _arg_cache_generate_metadata_in_ghash(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
return TRUE;
arg_cache->in_marshaler = _pygi_marshal_in_ghash;
PyErr_Format(PyExc_NotImplementedError,
"Caching for this type is not fully implemented yet");
return FALSE;
}
static inline boolean
......@@ -289,19 +324,25 @@ _arg_cache_generate_metadata_in_error(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info)
{
return TRUE;
arg_cache->in_marshaler = _pygi_marshal_in_error;
PyErr_Format(PyExc_NotImplementedError,
"Caching for this type is not fully implemented yet");
return FALSE;
}
static inline boolean
_arg_cache_generate_metadata_in(PyGIArgCache *arg_cache,
PyGIFunctionCache *function_cache,
GIArgInfo *arg_info,
GITypeTag type_tag,
gint arg_index)
GITypeTag type_tag)
{
gboolean success = True;
function_info->n_in_args++;
arg_cache->c_arg_index = i + function_cache->is_method;
arg_cache->py_arg_index =
function_info->n_in_args + function_cache->is_method;
function_info->n_in_args++;
switch (type_tag) {
case GI_TYPE_TAG_VOID:
success = _arg_cache_generate_metadata_in_void(arg_cache,
......@@ -443,21 +484,18 @@ _args_cache_generate(GIFunctionInfo *function_info,
switch(direction) {
case GI_DIRECTION_IN:
function_info->n_in_args++;
switch (type_tag) {
case GI_TYPE_TAG_...:
ac->in_validator = <type validation function pointer>
ac->in_marshaler = <type marshaling function pointer>
ac->cleanup = <type cleanup function pointer>
_arg_cache_generate_metadata_in(arg_cache,
function_cache,
arg_info,
type_tag);
break;
fc->in_args = g_slist_append(fc->in_args, ac);
break;
case GI_DIRECTION_OUT:
function_info->n_out_args++;
switch (type_tag) {
case GI_TYPE_TAG_...:
ac->out_marshaler = <type marshaling function pointer>
ac->cleanup = <type cleanup function pointer>
fc->out_args = g_slist_append(fc->out_args, ac);
......
......@@ -19,12 +19,27 @@
* USA
*/
/* placeholders for now */
typedef gboolean (*PyGIValidateInFunc) (void);
typedef gboolean (*PyGIMarshalInFunc) (void);
#ifndef __PYGI_CACHE_H__
#define __PYGI_CACHE_H__
#include <Python.h>
#include <girepository.h>
G_BEGIN_DECLS
typedef struct _PyGIFunctionCache PyGIFunctionCache;
typedef struct _PyGIArgCache PyGIArgCache;
typedef gboolean (*PyGIMarshalInFunc) (PyGIState *state,
PyGIFunctionCache *function_cache,
PyGIArgCache *arg_cache,
PyObject *py_arg,
GIArgument *arg);
typedef gboolean (*PyGIMarshalOutFunc) (void);
typedef gboolean (*PyGIArgCleanupFunc) (gpointer data);
typedef struct _PyGISequenceCache
{
gssize fixed_size;
......@@ -34,7 +49,7 @@ typedef struct _PyGISequenceCache
gboolean is_zero_terminated;
gsize item_size;
GITypeTag item_tag_type;
}
} PyGISequenceCache;
typedef struct _PyGIInterfaceCache
{
......@@ -61,14 +76,15 @@ typedef struct _PyGICallbackCache
GScope scope;
} PyGICallbackCache;
typedef struct _PyGIArgCache
struct _PyGIArgCache
{
gboolean is_aux;
gboolean is_pointer;
GIDirection direction;
GIDirection direction;
GITransfer transfer;
GIArgInfo *arg_info;
GIArgument *default_value;
PyGIValidateInFunc in_validator;
PyGIMashalInFunc in_marshaler;
PyGIMarshalOutFunc out_marshaler;
PyGIArgCleanupFunc cleanup;
......@@ -80,9 +96,9 @@ typedef struct _PyGIArgCache
gint c_arg_index;
gint py_arg_index;
} PyGIArgCache;
};
typedef struct _PyGIFunctionCache
struct _PyGIFunctionCache
{
gboolean is_method;
gboolean is_constructor;
......@@ -95,10 +111,13 @@ typedef struct _PyGIFunctionCache
guint n_in_args;
guint n_out_args;
guint n_args;
} PyGIFunctionCache;
};
void _pygi_arg_cache_clear (PyGIArgCache *cache);
void _pygi_function_cache_free (PyGIFunctionCache *cache);
PyGIFunctionCache *_pygi_generate_function_cache (GIFunctionInfo *function_info);
PyGIFunctionCache *_pygi_function_cache_new (GIFunctionInfo *function_info);
G_END_DECLS
#endif /* __PYGI_CACHE_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment