formatting edits & remove debug print.
This commit is contained in:
@@ -109,7 +109,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
|
||||
|
||||
list= PyList_New(0);
|
||||
|
||||
for(BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
|
||||
for (BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
|
||||
/* build the list */
|
||||
if (absolute) {
|
||||
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
|
||||
@@ -149,10 +149,10 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
return NULL;
|
||||
|
||||
/* stupid string compare */
|
||||
if (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
|
||||
else if(!strcmp(type, "CONFIG")) folder_id= BLENDER_USER_CONFIG;
|
||||
else if(!strcmp(type, "SCRIPTS")) folder_id= BLENDER_USER_SCRIPTS;
|
||||
else if(!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
|
||||
if (!strcmp(type, "DATAFILES")) folder_id= BLENDER_USER_DATAFILES;
|
||||
else if (!strcmp(type, "CONFIG")) folder_id= BLENDER_USER_CONFIG;
|
||||
else if (!strcmp(type, "SCRIPTS")) folder_id= BLENDER_USER_SCRIPTS;
|
||||
else if (!strcmp(type, "AUTOSAVE")) folder_id= BLENDER_USER_AUTOSAVE;
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
|
||||
return NULL;
|
||||
@@ -193,9 +193,9 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
return NULL;
|
||||
|
||||
/* stupid string compare */
|
||||
if (!strcmp(type, "USER")) folder_id= BLENDER_RESOURCE_PATH_USER;
|
||||
else if(!strcmp(type, "LOCAL")) folder_id= BLENDER_RESOURCE_PATH_LOCAL;
|
||||
else if(!strcmp(type, "SYSTEM")) folder_id= BLENDER_RESOURCE_PATH_SYSTEM;
|
||||
if (!strcmp(type, "USER")) folder_id= BLENDER_RESOURCE_PATH_USER;
|
||||
else if (!strcmp(type, "LOCAL")) folder_id= BLENDER_RESOURCE_PATH_LOCAL;
|
||||
else if (!strcmp(type, "SYSTEM")) folder_id= BLENDER_RESOURCE_PATH_SYSTEM;
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid resource argument");
|
||||
return NULL;
|
||||
@@ -215,7 +215,7 @@ static PyMethodDef meth_bpy_resource_path= {"resource_path", (PyCFunction)bpy_re
|
||||
static PyObject *bpy_import_test(const char *modname)
|
||||
{
|
||||
PyObject *mod= PyImport_ImportModuleLevel((char *)modname, NULL, NULL, NULL, 0);
|
||||
if(mod) {
|
||||
if (mod) {
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
else {
|
||||
@@ -238,7 +238,7 @@ void BPy_init_modules(void)
|
||||
|
||||
/* Needs to be first since this dir is needed for future modules */
|
||||
char *modpath= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules");
|
||||
if(modpath) {
|
||||
if (modpath) {
|
||||
// printf("bpy: found module path '%s'.\n", modpath);
|
||||
PyObject *sys_path= PySys_GetObject("path"); /* borrow */
|
||||
PyObject *py_modpath= PyUnicode_FromString(modpath);
|
||||
|
||||
@@ -168,13 +168,13 @@ static int bpy_app_debug_set(PyObject *UNUSED(self), PyObject *value, void *UNUS
|
||||
{
|
||||
int param= PyObject_IsTrue(value);
|
||||
|
||||
if(param < 0) {
|
||||
if (param < 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "bpy.app.debug can only be True/False");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(param) G.f |= G_DEBUG;
|
||||
else G.f &= ~G_DEBUG;
|
||||
if (param) G.f |= G_DEBUG;
|
||||
else G.f &= ~G_DEBUG;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ static void py_struct_seq_getset_init(void)
|
||||
/* tricky dynamic members, not to py-spec! */
|
||||
PyGetSetDef *getset;
|
||||
|
||||
for(getset= bpy_app_getsets; getset->name; getset++) {
|
||||
for (getset= bpy_app_getsets; getset->name; getset++) {
|
||||
PyDict_SetItemString(BlenderAppType.tp_dict, getset->name, PyDescr_NewGetSet(&BlenderAppType, getset));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,13 +77,13 @@ static PyObject *make_app_cb_info(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
if(app_cb_info_fields[pos].name == NULL) {
|
||||
for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
if (app_cb_info_fields[pos].name == NULL) {
|
||||
Py_FatalError("invalid callback slots 1");
|
||||
}
|
||||
PyStructSequence_SET_ITEM(app_cb_info, pos, (py_cb_array[pos]= PyList_New(0)));
|
||||
}
|
||||
if(app_cb_info_fields[pos].name != NULL) {
|
||||
if (app_cb_info_fields[pos].name != NULL) {
|
||||
Py_FatalError("invalid callback slots 2");
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ PyObject *BPY_app_handlers_struct(void)
|
||||
BlenderAppCbType.tp_new= NULL;
|
||||
|
||||
/* assign the C callbacks */
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{NULL}};
|
||||
bCallbackFuncStore *funcstore;
|
||||
int pos= 0;
|
||||
|
||||
for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
funcstore= &funcstore_array[pos];
|
||||
funcstore->func= bpy_app_generic_callback;
|
||||
funcstore->alloc= 0;
|
||||
@@ -124,7 +124,7 @@ void BPY_app_handlers_reset(void)
|
||||
{
|
||||
int pos= 0;
|
||||
|
||||
for(pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
for (pos= 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL);
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
|
||||
{
|
||||
PyObject *cb_list= py_cb_array[GET_INT_FROM_POINTER(arg)];
|
||||
Py_ssize_t cb_list_len;
|
||||
if((cb_list_len= PyList_GET_SIZE(cb_list)) > 0) {
|
||||
if ((cb_list_len= PyList_GET_SIZE(cb_list)) > 0) {
|
||||
PyGILState_STATE gilstate= PyGILState_Ensure();
|
||||
|
||||
PyObject* args= PyTuple_New(1); // save python creating each call
|
||||
@@ -143,7 +143,7 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
|
||||
Py_ssize_t pos;
|
||||
|
||||
/* setup arguments */
|
||||
if(id) {
|
||||
if (id) {
|
||||
PointerRNA id_ptr;
|
||||
RNA_id_pointer_create(id, &id_ptr);
|
||||
PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(&id_ptr));
|
||||
|
||||
@@ -99,7 +99,7 @@ void BPY_driver_reset(void)
|
||||
PyGILState_STATE gilstate;
|
||||
int use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
gilstate= PyGILState_Ensure();
|
||||
|
||||
if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
|
||||
@@ -108,7 +108,7 @@ void BPY_driver_reset(void)
|
||||
bpy_pydriver_Dict= NULL;
|
||||
}
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
PyGILState_Release(gilstate);
|
||||
|
||||
return;
|
||||
@@ -157,14 +157,14 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
if ((expr == NULL) || (expr[0]=='\0'))
|
||||
return 0.0f;
|
||||
|
||||
if(!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
if (!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression);
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
gilstate= PyGILState_Ensure();
|
||||
|
||||
/* needed since drivers are updated directly after undo where 'main' is
|
||||
@@ -175,17 +175,17 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
if (!bpy_pydriver_Dict) {
|
||||
if (bpy_pydriver_create_dict() != 0) {
|
||||
fprintf(stderr, "Pydriver error: couldn't create Python dictionary");
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
PyGILState_Release(gilstate);
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if(driver->expr_comp==NULL)
|
||||
if (driver->expr_comp==NULL)
|
||||
driver->flag |= DRIVER_FLAG_RECOMPILE;
|
||||
|
||||
/* compile the expression first if it hasn't been compiled or needs to be rebuilt */
|
||||
if(driver->flag & DRIVER_FLAG_RECOMPILE) {
|
||||
if (driver->flag & DRIVER_FLAG_RECOMPILE) {
|
||||
Py_XDECREF(driver->expr_comp);
|
||||
driver->expr_comp= PyTuple_New(2);
|
||||
|
||||
@@ -199,7 +199,7 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
expr_code= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 0);
|
||||
}
|
||||
|
||||
if(driver->flag & DRIVER_FLAG_RENAMEVAR) {
|
||||
if (driver->flag & DRIVER_FLAG_RENAMEVAR) {
|
||||
/* may not be set */
|
||||
expr_vars= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 1);
|
||||
Py_XDECREF(expr_vars);
|
||||
@@ -260,7 +260,7 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
if (retval == NULL) {
|
||||
pydriver_error(driver);
|
||||
}
|
||||
else if((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
|
||||
else if ((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
|
||||
pydriver_error(driver);
|
||||
Py_DECREF(retval);
|
||||
result= 0.0;
|
||||
@@ -271,10 +271,10 @@ float BPY_driver_exec(ChannelDriver *driver)
|
||||
Py_DECREF(retval);
|
||||
}
|
||||
|
||||
if(use_gil)
|
||||
if (use_gil)
|
||||
PyGILState_Release(gilstate);
|
||||
|
||||
if(finite(result)) {
|
||||
if (finite(result)) {
|
||||
return (float)result;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -100,14 +100,14 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
|
||||
{
|
||||
py_call_level++;
|
||||
|
||||
if(gilstate)
|
||||
if (gilstate)
|
||||
*gilstate= PyGILState_Ensure();
|
||||
|
||||
if(py_call_level==1) {
|
||||
if (py_call_level==1) {
|
||||
bpy_context_update(C);
|
||||
|
||||
#ifdef TIME_PY_RUN
|
||||
if(bpy_timer_count==0) {
|
||||
if (bpy_timer_count==0) {
|
||||
/* record time from the beginning */
|
||||
bpy_timer= PIL_check_seconds_timer();
|
||||
bpy_timer_run= bpy_timer_run_tot= 0.0;
|
||||
@@ -125,13 +125,13 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
|
||||
{
|
||||
py_call_level--;
|
||||
|
||||
if(gilstate)
|
||||
if (gilstate)
|
||||
PyGILState_Release(*gilstate);
|
||||
|
||||
if(py_call_level < 0) {
|
||||
if (py_call_level < 0) {
|
||||
fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
|
||||
}
|
||||
else if(py_call_level==0) {
|
||||
else if (py_call_level==0) {
|
||||
// XXX - Calling classes currently wont store the context :\, cant set NULL because of this. but this is very flakey still.
|
||||
//BPy_SetContext(NULL);
|
||||
//bpy_import_main_set(NULL);
|
||||
@@ -146,7 +146,7 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
|
||||
|
||||
void BPY_text_free_code(Text *text)
|
||||
{
|
||||
if(text->compiled) {
|
||||
if (text->compiled) {
|
||||
Py_DECREF((PyObject *)text->compiled);
|
||||
text->compiled= NULL;
|
||||
}
|
||||
@@ -273,10 +273,10 @@ void BPY_python_end(void)
|
||||
printf("*bpy stats* - ");
|
||||
printf("tot exec: %d, ", bpy_timer_count);
|
||||
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
|
||||
if(bpy_timer_count>0)
|
||||
if (bpy_timer_count>0)
|
||||
printf("average run: %.6fsec, ", (bpy_timer_run_tot/bpy_timer_count));
|
||||
|
||||
if(bpy_timer>0.0)
|
||||
if (bpy_timer>0.0)
|
||||
printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer)*100.0);
|
||||
|
||||
printf("\n");
|
||||
@@ -292,7 +292,7 @@ static void python_script_error_jump_text(struct Text *text)
|
||||
int lineno;
|
||||
int offset;
|
||||
python_script_error_jump(text->id.name+2, &lineno, &offset);
|
||||
if(lineno != -1) {
|
||||
if (lineno != -1) {
|
||||
/* select the line with the error */
|
||||
txt_move_to(text, lineno - 1, INT_MAX, FALSE);
|
||||
txt_move_to(text, lineno - 1, offset, TRUE);
|
||||
@@ -332,22 +332,22 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
char fn_dummy[FILE_MAXDIR];
|
||||
bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
|
||||
|
||||
if(text->compiled == NULL) { /* if it wasn't already compiled, do it now */
|
||||
if (text->compiled == NULL) { /* if it wasn't already compiled, do it now */
|
||||
char *buf= txt_to_buf(text);
|
||||
|
||||
text->compiled= Py_CompileString(buf, fn_dummy, Py_file_input);
|
||||
|
||||
MEM_freeN(buf);
|
||||
|
||||
if(PyErr_Occurred()) {
|
||||
if(do_jump) {
|
||||
if (PyErr_Occurred()) {
|
||||
if (do_jump) {
|
||||
python_script_error_jump_text(text);
|
||||
}
|
||||
BPY_text_free_code(text);
|
||||
}
|
||||
}
|
||||
|
||||
if(text->compiled) {
|
||||
if (text->compiled) {
|
||||
py_dict= PyC_DefaultNameSpace(fn_dummy);
|
||||
py_result= PyEval_EvalCode(text->compiled, py_dict, py_dict);
|
||||
}
|
||||
@@ -356,7 +356,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
else {
|
||||
FILE *fp= fopen(fn, "r");
|
||||
|
||||
if(fp) {
|
||||
if (fp) {
|
||||
py_dict= PyC_DefaultNameSpace(fn);
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -390,8 +390,8 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
}
|
||||
|
||||
if (!py_result) {
|
||||
if(text) {
|
||||
if(do_jump) {
|
||||
if (text) {
|
||||
if (do_jump) {
|
||||
python_script_error_jump_text(text);
|
||||
}
|
||||
}
|
||||
@@ -401,7 +401,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
Py_DECREF(py_result);
|
||||
}
|
||||
|
||||
if(py_dict) {
|
||||
if (py_dict) {
|
||||
#ifdef PYMODULE_CLEAR_WORKAROUND
|
||||
PyModuleObject *mmod= (PyModuleObject *)PyDict_GetItemString(PyThreadState_GET()->interp->modules, "__main__");
|
||||
PyObject *dict_back= mmod->md_dict;
|
||||
@@ -450,7 +450,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
|
||||
if (!value || !expr) return -1;
|
||||
|
||||
if(expr[0]=='\0') {
|
||||
if (expr[0]=='\0') {
|
||||
*value= 0.0;
|
||||
return error_ret;
|
||||
}
|
||||
@@ -479,13 +479,13 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
else {
|
||||
double val;
|
||||
|
||||
if(PyTuple_Check(retval)) {
|
||||
if (PyTuple_Check(retval)) {
|
||||
/* Users my have typed in 10km, 2m
|
||||
* add up all values */
|
||||
int i;
|
||||
val= 0.0;
|
||||
|
||||
for(i=0; i<PyTuple_GET_SIZE(retval); i++) {
|
||||
for (i=0; i<PyTuple_GET_SIZE(retval); i++) {
|
||||
val+= PyFloat_AsDouble(PyTuple_GET_ITEM(retval, i));
|
||||
}
|
||||
}
|
||||
@@ -494,7 +494,7 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
}
|
||||
Py_DECREF(retval);
|
||||
|
||||
if(val==-1 && PyErr_Occurred()) {
|
||||
if (val==-1 && PyErr_Occurred()) {
|
||||
error_ret= -1;
|
||||
}
|
||||
else if (!finite(val)) {
|
||||
@@ -505,8 +505,8 @@ int BPY_button_exec(bContext *C, const char *expr, double *value, const short ve
|
||||
}
|
||||
}
|
||||
|
||||
if(error_ret) {
|
||||
if(verbose) {
|
||||
if (error_ret) {
|
||||
if (verbose) {
|
||||
BPy_errors_to_report(CTX_wm_reports(C));
|
||||
}
|
||||
else {
|
||||
@@ -531,7 +531,7 @@ int BPY_string_exec(bContext *C, const char *expr)
|
||||
|
||||
if (!expr) return -1;
|
||||
|
||||
if(expr[0]=='\0') {
|
||||
if (expr[0]=='\0') {
|
||||
return error_ret;
|
||||
}
|
||||
|
||||
@@ -572,20 +572,20 @@ void BPY_modules_load_user(bContext *C)
|
||||
Text *text;
|
||||
|
||||
/* can happen on file load */
|
||||
if(bmain==NULL)
|
||||
if (bmain==NULL)
|
||||
return;
|
||||
|
||||
/* update pointers since this can run from a nested script
|
||||
* on file load */
|
||||
if(py_call_level) {
|
||||
if (py_call_level) {
|
||||
bpy_context_update(C);
|
||||
}
|
||||
|
||||
bpy_context_set(C, &gilstate);
|
||||
|
||||
for(text=CTX_data_main(C)->text.first; text; text= text->id.next) {
|
||||
if(text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
|
||||
if(!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
for (text=CTX_data_main(C)->text.first; text; text= text->id.next) {
|
||||
if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name+2, ".py")) {
|
||||
if (!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name+2);
|
||||
}
|
||||
else {
|
||||
@@ -611,13 +611,13 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
PointerRNA *ptr= NULL;
|
||||
int done= 0;
|
||||
|
||||
if(item==NULL) {
|
||||
if (item==NULL) {
|
||||
/* pass */
|
||||
}
|
||||
else if(item==Py_None) {
|
||||
else if (item==Py_None) {
|
||||
/* pass */
|
||||
}
|
||||
else if(BPy_StructRNA_Check(item)) {
|
||||
else if (BPy_StructRNA_Check(item)) {
|
||||
ptr= &(((BPy_StructRNA *)item)->ptr);
|
||||
|
||||
//result->ptr= ((BPy_StructRNA *)item)->ptr;
|
||||
@@ -633,10 +633,10 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
else {
|
||||
int len= PySequence_Fast_GET_SIZE(seq_fast);
|
||||
int i;
|
||||
for(i= 0; i < len; i++) {
|
||||
for (i= 0; i < len; i++) {
|
||||
PyObject *list_item= PySequence_Fast_GET_ITEM(seq_fast, i);
|
||||
|
||||
if(BPy_StructRNA_Check(list_item)) {
|
||||
if (BPy_StructRNA_Check(list_item)) {
|
||||
/*
|
||||
CollectionPointerLink *link= MEM_callocN(sizeof(CollectionPointerLink), "bpy_context_get");
|
||||
link->ptr= ((BPy_StructRNA *)item)->ptr;
|
||||
@@ -656,12 +656,12 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
}
|
||||
}
|
||||
|
||||
if(done==0) {
|
||||
if (done==0) {
|
||||
if (item) printf("PyContext '%s' not a valid type\n", member);
|
||||
else printf("PyContext '%s' not found\n", member);
|
||||
}
|
||||
else {
|
||||
if(G.f & G_DEBUG) {
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("PyContext '%s' found\n", member);
|
||||
}
|
||||
}
|
||||
@@ -759,7 +759,7 @@ PyInit_bpy(void)
|
||||
dealloc_obj_Type.tp_dealloc= dealloc_obj_dealloc;
|
||||
dealloc_obj_Type.tp_flags= Py_TPFLAGS_DEFAULT;
|
||||
|
||||
if(PyType_Ready(&dealloc_obj_Type) < 0)
|
||||
if (PyType_Ready(&dealloc_obj_Type) < 0)
|
||||
return NULL;
|
||||
|
||||
dob= (dealloc_obj *) dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0);
|
||||
|
||||
@@ -68,7 +68,7 @@ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
|
||||
Py_DECREF(atexit_func);
|
||||
Py_DECREF(args);
|
||||
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
else { /* should never happen */
|
||||
|
||||
@@ -184,7 +184,7 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
|
||||
const char* filename= NULL;
|
||||
int is_rel= 0, is_link= 0;
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
|
||||
return NULL;
|
||||
|
||||
ret= PyObject_New(BPy_Library, &bpy_lib_Type);
|
||||
@@ -210,10 +210,10 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
|
||||
|
||||
names= BLO_blendhandle_get_datablock_names(self->blo_handle, blocktype, &totnames);
|
||||
|
||||
if(names) {
|
||||
if (names) {
|
||||
int counter= 0;
|
||||
list= PyList_New(totnames);
|
||||
for(l= names; l; l= l->next) {
|
||||
for (l= names; l; l= l->next) {
|
||||
PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
|
||||
counter++;
|
||||
}
|
||||
@@ -237,8 +237,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
|
||||
|
||||
self->blo_handle= BLO_blendhandle_from_file(self->abspath, &reports);
|
||||
|
||||
if(self->blo_handle == NULL) {
|
||||
if(BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
|
||||
if (self->blo_handle == NULL) {
|
||||
if (BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
|
||||
PyErr_Format(PyExc_IOError,
|
||||
"load: %s failed to open blend file",
|
||||
self->abspath);
|
||||
@@ -247,8 +247,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
|
||||
}
|
||||
else {
|
||||
int i= 0, code;
|
||||
while((code= BKE_idcode_iter_step(&i))) {
|
||||
if(BKE_idcode_is_linkable(code)) {
|
||||
while ((code= BKE_idcode_iter_step(&i))) {
|
||||
if (BKE_idcode_is_linkable(code)) {
|
||||
const char *name_plural= BKE_idcode_to_name_plural(code);
|
||||
PyObject *str= PyUnicode_FromString(name_plural);
|
||||
PyDict_SetItem(self->dict, str, PyList_New(0));
|
||||
@@ -322,27 +322,27 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
|
||||
{
|
||||
int i= 0, code;
|
||||
while((code= BKE_idcode_iter_step(&i))) {
|
||||
if(BKE_idcode_is_linkable(code)) {
|
||||
while ((code= BKE_idcode_iter_step(&i))) {
|
||||
if (BKE_idcode_is_linkable(code)) {
|
||||
const char *name_plural= BKE_idcode_to_name_plural(code);
|
||||
PyObject *ls= PyDict_GetItemString(self->dict, name_plural);
|
||||
// printf("lib: %s\n", name_plural);
|
||||
if(ls && PyList_Check(ls)) {
|
||||
if (ls && PyList_Check(ls)) {
|
||||
/* loop */
|
||||
Py_ssize_t size= PyList_GET_SIZE(ls);
|
||||
Py_ssize_t i;
|
||||
PyObject *item;
|
||||
const char *item_str;
|
||||
|
||||
for(i= 0; i < size; i++) {
|
||||
for (i= 0; i < size; i++) {
|
||||
item= PyList_GET_ITEM(ls, i);
|
||||
item_str= _PyUnicode_AsString(item);
|
||||
|
||||
// printf(" %s\n", item_str);
|
||||
|
||||
if(item_str) {
|
||||
if (item_str) {
|
||||
ID *id= BLO_library_append_named_part(mainl, &(self->blo_handle), item_str, code);
|
||||
if(id) {
|
||||
if (id) {
|
||||
#ifdef USE_RNA_DATABLOCKS
|
||||
PointerRNA id_ptr;
|
||||
RNA_id_pointer_create(id, &id_ptr);
|
||||
@@ -382,7 +382,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
}
|
||||
}
|
||||
|
||||
if(err == -1) {
|
||||
if (err == -1) {
|
||||
/* exception raised above, XXX, this leaks some memory */
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle= NULL;
|
||||
@@ -399,10 +399,10 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
recalc_all_library_objects(G.main);
|
||||
|
||||
/* append, rather than linking */
|
||||
if((self->flag & FILE_LINK)==0) {
|
||||
if ((self->flag & FILE_LINK)==0) {
|
||||
Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
|
||||
if(lib) all_local(lib, 1);
|
||||
else BLI_assert(!"cant find name of just added library!");
|
||||
if (lib) all_local(lib, 1);
|
||||
else BLI_assert(!"cant find name of just added library!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ int bpy_lib_init(PyObject *mod_par)
|
||||
/* some compilers dont like accessing this directly, delay assignment */
|
||||
bpy_lib_Type.tp_getattro= PyObject_GenericGetAttr;
|
||||
|
||||
if(PyType_Ready(&bpy_lib_Type) < 0)
|
||||
if (PyType_Ready(&bpy_lib_Type) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
|
||||
bContext *C= (bContext *)BPy_GetContext();
|
||||
|
||||
if(C==NULL) {
|
||||
if (C==NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
|
||||
return NULL;
|
||||
}
|
||||
@@ -93,8 +93,8 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(context_str) {
|
||||
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
if (context_str) {
|
||||
if (RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
char *enum_str= BPy_enum_as_string(operator_context_items);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Calling operator \"bpy.ops.%s.poll\" error, "
|
||||
@@ -105,7 +105,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
if(context_dict==NULL || context_dict==Py_None) {
|
||||
if (context_dict==NULL || context_dict==Py_None) {
|
||||
context_dict= NULL;
|
||||
}
|
||||
else if (!PyDict_Check(context_dict)) {
|
||||
@@ -150,7 +150,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
|
||||
bContext *C= (bContext *)BPy_GetContext();
|
||||
|
||||
if(C==NULL) {
|
||||
if (C==NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators");
|
||||
return NULL;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!pyrna_write_check()) {
|
||||
if (!pyrna_write_check()) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"Calling operator \"bpy.ops.%s\" error, "
|
||||
"can't modify blend data in this state (drawing/rendering)",
|
||||
@@ -175,8 +175,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(context_str) {
|
||||
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
if (context_str) {
|
||||
if (RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
|
||||
char *enum_str= BPy_enum_as_string(operator_context_items);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"Calling operator \"bpy.ops.%s\" error, "
|
||||
@@ -187,7 +187,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
if(context_dict==NULL || context_dict==Py_None) {
|
||||
if (context_dict==NULL || context_dict==Py_None) {
|
||||
context_dict= NULL;
|
||||
}
|
||||
else if (!PyDict_Check(context_dict)) {
|
||||
@@ -203,7 +203,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
CTX_py_dict_set(C, (void *)context_dict);
|
||||
Py_XINCREF(context_dict); /* so we done loose it */
|
||||
|
||||
if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
|
||||
if (WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
|
||||
const char *msg= CTX_wm_operator_poll_msg_get(C);
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"Operator bpy.ops.%.200s.poll() %.200s",
|
||||
@@ -215,7 +215,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
WM_operator_properties_sanitize(&ptr, 0);
|
||||
|
||||
if(kw && PyDict_Size(kw))
|
||||
if (kw && PyDict_Size(kw))
|
||||
error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
|
||||
|
||||
|
||||
@@ -245,10 +245,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
error_val= BPy_reports_to_error(reports, PyExc_RuntimeError, FALSE);
|
||||
|
||||
/* operator output is nice to have in the terminal/console too */
|
||||
if(reports->list.first) {
|
||||
if (reports->list.first) {
|
||||
char *report_str= BKE_reports_string(reports, 0); /* all reports */
|
||||
|
||||
if(report_str) {
|
||||
if (report_str) {
|
||||
PySys_WriteStdout("%s\n", report_str);
|
||||
MEM_freeN(report_str);
|
||||
}
|
||||
@@ -315,7 +315,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
|
||||
bContext *C= (bContext *)BPy_GetContext();
|
||||
|
||||
if(C==NULL) {
|
||||
if (C==NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Context is None, cant get the string representation of this object.");
|
||||
return NULL;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
/* Save another lookup */
|
||||
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
|
||||
|
||||
if(kw && PyDict_Size(kw))
|
||||
if (kw && PyDict_Size(kw))
|
||||
error_val= pyrna_pydict_to_props(&ptr, kw, 0, "Converting py args to operator properties: ");
|
||||
|
||||
if (error_val==0)
|
||||
@@ -348,7 +348,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(buf) {
|
||||
if (buf) {
|
||||
pybuf= PyUnicode_FromString(buf);
|
||||
MEM_freeN(buf);
|
||||
}
|
||||
@@ -364,7 +364,7 @@ static PyObject *pyop_dir(PyObject *UNUSED(self))
|
||||
GHashIterator *iter= WM_operatortype_iter();
|
||||
PyObject *list= PyList_New(0), *name;
|
||||
|
||||
for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
|
||||
|
||||
name= PyUnicode_FromString(ot->idname);
|
||||
@@ -383,12 +383,12 @@ static PyObject *pyop_getrna(PyObject *UNUSED(self), PyObject *value)
|
||||
char *opname= _PyUnicode_AsString(value);
|
||||
BPy_StructRNA *pyrna= NULL;
|
||||
|
||||
if(opname==NULL) {
|
||||
if (opname==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_rna() expects a string argument");
|
||||
return NULL;
|
||||
}
|
||||
ot= WM_operatortype_find(opname, TRUE);
|
||||
if(ot==NULL) {
|
||||
if (ot==NULL) {
|
||||
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_rna(\"%s\") not found", opname);
|
||||
return NULL;
|
||||
}
|
||||
@@ -416,12 +416,12 @@ static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
|
||||
char *opname= _PyUnicode_AsString(value);
|
||||
BPy_StructRNA *pyrna= NULL;
|
||||
|
||||
if(opname==NULL) {
|
||||
if (opname==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_instance() expects a string argument");
|
||||
return NULL;
|
||||
}
|
||||
ot= WM_operatortype_find(opname, TRUE);
|
||||
if(ot==NULL) {
|
||||
if (ot==NULL) {
|
||||
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_instance(\"%s\") not found", opname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ static void operator_properties_init(wmOperatorType *ot)
|
||||
* later */
|
||||
RNA_def_struct_identifier(ot->srna, ot->idname);
|
||||
|
||||
if(pyrna_deferred_register_class(ot->srna, py_class) != 0) {
|
||||
if (pyrna_deferred_register_class(ot->srna, py_class) != 0) {
|
||||
PyErr_Print(); /* failed to register operator props */
|
||||
PyErr_Clear();
|
||||
}
|
||||
@@ -72,8 +72,9 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
|
||||
prop= RNA_struct_find_property(&ptr, "type");
|
||||
if(prop)
|
||||
if (prop) {
|
||||
ot->prop= prop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,11 +123,11 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
|
||||
PyObject *self= NULL;
|
||||
/* first get self */
|
||||
/* operators can store their own instance for later use */
|
||||
if(ptr->data) {
|
||||
if (ptr->data) {
|
||||
void **instance= RNA_struct_instance(ptr);
|
||||
|
||||
if(instance) {
|
||||
if(*instance) {
|
||||
if (instance) {
|
||||
if (*instance) {
|
||||
self= *instance;
|
||||
Py_INCREF(self);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ static PyObject *pyrna_struct_as_instance(PointerRNA *ptr)
|
||||
}
|
||||
|
||||
/* in most cases this will run */
|
||||
if(self == NULL) {
|
||||
if (self == NULL) {
|
||||
self= pyrna_struct_CreatePyObject(ptr);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
|
||||
PyTuple_SET_ITEM(ret, 0, func);
|
||||
Py_INCREF(func);
|
||||
|
||||
if(kw==NULL)
|
||||
if (kw==NULL)
|
||||
kw= PyDict_New();
|
||||
else
|
||||
Py_INCREF(kw);
|
||||
@@ -190,7 +190,7 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
|
||||
|
||||
BLI_assert(py_data != NULL);
|
||||
|
||||
if(!is_write_ok) {
|
||||
if (!is_write_ok) {
|
||||
pyrna_write_set(TRUE);
|
||||
}
|
||||
|
||||
@@ -209,11 +209,11 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
|
||||
|
||||
Py_DECREF(args);
|
||||
|
||||
if(ret == NULL) {
|
||||
if (ret == NULL) {
|
||||
printf_func_error(py_func);
|
||||
}
|
||||
else {
|
||||
if(ret != Py_None) {
|
||||
if (ret != Py_None) {
|
||||
PyErr_SetString(PyExc_ValueError, "the return value must be None");
|
||||
printf_func_error(py_func);
|
||||
}
|
||||
@@ -223,15 +223,15 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
|
||||
|
||||
bpy_context_clear(C, &gilstate);
|
||||
|
||||
if(!is_write_ok) {
|
||||
if (!is_write_ok) {
|
||||
pyrna_write_set(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static int bpy_prop_callback_check(PyObject *py_func, int argcount)
|
||||
{
|
||||
if(py_func) {
|
||||
if(!PyFunction_Check(py_func)) {
|
||||
if (py_func) {
|
||||
if (!PyFunction_Check(py_func)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"update keyword: expected a function type, not a %.200s",
|
||||
Py_TYPE(py_func)->tp_name);
|
||||
@@ -255,7 +255,7 @@ static int bpy_prop_callback_check(PyObject *py_func, int argcount)
|
||||
static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_cb)
|
||||
{
|
||||
/* assume this is already checked for type and arg length */
|
||||
if(update_cb) {
|
||||
if (update_cb) {
|
||||
PyObject **py_data= MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, "bpy_prop_callback_assign");
|
||||
RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb);
|
||||
py_data[BPY_DATA_CB_SLOT_UPDATE]= update_cb;
|
||||
@@ -270,7 +270,7 @@ static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_c
|
||||
/* utility function we need for parsing int's in an if statement */
|
||||
static int py_long_as_int(PyObject *py_long, int *r_int)
|
||||
{
|
||||
if(PyLong_CheckExact(py_long)) {
|
||||
if (PyLong_CheckExact(py_long)) {
|
||||
*r_int= (int)PyLong_AS_LONG(py_long);
|
||||
return 0;
|
||||
}
|
||||
@@ -295,8 +295,8 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
|
||||
return NULL; \
|
||||
} \
|
||||
srna= srna_from_self(self, #_func"(...):"); \
|
||||
if(srna==NULL) { \
|
||||
if(PyErr_Occurred()) \
|
||||
if (srna==NULL) { \
|
||||
if (PyErr_Occurred()) \
|
||||
return NULL; \
|
||||
return bpy_prop_deferred_return((void *)pymeth_##_func, kw); \
|
||||
} \
|
||||
@@ -304,24 +304,24 @@ static int py_long_as_int(PyObject *py_long, int *r_int)
|
||||
/* terse macros for error checks shared between all funcs cant use function
|
||||
* calls because of static strins passed to pyrna_set_to_enum_bitfield */
|
||||
#define BPY_PROPDEF_CHECK(_func, _property_flag_items) \
|
||||
if(id_len >= MAX_IDPROP_NAME) { \
|
||||
if (id_len >= MAX_IDPROP_NAME) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
#_func"(): '%.200s' too long, max length is %d", \
|
||||
id, MAX_IDPROP_NAME-1); \
|
||||
return NULL; \
|
||||
} \
|
||||
if(RNA_def_property_free_identifier(srna, id) == -1) { \
|
||||
if (RNA_def_property_free_identifier(srna, id) == -1) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
#_func"(): '%s' is defined as a non-dynamic type", \
|
||||
id); \
|
||||
return NULL; \
|
||||
} \
|
||||
if(pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \
|
||||
if (pyopts && pyrna_set_to_enum_bitfield(_property_flag_items, pyopts, &opts, #_func"(options={...}):")) \
|
||||
return NULL; \
|
||||
|
||||
#define BPY_PROPDEF_SUBTYPE_CHECK(_func, _property_flag_items, _subtype) \
|
||||
BPY_PROPDEF_CHECK(_func, _property_flag_items) \
|
||||
if(pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \
|
||||
if (pysubtype && RNA_enum_value_from_id(_subtype, pysubtype, &subtype)==0) { \
|
||||
PyErr_Format(PyExc_TypeError, \
|
||||
#_func"(subtype='%s'): invalid subtype", \
|
||||
pysubtype); \
|
||||
@@ -380,7 +380,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(BoolProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -412,9 +412,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
RNA_def_property_boolean_default(prop, def);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -446,7 +446,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_HEAD(BoolVectorProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "options", "subtype", "size", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -472,12 +472,12 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items)
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
if (size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "BoolVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0)
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyBool_Type, FALSE, "BoolVectorProperty(default=sequence)") < 0)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@@ -487,12 +487,12 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
// prop= RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description);
|
||||
prop= RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
|
||||
RNA_def_property_array(prop, size);
|
||||
if(pydef) RNA_def_property_boolean_array_default(prop, def);
|
||||
if (pydef) RNA_def_property_boolean_array_default(prop, def);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -520,7 +520,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(IntProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -555,9 +555,9 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -588,7 +588,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_HEAD(IntVectorProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "size", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -616,12 +616,12 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items)
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
if (size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "IntVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, FALSE, "IntVectorProperty(default=sequence)") < 0)
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyLong_Type, FALSE, "IntVectorProperty(default=sequence)") < 0)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@@ -630,14 +630,14 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
prop= RNA_def_property(srna, id, PROP_INT, subtype);
|
||||
RNA_def_property_array(prop, size);
|
||||
if(pydef) RNA_def_property_int_array_default(prop, def);
|
||||
if (pydef) RNA_def_property_int_array_default(prop, def);
|
||||
RNA_def_property_range(prop, min, max);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -666,7 +666,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(FloatProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -695,7 +695,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items)
|
||||
|
||||
if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
if (pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatProperty(unit='%s'): invalid unit", pyunit);
|
||||
return NULL;
|
||||
}
|
||||
@@ -710,9 +710,9 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -744,7 +744,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
BPY_PROPDEF_HEAD(FloatVectorProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", "size", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -774,17 +774,17 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items)
|
||||
|
||||
if(pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
if (pyunit && RNA_enum_value_from_id(property_unit_items, pyunit, &unit)==0) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(unit='%s'): invalid unit", pyunit);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
if (size < 1 || size > PYRNA_STACK_ARRAY) {
|
||||
PyErr_Format(PyExc_TypeError, "FloatVectorProperty(size=%d): size must be between 0 and " STRINGIFY(PYRNA_STACK_ARRAY), size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, FALSE, "FloatVectorProperty(default=sequence)") < 0)
|
||||
if (pydef && PyC_AsArray(def, pydef, size, &PyFloat_Type, FALSE, "FloatVectorProperty(default=sequence)") < 0)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@@ -793,14 +793,14 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
prop= RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
|
||||
RNA_def_property_array(prop, size);
|
||||
if(pydef) RNA_def_property_float_array_default(prop, def);
|
||||
if (pydef) RNA_def_property_float_array_default(prop, def);
|
||||
RNA_def_property_range(prop, min, max);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -827,7 +827,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
|
||||
BPY_PROPDEF_HEAD(StringProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "name", "description", "default", "maxlen", "options", "subtype", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="", *def="";
|
||||
int id_len;
|
||||
@@ -856,13 +856,13 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
}
|
||||
|
||||
prop= RNA_def_property(srna, id, PROP_STRING, subtype);
|
||||
if(maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
|
||||
if(def) RNA_def_property_string_default(prop, def);
|
||||
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
|
||||
if (def) RNA_def_property_string_default(prop, def);
|
||||
RNA_def_property_ui_text(prop, name, description);
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -878,7 +878,7 @@ static size_t strswapbufcpy(char *buf, const char **orig)
|
||||
char *dst= buf;
|
||||
size_t i= 0;
|
||||
*orig= buf;
|
||||
while((*dst= *src)) { dst++; src++; i++; }
|
||||
while ((*dst= *src)) { dst++; src++; i++; }
|
||||
return i + 1; /* include '\0' */
|
||||
}
|
||||
#endif
|
||||
@@ -893,12 +893,12 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
short def_used= 0;
|
||||
const char *def_cmp= NULL;
|
||||
|
||||
if(is_enum_flag) {
|
||||
if(seq_len > RNA_ENUM_BITFLAG_SIZE) {
|
||||
if (is_enum_flag) {
|
||||
if (seq_len > RNA_ENUM_BITFLAG_SIZE) {
|
||||
PyErr_SetString(PyExc_TypeError, "EnumProperty(...): maximum " STRINGIFY(RNA_ENUM_BITFLAG_SIZE) " members for a ENUM_FLAG type property");
|
||||
return NULL;
|
||||
}
|
||||
if(def && !PySet_Check(def)) {
|
||||
if (def && !PySet_Check(def)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"EnumProperty(...): default option must be a 'set' "
|
||||
"type when ENUM_FLAG is enabled, not a '%.200s'",
|
||||
@@ -907,9 +907,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(def) {
|
||||
if (def) {
|
||||
def_cmp= _PyUnicode_AsString(def);
|
||||
if(def_cmp==NULL) {
|
||||
if (def_cmp==NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"EnumProperty(...): default option must be a 'str' "
|
||||
"type when ENUM_FLAG is disabled, not a '%.200s'",
|
||||
@@ -924,7 +924,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
|
||||
items= MEM_callocN(sizeof(EnumPropertyItem) * (seq_len + 1), "enum_items_from_py1");
|
||||
|
||||
for(i=0; i<seq_len; i++) {
|
||||
for (i=0; i<seq_len; i++) {
|
||||
EnumPropertyItem tmp= {0, "", 0, "", ""};
|
||||
Py_ssize_t item_size;
|
||||
Py_ssize_t id_str_size;
|
||||
@@ -933,7 +933,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
|
||||
item= PySequence_Fast_GET_ITEM(seq_fast, i);
|
||||
|
||||
if( (PyTuple_CheckExact(item)) &&
|
||||
if ( (PyTuple_CheckExact(item)) &&
|
||||
(item_size= PyTuple_GET_SIZE(item)) &&
|
||||
(item_size == 3 || item_size == 4) &&
|
||||
(tmp.identifier= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) &&
|
||||
@@ -941,22 +941,22 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
(tmp.description= _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) &&
|
||||
(item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1) /* TODO, number isnt ensured to be unique from the script author */
|
||||
) {
|
||||
if(is_enum_flag) {
|
||||
if(item_size < 4) {
|
||||
if (is_enum_flag) {
|
||||
if (item_size < 4) {
|
||||
tmp.value= 1<<i;
|
||||
}
|
||||
|
||||
if(def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
|
||||
if (def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
|
||||
*defvalue |= tmp.value;
|
||||
def_used++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(item_size < 4) {
|
||||
if (item_size < 4) {
|
||||
tmp.value= i;
|
||||
}
|
||||
|
||||
if(def && def_used == 0 && strcmp(def_cmp, tmp.identifier)==0) {
|
||||
if (def && def_used == 0 && strcmp(def_cmp, tmp.identifier)==0) {
|
||||
*defvalue= tmp.value;
|
||||
def_used++; /* only ever 1 */
|
||||
}
|
||||
@@ -978,9 +978,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
|
||||
}
|
||||
|
||||
if(is_enum_flag) {
|
||||
if (is_enum_flag) {
|
||||
/* strict check that all set members were used */
|
||||
if(def && def_used != PySet_GET_SIZE(def)) {
|
||||
if (def && def_used != PySet_GET_SIZE(def)) {
|
||||
MEM_freeN(items);
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
@@ -990,7 +990,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(def && def_used == 0) {
|
||||
if (def && def_used == 0) {
|
||||
MEM_freeN(items);
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
@@ -1012,7 +1012,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
EnumPropertyItem *items_ptr= items_dup;
|
||||
char *buf= ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
|
||||
memcpy(items_dup, items, sizeof(EnumPropertyItem) * (seq_len + 1));
|
||||
for(i=0; i<seq_len; i++, items_ptr++) {
|
||||
for (i=0; i<seq_len; i++, items_ptr++) {
|
||||
buf += strswapbufcpy(buf, &items_ptr->identifier);
|
||||
buf += strswapbufcpy(buf, &items_ptr->name);
|
||||
buf += strswapbufcpy(buf, &items_ptr->description);
|
||||
@@ -1052,14 +1052,14 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
|
||||
Py_DECREF(args);
|
||||
|
||||
if(items==NULL) {
|
||||
if (items==NULL) {
|
||||
err= -1;
|
||||
}
|
||||
else {
|
||||
PyObject *items_fast;
|
||||
int defvalue_dummy=0;
|
||||
|
||||
if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) {
|
||||
if (!(items_fast= PySequence_Fast(items, "EnumProperty(...): return value from the callback was not a sequence"))) {
|
||||
err= -1;
|
||||
}
|
||||
else {
|
||||
@@ -1067,7 +1067,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
|
||||
Py_DECREF(items_fast);
|
||||
|
||||
if(!eitems) {
|
||||
if (!eitems) {
|
||||
err= -1;
|
||||
}
|
||||
}
|
||||
@@ -1075,7 +1075,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
Py_DECREF(items);
|
||||
}
|
||||
|
||||
if(err != -1) { /* worked */
|
||||
if (err != -1) { /* worked */
|
||||
*free= 1;
|
||||
}
|
||||
else {
|
||||
@@ -1118,7 +1118,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
BPY_PROPDEF_HEAD(EnumProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "items", "name", "description", "default", "options", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
PyObject *def= NULL;
|
||||
@@ -1149,16 +1149,16 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
}
|
||||
|
||||
/* items can be a list or a callable */
|
||||
if(PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
|
||||
if (PyFunction_Check(items)) { /* dont use PyCallable_Check because we need the function code for errors */
|
||||
PyCodeObject *f_code= (PyCodeObject *)PyFunction_GET_CODE(items);
|
||||
if(f_code->co_argcount != 2) {
|
||||
if (f_code->co_argcount != 2) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"EnumProperty(...): expected 'items' function to take 2 arguments, not %d",
|
||||
f_code->co_argcount);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(def) {
|
||||
if (def) {
|
||||
/* note, using type error here is odd but python does this for invalid arguments */
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"EnumProperty(...): 'default' can't be set when 'items' is a function");
|
||||
@@ -1169,7 +1169,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
eitems= DummyRNA_NULL_items;
|
||||
}
|
||||
else {
|
||||
if(!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) {
|
||||
if (!(items_fast= PySequence_Fast(items, "EnumProperty(...): expected a sequence of tuples for the enum items or a function"))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1177,28 +1177,28 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
Py_DECREF(items_fast);
|
||||
|
||||
if(!eitems) {
|
||||
if (!eitems) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(opts & PROP_ENUM_FLAG) prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
|
||||
else prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
|
||||
if (opts & PROP_ENUM_FLAG) prop= RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
|
||||
else prop= RNA_def_enum(srna, id, eitems, defvalue, name, description);
|
||||
|
||||
if(is_itemf) {
|
||||
if (is_itemf) {
|
||||
RNA_def_enum_funcs(prop, bpy_props_enum_itemf);
|
||||
RNA_def_enum_py_data(prop, (void *)items);
|
||||
/* Py_INCREF(items); */ /* watch out!, if user is tricky they can probably crash blender if they manage to free the callback, take care! */
|
||||
}
|
||||
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
|
||||
if(is_itemf == FALSE) {
|
||||
if (is_itemf == FALSE) {
|
||||
MEM_freeN(eitems);
|
||||
}
|
||||
}
|
||||
@@ -1210,8 +1210,8 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
|
||||
StructRNA *srna;
|
||||
|
||||
srna= srna_from_self(value, "");
|
||||
if(!srna) {
|
||||
if(PyErr_Occurred()) {
|
||||
if (!srna) {
|
||||
if (PyErr_Occurred()) {
|
||||
PyObject *msg= PyC_ExceptionBuffer();
|
||||
char *msg_char= _PyUnicode_AsString(msg);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
@@ -1227,7 +1227,7 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
|
||||
if (!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s expected an RNA type derived from PropertyGroup",
|
||||
error_prefix);
|
||||
@@ -1256,7 +1256,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
|
||||
|
||||
BPY_PROPDEF_HEAD(PointerProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "type", "name", "description", "options", "update", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -1280,7 +1280,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
|
||||
BPY_PROPDEF_CHECK(PointerProperty, property_flag_items)
|
||||
|
||||
ptype= pointer_type_from_py(type, "PointerProperty(...):");
|
||||
if(!ptype)
|
||||
if (!ptype)
|
||||
return NULL;
|
||||
|
||||
if (bpy_prop_callback_check(update_cb, 2) == -1) {
|
||||
@@ -1288,9 +1288,9 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
|
||||
}
|
||||
|
||||
prop= RNA_def_pointer_runtime(srna, id, ptype, name, description);
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
bpy_prop_callback_assign(prop, update_cb);
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
@@ -1316,7 +1316,7 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
BPY_PROPDEF_HEAD(CollectionProperty)
|
||||
|
||||
if(srna) {
|
||||
if (srna) {
|
||||
static const char *kwlist[]= {"attr", "type", "name", "description", "options", NULL};
|
||||
const char *id=NULL, *name="", *description="";
|
||||
int id_len;
|
||||
@@ -1338,13 +1338,13 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
|
||||
BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items)
|
||||
|
||||
ptype= pointer_type_from_py(type, "CollectionProperty(...):");
|
||||
if(!ptype)
|
||||
if (!ptype)
|
||||
return NULL;
|
||||
|
||||
prop= RNA_def_collection_runtime(srna, id, ptype, name, description);
|
||||
if(pyopts) {
|
||||
if(opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
if (pyopts) {
|
||||
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
if ((opts & PROP_ANIMATABLE)==0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
RNA_def_property_duplicate_pointers(srna, prop);
|
||||
}
|
||||
@@ -1363,7 +1363,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
||||
if(PyTuple_GET_SIZE(args) == 1) {
|
||||
if (PyTuple_GET_SIZE(args) == 1) {
|
||||
PyObject *ret;
|
||||
self= PyTuple_GET_ITEM(args, 0);
|
||||
args= PyTuple_New(0);
|
||||
@@ -1377,10 +1377,10 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
}
|
||||
|
||||
srna= srna_from_self(self, "RemoveProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
if (srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
else if(srna==NULL) {
|
||||
else if (srna==NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "RemoveProperty(): struct rna not available for this type");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1396,7 +1396,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(RNA_def_property_free_identifier(srna, id) != 1) {
|
||||
if (RNA_def_property_free_identifier(srna, id) != 1) {
|
||||
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,18 +70,18 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
}
|
||||
|
||||
/* full paths can only be given from ID base */
|
||||
if(is_idbase) {
|
||||
if (is_idbase) {
|
||||
int r_index= -1;
|
||||
if(RNA_path_resolve_full(ptr, path, &r_ptr, &prop, &r_index)==0) {
|
||||
if (RNA_path_resolve_full(ptr, path, &r_ptr, &prop, &r_index)==0) {
|
||||
prop= NULL;
|
||||
}
|
||||
else if(r_index != -1) {
|
||||
else if (r_index != -1) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s path includes index, must be a separate argument",
|
||||
error_prefix, path);
|
||||
return -1;
|
||||
}
|
||||
else if(ptr->id.data != r_ptr.id.data) {
|
||||
else if (ptr->id.data != r_ptr.id.data) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s path spans ID blocks",
|
||||
error_prefix, path);
|
||||
@@ -107,8 +107,8 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(RNA_property_array_check(prop) == 0) {
|
||||
if((*index) == -1) {
|
||||
if (RNA_property_array_check(prop) == 0) {
|
||||
if ((*index) == -1) {
|
||||
*index= 0;
|
||||
}
|
||||
else {
|
||||
@@ -120,7 +120,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
}
|
||||
else {
|
||||
int array_len= RNA_property_array_length(&r_ptr, prop);
|
||||
if((*index) < -1 || (*index) >= array_len) {
|
||||
if ((*index) < -1 || (*index) >= array_len) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s index out of range \"%s\", given %d, array length is %d",
|
||||
error_prefix, path, *index, array_len);
|
||||
@@ -128,7 +128,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
|
||||
}
|
||||
}
|
||||
|
||||
if(is_idbase) {
|
||||
if (is_idbase) {
|
||||
*path_full= BLI_strdup(path);
|
||||
}
|
||||
else {
|
||||
@@ -156,10 +156,10 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, PyObject
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kw, parse_str, (char **)kwlist, &path, index, cfra, group_name))
|
||||
return -1;
|
||||
|
||||
if(pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
|
||||
if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
|
||||
return -1;
|
||||
|
||||
if(*cfra==FLT_MAX)
|
||||
if (*cfra==FLT_MAX)
|
||||
*cfra= CTX_data_scene(BPy_GetContext())->r.cfra;
|
||||
|
||||
return 0; /* success */
|
||||
@@ -191,7 +191,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
|
||||
PYRNA_STRUCT_CHECK_OBJ(self);
|
||||
|
||||
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw,
|
||||
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)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
result= insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
@@ -239,7 +239,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
|
||||
PYRNA_STRUCT_CHECK_OBJ(self);
|
||||
|
||||
if(pyrna_struct_keyframe_parse(&self->ptr, args, kw,
|
||||
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)
|
||||
@@ -255,7 +255,7 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
|
||||
result= delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
@@ -285,7 +285,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
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 {
|
||||
@@ -297,10 +297,10 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
result= ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
if(result) {
|
||||
if (result) {
|
||||
ID *id= self->ptr.id.data;
|
||||
AnimData *adt= BKE_animdata_from_id(id);
|
||||
FCurve *fcu;
|
||||
@@ -308,10 +308,10 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
PointerRNA tptr;
|
||||
PyObject *item;
|
||||
|
||||
if(index == -1) { /* all, use a list */
|
||||
if (index == -1) { /* all, use a list */
|
||||
int i= 0;
|
||||
ret= PyList_New(0);
|
||||
while((fcu= list_find_fcurve(&adt->drivers, path_full, i++))) {
|
||||
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);
|
||||
@@ -361,7 +361,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
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 {
|
||||
@@ -374,7 +374,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
MEM_freeN((void *)path_full);
|
||||
|
||||
if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL);
|
||||
|
||||
@@ -67,7 +67,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
if (dim + 1 < totdim) {
|
||||
/* check that a sequence contains dimsize[dim] items */
|
||||
const Py_ssize_t seq_size= PySequence_Size(seq);
|
||||
if(seq_size == -1) {
|
||||
if (seq_size == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'",
|
||||
error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name);
|
||||
return -1;
|
||||
@@ -77,7 +77,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
int ok= 1;
|
||||
item= PySequence_GetItem(seq, i);
|
||||
|
||||
if(item == NULL) {
|
||||
if (item == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d",
|
||||
error_prefix, Py_TYPE(seq)->tp_name, i);
|
||||
ok= 0;
|
||||
@@ -112,7 +112,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
else {
|
||||
/* check that items are of correct type */
|
||||
const int seq_size= PySequence_Size(seq);
|
||||
if(seq_size == -1) {
|
||||
if (seq_size == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "%s sequence expected at dimension %d, not '%s'",
|
||||
error_prefix, (int)dim + 1, Py_TYPE(seq)->tp_name);
|
||||
return -1;
|
||||
@@ -120,7 +120,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[]
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
|
||||
if(item == NULL) {
|
||||
if (item == NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "%s sequence type '%s' failed to retrieve index %d",
|
||||
error_prefix, Py_TYPE(seq)->tp_name, i);
|
||||
return -1;
|
||||
@@ -146,15 +146,15 @@ static int count_items(PyObject *seq, int dim)
|
||||
{
|
||||
int totitem= 0;
|
||||
|
||||
if(dim > 1) {
|
||||
if (dim > 1) {
|
||||
const Py_ssize_t seq_size= PySequence_Size(seq);
|
||||
Py_ssize_t i;
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
if(item) {
|
||||
if (item) {
|
||||
const int tot= count_items(item, dim - 1);
|
||||
Py_DECREF(item);
|
||||
if(tot != -1) {
|
||||
if (tot != -1) {
|
||||
totitem += tot;
|
||||
}
|
||||
else {
|
||||
@@ -184,7 +184,7 @@ static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA
|
||||
totdim= RNA_property_array_dimension(ptr, prop, dimsize);
|
||||
tot= count_items(rvalue, totdim - lvalue_dim);
|
||||
|
||||
if(tot == -1) {
|
||||
if (tot == -1) {
|
||||
PyErr_Format(PyExc_ValueError, "%s %.200s.%.200s, error validating the sequence length",
|
||||
error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
@@ -294,13 +294,13 @@ static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int
|
||||
|
||||
/* Note that 'data can be NULL' */
|
||||
|
||||
if(seq_size == -1) {
|
||||
if (seq_size == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i= 0; i < seq_size; i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
if(item) {
|
||||
if (item) {
|
||||
if (dim + 1 < totdim) {
|
||||
data= copy_values(item, ptr, prop, dim + 1, data, item_size, index, convert_item, rna_set_index);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ static int py_to_array(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, char *
|
||||
|
||||
if (totitem) {
|
||||
/* note: this code is confusing */
|
||||
if(param_data && RNA_property_flag(prop) & PROP_DYNAMIC) {
|
||||
if (param_data && RNA_property_flag(prop) & PROP_DYNAMIC) {
|
||||
/* not freeing allocated mem, RNA_parameter_list_free() will do this */
|
||||
ParameterDynAlloc *param_alloc= (ParameterDynAlloc *)param_data;
|
||||
param_alloc->array_tot= (int)totitem;
|
||||
@@ -351,7 +351,7 @@ static int py_to_array(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, char *
|
||||
|
||||
/* will only fail in very rare cases since we already validated the
|
||||
* python data, the check here is mainly for completeness. */
|
||||
if(copy_values(seq, ptr, prop, 0, data, item_size, NULL, convert_item, NULL) != NULL) {
|
||||
if (copy_values(seq, ptr, prop, 0, data, item_size, NULL, convert_item, NULL) != NULL) {
|
||||
if (param_data==NULL) {
|
||||
/* NULL can only pass through in case RNA property arraylength is 0 (impossible?) */
|
||||
rna_set_array(ptr, prop, data);
|
||||
@@ -396,8 +396,8 @@ static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, i
|
||||
|
||||
index += arrayoffset;
|
||||
|
||||
if(lvalue_dim == totdim) { /* single item, assign directly */
|
||||
if(!check_item_type(py)) {
|
||||
if (lvalue_dim == totdim) { /* single item, assign directly */
|
||||
if (!check_item_type(py)) {
|
||||
PyErr_Format(PyExc_TypeError, "%s %.200s.%.200s, expected a %s type, not %s",
|
||||
error_prefix, RNA_struct_identifier(ptr->type),
|
||||
RNA_property_identifier(prop), item_type_str,
|
||||
@@ -628,7 +628,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
int type;
|
||||
int i;
|
||||
|
||||
if(len==0) /* possible with dynamic arrays */
|
||||
if (len==0) /* possible with dynamic arrays */
|
||||
return 0;
|
||||
|
||||
if (RNA_property_array_dimension(ptr, prop, NULL) > 1) {
|
||||
@@ -642,7 +642,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
float value_f= PyFloat_AsDouble(value);
|
||||
if(value_f==-1 && PyErr_Occurred()) {
|
||||
if (value_f==-1 && PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
@@ -650,7 +650,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
float tmp[32];
|
||||
float *tmp_arr;
|
||||
|
||||
if(len * sizeof(float) > sizeof(tmp)) {
|
||||
if (len * sizeof(float) > sizeof(tmp)) {
|
||||
tmp_arr= PyMem_MALLOC(len * sizeof(float));
|
||||
}
|
||||
else {
|
||||
@@ -659,11 +659,13 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
|
||||
RNA_property_float_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
if(tmp_arr[i] == value_f)
|
||||
for (i=0; i<len; i++) {
|
||||
if (tmp_arr[i] == value_f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(tmp_arr != tmp)
|
||||
if (tmp_arr != tmp)
|
||||
PyMem_FREE(tmp_arr);
|
||||
|
||||
return i<len ? 1 : 0;
|
||||
@@ -674,7 +676,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
case PROP_INT:
|
||||
{
|
||||
int value_i= PyLong_AsSsize_t(value);
|
||||
if(value_i==-1 && PyErr_Occurred()) {
|
||||
if (value_i==-1 && PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
@@ -682,23 +684,25 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
int tmp[32];
|
||||
int *tmp_arr;
|
||||
|
||||
if(len * sizeof(int) > sizeof(tmp)) {
|
||||
if (len * sizeof(int) > sizeof(tmp)) {
|
||||
tmp_arr= PyMem_MALLOC(len * sizeof(int));
|
||||
}
|
||||
else {
|
||||
tmp_arr= tmp;
|
||||
}
|
||||
|
||||
if(type==PROP_BOOLEAN)
|
||||
if (type==PROP_BOOLEAN)
|
||||
RNA_property_boolean_get_array(ptr, prop, tmp_arr);
|
||||
else
|
||||
RNA_property_int_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
if(tmp_arr[i] == value_i)
|
||||
for (i=0; i<len; i++) {
|
||||
if (tmp_arr[i] == value_i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(tmp_arr != tmp)
|
||||
if (tmp_arr != tmp)
|
||||
PyMem_FREE(tmp_arr);
|
||||
|
||||
return i<len ? 1 : 0;
|
||||
|
||||
@@ -114,19 +114,19 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
|
||||
|
||||
PyErr_Fetch(&exception, &value, (PyObject **)&tb);
|
||||
|
||||
if(exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
|
||||
if (exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
|
||||
/* no traceback available when SyntaxError.
|
||||
* python has no api's to this. reference parse_syntax_error() from pythonrun.c */
|
||||
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
|
||||
if(value) { /* should always be true */
|
||||
if (value) { /* should always be true */
|
||||
PyObject *message;
|
||||
const char *filename, *text;
|
||||
|
||||
if(parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
|
||||
if (parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
|
||||
/* python adds a '/', prefix, so check for both */
|
||||
if( (strcmp(filename, filepath) == 0) ||
|
||||
if ((strcmp(filename, filepath) == 0) ||
|
||||
((filename[0] == '\\' || filename[0] == '/') && strcmp(filename + 1, filepath) == 0)
|
||||
) {
|
||||
/* good */
|
||||
@@ -145,13 +145,13 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
PyErr_Print();
|
||||
|
||||
for(tb= (PyTracebackObject *)PySys_GetObject("last_traceback"); tb && (PyObject *)tb != Py_None; tb= tb->tb_next) {
|
||||
for (tb= (PyTracebackObject *)PySys_GetObject("last_traceback"); tb && (PyObject *)tb != Py_None; tb= tb->tb_next) {
|
||||
PyObject *coerce;
|
||||
const char *tb_filepath= traceback_filepath(tb, &coerce);
|
||||
const int match= strcmp(tb_filepath, filepath) != 0;
|
||||
Py_DECREF(coerce);
|
||||
|
||||
if(match) {
|
||||
if (match) {
|
||||
*lineno= tb->tb_lineno;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
|
||||
char *cstring;
|
||||
|
||||
for (e= item; item->identifier; item++) {
|
||||
if(item->identifier[0])
|
||||
if (item->identifier[0])
|
||||
BLI_dynstr_appendf(dynstr, (e==item)?"'%s'":", '%s'", item->identifier);
|
||||
}
|
||||
|
||||
@@ -63,11 +63,11 @@ short BPy_reports_to_error(ReportList *reports, PyObject *exception, const short
|
||||
|
||||
report_str= BKE_reports_string(reports, RPT_ERROR);
|
||||
|
||||
if(clear) {
|
||||
if (clear) {
|
||||
BKE_reports_clear(reports);
|
||||
}
|
||||
|
||||
if(report_str) {
|
||||
if (report_str) {
|
||||
PyErr_SetString(exception, report_str);
|
||||
MEM_freeN(report_str);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ short BPy_errors_to_report(ReportList *reports)
|
||||
return 1;
|
||||
|
||||
/* less hassle if we allow NULL */
|
||||
if(reports==NULL) {
|
||||
if (reports==NULL) {
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
return 1;
|
||||
@@ -97,13 +97,13 @@ short BPy_errors_to_report(ReportList *reports)
|
||||
|
||||
pystring= PyC_ExceptionBuffer();
|
||||
|
||||
if(pystring==NULL) {
|
||||
if (pystring==NULL) {
|
||||
BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyC_FileAndNum(&filename, &lineno);
|
||||
if(filename==NULL)
|
||||
if (filename==NULL)
|
||||
filename= "<unknown location>";
|
||||
|
||||
cstring= _PyUnicode_AsString(pystring);
|
||||
|
||||
@@ -77,7 +77,7 @@ PyInit_gpu(void)
|
||||
PyObject* m;
|
||||
|
||||
m = PyModule_Create(&gpumodule);
|
||||
if(m == NULL)
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
// device constants
|
||||
@@ -164,7 +164,7 @@ static PyObject* GPU_export_shader(PyObject* UNUSED(self), PyObject *args, PyObj
|
||||
|
||||
static const char *kwlist[] = {"scene", "material", NULL};
|
||||
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char**)(kwlist), &pyscene, &pymat))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char**)(kwlist), &pyscene, &pymat))
|
||||
return NULL;
|
||||
|
||||
if (!strcmp(Py_TYPE(pyscene)->tp_name, "Scene") &&
|
||||
|
||||
Reference in New Issue
Block a user