Commit 204f5a18 authored by Simon Feltman's avatar Simon Feltman
Browse files

marshal refactoring: Move GValue marshaling from pytype into pygi-value

Move marshaling of GValues to and from PyObjects into pygi-value.c. Make
PyGTypeMarshal struct and related functions accessible via pygtype.h.

https://bugzilla.gnome.org/show_bug.cgi?id=709700
parent b8120d84
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "pygtype.h" #include "pygtype.h"
#include "pygoptiongroup.h" #include "pygoptiongroup.h"
#include "pygi-value.h"
static GHashTable *log_handlers = NULL; static GHashTable *log_handlers = NULL;
static gboolean log_handlers_disabled = FALSE; static gboolean log_handlers_disabled = FALSE;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "pygi-struct-marshal.h" #include "pygi-struct-marshal.h"
#include "pygi-private.h" #include "pygi-private.h"
#include "pygi-value.h"
/* /*
* _is_union_member - check to see if the py_arg is actually a member of the * _is_union_member - check to see if the py_arg is actually a member of the
......
This diff is collapsed.
...@@ -20,12 +20,24 @@ ...@@ -20,12 +20,24 @@
#include <glib-object.h> #include <glib-object.h>
#include <girepository.h> #include <girepository.h>
#include <Python.h>
G_BEGIN_DECLS G_BEGIN_DECLS
GIArgument _pygi_argument_from_g_value(const GValue *value, GIArgument _pygi_argument_from_g_value(const GValue *value,
GITypeInfo *type_info); GITypeInfo *type_info);
int pyg_value_from_pyobject(GValue *value, PyObject *obj);
int pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj);
PyObject *pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed);
int pyg_param_gvalue_from_pyobject(GValue* value,
PyObject* py_obj,
const GParamSpec* pspec);
PyObject *pyg_param_gvalue_as_pyobject(const GValue* gvalue,
gboolean copy_boxed,
const GParamSpec* pspec);
PyObject *pyg_strv_from_gvalue(const GValue *value);
int pyg_strv_to_gvalue(GValue *value, PyObject *obj);
G_END_DECLS G_END_DECLS
......
...@@ -78,22 +78,6 @@ gint pyg_enum_get_value (GType enum_type, PyObject *obj, gint *val); ...@@ -78,22 +78,6 @@ gint pyg_enum_get_value (GType enum_type, PyObject *obj, gint *val);
gint pyg_flags_get_value (GType flag_type, PyObject *obj, guint *val); gint pyg_flags_get_value (GType flag_type, PyObject *obj, guint *val);
int pyg_pyobj_to_unichar_conv (PyObject* py_obj, void* ptr); int pyg_pyobj_to_unichar_conv (PyObject* py_obj, void* ptr);
typedef PyObject *(* fromvaluefunc)(const GValue *value);
typedef int (*tovaluefunc)(GValue *value, PyObject *obj);
void pyg_register_gtype_custom(GType gtype,
fromvaluefunc from_func,
tovaluefunc to_func);
int pyg_value_from_pyobject(GValue *value, PyObject *obj);
int pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj);
PyObject *pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed);
int pyg_param_gvalue_from_pyobject(GValue* value,
PyObject* py_obj,
const GParamSpec* pspec);
PyObject *pyg_param_gvalue_as_pyobject(const GValue* gvalue,
gboolean copy_boxed,
const GParamSpec* pspec);
GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data); GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data);
void pyg_closure_set_exception_handler(GClosure *closure, void pyg_closure_set_exception_handler(GClosure *closure,
PyClosureExceptionHandler handler); PyClosureExceptionHandler handler);
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "pygparamspec.h" #include "pygparamspec.h"
#include "pygi.h" #include "pygi.h"
#include "pygi-value.h"
static void pygobject_dealloc(PyGObject *self); static void pygobject_dealloc(PyGObject *self);
static int pygobject_traverse(PyGObject *self, visitproc visit, void *arg); static int pygobject_traverse(PyGObject *self, visitproc visit, void *arg);
......
This diff is collapsed.
...@@ -23,6 +23,23 @@ ...@@ -23,6 +23,23 @@
#ifndef __PYGOBJECT_TYPE_H__ #ifndef __PYGOBJECT_TYPE_H__
#define __PYGOBJECT_TYPE_H__ #define __PYGOBJECT_TYPE_H__
#include <glib-object.h>
#include <Python.h>
typedef PyObject *(* fromvaluefunc)(const GValue *value);
typedef int (*tovaluefunc)(GValue *value, PyObject *obj);
typedef struct {
fromvaluefunc fromvalue;
tovaluefunc tovalue;
} PyGTypeMarshal;
PyGTypeMarshal *pyg_type_lookup(GType type);
void pyg_register_gtype_custom(GType gtype,
fromvaluefunc from_func,
tovaluefunc to_func);
void pygobject_type_register_types(PyObject *d); void pygobject_type_register_types(PyObject *d);
#endif /* __PYGOBJECT_TYPE_H__ */ #endif /* __PYGOBJECT_TYPE_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