mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Refactor: RNA: Use parsed DNA structs instead of renamed SDNA
RNA used the SDNA blob which has renames baked in, and would then imperfectly map it back to the original C++ names that we are actually binding to. With recent DNA refactoring we can get the structs and members without the renames, and make the implementation for mapping them and their default values to RNA a bit cleaner. For DNA defaults, a table is now generated with a pointer to the default value for each member, rather than computing it through offset and size. Mapping integer types to known DNA integer types was moved into type substitution instead of the rename mapping so it applies to RNA as well. This change will make it easier to support more C++ types in RNA as we can avoid substiting some C++ types to bind them directly with RNA. It also leads to two small improvements in RNA definitions: properly recognize default for fix_to_cam_flag and use the actual bScreen struct name. Pull Request: https://projects.blender.org/blender/blender/pulls/158074
This commit is contained in:
parent
acfaedb3a5
commit
bc393beb31
13 changed files with 454 additions and 524 deletions
|
|
@ -809,7 +809,28 @@ static void substitute_vector_or_matrix(ParsedMember &member)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool substitute_cpp_types(Vector<ParsedStruct> &structs, const Span<ParsedEnum> enums)
|
/** Map modern C integer type names to old SDNA names. */
|
||||||
|
static void substitute_sdna_integer_type(ParsedMember &member)
|
||||||
|
{
|
||||||
|
static const std::pair<const char *, const char *> integer_type_aliases[] = {
|
||||||
|
{"uint8_t", "uchar"},
|
||||||
|
{"int16_t", "short"},
|
||||||
|
{"uint16_t", "ushort"},
|
||||||
|
{"int32_t", "int"},
|
||||||
|
{"uint32_t", "int"},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto &[alias, sdna_name] : integer_type_aliases) {
|
||||||
|
if (member.type_name == alias) {
|
||||||
|
member.type_name = sdna_name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool substitute_cpp_types(Vector<ParsedStruct> &structs,
|
||||||
|
const Span<ParsedEnum> enums,
|
||||||
|
bool /*for_rna*/)
|
||||||
{
|
{
|
||||||
Map<StringRef, const ParsedEnum *> enum_map;
|
Map<StringRef, const ParsedEnum *> enum_map;
|
||||||
enum_map.reserve(enums.size());
|
enum_map.reserve(enums.size());
|
||||||
|
|
@ -824,6 +845,7 @@ bool substitute_cpp_types(Vector<ParsedStruct> &structs, const Span<ParsedEnum>
|
||||||
if (!substitute_enum(parsed_struct, member, enum_map)) {
|
if (!substitute_enum(parsed_struct, member, enum_map)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
substitute_sdna_integer_type(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ Span<const char *> default_dna_header_filenames();
|
||||||
Span<const char *> include_files);
|
Span<const char *> include_files);
|
||||||
|
|
||||||
/** Convert C++ types to plain C types understood by DNA. */
|
/** Convert C++ types to plain C types understood by DNA. */
|
||||||
[[nodiscard]] bool substitute_cpp_types(Vector<ParsedStruct> &structs, Span<ParsedEnum> enums);
|
[[nodiscard]] bool substitute_cpp_types(Vector<ParsedStruct> &structs,
|
||||||
|
Span<ParsedEnum> enums,
|
||||||
|
bool for_rna);
|
||||||
|
|
||||||
} // namespace blender::dna
|
} // namespace blender::dna
|
||||||
|
|
|
||||||
|
|
@ -212,12 +212,6 @@ DnaRenameMaps DNA_rename_maps_alias_to_static()
|
||||||
for (const StructRename &r : struct_renames) {
|
for (const StructRename &r : struct_renames) {
|
||||||
data.types.add_new(r.new_name, r.old_name);
|
data.types.add_new(r.new_name, r.old_name);
|
||||||
}
|
}
|
||||||
/* Map modern integer types to old SDNA names. */
|
|
||||||
data.types.add_new("uint8_t", "uchar");
|
|
||||||
data.types.add_new("int16_t", "short");
|
|
||||||
data.types.add_new("uint16_t", "ushort");
|
|
||||||
data.types.add_new("int32_t", "int");
|
|
||||||
data.types.add_new("uint32_t", "int");
|
|
||||||
for (const MemberRename &r : member_renames) {
|
for (const MemberRename &r : member_renames) {
|
||||||
const StringRefNull struct_static = data.types.lookup_default(r.new_struct_name,
|
const StringRefNull struct_static = data.types.lookup_default(r.new_struct_name,
|
||||||
r.new_struct_name);
|
r.new_struct_name);
|
||||||
|
|
|
||||||
|
|
@ -689,10 +689,9 @@ static void write_sdna_type_offsets(FILE *file, const Span<dna::ParsedStruct> pa
|
||||||
/** Write the `dna_struct_ids.cc` file for `sdna_struct_id_get<T>()`. */
|
/** Write the `dna_struct_ids.cc` file for `sdna_struct_id_get<T>()`. */
|
||||||
static void write_sdna_struct_ids(FILE *file, const Span<dna::ParsedStruct> parsed_structs)
|
static void write_sdna_struct_ids(FILE *file, const Span<dna::ParsedStruct> parsed_structs)
|
||||||
{
|
{
|
||||||
|
fprintf(file, "#include \"DNA_sdna_type_ids.hh\"\n\n");
|
||||||
fprintf(file, "namespace blender {\n");
|
fprintf(file, "namespace blender {\n");
|
||||||
fprintf(file, "namespace dna {\n\n");
|
fprintf(file, "namespace dna {\n\n");
|
||||||
fprintf(file, "template<typename T> int sdna_struct_id_get();\n\n");
|
|
||||||
fprintf(file, "int sdna_struct_id_get_max();\n");
|
|
||||||
fprintf(file, "int sdna_struct_id_get_max() { return %d; }\n", int(parsed_structs.size()));
|
fprintf(file, "int sdna_struct_id_get_max() { return %d; }\n", int(parsed_structs.size()));
|
||||||
fprintf(file, "\n}\n");
|
fprintf(file, "\n}\n");
|
||||||
|
|
||||||
|
|
@ -708,41 +707,53 @@ static void write_sdna_struct_ids(FILE *file, const Span<dna::ParsedStruct> pars
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write the `dna_defaults.cc` for RNA to automatically set property defaults. */
|
/** Write the `dna_defaults.cc` for RNA to automatically set property defaults. */
|
||||||
static void write_sdna_defaults(FILE *file,
|
static void write_rna_defaults(FILE *file,
|
||||||
const StringRefNull base_directory,
|
const StringRefNull base_directory,
|
||||||
const Span<dna::ParsedStruct> parsed_structs)
|
const Span<dna::ParsedStruct> parsed_structs)
|
||||||
{
|
{
|
||||||
fprintf(file, "/* Default struct member values for RNA. */\n");
|
fprintf(file, "/* Default struct member values for RNA. */\n");
|
||||||
fprintf(file, "#define DNA_DEPRECATED_ALLOW\n");
|
fprintf(file, "#define DNA_DEPRECATED_ALLOW\n");
|
||||||
fprintf(file, "#define DNA_NO_EXTERNAL_CONSTRUCTORS\n");
|
fprintf(file, "#define DNA_NO_EXTERNAL_CONSTRUCTORS\n");
|
||||||
for (int i = 0; *(includefiles[i]) != '\0'; i++) {
|
fprintf(file, "#include \"DNA_sdna_type_ids.hh\"\n\n");
|
||||||
fprintf(file, "#include \"%s%s\"\n", base_directory.c_str(), includefiles[i]);
|
|
||||||
}
|
for (const char *filename : includefiles) {
|
||||||
fprintf(file, "using namespace blender;\n");
|
fprintf(file, "#include \"%s%s\"\n", base_directory.c_str(), filename);
|
||||||
for (const dna::ParsedStruct &parsed_struct : parsed_structs) {
|
|
||||||
const char *name = parsed_struct.alias_type_name.c_str();
|
|
||||||
if (STREQ(name, "bTheme")) {
|
|
||||||
/* Exception for bTheme which is auto-generated. */
|
|
||||||
fprintf(file, "extern \"C\" const bTheme U_theme_default;\n");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(file, "static const %s DNA_DEFAULT_%s = {};\n", name, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(file, "const void *DNA_default_table[%d] = {\n", 1 + int(parsed_structs.size()));
|
fprintf(file, "namespace blender {\n\n");
|
||||||
fprintf(file, " nullptr,\n");
|
|
||||||
|
/* Define an instance of each struct. */
|
||||||
for (const dna::ParsedStruct &parsed_struct : parsed_structs) {
|
for (const dna::ParsedStruct &parsed_struct : parsed_structs) {
|
||||||
const char *name = parsed_struct.alias_type_name.c_str();
|
const StringRefNull name = parsed_struct.type_name.c_str();
|
||||||
if (STREQ(name, "bTheme")) {
|
std::string default_var;
|
||||||
fprintf(file, " &U_theme_default,\n");
|
|
||||||
|
if (name == "bTheme") {
|
||||||
|
/* Exception for bTheme which is auto-generated. */
|
||||||
|
fprintf(file, "extern \"C\" const bTheme U_theme_default;\n");
|
||||||
|
default_var = "U_theme_default";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(file, " &DNA_DEFAULT_%s,\n", name);
|
fprintf(file, "static const %s DNA_DEFAULT_%s = {};\n", name.c_str(), name.c_str());
|
||||||
|
default_var = "DNA_DEFAULT_" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Table with pointer to each member. */
|
||||||
|
fprintf(file, "static const void *const member_defaults_%s[] = {\n", name.c_str());
|
||||||
|
for (const dna::ParsedMember &pm : parsed_struct.members) {
|
||||||
|
const StringRef bare_id = DNA_member_id_string_ref(pm.member_name);
|
||||||
|
fprintf(file, " &%s.%.*s,\n", default_var.c_str(), int(bare_id.size()), bare_id.data());
|
||||||
|
}
|
||||||
|
fprintf(file, "};\n");
|
||||||
}
|
}
|
||||||
fprintf(file, "};\n");
|
|
||||||
fprintf(file, "\n");
|
/* Table with all structs. */
|
||||||
|
fprintf(file, "\nextern const void *const *const DNA_member_default_table[] = {\n");
|
||||||
|
for (const dna::ParsedStruct &parsed_struct : parsed_structs) {
|
||||||
|
fprintf(file, " member_defaults_%s,\n", parsed_struct.type_name.c_str());
|
||||||
|
}
|
||||||
|
fprintf(file, "};\n\n");
|
||||||
|
|
||||||
|
fprintf(file, "} // namespace blender\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write `dna_verify.cc` file to verify `sizeof` and `offsetof` match what we computed. */
|
/** Write `dna_verify.cc` file to verify `sizeof` and `offsetof` match what we computed. */
|
||||||
|
|
@ -758,8 +769,8 @@ static void write_sdna_verify(FILE *file,
|
||||||
/* Workaround enum naming collision in static asserts
|
/* Workaround enum naming collision in static asserts
|
||||||
* (ideally this included a unique name/id per file). */
|
* (ideally this included a unique name/id per file). */
|
||||||
fprintf(file, "#define assert_line_ assert_line_DNA_\n");
|
fprintf(file, "#define assert_line_ assert_line_DNA_\n");
|
||||||
for (int i = 0; *(includefiles[i]) != '\0'; i++) {
|
for (const char *filename : includefiles) {
|
||||||
fprintf(file, "#include \"%s%s\"\n", base_directory.c_str(), includefiles[i]);
|
fprintf(file, "#include \"%s%s\"\n", base_directory.c_str(), filename);
|
||||||
}
|
}
|
||||||
fprintf(file, "#undef assert_line_\n");
|
fprintf(file, "#undef assert_line_\n");
|
||||||
fprintf(file, "\n");
|
fprintf(file, "\n");
|
||||||
|
|
@ -871,8 +882,12 @@ static bool make_structDNA(const StringRefNull base_directory,
|
||||||
}
|
}
|
||||||
DEBUG_PRINTF(0, "\tFinished scanning headers.\n");
|
DEBUG_PRINTF(0, "\tFinished scanning headers.\n");
|
||||||
|
|
||||||
|
/* Write default values for RNA before any substitution or renaming, as RNA binds
|
||||||
|
* to the actual C++ data structures rather than SDNA. */
|
||||||
|
write_rna_defaults(file_defaults, base_directory, parsed_structs);
|
||||||
|
|
||||||
/* Substitute C++ types with C types known to SDNA. */
|
/* Substitute C++ types with C types known to SDNA. */
|
||||||
if (!dna::substitute_cpp_types(parsed_structs, parsed_enums)) {
|
if (!dna::substitute_cpp_types(parsed_structs, parsed_enums, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -896,7 +911,6 @@ static bool make_structDNA(const StringRefNull base_directory,
|
||||||
/* Write auxiliary files. */
|
/* Write auxiliary files. */
|
||||||
write_sdna_type_offsets(file_offsets, parsed_structs);
|
write_sdna_type_offsets(file_offsets, parsed_structs);
|
||||||
write_sdna_struct_ids(file_ids, parsed_structs);
|
write_sdna_struct_ids(file_ids, parsed_structs);
|
||||||
write_sdna_defaults(file_defaults, base_directory, parsed_structs);
|
|
||||||
write_sdna_verify(file_verify, table, parsed_structs, base_directory);
|
write_sdna_verify(file_verify, table, parsed_structs, base_directory);
|
||||||
|
|
||||||
DEBUG_PRINTF(0, "done.\n");
|
DEBUG_PRINTF(0, "done.\n");
|
||||||
|
|
|
||||||
|
|
@ -721,10 +721,6 @@ void RNA_def_property_free_pointers_set_py_data_callback(
|
||||||
/* Utilities. */
|
/* Utilities. */
|
||||||
|
|
||||||
const char *RNA_property_typename(PropertyType type);
|
const char *RNA_property_typename(PropertyType type);
|
||||||
#define IS_DNATYPE_FLOAT_COMPAT(_str) ELEM(_str, "float", "double")
|
|
||||||
#define IS_DNATYPE_INT_COMPAT(_str) ELEM(_str, "int", "short", "char", "uchar", "ushort", "int8_t")
|
|
||||||
#define IS_DNATYPE_BOOLEAN_COMPAT(_str) \
|
|
||||||
(IS_DNATYPE_INT_COMPAT(_str) || ELEM(_str, "int64_t", "uint64_t"))
|
|
||||||
|
|
||||||
bool RNA_validate_identifier(const char *identifier,
|
bool RNA_validate_identifier(const char *identifier,
|
||||||
bool is_property,
|
bool is_property,
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,7 @@ set(SRC
|
||||||
${DEFSRC}
|
${DEFSRC}
|
||||||
${APISRC}
|
${APISRC}
|
||||||
../../../../intern/clog/clog.cc
|
../../../../intern/clog/clog.cc
|
||||||
|
../../makesdna/intern/dna_parse.cc
|
||||||
|
|
||||||
makesrna_utils.hh
|
makesrna_utils.hh
|
||||||
)
|
)
|
||||||
|
|
@ -251,6 +252,7 @@ set(INC
|
||||||
../../imbuf
|
../../imbuf
|
||||||
../../imbuf/movie
|
../../imbuf/movie
|
||||||
../../io/usd
|
../../io/usd
|
||||||
|
../../makesdna/intern
|
||||||
../../modifiers
|
../../modifiers
|
||||||
../../nodes
|
../../nodes
|
||||||
../../nodes/composite/include
|
../../nodes/composite/include
|
||||||
|
|
@ -267,9 +269,10 @@ set(INC
|
||||||
../../../../intern/memutil
|
../../../../intern/memutil
|
||||||
../../../../intern/mantaflow/extern
|
../../../../intern/mantaflow/extern
|
||||||
|
|
||||||
|
|
||||||
# RNA_prototypes.hh
|
# RNA_prototypes.hh
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../../makesrna/
|
${CMAKE_CURRENT_BINARY_DIR}/../../makesrna/
|
||||||
|
# dna_includes_as_strings.h
|
||||||
|
${CMAKE_BINARY_DIR}/source/blender/makesdna
|
||||||
)
|
)
|
||||||
|
|
||||||
set(INC_SYS
|
set(INC_SYS
|
||||||
|
|
@ -419,7 +422,7 @@ add_custom_command(
|
||||||
OUTPUT ${GENSRC}
|
OUTPUT ${GENSRC}
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_COMMAND} -E env ${PLATFORM_ENV_BUILD}
|
${CMAKE_COMMAND} -E env ${PLATFORM_ENV_BUILD}
|
||||||
"$<TARGET_FILE:makesrna>" ${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/../
|
"$<TARGET_FILE:makesrna>" ${CMAKE_SOURCE_DIR}/source/blender/makesdna/ ${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
DEPENDS makesrna
|
DEPENDS makesrna
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
#include "RNA_enum_types.hh"
|
#include "RNA_enum_types.hh"
|
||||||
#include "RNA_types.hh"
|
#include "RNA_types.hh"
|
||||||
|
|
||||||
|
#include "dna_parse.h"
|
||||||
|
|
||||||
#include "makesrna_utils.hh"
|
#include "makesrna_utils.hh"
|
||||||
#include "rna_internal.hh"
|
#include "rna_internal.hh"
|
||||||
|
|
||||||
|
|
@ -406,7 +408,7 @@ static StructRNA *rna_find_struct(const char *identifier)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *rna_find_type(const char *type)
|
static const char *rna_find_type(const StringRef type)
|
||||||
{
|
{
|
||||||
StructDefRNA *ds;
|
StructDefRNA *ds;
|
||||||
|
|
||||||
|
|
@ -528,7 +530,7 @@ static bool rna_parameter_is_const(const PropertyDefRNA *dparm)
|
||||||
static bool rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
|
static bool rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
|
||||||
{
|
{
|
||||||
return ((prop->type == PROP_FLOAT) && ELEM(prop->subtype, PROP_COLOR, PROP_COLOR_GAMMA) &&
|
return ((prop->type == PROP_FLOAT) && ELEM(prop->subtype, PROP_COLOR, PROP_COLOR_GAMMA) &&
|
||||||
(IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0));
|
!is_dnatype_float_compat(dp->dnatype));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -631,7 +633,7 @@ static char *rna_def_property_get_func(
|
||||||
if (!dp->dnatype.is_empty()) {
|
if (!dp->dnatype.is_empty()) {
|
||||||
|
|
||||||
if (prop->type == PROP_FLOAT) {
|
if (prop->type == PROP_FLOAT) {
|
||||||
if (!IS_DNATYPE_FLOAT_COMPAT(dp->dnatype)) {
|
if (!is_dnatype_float_compat(dp->dnatype)) {
|
||||||
/* Colors are an exception. these get translated. */
|
/* Colors are an exception. these get translated. */
|
||||||
if (prop->subtype != PROP_COLOR_GAMMA) {
|
if (prop->subtype != PROP_COLOR_GAMMA) {
|
||||||
CLOG_ERROR(&LOG,
|
CLOG_ERROR(&LOG,
|
||||||
|
|
@ -646,7 +648,7 @@ static char *rna_def_property_get_func(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (prop->type == PROP_BOOLEAN) {
|
else if (prop->type == PROP_BOOLEAN) {
|
||||||
if (!IS_DNATYPE_BOOLEAN_COMPAT(dp->dnatype)) {
|
if (!is_dnatype_boolean_compat(dp->dnatype)) {
|
||||||
CLOG_ERROR(&LOG,
|
CLOG_ERROR(&LOG,
|
||||||
"%s.%s is a '%s' but wrapped as type '%s'.",
|
"%s.%s is a '%s' but wrapped as type '%s'.",
|
||||||
srna->identifier,
|
srna->identifier,
|
||||||
|
|
@ -658,7 +660,7 @@ static char *rna_def_property_get_func(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ELEM(prop->type, PROP_INT, PROP_ENUM)) {
|
else if (ELEM(prop->type, PROP_INT, PROP_ENUM)) {
|
||||||
if (!IS_DNATYPE_INT_COMPAT(dp->dnatype)) {
|
if (!is_dnatype_int_compat(dp->dnatype)) {
|
||||||
CLOG_ERROR(&LOG,
|
CLOG_ERROR(&LOG,
|
||||||
"%s.%s is a '%s' but wrapped as type '%s'.",
|
"%s.%s is a '%s' but wrapped as type '%s'.",
|
||||||
srna->identifier,
|
srna->identifier,
|
||||||
|
|
@ -4399,16 +4401,26 @@ int main(int argc, char **argv)
|
||||||
CLG_output_use_basename_set(true);
|
CLG_output_use_basename_set(true);
|
||||||
CLG_level_set(debugSRNA ? CLG_LEVEL_DEBUG : CLG_LEVEL_WARN);
|
CLG_level_set(debugSRNA ? CLG_LEVEL_DEBUG : CLG_LEVEL_WARN);
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 3) {
|
||||||
fprintf(stderr, "Usage: %s outdirectory [public header outdirectory]/\n", argv[0]);
|
fprintf(stderr, "Usage: %s dna_dir out_dir [header_out_dir]/\n", argv[0]);
|
||||||
return_status = EXIT_FAILURE;
|
return_status = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
const char *dna_header_path = argv[1];
|
||||||
|
Vector<dna::ParsedEnum> enums;
|
||||||
|
if (!(dna::parse_dna_headers(
|
||||||
|
dna_header_path, DefRNA.dna_structs, enums, dna::default_dna_header_filenames()) &&
|
||||||
|
dna::substitute_cpp_types(DefRNA.dna_structs, enums, true)))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Fatal!\n");
|
||||||
|
CLOG_FATAL(&LOG, "Failed to parse DNA headers for RNA registration");
|
||||||
|
}
|
||||||
|
|
||||||
if (debugSRNA > 0) {
|
if (debugSRNA > 0) {
|
||||||
fprintf(stderr, "Running makesrna\n");
|
fprintf(stderr, "Running makesrna\n");
|
||||||
}
|
}
|
||||||
makesrna_path = argv[0];
|
makesrna_path = argv[0];
|
||||||
return_status = rna_preprocess(argv[1], (argc > 2) ? argv[2] : nullptr);
|
return_status = rna_preprocess(argv[2], (argc > 2) ? argv[3] : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLG_exit();
|
CLG_exit();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
/* SPDX-FileCopyrightText: 2025-2026 Blender Authors
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
|
@ -13,4 +13,8 @@
|
||||||
|
|
||||||
#include "dna_type_offsets.h"
|
#include "dna_type_offsets.h"
|
||||||
|
|
||||||
extern const void *DNA_default_table[SDNA_TYPE_MAX];
|
namespace blender {
|
||||||
|
|
||||||
|
extern const void *const *const DNA_member_default_table[];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -12,9 +12,14 @@
|
||||||
|
|
||||||
#include "BLI_compiler_attrs.h"
|
#include "BLI_compiler_attrs.h"
|
||||||
#include "BLI_string_ref.hh"
|
#include "BLI_string_ref.hh"
|
||||||
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
#include "DNA_listBase.h"
|
#include "DNA_listBase.h"
|
||||||
|
|
||||||
|
#ifndef RNA_RUNTIME
|
||||||
|
# include "dna_parse.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "rna_internal_types.hh"
|
#include "rna_internal_types.hh"
|
||||||
|
|
||||||
#include "UI_resources.hh" /* IWYU pragma: export */
|
#include "UI_resources.hh" /* IWYU pragma: export */
|
||||||
|
|
@ -44,9 +49,9 @@ struct SDNA;
|
||||||
struct Strip;
|
struct Strip;
|
||||||
struct ViewLayer;
|
struct ViewLayer;
|
||||||
|
|
||||||
#ifndef RNA_RUNTIME
|
|
||||||
/* Data structures used during define */
|
/* Data structures used during define */
|
||||||
|
|
||||||
|
#ifndef RNA_RUNTIME
|
||||||
struct ContainerDefRNA {
|
struct ContainerDefRNA {
|
||||||
void *next, *prev;
|
void *next, *prev;
|
||||||
|
|
||||||
|
|
@ -79,11 +84,7 @@ struct PropertyDefRNA {
|
||||||
StringRefNull dnatype;
|
StringRefNull dnatype;
|
||||||
int dnaarraylength = 0;
|
int dnaarraylength = 0;
|
||||||
int dnapointerlevel = 0;
|
int dnapointerlevel = 0;
|
||||||
/**
|
const void *dnadefaultdata = nullptr;
|
||||||
* Offset in bytes within `dnastructname`.
|
|
||||||
* -1 when unusable (follows pointer for example). */
|
|
||||||
int dnaoffset = 0;
|
|
||||||
int dnasize = 0;
|
|
||||||
|
|
||||||
/* for finding length of array collections */
|
/* for finding length of array collections */
|
||||||
StringRefNull dnalengthstructname;
|
StringRefNull dnalengthstructname;
|
||||||
|
|
@ -120,7 +121,6 @@ struct AllocDefRNA {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct BlenderDefRNA {
|
struct BlenderDefRNA {
|
||||||
struct SDNA *sdna = nullptr;
|
|
||||||
struct StructRNA *laststruct = nullptr;
|
struct StructRNA *laststruct = nullptr;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
bool silent = false;
|
bool silent = false;
|
||||||
|
|
@ -131,6 +131,7 @@ struct BlenderDefRNA {
|
||||||
|
|
||||||
/* Keep last. */
|
/* Keep last. */
|
||||||
#ifndef RNA_RUNTIME
|
#ifndef RNA_RUNTIME
|
||||||
|
Vector<dna::ParsedStruct> dna_structs;
|
||||||
ListBaseT<StructDefRNA> structs = {};
|
ListBaseT<StructDefRNA> structs = {};
|
||||||
ListBaseT<AllocDefRNA> allocs = {};
|
ListBaseT<AllocDefRNA> allocs = {};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -757,4 +757,26 @@ struct BlenderRNA {
|
||||||
|
|
||||||
#define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont)) + 1))
|
#define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont)) + 1))
|
||||||
|
|
||||||
|
/* Check compatibility of DNA types with RNA types. */
|
||||||
|
inline bool is_dnatype_float_compat(const StringRef dnatype)
|
||||||
|
{
|
||||||
|
return ELEM(dnatype, "float", "double");
|
||||||
|
}
|
||||||
|
inline bool is_dnatype_int_compat(const StringRef dnatype)
|
||||||
|
{
|
||||||
|
return ELEM(dnatype, "int", "short", "char", "uchar", "ushort", "int8_t");
|
||||||
|
}
|
||||||
|
inline bool is_dnatype_boolean_compat(const StringRef dnatype)
|
||||||
|
{
|
||||||
|
return is_dnatype_int_compat(dnatype) || ELEM(dnatype, "int64_t", "uint64_t");
|
||||||
|
}
|
||||||
|
inline bool is_dnatype_boolean_bitshift_fullrange_compat(const StringRef dnatype)
|
||||||
|
{
|
||||||
|
/* Several types cannot use all their bytes to store a bit-set (bit-shift operations on negative
|
||||||
|
* numbers are "arithmetic", i.e. preserve the sign, i.e. are not "pure" binary shifting).
|
||||||
|
*
|
||||||
|
* Currently, all signed types and `uint64_t` cannot use their left-most bit (i.e. sign bit). */
|
||||||
|
return ELEM(dnatype, "char", "uchar", "ushort", "uint", "uint8_t", "uint16_t", "uint32_t");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender
|
} // namespace blender
|
||||||
|
|
|
||||||
|
|
@ -4275,19 +4275,16 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "anim_fix_to_cam_use_loc", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "anim_fix_to_cam_use_loc", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, nullptr, "fix_to_cam_flag", FIX_TO_CAM_FLAG_USE_LOC);
|
RNA_def_property_boolean_sdna(prop, nullptr, "fix_to_cam_flag", FIX_TO_CAM_FLAG_USE_LOC);
|
||||||
RNA_def_property_boolean_default(prop, true);
|
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "Use Location for Camera Fix", "Create location keys when fixing to the scene camera");
|
prop, "Use Location for Camera Fix", "Create location keys when fixing to the scene camera");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "anim_fix_to_cam_use_rot", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "anim_fix_to_cam_use_rot", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, nullptr, "fix_to_cam_flag", FIX_TO_CAM_FLAG_USE_ROT);
|
RNA_def_property_boolean_sdna(prop, nullptr, "fix_to_cam_flag", FIX_TO_CAM_FLAG_USE_ROT);
|
||||||
RNA_def_property_boolean_default(prop, true);
|
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "Use Rotation for Camera Fix", "Create rotation keys when fixing to the scene camera");
|
prop, "Use Rotation for Camera Fix", "Create rotation keys when fixing to the scene camera");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "anim_fix_to_cam_use_scale", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "anim_fix_to_cam_use_scale", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, nullptr, "fix_to_cam_flag", FIX_TO_CAM_FLAG_USE_SCALE);
|
RNA_def_property_boolean_sdna(prop, nullptr, "fix_to_cam_flag", FIX_TO_CAM_FLAG_USE_SCALE);
|
||||||
RNA_def_property_boolean_default(prop, true);
|
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "Use Scale for Camera Fix", "Create scale keys when fixing to the scene camera");
|
prop, "Use Scale for Camera Fix", "Create scale keys when fixing to the scene camera");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ static void rna_def_screen(BlenderRNA *brna)
|
||||||
PropertyRNA *parm;
|
PropertyRNA *parm;
|
||||||
|
|
||||||
srna = RNA_def_struct(brna, "Screen", "ID");
|
srna = RNA_def_struct(brna, "Screen", "ID");
|
||||||
RNA_def_struct_sdna(srna, "Screen"); /* Actually #bScreen but for 2.5 the DNA is patched! */
|
RNA_def_struct_sdna(srna, "bScreen");
|
||||||
RNA_def_struct_ui_text(
|
RNA_def_struct_ui_text(
|
||||||
srna, "Screen", "Screen data-block, defining the layout of areas in a window");
|
srna, "Screen", "Screen data-block, defining the layout of areas in a window");
|
||||||
RNA_def_struct_ui_icon(srna, ICON_WORKSPACE);
|
RNA_def_struct_ui_icon(srna, ICON_WORKSPACE);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue