Files
test2/source/blender/nodes/NOD_rna_define.hh
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00

73 lines
2.4 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include <optional>
#include "BLI_function_ref.hh"
#include "RNA_define.hh"
#include "WM_types.hh" /* For notifier defines */
void rna_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr);
void rna_Node_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr);
namespace blender::nodes {
struct EnumRNAAccessors {
EnumPropertyGetFunc getter;
EnumPropertySetFunc setter;
EnumRNAAccessors(EnumPropertyGetFunc getter, EnumPropertySetFunc setter)
: getter(getter), setter(setter)
{
}
};
/**
* Generates accessor methods for a property stored directly in the `bNode`, typically
* `bNode->custom1` or similar.
*/
#define NOD_inline_enum_accessors(member) \
EnumRNAAccessors( \
[](PointerRNA *ptr, PropertyRNA * /*prop*/) -> int { \
const bNode &node = *static_cast<const bNode *>(ptr->data); \
return node.member; \
}, \
[](PointerRNA *ptr, PropertyRNA * /*prop*/, const int value) { \
bNode &node = *static_cast<bNode *>(ptr->data); \
node.member = value; \
})
/**
* Generates accessor methods for a property stored in `bNode->storage`. This is expected to be
* used in a node file that uses #NODE_STORAGE_FUNCS.
*/
#define NOD_storage_enum_accessors(member) \
EnumRNAAccessors( \
[](PointerRNA *ptr, PropertyRNA * /*prop*/) -> int { \
const bNode &node = *static_cast<const bNode *>(ptr->data); \
return node_storage(node).member; \
}, \
[](PointerRNA *ptr, PropertyRNA * /*prop*/, const int value) { \
bNode &node = *static_cast<bNode *>(ptr->data); \
node_storage(node).member = value; \
})
const EnumPropertyItem *enum_items_filter(const EnumPropertyItem *original_item_array,
FunctionRef<bool(const EnumPropertyItem &item)> fn);
PropertyRNA *RNA_def_node_enum(StructRNA *srna,
const char *identifier,
const char *ui_name,
const char *ui_description,
const EnumPropertyItem *static_items,
const EnumRNAAccessors accessors,
std::optional<int> default_value = std::nullopt,
const EnumPropertyItemFunc item_func = nullptr);
} // namespace blender::nodes