diff options
Diffstat (limited to 'source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c')
-rw-r--r-- | source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c index 5e391e02feb..75c6799c92a 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -27,22 +27,22 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef DISABLE_PYTHON +/* TODO, support python3.x */ +#undef WITH_PYTHON + +#ifdef WITH_PYTHON #include <Python.h> #include <compile.h> #include <eval.h> #endif -/* TODO, support python3.x */ -#define DISABLE_PYTHON 1 - #include "DNA_text_types.h" #include "BKE_text.h" -#include "BKE_utildefines.h" + // XXX #if 0 -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "api2_2x/Node.h" #include "api2_2x/gen_utils.h" #include "BPY_extern.h" @@ -57,7 +57,7 @@ static void node_dynamic_setup(bNode *node); static void node_dynamic_exec_cb(void *data, bNode *node, bNodeStack **in, bNodeStack **out); static void node_dynamic_free_storage_cb(bNode *node); -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON static PyObject *init_dynamicdict(void) { PyObject *newscriptdict, *item; PyGILState_STATE gilstate = PyGILState_Ensure(); @@ -156,7 +156,7 @@ static void node_dynamic_update_socket_links(bNode *node, bNodeTree *ntree) static void node_dynamic_free_storage_cb(bNode *node) { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON NodeScriptDict *nsd; PyObject *pydict; BPy_Node *pynode; @@ -186,7 +186,7 @@ static void node_dynamic_disable(bNode *node) /* Disable all pynodes using the given text (script) id */ static void node_dynamic_disable_all_by_id(ID *id) { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON Material *ma; /* XXX hardcoded for shaders */ for (ma= G.main->mat.first; ma; ma= ma->id.next) { @@ -346,7 +346,7 @@ int nodeDynamicUnlinkText(ID *txtid) { static void node_dynamic_pyerror_print(bNode *node) { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON PyGILState_STATE gilstate = PyGILState_Ensure(); fprintf(stderr, "\nError in dynamic node script \"%s\":\n", node->name); @@ -373,7 +373,7 @@ static void node_dynamic_register_type(bNode *node) node->typeinfo->name = BLI_strdup(node->name); } -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* node_dynamic_get_pynode: * Find the pynode definition from the script */ static PyObject *node_dynamic_get_pynode(PyObject *dict) @@ -415,11 +415,11 @@ static PyObject *node_dynamic_get_pynode(PyObject *dict) "no PyNode definition found in the script!"); return NULL; } -#endif /* DISABLE_PYTHON */ +#endif /* WITH_PYTHON */ static int node_dynamic_parse(struct bNode *node) { -#ifdef DISABLE_PYTHON +#ifndef WITH_PYTHON return -1; #else PyObject *dict= NULL; @@ -516,7 +516,7 @@ static int node_dynamic_parse(struct bNode *node) * pynodes already linked to a script (node->id != NULL). */ static void node_dynamic_setup(bNode *node) { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON NodeScriptDict *nsd = NULL; bNodeTree *nodetree = NULL; bNodeType *ntype = NULL; @@ -640,7 +640,7 @@ static void node_dynamic_setup(bNode *node) node->custom1 = BSET(node->custom1, NODE_DYNAMIC_READY); PyGILState_Release(gilstate); -#endif /* DISABLE_PYTHON */ +#endif /* WITH_PYTHON */ return; } @@ -673,7 +673,7 @@ static void node_dynamic_init_cb(bNode *node) { /* node_dynamic_copy_cb: pynode copy callback */ static void node_dynamic_copy_cb(bNode *orig_node, bNode *new_node) { -#ifdef DISABLE_PYTHON +#ifndef WITH_PYTHON return; #else NodeScriptDict *nsd; @@ -698,7 +698,7 @@ static void node_dynamic_copy_cb(bNode *orig_node, bNode *new_node) /* node_dynamic_exec_cb: the execution callback called per pixel * during rendering. */ static void node_dynamic_exec_cb(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { -#ifdef DISABLE_PYTHON +#ifndef WITH_PYTHON return; #else BPy_Node *mynode = NULL; @@ -758,26 +758,29 @@ static void node_dynamic_exec_cb(void *data, bNode *node, bNodeStack **in, bNode #endif } -bNodeType node_dynamic_typeinfo = { - /* next, prev */ NULL, NULL, - /* type code */ NODE_DYNAMIC, - /* name */ "Dynamic", - /* width+range */ 150, 60, 300, - /* class+opts */ NODE_CLASS_OP_DYNAMIC, NODE_OPTIONS, - /* input sock */ NULL, - /* output sock */ NULL, - /* storage */ "NodeScriptDict", - /* execfunc */ node_dynamic_exec_cb, - /* butfunc */ NULL, - /* initfunc */ node_dynamic_init_cb, - /* freefunc */ node_dynamic_free_storage_cb, - /* copyfunc */ node_dynamic_copy_cb, - /* id */ NULL -}; +void register_node_type_sh_dynamic(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, NODE_DYNAMIC, "Dynamic", NODE_CLASS_OP_DYNAMIC, NODE_OPTIONS, NULL, NULL); + node_type_size(&ntype, 150, 60, 300); + node_type_init(&ntype, node_dynamic_init_cb); + node_type_storage(&ntype, "NodeScriptDict", node_dynamic_free_storage_cb, node_dynamic_copy_cb); + node_type_exec(&ntype, node_dynamic_exec_cb); + + nodeRegisterType(lb, &ntype); +} #else -bNodeType node_dynamic_typeinfo = {NULL}; +void register_node_type_sh_dynamic(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, NODE_DYNAMIC, "Dynamic", NODE_CLASS_OP_DYNAMIC, 0, NULL, NULL); + + nodeRegisterType(lb, &ntype); +} #endif |