summaryrefslogtreecommitdiff
path: root/gi/pygi-cache.h
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:42:12 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:42:16 +0900
commit7db802a3275790915ed33b470f58786a362551c6 (patch)
treede7b66f2e6ded30942469c5173eb51241422aa48 /gi/pygi-cache.h
parentfecadc1d4b1cd7bafc93313c1120a4b350e2bced (diff)
downloadpygobject2-7db802a3275790915ed33b470f58786a362551c6.tar.gz
pygobject2-7db802a3275790915ed33b470f58786a362551c6.tar.bz2
pygobject2-7db802a3275790915ed33b470f58786a362551c6.zip
Imported Upstream version 3.13.4
Change-Id: If8453fcd54aeed1d4cec58fcabaf92a68d0efbb5 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/pygi-cache.h')
-rw-r--r--gi/pygi-cache.h110
1 files changed, 80 insertions, 30 deletions
diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h
index cb8a2e7..093dde2 100644
--- a/gi/pygi-cache.h
+++ b/gi/pygi-cache.h
@@ -29,8 +29,16 @@
G_BEGIN_DECLS
-typedef struct _PyGICallableCache PyGICallableCache;
typedef struct _PyGIArgCache PyGIArgCache;
+typedef struct _PyGICallableCache PyGICallableCache;
+typedef struct _PyGIFunctionCache PyGIFunctionCache;
+typedef struct _PyGIVFuncCache PyGIVFuncCache;
+
+typedef PyGIFunctionCache PyGICCallbackCache;
+typedef PyGIFunctionCache PyGIConstructorCache;
+typedef PyGIFunctionCache PyGIFunctionWithInstanceCache;
+typedef PyGIFunctionCache PyGIMethodCache;
+typedef PyGICallableCache PyGIClosureCache;
typedef gboolean (*PyGIMarshalFromPyFunc) (PyGIInvokeState *state,
PyGICallableCache *callable_cache,
@@ -70,32 +78,24 @@ typedef enum {
} PyGIMetaArgType;
/*
- * GI determines function types via a combination of flags and info classes.
- * Since for branching purposes they are mutually exclusive, the
- * PyGIFunctionType enum consolidates them into one enumeration for ease of
- * branching and debugging.
+ * Argument direction types denotes how we marshal,
+ * e.g. to Python or from Python or both.
*/
typedef enum {
- PYGI_FUNCTION_TYPE_FUNCTION,
- PYGI_FUNCTION_TYPE_METHOD,
- PYGI_FUNCTION_TYPE_CONSTRUCTOR,
- PYGI_FUNCTION_TYPE_VFUNC,
- PYGI_FUNCTION_TYPE_CALLBACK,
- PYGI_FUNCTION_TYPE_CCALLBACK,
- } PyGIFunctionType;
+ PYGI_DIRECTION_TO_PYTHON = 1 << 0,
+ PYGI_DIRECTION_FROM_PYTHON = 1 << 1,
+ PYGI_DIRECTION_BIDIRECTIONAL = PYGI_DIRECTION_TO_PYTHON | PYGI_DIRECTION_FROM_PYTHON
+ } PyGIDirection;
/*
* 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.
+ * of the callable, e.g. is it a callback that is being called from C or a
+ * function that is being called from Python.
*/
typedef enum {
- PYGI_DIRECTION_TO_PYTHON = 1 << 0,
- PYGI_DIRECTION_FROM_PYTHON = 1 << 1,
- PYGI_DIRECTION_BIDIRECTIONAL = PYGI_DIRECTION_TO_PYTHON | PYGI_DIRECTION_FROM_PYTHON
- } PyGIDirection;
+ PYGI_CALLING_CONTEXT_IS_FROM_C,
+ PYGI_CALLING_CONTEXT_IS_FROM_PY
+} PyGICallingContext;
struct _PyGIArgCache
@@ -159,7 +159,7 @@ struct _PyGICallableCache
{
const gchar *name;
- PyGIFunctionType function_type;
+ PyGICallingContext calling_context;
PyGIArgCache *return_cache;
GPtrArray *args_cache;
@@ -171,6 +171,9 @@ struct _PyGICallableCache
/* Index of user_data arg that can eat variable args passed to a callable. */
gssize user_data_varargs_index;
+ /* Number of args already added */
+ gssize args_offset;
+
/* Number of out args passed to g_function_info_invoke.
* This is used for the length of PyGIInvokeState.out_values */
gssize n_to_py_args;
@@ -188,9 +191,30 @@ struct _PyGICallableCache
* This count does not include args with defaults. */
gssize n_py_required_args;
+ void (*deinit) (PyGICallableCache *callable_cache);
+
+ gboolean (*generate_args_cache) (PyGICallableCache *callable_cache,
+ GICallableInfo *callable_info);
+};
+
+typedef struct _PyGIFunctionCache {
+ PyGICallableCache callable_cache;
+
/* An invoker with ffi_cif already setup */
GIFunctionInvoker invoker;
-};
+
+ PyObject *(*invoke) (PyGIFunctionCache *function_cache,
+ PyGIInvokeState *state,
+ PyObject *py_args,
+ PyObject *py_kwargs);
+} PyGIFunctionCache;
+
+typedef struct _PyGIVFuncCache {
+ PyGIFunctionWithInstanceCache fwi_cache;
+
+ GIBaseInfo *info;
+} PyGIVFuncCache;
+
gboolean
pygi_arg_base_setup (PyGIArgCache *arg_cache,
@@ -212,7 +236,8 @@ pygi_arg_sequence_setup (PyGISequenceCache *sc,
GITypeInfo *type_info,
GIArgInfo *arg_info, /* may be NULL for return arguments */
GITransfer transfer,
- PyGIDirection direction);
+ PyGIDirection direction,
+ PyGICallableCache *callable_cache);
PyGIArgCache *
pygi_arg_interface_new_from_info (GITypeInfo *type_info,
@@ -229,21 +254,46 @@ pygi_arg_cache_new (GITypeInfo *type_info,
GIArgInfo *arg_info,
GITransfer transfer,
PyGIDirection direction,
+ PyGICallableCache *callable_cache,
/* will be removed */
gssize c_arg_index,
- gssize py_arg_index,
- PyGICallableCache *callable_cache);
+ gssize py_arg_index);
void
pygi_arg_cache_free (PyGIArgCache *cache);
void
-pygi_callable_cache_free (PyGICallableCache *cache);
+pygi_callable_cache_free (PyGICallableCache *cache);
+
+PyGIFunctionCache *
+pygi_function_cache_new (GICallableInfo *info);
+
+PyObject *
+pygi_function_cache_invoke (PyGIFunctionCache *function_cache,
+ PyObject *py_args,
+ PyObject *py_kwargs);
+
+PyGIFunctionCache *
+pygi_ccallback_cache_new (GICallableInfo *info,
+ GCallback function_ptr);
+
+PyObject *
+pygi_ccallback_cache_invoke (PyGIFunctionCache *function_cache,
+ PyObject *py_args,
+ PyObject *py_kwargs,
+ gpointer user_data);
+
+PyGIFunctionCache *
+pygi_constructor_cache_new (GICallableInfo *info);
+
+PyGIFunctionCache *
+pygi_method_cache_new (GICallableInfo *info);
+
+PyGIFunctionCache *
+pygi_vfunc_cache_new (GICallableInfo *info);
-PyGICallableCache *
-pygi_callable_cache_new (GICallableInfo *callable_info,
- GCallback function_ptr,
- gboolean is_ccallback);
+PyGIClosureCache *
+pygi_closure_cache_new (GICallableInfo *info);
#define _pygi_callable_cache_args_len(cache) ((cache)->args_cache)->len