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-20 13:49:15 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-12-20 13:49:15 +0400
commit2f3d2483c3e8cfc615cf75395bd686ba09ecef0f (patch)
tree12ab96c9b5627789543e0ca2253bfdb01995db3f /source/blender/makesrna/intern/rna_nodetree.c
parenta83cdfe41a1af28df6836e971e19835cb5b338e6 (diff)
Make the get_node_type method in Node subtype an actual classmethod by setting the new FUNC_USE_SELF_TYPE flag.
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 93ce3b8dc07..0e38f8d73a1 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -271,24 +271,23 @@ 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; \
+static const char *rna_Node_get_node_type(StructRNA *type)
+{
+ bNodeType *nodetype = RNA_struct_blender_type_get(type);
+ if (nodetype) {
+ /* XXX hack: with customnodes branch, nodes will use an identifier string instead of integer ID.
+ * Then this can be returned directly instead of doing this ugly include thingy ...
+ */
+ #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
+ if (ID == nodetype->type) { \
+ return EnumName; \
+ }
+
+ #include "rna_nodetree_types.h"
+ }
+ return "";
}
-#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;
@@ -1283,12 +1282,20 @@ static void init(void)
static StructRNA *def_node(BlenderRNA *brna, int node_id)
{
StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
NodeInfo *node = nodes + node_id;
srna = RNA_def_struct(brna, node->struct_name, node->base_name);
RNA_def_struct_ui_text(srna, node->ui_name, node->ui_desc);
RNA_def_struct_sdna(srna, "bNode");
+ func = RNA_def_function(srna, "get_node_type", "rna_Node_get_node_type");
+ RNA_def_function_ui_description(func, "Get the identifier of the node type");
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_SELF_TYPE);
+ parm = RNA_def_string(func, "result", "", 0, "Result", "");
+ RNA_def_function_return(func, parm);
+
return srna;
}
@@ -4924,20 +4931,12 @@ 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 (*def_func)(StructRNA *), const char *get_node_type_func)
+static void define_specific_node(BlenderRNA *brna, int id, void (*def_func)(StructRNA *))
{
StructRNA *srna = def_node(brna, id);
- 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)
@@ -4968,13 +4967,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, "rna_" STRINGIFY_ARG(Category##StructName) "_get_node_type");
+ define_specific_node(brna, ID, DefFunc);
#include "rna_nodetree_types.h"
- 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");
+ define_specific_node(brna, NODE_GROUP, def_group);
+ define_specific_node(brna, NODE_FRAME, def_frame);
+ define_specific_node(brna, NODE_REROUTE, 0);
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);