| 1 |
/* -*- Mode: C; c-basic-offset: 4 -*- |
| 2 |
* vim: tabstop=4 shiftwidth=4 expandtab |
| 3 |
* |
| 4 |
* Copyright (C) 2005-2009 Johan Dahlin <[email protected]> |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef __PYGI_ARGUMENT_H__ |
| 21 |
#define __PYGI_ARGUMENT_H__ |
| 22 |
|
| 23 |
#include "pygi-invoke-state-struct.h" |
| 24 |
|
| 25 |
G_BEGIN_DECLS |
| 26 |
|
| 27 |
/* GIArgument is initialized based on the assumption that |
| 28 |
* it's the same size as a gint64 (long long). |
| 29 |
*/ |
| 30 |
G_STATIC_ASSERT (sizeof (GIArgument) == sizeof (gint64)); |
| 31 |
|
| 32 |
#define PYGI_ARG_INIT { .v_int64 = 0 } |
| 33 |
|
| 34 |
/** |
| 35 |
* Pass PyGIArgumentFromPyCleanupData as zero-initialized struct to pygi_argument_from_py. |
| 36 |
* Some cleanup related state will be stored in this struct. After processing the argument, |
| 37 |
* cleanup can be performed by calling pygi_argument_from_py_cleanup. |
| 38 |
*/ |
| 39 |
typedef struct { |
| 40 |
PyObject *object; |
| 41 |
gpointer cache; |
| 42 |
gpointer cleanup_data; |
| 43 |
PyGIInvokeState state; |
| 44 |
} PyGIArgumentFromPyCleanupData; |
| 45 |
|
| 46 |
GIArgument pygi_argument_from_py (GITypeInfo *type_info, PyObject *object, |
| 47 |
GITransfer transfer, |
| 48 |
PyGIArgumentFromPyCleanupData *arg_cleanup); |
| 49 |
|
| 50 |
/* Invoke pygi_argument_from_py_cleanup after you're done handling the argument acquired by pygi_argument_from_py. */ |
| 51 |
void pygi_argument_from_py_cleanup ( |
| 52 |
PyGIArgumentFromPyCleanupData *arg_cleanup); |
| 53 |
|
| 54 |
PyObject *pygi_argument_to_py (GITypeInfo *type_info, GIArgument arg, |
| 55 |
GITransfer transfer); |
| 56 |
|
| 57 |
PyObject *pygi_argument_to_py_with_array_length (GITypeInfo *type_info, |
| 58 |
GIArgument arg, |
| 59 |
GITransfer transfer, |
| 60 |
gsize array_length); |
| 61 |
|
| 62 |
gpointer _pygi_arg_to_hash_pointer (const GIArgument arg, |
| 63 |
GITypeInfo *type_info); |
| 64 |
|
| 65 |
void _pygi_hash_pointer_to_arg_in_place (GIArgument *arg, |
| 66 |
GITypeInfo *type_info); |
| 67 |
|
| 68 |
gboolean pygi_argument_to_gsize (GIArgument arg, GITypeTag type_tag, |
| 69 |
gsize *gsize_out); |
| 70 |
|
| 71 |
G_END_DECLS |
| 72 |
|
| 73 |
#endif /* __PYGI_ARGUMENT_H__ */ |