Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-02 22:57:57 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-02-02 22:57:57 +0300
commit284db61572125c8b2a916a20e5a4333ea72440dc (patch)
tree826d68aaccaee0cba7855955cc0e5dcf3a90ef62 /source/blender/python
parenteb00687cde2fd5724b22a8831d3294f4846ff934 (diff)
RNA: C API
* RNA_blender.h is now generated along with the other files. It is not used anywhere yet, and still located quite hidden next to the other rna_*_gen.c files. Read only access for now. * Inherited properties are not copied from the base anymore but iterated over. Patch by Vekoon, thanks! * Array get/set callbacks now do the whole array instead of getting an index. This is needed for some layers for example so python can set the array as a whole, otherwise the check that one layer has to be enabled at all times gets in the way. Also nicer for the C API. * Also some changes to returning pointers to make the API cleaner, got rid of the type() callback and instead let get() return PointerRNA with the type included. The C API looks like this currently: http://users.pandora.be/blendix/RNA_blender.h
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4156db21507..35febecfe15 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -163,7 +163,7 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
case PROP_POINTER:
{
PointerRNA newptr;
- RNA_property_pointer_get(ptr, prop, &newptr);
+ newptr= RNA_property_pointer_get(ptr, prop);
if (newptr.data) {
ret = pyrna_struct_CreatePyObject(&newptr);
} else {
@@ -209,7 +209,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
switch (type) {
case PROP_BOOLEAN:
{
- signed char *param_arr = MEM_mallocN(sizeof(char) * len, "pyrna bool array");
+ int *param_arr = MEM_mallocN(sizeof(char) * len, "pyrna bool array");
/* collect the variables before assigning, incase one of them is incorrect */
for (i=0; i<len; i++) {
@@ -224,9 +224,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
}
}
- for (i=0; i<len; i++) {
- RNA_property_boolean_set_array(ptr, prop, i, param_arr[i]);
- }
+ RNA_property_boolean_set_array(ptr, prop, param_arr);
MEM_freeN(param_arr);
break;
@@ -248,9 +246,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
return -1;
}
- for (i=0; i<len; i++) {
- RNA_property_int_set_array(ptr, prop, i, param_arr[i]);
- }
+ RNA_property_int_set_array(ptr, prop, param_arr);
MEM_freeN(param_arr);
break;
@@ -272,9 +268,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
return -1;
}
- for (i=0; i<len; i++) {
- RNA_property_float_set_array(ptr, prop, i, param_arr[i]);
- }
+ RNA_property_float_set_array(ptr, prop, param_arr);
MEM_freeN(param_arr);
break;
@@ -385,13 +379,13 @@ static PyObject * pyrna_prop_to_py_index(PointerRNA *ptr, PropertyRNA *prop, int
/* see if we can coorce into a python type - PropertyType */
switch (type) {
case PROP_BOOLEAN:
- ret = PyBool_FromLong( RNA_property_boolean_get_array(ptr, prop, index) );
+ ret = PyBool_FromLong( RNA_property_boolean_get_index(ptr, prop, index) );
break;
case PROP_INT:
- ret = PyLong_FromSize_t( (size_t)RNA_property_int_get_array(ptr, prop, index) );
+ ret = PyLong_FromSize_t( (size_t)RNA_property_int_get_index(ptr, prop, index) );
break;
case PROP_FLOAT:
- ret = PyFloat_FromDouble( RNA_property_float_get_array(ptr, prop, index) );
+ ret = PyFloat_FromDouble( RNA_property_float_get_index(ptr, prop, index) );
break;
default:
PyErr_SetString(PyExc_AttributeError, "not an array type");
@@ -419,7 +413,7 @@ static int pyrna_py_to_prop_index(PointerRNA *ptr, PropertyRNA *prop, int index,
PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
ret = -1;
} else {
- RNA_property_boolean_set_array(ptr, prop, index, param);
+ RNA_property_boolean_set_index(ptr, prop, index, param);
}
break;
}
@@ -430,7 +424,7 @@ static int pyrna_py_to_prop_index(PointerRNA *ptr, PropertyRNA *prop, int index,
PyErr_SetString(PyExc_TypeError, "expected an int type");
ret = -1;
} else {
- RNA_property_int_set_array(ptr, prop, index, param);
+ RNA_property_int_set_index(ptr, prop, index, param);
}
break;
}
@@ -441,7 +435,7 @@ static int pyrna_py_to_prop_index(PointerRNA *ptr, PropertyRNA *prop, int index,
PyErr_SetString(PyExc_TypeError, "expected a float type");
ret = -1;
} else {
- RNA_property_float_set_array(ptr, prop, index, param);
+ RNA_property_float_set_index(ptr, prop, index, param);
}
break;
}
@@ -679,7 +673,7 @@ PyObject *pyrna_struct_to_docstring(BPy_StructRNA *self)
// TODO - why does this crash sometimes
// PointerRNA newptr;
- // RNA_property_pointer_get(&iter.ptr, prop, &newptr);
+ // newptr= RNA_property_pointer_get(&iter.ptr, prop);
// Use this instead, its not that useful
BLI_dynstr_appendf(dynstr, "@type %s: PyRNA %s\n", identifier, RNA_struct_identifier(&iter.ptr));