Blender  V3.3
node_fn_input_string.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "node_function_util.hh"
4 
5 #include "UI_interface.h"
6 #include "UI_resources.h"
7 
9 
11 {
12  b.is_function_node();
13  b.add_output<decl::String>(N_("String"));
14 }
15 
17 {
18  uiItemR(layout, ptr, "string", 0, "", ICON_NONE);
19 }
20 
22 {
23  bNode &bnode = builder.node();
24  NodeInputString *node_storage = static_cast<NodeInputString *>(bnode.storage);
25  std::string string = std::string((node_storage->string) ? node_storage->string : "");
27 }
28 
30 {
31  node->storage = MEM_callocN(sizeof(NodeInputString), __func__);
32 }
33 
35 {
36  NodeInputString *storage = (NodeInputString *)node->storage;
37  if (storage == nullptr) {
38  return;
39  }
40  if (storage->string != nullptr) {
41  MEM_freeN(storage->string);
42  }
43  MEM_freeN(storage);
44 }
45 
46 static void fn_node_string_copy(bNodeTree *UNUSED(dest_ntree),
47  bNode *dest_node,
48  const bNode *src_node)
49 {
50  NodeInputString *source_storage = (NodeInputString *)src_node->storage;
51  NodeInputString *destination_storage = (NodeInputString *)MEM_dupallocN(source_storage);
52 
53  if (source_storage->string) {
54  destination_storage->string = (char *)MEM_dupallocN(source_storage->string);
55  }
56 
57  dest_node->storage = destination_storage;
58 }
59 
60 } // namespace blender::nodes::node_fn_input_string_cc
61 
63 {
64  namespace file_ns = blender::nodes::node_fn_input_string_cc;
65 
66  static bNodeType ntype;
67 
75  nodeRegisterType(&ntype);
76 }
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
#define FN_NODE_INPUT_STRING
Definition: BKE_node.h:1523
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4426
#define NODE_CLASS_INPUT
Definition: BKE_node.h:345
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
OperationNode * node
bNodeTree * ntree
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
static void fn_node_input_string_build_multi_function(NodeMultiFunctionBuilder &builder)
static void fn_node_string_copy(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
static void fn_node_input_string_declare(NodeDeclarationBuilder &b)
static void fn_node_input_string_init(bNodeTree *UNUSED(ntree), bNode *node)
static void fn_node_input_string_free(bNode *node)
static void fn_node_input_string_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_fn_input_string()
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition: BKE_node.h:226
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:244
NodeMultiFunctionBuildFunction build_multi_function
Definition: BKE_node.h:313
NodeDeclareFunction declare
Definition: BKE_node.h:324
void * storage
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480