style cleanup: py api
This commit is contained in:
@@ -3054,8 +3054,8 @@ int bpy_bm_generic_valid_check(BPy_BMGeneric *self)
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_ReferenceError,
|
||||
"BMesh data of type %.200s has been removed",
|
||||
Py_TYPE(self)->tp_name);
|
||||
"BMesh data of type %.200s has been removed",
|
||||
Py_TYPE(self)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ void BPy_BM_init_types_customdata(void)
|
||||
|
||||
/**
|
||||
* helper function for get/set, NULL return means the error is set
|
||||
*/
|
||||
*/
|
||||
static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
|
||||
{
|
||||
void *value;
|
||||
@@ -746,7 +746,7 @@ static void *bpy_bmlayeritem_ptr_get(BPy_BMElem *py_ele, BPy_BMLayerItem *py_lay
|
||||
if (UNLIKELY(value == NULL)) {
|
||||
/* this should be fairly unlikely but possible if layers move about after we get them */
|
||||
PyErr_SetString(PyExc_KeyError,
|
||||
"BMElem[key]: layer not found");
|
||||
"BMElem[key]: layer not found");
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/* external util modules */
|
||||
/* external util modules */
|
||||
#include "../generic/idprop_py_api.h"
|
||||
#include "../generic/bgl.h"
|
||||
#include "../generic/blf_py_api.h"
|
||||
@@ -211,11 +211,11 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
static PyMethodDef meth_bpy_script_paths =
|
||||
{"script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc};
|
||||
static PyMethodDef meth_bpy_blend_paths =
|
||||
{"blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc};
|
||||
{"blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS | METH_KEYWORDS, bpy_blend_paths_doc};
|
||||
static PyMethodDef meth_bpy_user_resource =
|
||||
{"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS|METH_KEYWORDS, NULL};
|
||||
{"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS | METH_KEYWORDS, NULL};
|
||||
static PyMethodDef meth_bpy_resource_path =
|
||||
{"resource_path", (PyCFunction)bpy_resource_path, METH_VARARGS|METH_KEYWORDS, bpy_resource_path_doc};
|
||||
{"resource_path", (PyCFunction)bpy_resource_path, METH_VARARGS | METH_KEYWORDS, bpy_resource_path_doc};
|
||||
|
||||
|
||||
static PyObject *bpy_import_test(const char *modname)
|
||||
@@ -279,7 +279,7 @@ void BPy_init_modules(void)
|
||||
PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */
|
||||
bpy_import_test("bpy_types");
|
||||
PyModule_AddObject(mod, "props", BPY_rna_props());
|
||||
/* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
|
||||
/* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */
|
||||
PyModule_AddObject(mod, "ops", BPY_operator_module());
|
||||
PyModule_AddObject(mod, "app", BPY_app_struct());
|
||||
|
||||
|
||||
@@ -223,10 +223,11 @@ PyDoc_STRVAR(bpy_app_driver_dict_doc,
|
||||
);
|
||||
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
||||
{
|
||||
if (bpy_pydriver_Dict == NULL)
|
||||
if (bpy_pydriver_Dict == NULL) {
|
||||
if (bpy_pydriver_create_dict() != 0) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "bpy.app.driver_namespace failed to create dictionary");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Py_INCREF(bpy_pydriver_Dict);
|
||||
|
||||
@@ -88,16 +88,18 @@ static PyObject *make_ffmpeg_info(void)
|
||||
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, obj)
|
||||
|
||||
#ifdef WITH_FFMPEG
|
||||
#define FFMPEG_LIB_VERSION(lib) \
|
||||
# define FFMPEG_LIB_VERSION(lib) { \
|
||||
curversion = lib ## _version(); \
|
||||
SetObjItem(Py_BuildValue("(iii)", \
|
||||
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
|
||||
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
|
||||
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", \
|
||||
curversion >> 16, (curversion >> 8) % 256, curversion % 256));
|
||||
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
|
||||
} (void)0
|
||||
#else
|
||||
#define FFMPEG_LIB_VERSION(lib) \
|
||||
# define FFMPEG_LIB_VERSION(lib) { \
|
||||
SetStrItem("Unknown"); \
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown"); \
|
||||
} (void)0
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FFMPEG
|
||||
|
||||
@@ -71,7 +71,7 @@ static PyStructSequence_Desc app_cb_info_desc = {
|
||||
};
|
||||
|
||||
#if 0
|
||||
# if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields)/sizeof(PyStructSequence_Field))))
|
||||
# if (BLI_CB_EVT_TOT != ((sizeof(app_cb_info_fields) / sizeof(PyStructSequence_Field))))
|
||||
# error "Callbacks are out of sync"
|
||||
# endif
|
||||
#endif
|
||||
@@ -118,51 +118,51 @@ static PyObject *bpy_app_handlers_persistent_new(PyTypeObject *UNUSED(type), PyO
|
||||
static PyTypeObject BPyPersistent_Type = {
|
||||
|
||||
#if defined(_MSC_VER) || defined(FREE_WINDOWS)
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
#else
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
#endif
|
||||
|
||||
"persistent", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_reserved */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
||||
Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
bpy_app_handlers_persistent_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
"persistent", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_reserved */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
||||
Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
bpy_app_handlers_persistent_new, /* tp_new */
|
||||
0, /* tp_free */
|
||||
};
|
||||
|
||||
static PyObject *py_cb_array[BLI_CB_EVT_TOT] = {NULL};
|
||||
@@ -237,7 +237,7 @@ void BPY_app_handlers_reset(const short do_all)
|
||||
int pos = 0;
|
||||
|
||||
if (do_all) {
|
||||
for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
|
||||
/* clear list */
|
||||
PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL);
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ BPy_StructRNA *bpy_context_module = NULL; /* for fast access */
|
||||
|
||||
#ifdef TIME_PY_RUN
|
||||
#include "PIL_time.h"
|
||||
static int bpy_timer_count = 0;
|
||||
static double bpy_timer; /* time since python starts */
|
||||
static double bpy_timer_run; /* time for each python script run */
|
||||
static double bpy_timer_run_tot; /* accumulate python runs */
|
||||
static int bpy_timer_count = 0;
|
||||
static double bpy_timer; /* time since python starts */
|
||||
static double bpy_timer_run; /* time for each python script run */
|
||||
static double bpy_timer_run_tot; /* accumulate python runs */
|
||||
#endif
|
||||
|
||||
/* use for updating while a python script runs - in case of file load */
|
||||
@@ -184,7 +184,7 @@ extern PyObject *AUD_initPython(void);
|
||||
/* defined in cycles module */
|
||||
static PyObject *CCL_initPython(void)
|
||||
{
|
||||
return (PyObject*)CCL_python_module_init();
|
||||
return (PyObject *)CCL_python_module_init();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -195,8 +195,8 @@ static struct _inittab bpy_internal_modules[] = {
|
||||
{(char *)"bgl", BPyInit_bgl},
|
||||
{(char *)"blf", BPyInit_blf},
|
||||
{(char *)"bmesh", BPyInit_bmesh},
|
||||
// {(char *)"bmesh.types", BPyInit_bmesh_types},
|
||||
// {(char *)"bmesh.utils", BPyInit_bmesh_utils},
|
||||
// {(char *)"bmesh.types", BPyInit_bmesh_types},
|
||||
// {(char *)"bmesh.utils", BPyInit_bmesh_utils},
|
||||
#ifdef WITH_AUDASPACE
|
||||
{(char *)"aud", AUD_initPython},
|
||||
#endif
|
||||
@@ -308,10 +308,10 @@ void BPY_python_end(void)
|
||||
printf("tot exec: %d, ", bpy_timer_count);
|
||||
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
|
||||
if (bpy_timer_count > 0)
|
||||
printf("average run: %.6fsec, ", (bpy_timer_run_tot/bpy_timer_count));
|
||||
printf("average run: %.6fsec, ", (bpy_timer_run_tot / bpy_timer_count));
|
||||
|
||||
if (bpy_timer > 0.0)
|
||||
printf("tot usage %.4f%%", (bpy_timer_run_tot/bpy_timer) * 100.0);
|
||||
printf("tot usage %.4f%%", (bpy_timer_run_tot / bpy_timer) * 100.0);
|
||||
|
||||
printf("\n");
|
||||
|
||||
@@ -367,7 +367,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text,
|
||||
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);
|
||||
@@ -692,8 +692,8 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
}
|
||||
|
||||
if (done == 0) {
|
||||
if (item) printf("PyContext '%s' not a valid type\n", member);
|
||||
else printf("PyContext '%s' not found\n", member);
|
||||
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) {
|
||||
|
||||
@@ -92,75 +92,75 @@ static void bpy_lib_dealloc(BPy_Library *self)
|
||||
|
||||
static PyTypeObject bpy_lib_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"bpy_lib", /* tp_name */
|
||||
sizeof(BPy_Library), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
"bpy_lib", /* tp_name */
|
||||
sizeof(BPy_Library), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)bpy_lib_dealloc,/* tp_dealloc */
|
||||
(destructor)bpy_lib_dealloc, /* tp_dealloc */
|
||||
NULL, /* printfunc tp_print; */
|
||||
NULL, /* getattrfunc tp_getattr; */
|
||||
NULL, /* getattrfunc tp_getattr; */
|
||||
NULL, /* setattrfunc tp_setattr; */
|
||||
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
|
||||
NULL, /* tp_repr */
|
||||
NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */
|
||||
NULL, /* tp_repr */
|
||||
|
||||
/* Method suites for standard classes */
|
||||
|
||||
NULL, /* PyNumberMethods *tp_as_number; */
|
||||
NULL, /* PySequenceMethods *tp_as_sequence; */
|
||||
NULL, /* PyMappingMethods *tp_as_mapping; */
|
||||
NULL, /* PyNumberMethods *tp_as_number; */
|
||||
NULL, /* PySequenceMethods *tp_as_sequence; */
|
||||
NULL, /* PyMappingMethods *tp_as_mapping; */
|
||||
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
|
||||
NULL, /* hashfunc tp_hash; */
|
||||
NULL, /* hashfunc tp_hash; */
|
||||
NULL, /* ternaryfunc tp_call; */
|
||||
NULL, /* reprfunc tp_str; */
|
||||
|
||||
/* will only use these if this is a subtype of a py class */
|
||||
NULL /*PyObject_GenericGetAttr is assigned later */, /* getattrofunc tp_getattro; */
|
||||
NULL, /* setattrofunc tp_setattro; */
|
||||
NULL /*PyObject_GenericGetAttr is assigned later */, /* getattrofunc tp_getattro; */
|
||||
NULL, /* setattrofunc tp_setattro; */
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
NULL, /* PyBufferProcs *tp_as_buffer; */
|
||||
|
||||
/*** Flags to define presence of optional/expanded features ***/
|
||||
/*** Flags to define presence of optional/expanded features ***/
|
||||
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
|
||||
|
||||
NULL, /* char *tp_doc; Documentation string */
|
||||
/*** Assigned meaning in release 2.0 ***/
|
||||
NULL, /* char *tp_doc; Documentation string */
|
||||
/*** Assigned meaning in release 2.0 ***/
|
||||
/* call function for all accessible objects */
|
||||
NULL, /* traverseproc tp_traverse; */
|
||||
|
||||
/* delete references to contained objects */
|
||||
NULL, /* inquiry tp_clear; */
|
||||
|
||||
/*** Assigned meaning in release 2.1 ***/
|
||||
/*** rich comparisons ***/
|
||||
/*** Assigned meaning in release 2.1 ***/
|
||||
/*** rich comparisons ***/
|
||||
NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */
|
||||
|
||||
/*** weak reference enabler ***/
|
||||
/*** weak reference enabler ***/
|
||||
0,
|
||||
/*** Added in release 2.2 ***/
|
||||
/*** Added in release 2.2 ***/
|
||||
/* Iterators */
|
||||
NULL, /* getiterfunc tp_iter; */
|
||||
NULL, /* getiterfunc tp_iter; */
|
||||
NULL, /* iternextfunc tp_iternext; */
|
||||
|
||||
/*** Attribute descriptor and subclassing stuff ***/
|
||||
bpy_lib_methods, /* struct PyMethodDef *tp_methods; */
|
||||
/*** Attribute descriptor and subclassing stuff ***/
|
||||
bpy_lib_methods, /* struct PyMethodDef *tp_methods; */
|
||||
NULL, /* struct PyMemberDef *tp_members; */
|
||||
NULL, /* struct PyGetSetDef *tp_getset; */
|
||||
NULL, /* struct PyGetSetDef *tp_getset; */
|
||||
NULL, /* struct _typeobject *tp_base; */
|
||||
NULL, /* PyObject *tp_dict; */
|
||||
NULL, /* descrgetfunc tp_descr_get; */
|
||||
NULL, /* descrsetfunc tp_descr_set; */
|
||||
offsetof(BPy_Library, dict),/* long tp_dictoffset; */
|
||||
offsetof(BPy_Library, dict), /* long tp_dictoffset; */
|
||||
NULL, /* initproc tp_init; */
|
||||
NULL, /* allocfunc tp_alloc; */
|
||||
NULL, /* newfunc tp_new; */
|
||||
NULL, /* newfunc tp_new; */
|
||||
/* Low-level free-memory routine */
|
||||
NULL, /* freefunc tp_free; */
|
||||
/* For PyObject_IS_GC */
|
||||
NULL, /* inquiry tp_is_gc; */
|
||||
NULL, /* PyObject *tp_bases; */
|
||||
NULL, /* PyObject *tp_bases; */
|
||||
/* method resolution order */
|
||||
NULL, /* PyObject *tp_mro; */
|
||||
NULL, /* PyObject *tp_cache; */
|
||||
@@ -170,18 +170,18 @@ static PyTypeObject bpy_lib_Type = {
|
||||
};
|
||||
|
||||
PyDoc_STRVAR(bpy_lib_load_doc,
|
||||
".. method:: load(filepath, link=False, relative=False)\n"
|
||||
"\n"
|
||||
" Returns a context manager which exposes 2 library objects on entering.\n"
|
||||
" Each object has attributes matching bpy.data which are lists of strings to be linked.\n"
|
||||
"\n"
|
||||
" :arg filepath: The path to a blend file.\n"
|
||||
" :type filepath: string\n"
|
||||
" :arg link: When False reference to the original file is lost.\n"
|
||||
" :type link: bool\n"
|
||||
" :arg relative: When True the path is stored relative to the open blend file.\n"
|
||||
" :type relative: bool\n"
|
||||
);
|
||||
".. method:: load(filepath, link=False, relative=False)\n"
|
||||
"\n"
|
||||
" Returns a context manager which exposes 2 library objects on entering.\n"
|
||||
" Each object has attributes matching bpy.data which are lists of strings to be linked.\n"
|
||||
"\n"
|
||||
" :arg filepath: The path to a blend file.\n"
|
||||
" :type filepath: string\n"
|
||||
" :arg link: When False reference to the original file is lost.\n"
|
||||
" :type link: bool\n"
|
||||
" :arg relative: When True the path is stored relative to the open blend file.\n"
|
||||
" :type relative: bool\n"
|
||||
);
|
||||
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {"filepath", "link", "relative", NULL};
|
||||
@@ -222,7 +222,7 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
|
||||
PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
|
||||
counter++;
|
||||
}
|
||||
BLI_linklist_free(names, free); /* free linklist *and* each node's data */
|
||||
BLI_linklist_free(names, free); /* free linklist *and* each node's data */
|
||||
}
|
||||
else {
|
||||
list = PyList_New(0);
|
||||
@@ -401,7 +401,8 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle = NULL;
|
||||
|
||||
{ /* copied from wm_operator.c */
|
||||
/* copied from wm_operator.c */
|
||||
{
|
||||
/* mark all library linked objects to be updated */
|
||||
recalc_all_library_objects(G.main);
|
||||
|
||||
@@ -426,8 +427,8 @@ static PyObject *bpy_lib_dir(BPy_Library *self)
|
||||
int bpy_lib_init(PyObject *mod_par)
|
||||
{
|
||||
static PyMethodDef load_meth = {"load", (PyCFunction)bpy_lib_load,
|
||||
METH_STATIC|METH_VARARGS|METH_KEYWORDS,
|
||||
bpy_lib_load_doc};
|
||||
METH_STATIC | METH_VARARGS | METH_KEYWORDS,
|
||||
bpy_lib_load_doc};
|
||||
|
||||
PyModule_AddObject(mod_par, "_library_load", PyCFunction_New(&load_meth, NULL));
|
||||
|
||||
|
||||
@@ -65,11 +65,11 @@
|
||||
static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
|
||||
{
|
||||
wmOperatorType *ot;
|
||||
char *opname;
|
||||
PyObject *context_dict = NULL; /* optional args */
|
||||
PyObject *context_dict_back;
|
||||
char *context_str = NULL;
|
||||
PyObject *ret;
|
||||
char *opname;
|
||||
PyObject *context_dict = NULL; /* optional args */
|
||||
PyObject *context_dict_back;
|
||||
char *context_str = NULL;
|
||||
PyObject *ret;
|
||||
|
||||
int context = WM_OP_EXEC_DEFAULT;
|
||||
|
||||
@@ -139,11 +139,11 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
||||
PointerRNA ptr;
|
||||
int operator_ret = OPERATOR_CANCELLED;
|
||||
|
||||
char *opname;
|
||||
char *context_str = NULL;
|
||||
PyObject *kw = NULL; /* optional args */
|
||||
PyObject *context_dict = NULL; /* optional args */
|
||||
PyObject *context_dict_back;
|
||||
char *opname;
|
||||
char *context_str = NULL;
|
||||
PyObject *kw = NULL; /* optional args */
|
||||
PyObject *context_dict = NULL; /* optional args */
|
||||
PyObject *context_dict_back;
|
||||
|
||||
/* note that context is an int, python does the conversion in this case */
|
||||
int context = WM_OP_EXEC_DEFAULT;
|
||||
@@ -306,8 +306,8 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
|
||||
wmOperatorType *ot;
|
||||
PointerRNA ptr;
|
||||
|
||||
char *opname;
|
||||
PyObject *kw = NULL; /* optional args */
|
||||
char *opname;
|
||||
PyObject *kw = NULL; /* optional args */
|
||||
int all_args = 1;
|
||||
int error_val = 0;
|
||||
|
||||
@@ -462,7 +462,7 @@ static struct PyModuleDef bpy_ops_module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_bpy.ops",
|
||||
NULL,
|
||||
-1,/* multiple "initialization" just copies the module dict. */
|
||||
-1, /* multiple "initialization" just copies the module dict. */
|
||||
bpy_ops_methods,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
@@ -69,7 +69,8 @@ void operator_wrapper(wmOperatorType *ot, void *userdata)
|
||||
|
||||
operator_properties_init(ot);
|
||||
|
||||
{ /* XXX - not nice, set the first enum as searchable, should have a way for python to set */
|
||||
/* XXX - not nice, set the first enum as searchable, should have a way for python to set */
|
||||
{
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"options", "subtype", "update", NULL};
|
||||
"options", "subtype", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
int id_len;
|
||||
int def = 0;
|
||||
@@ -475,7 +475,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"options", "subtype", "size", "update", NULL};
|
||||
"options", "subtype", "size", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
int id_len;
|
||||
int def[PYRNA_STACK_ARRAY] = {0};
|
||||
@@ -561,7 +561,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "options", "subtype", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
int id_len;
|
||||
@@ -642,8 +642,8 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "options", "subtype", "size", "update", NULL};
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "options", "subtype", "size", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
int id_len;
|
||||
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1;
|
||||
@@ -736,8 +736,8 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "precision", "options", "subtype", "unit", "update", NULL};
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "precision", "options", "subtype", "unit", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
int id_len;
|
||||
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f;
|
||||
@@ -829,8 +829,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "precision", "options", "subtype", "unit", "size", "update", NULL};
|
||||
"min", "max", "soft_min", "soft_max",
|
||||
"step", "precision", "options", "subtype", "unit", "size", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
int id_len;
|
||||
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3;
|
||||
@@ -924,7 +924,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "name", "description", "default",
|
||||
"maxlen", "options", "subtype", "update", NULL};
|
||||
"maxlen", "options", "subtype", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "", *def = "";
|
||||
int id_len;
|
||||
int maxlen = 0;
|
||||
@@ -952,7 +952,7 @@ 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 (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 ? name : id, description);
|
||||
|
||||
@@ -1110,7 +1110,7 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
|
||||
* annoying because it works most of the time without this. */
|
||||
{
|
||||
EnumPropertyItem *items_dup = MEM_mallocN((sizeof(EnumPropertyItem) * (seq_len + 1)) + (sizeof(char) * totbuf),
|
||||
"enum_items_from_py2");
|
||||
"enum_items_from_py2");
|
||||
EnumPropertyItem *items_ptr = items_dup;
|
||||
char *buf = ((char *)items_dup) + (sizeof(EnumPropertyItem) * (seq_len + 1));
|
||||
memcpy(items_dup, items, sizeof(EnumPropertyItem) * (seq_len + 1));
|
||||
@@ -1162,7 +1162,7 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt
|
||||
int defvalue_dummy = 0;
|
||||
|
||||
if (!(items_fast = PySequence_Fast(items, "EnumProperty(...): "
|
||||
"return value from the callback was not a sequence")))
|
||||
"return value from the callback was not a sequence")))
|
||||
{
|
||||
err = -1;
|
||||
}
|
||||
@@ -1230,7 +1230,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
|
||||
if (srna) {
|
||||
static const char *kwlist[] = {"attr", "items", "name", "description", "default",
|
||||
"options", "update", NULL};
|
||||
"options", "update", NULL};
|
||||
const char *id = NULL, *name = NULL, *description = "";
|
||||
PyObject *def = NULL;
|
||||
int id_len;
|
||||
@@ -1281,7 +1281,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
}
|
||||
else {
|
||||
if (!(items_fast = PySequence_Fast(items, "EnumProperty(...): "
|
||||
"expected a sequence of tuples for the enum items or a function")))
|
||||
"expected a sequence of tuples for the enum items or a function")))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -1531,18 +1531,18 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
|
||||
}
|
||||
|
||||
static struct PyMethodDef props_methods[] = {
|
||||
{"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, BPy_BoolProperty_doc},
|
||||
{"BoolVectorProperty", (PyCFunction)BPy_BoolVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_BoolVectorProperty_doc},
|
||||
{"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, BPy_IntProperty_doc},
|
||||
{"IntVectorProperty", (PyCFunction)BPy_IntVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_IntVectorProperty_doc},
|
||||
{"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, BPy_FloatProperty_doc},
|
||||
{"FloatVectorProperty", (PyCFunction)BPy_FloatVectorProperty, METH_VARARGS|METH_KEYWORDS, BPy_FloatVectorProperty_doc},
|
||||
{"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, BPy_StringProperty_doc},
|
||||
{"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS|METH_KEYWORDS, BPy_EnumProperty_doc},
|
||||
{"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS|METH_KEYWORDS, BPy_PointerProperty_doc},
|
||||
{"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS|METH_KEYWORDS, BPy_CollectionProperty_doc},
|
||||
{"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS | METH_KEYWORDS, BPy_BoolProperty_doc},
|
||||
{"BoolVectorProperty", (PyCFunction)BPy_BoolVectorProperty, METH_VARARGS | METH_KEYWORDS, BPy_BoolVectorProperty_doc},
|
||||
{"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS | METH_KEYWORDS, BPy_IntProperty_doc},
|
||||
{"IntVectorProperty", (PyCFunction)BPy_IntVectorProperty, METH_VARARGS | METH_KEYWORDS, BPy_IntVectorProperty_doc},
|
||||
{"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS | METH_KEYWORDS, BPy_FloatProperty_doc},
|
||||
{"FloatVectorProperty", (PyCFunction)BPy_FloatVectorProperty, METH_VARARGS | METH_KEYWORDS, BPy_FloatVectorProperty_doc},
|
||||
{"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS | METH_KEYWORDS, BPy_StringProperty_doc},
|
||||
{"EnumProperty", (PyCFunction)BPy_EnumProperty, METH_VARARGS | METH_KEYWORDS, BPy_EnumProperty_doc},
|
||||
{"PointerProperty", (PyCFunction)BPy_PointerProperty, METH_VARARGS | METH_KEYWORDS, BPy_PointerProperty_doc},
|
||||
{"CollectionProperty", (PyCFunction)BPy_CollectionProperty, METH_VARARGS | METH_KEYWORDS, BPy_CollectionProperty_doc},
|
||||
|
||||
{"RemoveProperty", (PyCFunction)BPy_RemoveProperty, METH_VARARGS|METH_KEYWORDS, BPy_RemoveProperty_doc},
|
||||
{"RemoveProperty", (PyCFunction)BPy_RemoveProperty, METH_VARARGS | METH_KEYWORDS, BPy_RemoveProperty_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -1551,7 +1551,7 @@ static struct PyModuleDef props_module = {
|
||||
"bpy.props",
|
||||
"This module defines properties to extend blenders internal data, the result of these functions"
|
||||
" is used to assign properties to classes registered with blender and can't be used directly.",
|
||||
-1,/* multiple "initialization" just copies the module dict. */
|
||||
-1, /* multiple "initialization" just copies the module dict. */
|
||||
props_methods,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -149,8 +149,8 @@ static int pyrna_struct_anim_args_parse(
|
||||
|
||||
/* internal use for insert and delete */
|
||||
static int pyrna_struct_keyframe_parse(
|
||||
PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
|
||||
const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
|
||||
PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
|
||||
const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
|
||||
{
|
||||
static const char *kwlist[] = {"data_path", "index", "frame", "group", NULL};
|
||||
const char *path;
|
||||
@@ -195,8 +195,8 @@ 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,
|
||||
"s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
|
||||
&path_full, &index, &cfra, &group_name) == -1)
|
||||
"s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
|
||||
&path_full, &index, &cfra, &group_name) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -243,9 +243,9 @@ 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,
|
||||
"s|ifs:bpy_struct.keyframe_delete()",
|
||||
"bpy_struct.keyframe_insert()",
|
||||
&path_full, &index, &cfra, &group_name) == -1)
|
||||
"s|ifs:bpy_struct.keyframe_delete()",
|
||||
"bpy_struct.keyframe_insert()",
|
||||
&path_full, &index, &cfra, &group_name) == -1)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
|
||||
ret = pyrna_struct_CreatePyObject(&tptr);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL);
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
|
||||
}
|
||||
else {
|
||||
/* XXX, should be handled by reports, */
|
||||
@@ -380,7 +380,7 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
|
||||
if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
|
||||
return NULL;
|
||||
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL);
|
||||
WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);
|
||||
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define MAX_ARRAY_DIMENSION 10
|
||||
|
||||
typedef void (*ItemConvertFunc)(PyObject *, char *);
|
||||
typedef int (*ItemTypeCheckFunc)(PyObject *);
|
||||
typedef int (*ItemTypeCheckFunc)(PyObject *);
|
||||
typedef void (*RNA_SetArrayFunc)(PointerRNA *, PropertyRNA *, const char *);
|
||||
typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *);
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *)
|
||||
/* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */
|
||||
/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */
|
||||
static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[],
|
||||
ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix)
|
||||
ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix)
|
||||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce)
|
||||
/* copied from pythonrun.c, 3.2.0 */
|
||||
static int
|
||||
parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
|
||||
int *lineno, int *offset, const char **text)
|
||||
int *lineno, int *offset, const char **text)
|
||||
{
|
||||
long hold;
|
||||
PyObject *v;
|
||||
@@ -50,7 +50,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
|
||||
/* old style errors */
|
||||
if (PyTuple_Check(err))
|
||||
return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
|
||||
lineno, offset, text);
|
||||
lineno, offset, text);
|
||||
|
||||
/* new style errors. `err' is an instance */
|
||||
|
||||
@@ -96,7 +96,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
|
||||
if (v == Py_None)
|
||||
*text = NULL;
|
||||
else if (!PyUnicode_Check(v) ||
|
||||
!(*text = _PyUnicode_AsString(v)))
|
||||
!(*text = _PyUnicode_AsString(v)))
|
||||
goto finally;
|
||||
Py_DECREF(v);
|
||||
return 1;
|
||||
@@ -122,7 +122,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
|
||||
/* 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! */
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
|
||||
if (value) { /* should always be true */
|
||||
PyObject *message;
|
||||
@@ -146,7 +146,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
|
||||
}
|
||||
else {
|
||||
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
PyErr_Restore(exception, value, (PyObject *)tb); /* takes away reference! */
|
||||
PyErr_Print();
|
||||
|
||||
for (tb = (PyTracebackObject *)PySys_GetObject("last_traceback");
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
|
||||
#include "../generic/py_capi_utils.h"
|
||||
|
||||
static bContext* __py_context = NULL;
|
||||
bContext* BPy_GetContext(void) { return __py_context; }
|
||||
void BPy_SetContext(bContext *C) { __py_context = C; }
|
||||
static bContext* __py_context = NULL;
|
||||
bContext *BPy_GetContext(void) { return __py_context; }
|
||||
void BPy_SetContext(bContext *C) { __py_context = C; }
|
||||
|
||||
char *BPy_enum_as_string(EnumPropertyItem *item)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
|
||||
|
||||
for (e = item; item->identifier; item++) {
|
||||
if (item->identifier[0])
|
||||
BLI_dynstr_appendf(dynstr, (e == item)?"'%s'":", '%s'", item->identifier);
|
||||
BLI_dynstr_appendf(dynstr, (e == item) ? "'%s'" : ", '%s'", item->identifier);
|
||||
}
|
||||
|
||||
cstring = BLI_dynstr_get_cstring(dynstr);
|
||||
|
||||
@@ -60,18 +60,18 @@
|
||||
|
||||
#include "gpu.h"
|
||||
|
||||
#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
|
||||
#define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, # name, name)
|
||||
|
||||
PyDoc_STRVAR(M_gpu_doc,
|
||||
"This module provides access to the GLSL shader.");
|
||||
|
||||
"This module provides access to the GLSL shader."
|
||||
);
|
||||
static struct PyModuleDef gpumodule = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"gpu", /* name of module */
|
||||
M_gpu_doc, /* module documentation */
|
||||
-1, /* size of per-interpreter state of the module,
|
||||
* or -1 if the module keeps state in global variables. */
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
@@ -116,35 +116,35 @@ PyInit_gpu(void)
|
||||
return m;
|
||||
}
|
||||
|
||||
#define PY_DICT_ADD_STRING(d,s,f) \
|
||||
val = PyUnicode_FromString(s->f); \
|
||||
PyDict_SetItemString(d, #f, val); \
|
||||
#define PY_DICT_ADD_STRING(d, s, f) \
|
||||
val = PyUnicode_FromString(s->f); \
|
||||
PyDict_SetItemString(d, # f, val); \
|
||||
Py_DECREF(val)
|
||||
|
||||
#define PY_DICT_ADD_LONG(d,s,f) \
|
||||
val = PyLong_FromLong(s->f); \
|
||||
PyDict_SetItemString(d, #f, val); \
|
||||
#define PY_DICT_ADD_LONG(d, s, f) \
|
||||
val = PyLong_FromLong(s->f); \
|
||||
PyDict_SetItemString(d, # f, val); \
|
||||
Py_DECREF(val)
|
||||
|
||||
#define PY_DICT_ADD_ID(d,s,f) \
|
||||
RNA_id_pointer_create((struct ID*)s->f, &tptr); \
|
||||
val = pyrna_struct_CreatePyObject(&tptr); \
|
||||
PyDict_SetItemString(d, #f, val); \
|
||||
#define PY_DICT_ADD_ID(d, s, f) \
|
||||
RNA_id_pointer_create((struct ID *)s->f, &tptr); \
|
||||
val = pyrna_struct_CreatePyObject(&tptr); \
|
||||
PyDict_SetItemString(d, # f, val); \
|
||||
Py_DECREF(val)
|
||||
|
||||
#define PY_OBJ_ADD_ID(d,s,f) \
|
||||
val = PyUnicode_FromString(&s->f->id.name[2]); \
|
||||
PyObject_SetAttrString(d, #f, val); \
|
||||
#define PY_OBJ_ADD_ID(d, s, f) \
|
||||
val = PyUnicode_FromString(&s->f->id.name[2]); \
|
||||
PyObject_SetAttrString(d, # f, val); \
|
||||
Py_DECREF(val)
|
||||
|
||||
#define PY_OBJ_ADD_LONG(d,s,f) \
|
||||
val = PyLong_FromLong(s->f); \
|
||||
PyObject_SetAttrString(d, #f, val); \
|
||||
#define PY_OBJ_ADD_LONG(d, s, f) \
|
||||
val = PyLong_FromLong(s->f); \
|
||||
PyObject_SetAttrString(d, # f, val); \
|
||||
Py_DECREF(val)
|
||||
|
||||
#define PY_OBJ_ADD_STRING(d,s,f) \
|
||||
val = PyUnicode_FromString(s->f); \
|
||||
PyObject_SetAttrString(d, #f, val); \
|
||||
#define PY_OBJ_ADD_STRING(d, s, f) \
|
||||
val = PyUnicode_FromString(s->f); \
|
||||
PyObject_SetAttrString(d, # f, val); \
|
||||
Py_DECREF(val)
|
||||
|
||||
PyDoc_STRVAR(GPU_export_shader_doc,
|
||||
@@ -196,33 +196,34 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
// build a dictionary
|
||||
result = PyDict_New();
|
||||
if (shader->fragment) {
|
||||
PY_DICT_ADD_STRING(result,shader,fragment);
|
||||
PY_DICT_ADD_STRING(result, shader, fragment);
|
||||
}
|
||||
if (shader->vertex) {
|
||||
PY_DICT_ADD_STRING(result,shader,vertex);
|
||||
PY_DICT_ADD_STRING(result, shader, vertex);
|
||||
}
|
||||
seq = PyList_New(BLI_countlist(&shader->uniforms));
|
||||
for (i = 0, uniform = shader->uniforms.first; uniform; uniform = uniform->next, i++) {
|
||||
dict = PyDict_New();
|
||||
PY_DICT_ADD_STRING(dict,uniform,varname);
|
||||
PY_DICT_ADD_LONG(dict,uniform,datatype);
|
||||
PY_DICT_ADD_LONG(dict,uniform,type);
|
||||
PY_DICT_ADD_STRING(dict, uniform, varname);
|
||||
PY_DICT_ADD_LONG(dict, uniform, datatype);
|
||||
PY_DICT_ADD_LONG(dict, uniform, type);
|
||||
if (uniform->lamp) {
|
||||
PY_DICT_ADD_ID(dict,uniform,lamp);
|
||||
PY_DICT_ADD_ID(dict, uniform, lamp);
|
||||
}
|
||||
if (uniform->image) {
|
||||
PY_DICT_ADD_ID(dict,uniform,image);
|
||||
PY_DICT_ADD_ID(dict, uniform, image);
|
||||
}
|
||||
if (uniform->type == GPU_DYNAMIC_SAMPLER_2DBUFFER ||
|
||||
uniform->type == GPU_DYNAMIC_SAMPLER_2DIMAGE ||
|
||||
uniform->type == GPU_DYNAMIC_SAMPLER_2DSHADOW) {
|
||||
PY_DICT_ADD_LONG(dict,uniform,texnumber);
|
||||
uniform->type == GPU_DYNAMIC_SAMPLER_2DIMAGE ||
|
||||
uniform->type == GPU_DYNAMIC_SAMPLER_2DSHADOW)
|
||||
{
|
||||
PY_DICT_ADD_LONG(dict, uniform, texnumber);
|
||||
}
|
||||
if (uniform->texpixels) {
|
||||
val = PyByteArray_FromStringAndSize((const char *)uniform->texpixels, uniform->texsize * 4);
|
||||
PyDict_SetItemString(dict, "texpixels", val);
|
||||
Py_DECREF(val);
|
||||
PY_DICT_ADD_LONG(dict,uniform,texsize);
|
||||
PY_DICT_ADD_LONG(dict, uniform, texsize);
|
||||
}
|
||||
PyList_SET_ITEM(seq, i, dict);
|
||||
}
|
||||
@@ -232,13 +233,13 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj
|
||||
seq = PyList_New(BLI_countlist(&shader->attributes));
|
||||
for (i = 0, attribute = shader->attributes.first; attribute; attribute = attribute->next, i++) {
|
||||
dict = PyDict_New();
|
||||
PY_DICT_ADD_STRING(dict,attribute,varname);
|
||||
PY_DICT_ADD_LONG(dict,attribute,datatype);
|
||||
PY_DICT_ADD_LONG(dict,attribute,type);
|
||||
PY_DICT_ADD_LONG(dict,attribute,number);
|
||||
PY_DICT_ADD_STRING(dict, attribute, varname);
|
||||
PY_DICT_ADD_LONG(dict, attribute, datatype);
|
||||
PY_DICT_ADD_LONG(dict, attribute, type);
|
||||
PY_DICT_ADD_LONG(dict, attribute, number);
|
||||
if (attribute->name) {
|
||||
if (attribute->name[0] != 0) {
|
||||
PY_DICT_ADD_STRING(dict,attribute,name);
|
||||
PY_DICT_ADD_STRING(dict, attribute, name);
|
||||
}
|
||||
else {
|
||||
val = PyLong_FromLong(0);
|
||||
|
||||
Reference in New Issue
Block a user