diff options
Diffstat (limited to 'gi/pygi-marshal-from-py.c')
-rw-r--r-- | gi/pygi-marshal-from-py.c | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c index 41dcf542..e3b8ae8e 100644 --- a/gi/pygi-marshal-from-py.c +++ b/gi/pygi-marshal-from-py.c @@ -1142,131 +1142,6 @@ err: return TRUE; } -gboolean -_pygi_marshal_from_py_ghash (PyGIInvokeState *state, - PyGICallableCache *callable_cache, - PyGIArgCache *arg_cache, - PyObject *py_arg, - GIArgument *arg, - gpointer *cleanup_data) -{ - PyGIMarshalFromPyFunc key_from_py_marshaller; - PyGIMarshalFromPyFunc value_from_py_marshaller; - - int i; - Py_ssize_t length; - PyObject *py_keys, *py_values; - - GHashFunc hash_func; - GEqualFunc equal_func; - - GHashTable *hash_ = NULL; - PyGIHashCache *hash_cache = (PyGIHashCache *)arg_cache; - - if (py_arg == Py_None) { - arg->v_pointer = NULL; - return TRUE; - } - - py_keys = PyMapping_Keys (py_arg); - if (py_keys == NULL) { - PyErr_Format (PyExc_TypeError, "Must be mapping, not %s", - py_arg->ob_type->tp_name); - return FALSE; - } - - length = PyMapping_Length (py_arg); - if (length < 0) { - Py_DECREF (py_keys); - return FALSE; - } - - py_values = PyMapping_Values (py_arg); - if (py_values == NULL) { - Py_DECREF (py_keys); - return FALSE; - } - - key_from_py_marshaller = hash_cache->key_cache->from_py_marshaller; - value_from_py_marshaller = hash_cache->value_cache->from_py_marshaller; - - switch (hash_cache->key_cache->type_tag) { - case GI_TYPE_TAG_UTF8: - case GI_TYPE_TAG_FILENAME: - hash_func = g_str_hash; - equal_func = g_str_equal; - break; - default: - hash_func = NULL; - equal_func = NULL; - } - - hash_ = g_hash_table_new (hash_func, equal_func); - if (hash_ == NULL) { - PyErr_NoMemory (); - Py_DECREF (py_keys); - Py_DECREF (py_values); - return FALSE; - } - - for (i = 0; i < length; i++) { - GIArgument key, value; - gpointer key_cleanup_data = NULL; - gpointer value_cleanup_data = NULL; - PyObject *py_key = PyList_GET_ITEM (py_keys, i); - PyObject *py_value = PyList_GET_ITEM (py_values, i); - if (py_key == NULL || py_value == NULL) - goto err; - - if (!key_from_py_marshaller ( state, - callable_cache, - hash_cache->key_cache, - py_key, - &key, - &key_cleanup_data)) - goto err; - - if (!value_from_py_marshaller ( state, - callable_cache, - hash_cache->value_cache, - py_value, - &value, - &value_cleanup_data)) - goto err; - - g_hash_table_insert (hash_, - _pygi_arg_to_hash_pointer (&key, hash_cache->key_cache->type_tag), - _pygi_arg_to_hash_pointer (&value, hash_cache->value_cache->type_tag)); - continue; -err: - /* FIXME: cleanup hash keys and values */ - Py_XDECREF (py_key); - Py_XDECREF (py_value); - Py_DECREF (py_keys); - Py_DECREF (py_values); - g_hash_table_unref (hash_); - _PyGI_ERROR_PREFIX ("Item %i: ", i); - return FALSE; - } - - arg->v_pointer = hash_; - - if (arg_cache->transfer == GI_TRANSFER_NOTHING) { - /* Free everything in cleanup. */ - *cleanup_data = arg->v_pointer; - } else if (arg_cache->transfer == GI_TRANSFER_CONTAINER) { - /* Make a shallow copy so we can free the elements later in cleanup - * because it is possible invoke will free the list before our cleanup. */ - *cleanup_data = g_hash_table_ref (arg->v_pointer); - } else { /* GI_TRANSFER_EVERYTHING */ - /* No cleanup, everything is given to the callee. - * Note that the keys and values will leak for transfer everything because - * we do not use g_hash_table_new_full and set key/value_destroy_func. */ - *cleanup_data = NULL; - } - - return TRUE; -} gboolean _pygi_marshal_from_py_gerror (PyGIInvokeState *state, |