Cleanup: avoid using NOD_static_types.h for creating the node.type enum

The overall goal is to get rid of `NOD_static_types.h`. This patch removes
one usage of it to generate the `node.type` rna enum. Not all of the data
was available on `bNodeType` already, so I had to add the missing data there.

Pull Request: https://projects.blender.org/blender/blender/pulls/110810
This commit is contained in:
Jacques Lucke
2023-08-04 21:43:54 +02:00
parent 9909bf60c9
commit f18c45eb69
3 changed files with 16 additions and 10 deletions

View File

@@ -238,6 +238,8 @@ typedef struct bNodeType {
char ui_name[64]; /* MAX_NAME */
char ui_description[256];
int ui_icon;
/** Should usually use the idname instead, but this enum type is still exposed in Python. */
const char *enum_name_legacy;
float width, minwidth, maxwidth;
float height, minheight, maxheight;

View File

@@ -4503,6 +4503,8 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \
BLI_assert(ntype->rna_ext.srna != nullptr); \
RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \
ntype->enum_name_legacy = EnumName; \
STRNCPY(ntype->ui_description, UIDesc); \
break;
switch (type) {

View File

@@ -784,17 +784,19 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext * /*C*/,
category = "FunctionNode";
}
# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "Node") || STREQ(#Category, category)) { \
tmp.value = ID; \
tmp.identifier = EnumName; \
tmp.name = UIName; \
tmp.description = UIDesc; \
tmp.icon = ICON_NONE; \
RNA_enum_item_add(&item, &totitem, &tmp); \
NODE_TYPES_BEGIN (ntype) {
if (ntype->enum_name_legacy &&
(BLI_str_startswith(ntype->idname, "Node") || BLI_str_startswith(ntype->idname, category)))
{
tmp.value = ntype->type;
tmp.identifier = ntype->enum_name_legacy;
tmp.name = ntype->ui_name;
tmp.description = ntype->ui_description;
tmp.icon = ICON_NONE;
RNA_enum_item_add(&item, &totitem, &tmp);
}
# include "../../nodes/NOD_static_types.h"
# undef DefNode
}
NODE_TYPES_END;
RNA_enum_item_end(&item, &totitem);
*r_free = true;