Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-12-18 18:49:32 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-12-18 18:49:32 +0400
commit615d90b6e29b857833954ce4a62dfcafe0183c8f (patch)
tree5ab369c662ec911af8af70387c3c8f9ab5c73481 /source/blender/makesrna/intern/rna_nodetree.c
parentc21c4b07747dfaf9e4a14d9f23990de756cc4fb5 (diff)
Class method 'get_node_type' for node RNA types. This can be used to map RNA types and Python classes to the associated node type by means of the node type identifier.
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index eb614ba8fc1..93ce3b8dc07 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -271,6 +271,24 @@ static char *rna_Node_path(PointerRNA *ptr)
return BLI_sprintfN("nodes[\"%s\"]", node->name);
}
+/* define a get_type function for each node type */
+#define DEF_NODE_GET_NODE_TYPE(name, enum_name) \
+static const char *rna_##name##_get_node_type() \
+{ \
+ return enum_name; \
+}
+
+#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
+DEF_NODE_GET_NODE_TYPE(Category##StructName, EnumName)
+
+#include "rna_nodetree_types.h"
+
+/* some nodes not included in rna_nodetree_types.h */
+DEF_NODE_GET_NODE_TYPE(NodeGroup, "GROUP")
+DEF_NODE_GET_NODE_TYPE(NodeFrame, "FRAME")
+DEF_NODE_GET_NODE_TYPE(NodeReroute, "REROUTE")
+
+
static StructRNA *rna_NodeSocket_refine(PointerRNA *ptr)
{
bNodeSocket *sock = (bNodeSocket *)ptr->data;
@@ -4906,12 +4924,20 @@ static void rna_def_texture_nodetree(BlenderRNA *brna)
rna_def_texture_nodetree_api(brna, prop);
}
-static void define_specific_node(BlenderRNA *brna, int id, void (*func)(StructRNA *))
+static void define_specific_node(BlenderRNA *brna, int id, void (*def_func)(StructRNA *), const char *get_node_type_func)
{
StructRNA *srna = def_node(brna, id);
-
- if (func)
- func(srna);
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ if (def_func)
+ def_func(srna);
+
+ func = RNA_def_function(srna, "get_node_type", get_node_type_func);
+ RNA_def_function_ui_description(func, "Get the identifier of the node type");
+ RNA_def_function_flag(func, FUNC_NO_SELF);
+ parm = RNA_def_string(func, "result", "", 0, "Result", "");
+ RNA_def_function_return(func, parm);
}
void RNA_def_nodetree(BlenderRNA *brna)
@@ -4942,13 +4968,13 @@ void RNA_def_nodetree(BlenderRNA *brna)
rna_def_shader_nodetree(brna);
rna_def_texture_nodetree(brna);
#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
- define_specific_node(brna, ID, DefFunc);
+ define_specific_node(brna, ID, DefFunc, "rna_" STRINGIFY_ARG(Category##StructName) "_get_node_type");
#include "rna_nodetree_types.h"
- define_specific_node(brna, NODE_GROUP, def_group);
- define_specific_node(brna, NODE_FRAME, def_frame);
- define_specific_node(brna, NODE_REROUTE, 0);
+ define_specific_node(brna, NODE_GROUP, def_group, "rna_NodeGroup_get_node_type");
+ define_specific_node(brna, NODE_FRAME, def_frame, "rna_NodeFrame_get_node_type");
+ define_specific_node(brna, NODE_REROUTE, 0, "rna_NodeReroute_get_node_type");
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);