4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Campbell Barton
22 * ***** END GPL LICENSE BLOCK *****
29 #include "RNA_access.h"
30 #include "RNA_types.h"
31 #include "BKE_idprop.h"
33 extern PyTypeObject pyrna_struct_Type;
34 extern PyTypeObject pyrna_prop_Type;
36 #define BPy_StructRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_struct_Type))
37 #define BPy_StructRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_struct_Type)
38 #define BPy_PropertyRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_prop_Type))
39 #define BPy_PropertyRNA_CheckExact(v) (Py_TYPE(v) == &pyrna_prop_Type)
44 PyTypeObject *py_type;
49 PyObject_HEAD /* required python macro */
51 int freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */
55 PyObject_HEAD /* required python macro */
59 /* Arystan: this is a hack to allow sub-item r/w access like: face.uv[n][m] */
60 int arraydim; /* array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */
61 int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */
65 #define BPy_BaseTypeRNA BPy_PropertyRNA
67 void BPY_rna_init( void );
68 PyObject *BPY_rna_module( void );
69 void BPY_update_rna_module( void );
70 /*PyObject *BPY_rna_doc( void );*/
71 PyObject *BPY_rna_types( void );
72 PyObject *BPY_rna_props( void );
74 PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr );
75 PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop );
77 /* operators also need this to set args */
78 int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix);
79 int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const char *error_prefix);
80 PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop);
82 /* functions for setting up new props - experemental */
83 PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw);
84 PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw);
85 PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw);
86 PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw);
87 PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw);
88 PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw);
89 PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw);
91 /* function for registering types */
92 PyObject *pyrna_basetype_register(PyObject *self, PyObject *args);
93 PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *args);
95 int pyrna_deferred_register_props(struct StructRNA *srna, PyObject *class_dict);
97 /* called before stopping python */
98 void pyrna_alloc_types(void);
99 void pyrna_free_types(void);
101 /* primitive type conversion */
102 int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, char *param_data, PyObject *py, const char *error_prefix);
103 int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix);
105 PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop);
106 PyObject *pyrna_py_from_array_index(BPy_PropertyRNA *self, int index);
107 PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop);