summaryrefslogtreecommitdiff
path: root/gi/pygi-marshal-to-py.c
diff options
context:
space:
mode:
Diffstat (limited to 'gi/pygi-marshal-to-py.c')
-rw-r--r--gi/pygi-marshal-to-py.c155
1 files changed, 0 insertions, 155 deletions
diff --git a/gi/pygi-marshal-to-py.c b/gi/pygi-marshal-to-py.c
index 3c7d69e6..292f9628 100644
--- a/gi/pygi-marshal-to-py.c
+++ b/gi/pygi-marshal-to-py.c
@@ -113,161 +113,6 @@ gi_argument_to_gsize (GIArgument *arg_in,
}
PyObject *
-_pygi_marshal_to_py_void (PyGIInvokeState *state,
- PyGICallableCache *callable_cache,
- PyGIArgCache *arg_cache,
- GIArgument *arg)
-{
- if (arg_cache->is_pointer) {
- return PyLong_FromVoidPtr (arg->v_pointer);
- }
- Py_RETURN_NONE;
-}
-
-static PyObject *
-_pygi_marshal_to_py_unichar (GIArgument *arg)
-{
- PyObject *py_obj = NULL;
-
- /* Preserve the bidirectional mapping between 0 and "" */
- if (arg->v_uint32 == 0) {
- py_obj = PYGLIB_PyUnicode_FromString ("");
- } else if (g_unichar_validate (arg->v_uint32)) {
- gchar utf8[6];
- gint bytes;
-
- bytes = g_unichar_to_utf8 (arg->v_uint32, utf8);
- py_obj = PYGLIB_PyUnicode_FromStringAndSize ((char*)utf8, bytes);
- } else {
- /* TODO: Convert the error to an exception. */
- PyErr_Format (PyExc_TypeError,
- "Invalid unicode codepoint %" G_GUINT32_FORMAT,
- arg->v_uint32);
- }
-
- return py_obj;
-}
-
-static PyObject *
-_pygi_marshal_to_py_utf8 (GIArgument *arg)
-{
- PyObject *py_obj = NULL;
- if (arg->v_string == NULL) {
- Py_RETURN_NONE;
- }
-
- py_obj = PYGLIB_PyUnicode_FromString (arg->v_string);
- return py_obj;
-}
-
-static PyObject *
-_pygi_marshal_to_py_filename (GIArgument *arg)
-{
- gchar *string = NULL;
- PyObject *py_obj = NULL;
- GError *error = NULL;
-
- if (arg->v_string == NULL) {
- Py_RETURN_NONE;
- }
-
- string = g_filename_to_utf8 (arg->v_string, -1, NULL, NULL, &error);
- if (string == NULL) {
- PyErr_SetString (PyExc_Exception, error->message);
- /* TODO: Convert the error to an exception. */
- return NULL;
- }
-
- py_obj = PYGLIB_PyUnicode_FromString (string);
- g_free (string);
-
- return py_obj;
-}
-
-
-/**
- * _pygi_marshal_to_py_basic_type:
- * @arg: The argument to convert to an object.
- * @type_tag: Type tag for @arg
- * @transfer: Transfer annotation
- *
- * Convert the given argument to a Python object. This function
- * is restricted to simple types that only require the GITypeTag
- * and GITransfer. For a more complete conversion routine, use:
- * _pygi_argument_to_object.
- *
- * Returns: A PyObject representing @arg or NULL if it cannot convert
- * the argument.
- */
-PyObject *
-_pygi_marshal_to_py_basic_type (GIArgument *arg,
- GITypeTag type_tag,
- GITransfer transfer)
-{
- switch (type_tag) {
- case GI_TYPE_TAG_BOOLEAN:
- return PyBool_FromLong (arg->v_boolean);
-
- case GI_TYPE_TAG_INT8:
- return PYGLIB_PyLong_FromLong (arg->v_int8);
-
- case GI_TYPE_TAG_UINT8:
- return PYGLIB_PyLong_FromLong (arg->v_uint8);
-
- case GI_TYPE_TAG_INT16:
- return PYGLIB_PyLong_FromLong (arg->v_int16);
-
- case GI_TYPE_TAG_UINT16:
- return PYGLIB_PyLong_FromLong (arg->v_uint16);
-
- case GI_TYPE_TAG_INT32:
- return PYGLIB_PyLong_FromLong (arg->v_int32);
-
- case GI_TYPE_TAG_UINT32:
- return PyLong_FromLongLong (arg->v_uint32);
-
- case GI_TYPE_TAG_INT64:
- return PyLong_FromLongLong (arg->v_int64);
-
- case GI_TYPE_TAG_UINT64:
- return PyLong_FromUnsignedLongLong (arg->v_uint64);
-
- case GI_TYPE_TAG_FLOAT:
- return PyFloat_FromDouble (arg->v_float);
-
- case GI_TYPE_TAG_DOUBLE:
- return PyFloat_FromDouble (arg->v_double);
-
- case GI_TYPE_TAG_GTYPE:
- return pyg_type_wrapper_new ( (GType) arg->v_long);
-
- case GI_TYPE_TAG_UNICHAR:
- return _pygi_marshal_to_py_unichar (arg);
-
- case GI_TYPE_TAG_UTF8:
- return _pygi_marshal_to_py_utf8 (arg);
-
- case GI_TYPE_TAG_FILENAME:
- return _pygi_marshal_to_py_filename (arg);
-
- default:
- return NULL;
- }
- return NULL;
-}
-
-PyObject *
-_pygi_marshal_to_py_basic_type_cache_adapter (PyGIInvokeState *state,
- PyGICallableCache *callable_cache,
- PyGIArgCache *arg_cache,
- GIArgument *arg)
-{
- return _pygi_marshal_to_py_basic_type (arg,
- arg_cache->type_tag,
- arg_cache->transfer);
-}
-
-PyObject *
_pygi_marshal_to_py_array (PyGIInvokeState *state,
PyGICallableCache *callable_cache,
PyGIArgCache *arg_cache,