Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/intern/bpy_rna.c
| Show First 20 Lines • Show All 7,424 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_function) | static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_function) | ||||
| { | { | ||||
| return bpy_class_validate_recursive(dummyptr, dummyptr->type, py_data, have_function); | return bpy_class_validate_recursive(dummyptr, dummyptr->type, py_data, have_function); | ||||
| } | } | ||||
| /* TODO - multiple return values like with rna functions */ | /* TODO - multiple return values like with rna functions */ | ||||
| static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) | int BPY_class_call_ex(bContext *C, void *call_func, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) | ||||
| { | { | ||||
| PyObject *args; | PyObject *args; | ||||
| PyObject *ret = NULL, *py_srna = NULL, *py_class_instance = NULL, *parmitem; | PyObject *ret = NULL, *py_srna = NULL, *py_class_instance = NULL, *parmitem; | ||||
| PyTypeObject *py_class; | PyTypeObject *py_class; | ||||
| void **py_class_instance_store = NULL; | void **py_class_instance_store = NULL; | ||||
| PropertyRNA *parm; | PropertyRNA *parm; | ||||
| ParameterIterator iter; | ParameterIterator iter; | ||||
| PointerRNA funcptr; | PointerRNA funcptr; | ||||
| ▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | #endif | ||||
| *py_class_instance_store = py_class_instance; | *py_class_instance_store = py_class_instance; | ||||
| Py_INCREF(py_class_instance); | Py_INCREF(py_class_instance); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Initializing the class worked, now run its invoke function */ | /* Initializing the class worked, now run its invoke function */ | ||||
| if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) { | if (err != -1 && (is_staticmethod || is_classmethod || py_class_instance)) { | ||||
| PyObject *item = PyObject_GetAttrString((PyObject *)py_class, RNA_function_identifier(func)); | PyObject *item; | ||||
| if (call_func) | |||||
| item = call_func; | |||||
| else | |||||
| item = PyObject_GetAttrString((PyObject *)py_class, RNA_function_identifier(func)); | |||||
| if (item) { | if (item) { | ||||
| RNA_pointer_create(NULL, &RNA_Function, func, &funcptr); | RNA_pointer_create(NULL, &RNA_Function, func, &funcptr); | ||||
| if (is_staticmethod) { | if (is_staticmethod) { | ||||
| arg_count = ((PyCodeObject *)PyFunction_GET_CODE(((PyMethodObject *)item)->im_func))->co_argcount - 1; | arg_count = ((PyCodeObject *)PyFunction_GET_CODE(((PyMethodObject *)item)->im_func))->co_argcount - 1; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | #endif | ||||
| /* *** Done Calling *** */ | /* *** Done Calling *** */ | ||||
| #ifdef USE_PEDANTIC_WRITE | #ifdef USE_PEDANTIC_WRITE | ||||
| rna_disallow_writes = false; | rna_disallow_writes = false; | ||||
| #endif | #endif | ||||
| RNA_parameter_list_end(&iter); | RNA_parameter_list_end(&iter); | ||||
| if (!call_func) | |||||
| Py_DECREF(item); | Py_DECREF(item); | ||||
| Py_DECREF(args); | Py_DECREF(args); | ||||
| } | } | ||||
| else { | else { | ||||
| PyErr_Print(); | PyErr_Print(); | ||||
| PyErr_Clear(); | PyErr_Clear(); | ||||
| PyErr_Format(PyExc_TypeError, | PyErr_Format(PyExc_TypeError, | ||||
| "could not find function %.200s in %.200s to execute callback", | "could not find function %.200s in %.200s to execute callback", | ||||
| RNA_function_identifier(func), RNA_struct_identifier(ptr->type)); | RNA_function_identifier(func), RNA_struct_identifier(ptr->type)); | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | if (err != 0) { | ||||
| PyErr_Clear(); | PyErr_Clear(); | ||||
| } | } | ||||
| bpy_context_clear(C, &gilstate); | bpy_context_clear(C, &gilstate); | ||||
| return err; | return err; | ||||
| } | } | ||||
| static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) | |||||
| { | |||||
| return BPY_class_call_ex(C, NULL, ptr, func, parms); | |||||
| } | |||||
| static void bpy_class_free(void *pyob_ptr) | static void bpy_class_free(void *pyob_ptr) | ||||
| { | { | ||||
| PyObject *self = (PyObject *)pyob_ptr; | PyObject *self = (PyObject *)pyob_ptr; | ||||
| PyGILState_STATE gilstate; | PyGILState_STATE gilstate; | ||||
| gilstate = PyGILState_Ensure(); | gilstate = PyGILState_Ensure(); | ||||
| /* breaks re-registering classes */ | /* breaks re-registering classes */ | ||||
| ▲ Show 20 Lines • Show All 396 Lines • Show Last 20 Lines | |||||