Merged changes in the trunk up to revision 34010.

This commit is contained in:
2011-01-02 18:34:32 +00:00
201 changed files with 9201 additions and 8337 deletions

View File

@@ -24,7 +24,7 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
../
..
../../blenlib
../../makesdna
../../makesrna

View File

@@ -180,7 +180,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports);
if(BPy_reports_to_error(reports))
if(BPy_reports_to_error(reports, FALSE))
error_val = -1;
/* operator output is nice to have in the terminal/console too */

View File

@@ -1485,13 +1485,13 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
{
int count, totdim;
PyObject *list = PyList_New(stop - start);
PyObject *tuple= PyTuple_New(stop - start);
totdim = RNA_property_array_dimension(ptr, prop, NULL);
if (totdim > 1) {
for (count = start; count < stop; count++)
PyList_SET_ITEM(list, count - start, pyrna_prop_array_to_py_index(self, count));
PyTuple_SET_ITEM(tuple, count - start, pyrna_prop_array_to_py_index(self, count));
}
else {
switch (RNA_property_type(prop)) {
@@ -1504,7 +1504,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
RNA_property_float_get_array(ptr, prop, values);
for(count=start; count<stop; count++)
PyList_SET_ITEM(list, count-start, PyFloat_FromDouble(values[count]));
PyTuple_SET_ITEM(tuple, count-start, PyFloat_FromDouble(values[count]));
if(values != values_stack) {
PyMem_FREE(values);
@@ -1520,7 +1520,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
RNA_property_boolean_get_array(ptr, prop, values);
for(count=start; count<stop; count++)
PyList_SET_ITEM(list, count-start, PyBool_FromLong(values[count]));
PyTuple_SET_ITEM(tuple, count-start, PyBool_FromLong(values[count]));
if(values != values_stack) {
PyMem_FREE(values);
@@ -1536,7 +1536,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
RNA_property_int_get_array(ptr, prop, values);
for(count=start; count<stop; count++)
PyList_SET_ITEM(list, count-start, PyLong_FromSsize_t(values[count]));
PyTuple_SET_ITEM(tuple, count-start, PyLong_FromSsize_t(values[count]));
if(values != values_stack) {
PyMem_FREE(values);
@@ -1547,11 +1547,11 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
BKE_assert(!"Invalid array type");
PyErr_SetString(PyExc_TypeError, "not an array type");
Py_DECREF(list);
list= NULL;
Py_DECREF(tuple);
tuple= NULL;
}
}
return list;
return tuple;
}
static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject *key)
@@ -2167,20 +2167,29 @@ static char pyrna_struct_keyframe_insert_doc[] =
static PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
PyObject *result;
/* args, pyrna_struct_keyframe_parse handles these */
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
char *group_name= NULL;
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1)
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) {
return NULL;
}
else {
short result;
ReportList reports;
result= PyBool_FromLong(insert_keyframe(/*ReportList*/NULL, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0));
MEM_freeN(path_full);
BKE_reports_init(&reports, RPT_STORE);
return result;
result= insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN(path_full);
if(BPy_reports_to_error(&reports, TRUE))
return NULL;
return PyBool_FromLong(result);
}
}
static char pyrna_struct_keyframe_delete_doc[] =
@@ -2201,20 +2210,30 @@ static char pyrna_struct_keyframe_delete_doc[] =
static PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyObject *kw)
{
PyObject *result;
/* args, pyrna_struct_keyframe_parse handles these */
char *path_full= NULL;
int index= -1;
float cfra= FLT_MAX;
char *group_name= NULL;
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_delete()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1)
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_delete()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) {
return NULL;
}
else {
short result;
ReportList reports;
result= PyBool_FromLong(delete_keyframe(/*ReportList*/NULL, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0));
MEM_freeN(path_full);
BKE_reports_init(&reports, RPT_STORE);
result= delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN(path_full);
if(BPy_reports_to_error(&reports, TRUE))
return NULL;
return PyBool_FromLong(result);
}
return result;
}
static char pyrna_struct_driver_add_doc[] =
@@ -2233,46 +2252,59 @@ static PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
{
char *path, *path_full;
int index= -1;
PyObject *ret;
if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
return NULL;
if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0)
if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0) {
return NULL;
}
else {
PyObject *ret= NULL;
ReportList reports;
int result;
if(ANIM_add_driver((ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON)) {
ID *id= self->ptr.id.data;
AnimData *adt= BKE_animdata_from_id(id);
FCurve *fcu;
BKE_reports_init(&reports, RPT_STORE);
PointerRNA tptr;
PyObject *item;
result= ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON);
if(index == -1) { /* all, use a list */
int i= 0;
ret= PyList_New(0);
while((fcu= list_find_fcurve(&adt->drivers, path_full, i++))) {
if(BPy_reports_to_error(&reports, TRUE))
return NULL;
if(result) {
ID *id= self->ptr.id.data;
AnimData *adt= BKE_animdata_from_id(id);
FCurve *fcu;
PointerRNA tptr;
PyObject *item;
if(index == -1) { /* all, use a list */
int i= 0;
ret= PyList_New(0);
while((fcu= list_find_fcurve(&adt->drivers, path_full, i++))) {
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
item= pyrna_struct_CreatePyObject(&tptr);
PyList_Append(ret, item);
Py_DECREF(item);
}
}
else {
fcu= list_find_fcurve(&adt->drivers, path_full, index);
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
item= pyrna_struct_CreatePyObject(&tptr);
PyList_Append(ret, item);
Py_DECREF(item);
ret= pyrna_struct_CreatePyObject(&tptr);
}
}
else {
fcu= list_find_fcurve(&adt->drivers, path_full, index);
RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr);
ret= pyrna_struct_CreatePyObject(&tptr);
/* XXX, should be handled by reports, */
PyErr_SetString(PyExc_TypeError, "bpy_struct.driver_add(): failed because of an internal error");
return NULL;
}
}
else {
PyErr_SetString(PyExc_TypeError, "bpy_struct.driver_add(): failed because of an internal error");
return NULL;
}
MEM_freeN(path_full);
MEM_freeN(path_full);
return ret;
return ret;
}
}
@@ -2292,19 +2324,28 @@ static PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
{
char *path, *path_full;
int index= -1;
PyObject *ret;
if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index))
return NULL;
if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0)
if(pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0) {
return NULL;
}
else {
short result;
ReportList reports;
ret= PyBool_FromLong(ANIM_remove_driver((ID *)self->ptr.id.data, path_full, index, 0));
BKE_reports_init(&reports, RPT_STORE);
MEM_freeN(path_full);
result= ANIM_remove_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0);
return ret;
MEM_freeN(path_full);
if(BPy_reports_to_error(&reports, TRUE))
return NULL;
return PyBool_FromLong(result);
}
}
@@ -3897,8 +3938,7 @@ static PyObject * pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
BKE_reports_init(&reports, RPT_STORE);
RNA_function_call(C, &reports, self_ptr, self_func, &parms);
err= (BPy_reports_to_error(&reports))? -1: 0;
BKE_reports_clear(&reports);
err= (BPy_reports_to_error(&reports, TRUE))? -1: 0;
/* return value */
if(err==0) {
@@ -5498,13 +5538,10 @@ static PyObject *pyrna_basetype_register(PyObject *UNUSED(self), PyObject *py_cl
srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free);
if(!srna_new) {
BPy_reports_to_error(&reports);
BKE_reports_clear(&reports);
if(BPy_reports_to_error(&reports, TRUE))
return NULL;
}
BKE_reports_clear(&reports);
BKE_assert(srna_new != NULL);
pyrna_subtype_set_rna(py_class, srna_new); /* takes a ref to py_class */

View File

@@ -450,7 +450,7 @@ static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop
return NULL;
}
PyTuple_SetItem(tuple, i, item);
PyTuple_SET_ITEM(tuple, i, item);
}
return tuple;

View File

@@ -138,12 +138,16 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
return cstring;
}
int BPy_reports_to_error(ReportList *reports)
short BPy_reports_to_error(ReportList *reports, const short clear)
{
char *report_str;
report_str= BKE_reports_string(reports, RPT_ERROR);
if(clear) {
BKE_reports_clear(reports);
}
if(report_str) {
PyErr_SetString(PyExc_SystemError, report_str);
MEM_freeN(report_str);
@@ -153,7 +157,7 @@ int BPy_reports_to_error(ReportList *reports)
}
int BPy_errors_to_report(ReportList *reports)
short BPy_errors_to_report(ReportList *reports)
{
PyObject *pystring;
PyObject *pystring_format= NULL; // workaround, see below

View File

@@ -57,8 +57,8 @@ char *BPy_enum_as_string(struct EnumPropertyItem *item);
#define BLANK_PYTHON_TYPE {PyVarObject_HEAD_INIT(NULL, 0) 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
/* error reporting */
int BPy_reports_to_error(struct ReportList *reports);
int BPy_errors_to_report(struct ReportList *reports);
short BPy_reports_to_error(struct ReportList *reports, const short clear);
short BPy_errors_to_report(struct ReportList *reports);
/* TODO - find a better solution! */
struct bContext *BPy_GetContext(void);