Blender V5.3
blender::dna Namespace Reference

Namespaces

namespace  array
namespace  internal
namespace  pointers

Classes

struct  CppVectorMatrixTypeMap
struct  ParsedEnum
struct  ParsedMember
struct  ParsedStruct
struct  Token
class  TokenStream

Functions

template<typename T>
internal::ShallowDataConstRef< T > shallow_copy (const T &other)
template<typename T>
void shallow_copy_array (T *dst, const T *src, const int64_t size)
internal::ShallowZeroInitializeTag shallow_zero_initialize ()
template<typename T>
void shallow_swap (T &a, T &b)
void print_structs_at_address (const SDNA &sdna, int struct_id, const void *data, const void *address, int64_t element_num, std::ostream &stream)
void print_struct_by_id (int struct_id, const void *data)
template<typename T>
int sdna_struct_id_get ()
int sdna_struct_id_get_max ()
static void print_struct_array_recursive (const SDNA &sdna, const SDNA_Struct &sdna_struct, const void *initial_data, const int64_t element_num, const int indent, fmt::appender &dst)
static void print_single_struct_recursive (const SDNA &sdna, const SDNA_Struct &sdna_struct, const void *initial_data, const int indent, fmt::appender &dst)
static bool char_array_startswith_simple_name (const char *data, const int array_len)
 TEST_F (SDNATest, basic)
 TEST_F (SDNATest, index_without_alias)
 TEST_F (SDNATest, struct_size)
 TEST_F (SDNATest, struct_member_size)
 TEST_F (SDNATest, struct_member_offset_by_name_without_alias)
File I/O
Span< const char * > default_dna_header_filenames ()
static bool read_file_data (const StringRefNull filepath, Vector< char > &data)
Tokenizer
static bool is_identifier_start (char c)
static bool is_identifier_continuation (char c)
static TokenStream tokenize_dna_header (StringRef source)
static TokenStream strip_ignored_tokens (TokenStream stream)
Name Validation
static bool is_valid_type_name (const StringRefNull type_name, const StringRefNull filepath)
static bool is_valid_member_name (const StringRefNull name, const StringRefNull filepath)
Parser
static void skip_balanced (TokenStream &stream, TokenKind open, TokenKind close)
static void skip_initializer (TokenStream &stream)
static void append_array_suffix (TokenStream &stream, std::string &out)
static void append_template_suffix (TokenStream &stream, std::string &out)
static bool parse_paren_declaration (TokenStream &stream, std::string &out)
static bool parse_member_declaration (TokenStream &stream, std::string &out)
static bool parse_struct_body (TokenStream &stream, const StringRefNull filepath, ParsedStruct &r_struct)
static void skip_struct_body (TokenStream &stream)
static bool parse_enum_declaration (TokenStream &stream, const StringRefNull filepath, Vector< ParsedEnum > &r_enums)
static bool parse_dna_header (const StringRefNull filepath, Vector< ParsedStruct > &r_structs, Vector< ParsedEnum > &r_enums)
bool parse_dna_headers (const StringRefNull base_directory, Vector< ParsedStruct > &r_structs, Vector< ParsedEnum > &r_enums, Span< const char * > include_files)

Variables

constexpr int kRawDataStructId = 0
constexpr int kListBaseStructId = 1
constexpr int kTestStructId = 2
constexpr int kStructWithVectorMatrixTypesId = 3
constexpr int kStructWithEnumMembersId = 4

Token Stream

using TokenKind = int
constexpr TokenKind TOKEN_IDENTIFIER = 256
constexpr TokenKind TOKEN_NUMBER = 257
constexpr TokenKind TOKEN_END = 258

Type Substitution

static const CppVectorMatrixTypeMap cpp_array_type_mappings []
static void substitute_listbase_t (ParsedMember &member)
static void substitute_vector_or_matrix (ParsedMember &member)
static bool substitute_enum (const ParsedStruct &parsed_struct, ParsedMember &member, const Map< StringRef, const ParsedEnum * > &enum_map)
static void substitute_sdna_integer_type (ParsedMember &member)
bool substitute_cpp_types (Vector< ParsedStruct > &structs, const Span< ParsedEnum > enums, bool)

Typedef Documentation

◆ TokenKind

Definition at line 79 of file dna_parse.cc.

Function Documentation

◆ append_array_suffix()

◆ append_template_suffix()

void blender::dna::append_template_suffix ( TokenStream & stream,
std::string & out )
static

◆ char_array_startswith_simple_name()

bool blender::dna::char_array_startswith_simple_name ( const char * data,
const int array_len )
static

Uses a heuristic to detect if a char array should be printed as string.

Definition at line 2130 of file dna_genfile.cc.

References char_array_startswith_simple_name(), blender::data, and blender::IndexRange::IndexRange().

Referenced by char_array_startswith_simple_name(), and print_single_struct_recursive().

◆ default_dna_header_filenames()

Span< const char * > blender::dna::default_dna_header_filenames ( )

List of all DNA header filenames.

Definition at line 49 of file dna_parse.cc.

References blender::ARRAY_SIZE(), default_dna_header_filenames(), and blender::Span< T >::Span().

Referenced by default_dna_header_filenames(), and main().

◆ is_identifier_continuation()

bool blender::dna::is_identifier_continuation ( char c)
static

◆ is_identifier_start()

bool blender::dna::is_identifier_start ( char c)
static

◆ is_valid_member_name()

◆ is_valid_type_name()

bool blender::dna::is_valid_type_name ( const StringRefNull type_name,
const StringRefNull filepath )
static

◆ parse_dna_header()

◆ parse_dna_headers()

bool blender::dna::parse_dna_headers ( StringRefNull base_directory,
Vector< ParsedStruct > & r_structs,
Vector< ParsedEnum > & r_enums,
Span< const char * > include_files )
nodiscard

Extract structs, their members, and enums from DNA headers.

Definition at line 704 of file dna_parse.cc.

References blender::gpu::shader::parser::filename(), parse_dna_header(), and parse_dna_headers().

Referenced by main(), blender::make_structDNA(), and parse_dna_headers().

◆ parse_enum_declaration()

◆ parse_member_declaration()

◆ parse_paren_declaration()

bool blender::dna::parse_paren_declaration ( TokenStream & stream,
std::string & out )
staticnodiscard

Parse a parenthesized declaration: (*name)(args) (function pointer) or (*name)[N][M] (multi-dimensional array pointer). Both are stored in SDNA as (*name)().

Definition at line 460 of file dna_parse.cc.

References blender::dna::TokenStream::advance(), blender::dna::TokenStream::at_end(), blender::dna::TokenStream::consume(), blender::dna::TokenStream::kind(), blender::gpu::shader::metadata::out, parse_paren_declaration(), skip_balanced(), blender::dna::Token::text, and TOKEN_IDENTIFIER.

Referenced by parse_member_declaration(), and parse_paren_declaration().

◆ parse_struct_body()

◆ print_single_struct_recursive()

◆ print_struct_array_recursive()

void blender::dna::print_struct_array_recursive ( const SDNA & sdna,
const SDNA_Struct & sdna_struct,
const void * initial_data,
const int64_t element_num,
const int indent,
fmt::appender & dst )
static

◆ print_struct_by_id()

void blender::dna::print_struct_by_id ( int struct_id,
const void * data )

Prints all members of the struct to stdout.

Definition at line 2305 of file dna_genfile.cc.

References blender::data, blender::DNA_sdna_current_get(), print_struct_by_id(), and print_structs_at_address().

Referenced by print_struct_by_id().

◆ print_structs_at_address()

void blender::dna::print_structs_at_address ( const SDNA & sdna,
int struct_id,
const void * data,
const void * address,
int64_t element_num,
std::ostream & stream )

Print all members of the struct assuming that the data has the given address. This is mainly useful for observing what data is written to a .blend file.

Parameters
sdnaContains reflection information about DNA structs.
struct_idThe type the data points to. Used to index into sdna.structs.
dataWhere the data is stored.
addressThe address that should be printed. Often it's the same as data.
element_numThe number of elements in the array, or 1 if there is only one struct.
streamWhere to print the output.

Definition at line 2286 of file dna_genfile.cc.

References print_struct_array_recursive(), print_structs_at_address(), blender::SDNA::structs, blender::SDNA_Struct::type_index, and blender::SDNA::types.

Referenced by print_struct_by_id(), print_structs_at_address(), and blender::writestruct_at_address_nr().

◆ read_file_data()

bool blender::dna::read_file_data ( const StringRefNull filepath,
Vector< char > & data )
staticnodiscard

Definition at line 57 of file dna_parse.cc.

References blender::data, read_file_data(), and blender::true.

Referenced by parse_dna_header(), and read_file_data().

◆ sdna_struct_id_get()

◆ sdna_struct_id_get_max()

int blender::dna::sdna_struct_id_get_max ( )

The maximum identifier that will be returned by sdna_struct_id_get in this Blender build.

References sdna_struct_id_get_max().

Referenced by sdna_struct_id_get_max(), and blender::writestruct_at_address_nr().

◆ shallow_copy()

template<typename T>
internal::ShallowDataConstRef< T > blender::dna::shallow_copy ( const T & other)
inlinenodiscard

Definition at line 147 of file DNA_defs.h.

References shallow_copy(), and T.

Referenced by blender::action_flip_pchan(), blender::annotation_draw_stabilizer(), blender::annotation_draw_stroke_buffer(), blender::annotation_stroke_newfrombuffer(), blender::ed::object::apply_objects_internal(), blender::BKE_armature_mat_pose_to_bone_ex(), blender::BKE_curvemapping_copy_data(), blender::BKE_curvemapping_copy_data_single(), blender::BKE_multires_create_deformed_base_mesh_vert_coords(), blender::BKE_nurb_copy(), blender::BKE_nurb_duplicate(), blender::BKE_object_minmax_dupli(), blender::BKE_paint_copy(), blender::BKE_paint_ensure(), blender::BKE_pose_backup_restore(), blender::BKE_previewimg_copy(), blender::BKE_scene_copy_data_eevee(), blender::BKE_scene_duplicate(), blender::BKE_texture_mtex_default(), blender::brush_copy_data(), blender::copy_mtex_copybuf(), blender::crazyspace_init_object_for_eval(), blender::curve_to_mesh_eval_ensure(), blender::evil::DEG_iterator_temp_object_from_dupli(), blender::draw::drw_batch_cache_generate_requested_evaluated_mesh_or_curve(), blender::DupliCacheManager::extract_all(), blender::draw::gpencil::gpencil_viewport_material_overrides(), blender::linestyle_copy_data(), blender::ed::sculpt_paint::mask::mask_from_boundary_exec(), blender::ed::sculpt_paint::mask::mask_from_cavity_exec(), blender::mesh_new_from_mesh_object_with_layers(), blender::multiresModifier_reshapeFromDeformModifier(), blender::nodes::node_composite_file_output_cc::node_copy_storage(), blender::nodes::node_fn_format_string_cc::node_copy_storage(), blender::nodes::node_geo_attribute_capture_cc::node_copy_storage(), blender::nodes::node_geo_bake_cc::node_copy_storage(), blender::nodes::node_geo_closure_cc::output_node::node_copy_storage(), blender::nodes::node_geo_combine_bundle_cc::node_copy_storage(), blender::nodes::node_geo_combine_list_cc::node_copy_storage(), blender::nodes::node_geo_evaluate_closure_cc::node_copy_storage(), blender::nodes::node_geo_field_to_grid_cc::node_copy_storage(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_copy_storage(), blender::nodes::node_geo_index_switch_cc::node_copy_storage(), blender::nodes::node_geo_menu_switch_cc::node_copy_storage(), blender::nodes::node_geo_rasterize_points::node_copy_storage(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_copy_storage(), blender::nodes::node_geo_separate_bundle_cc::node_copy_storage(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_copy_storage(), blender::nodes::node_geo_viewer_cc::node_copy_storage(), blender::nodes::node_shader_raycast_cc::node_copy_storage(), blender::ed::object::object_apply_location(), blender::paste_mtex_copybuf(), blender::pose_backup_create(), blender::property_search_all_tabs(), blender::RE_RenderAnim(), blender::RE_RenderFrame(), blender::ed::asset::shelf::regiondata_duplicate(), blender::render_copy_renderdata(), blender::schedule_write_result(), blender::bke::tests::SceneTest::SetUpTestSuite(), shallow_copy(), blender::side_region_search_all_categories(), blender::texfn(), blender::texture_paint_image_from_view_exec(), blender::DEGObjectIterData::transfer_from(), blender::userpref_search_all_tabs(), blender::vfont_char_build_impl(), blender::view3d_localview_init(), blender::wm_homefile_read_exec(), and blender::wm_userpref_read_exec().

◆ shallow_copy_array()

template<typename T>
void blender::dna::shallow_copy_array ( T * dst,
const T * src,
const int64_t size )
inline

Definition at line 152 of file DNA_defs.h.

References blender::_DNA_internal_memcpy(), shallow_copy_array(), and T.

Referenced by shallow_copy_array().

◆ shallow_swap()

template<typename T>
void blender::dna::shallow_swap ( T & a,
T & b )
inline

◆ shallow_zero_initialize()

◆ skip_balanced()

void blender::dna::skip_balanced ( TokenStream & stream,
TokenKind open,
TokenKind close )
static

Consume a balanced open ... close group. The current token must be #open.

Definition at line 381 of file dna_parse.cc.

References blender::dna::TokenStream::advance(), blender::dna::TokenStream::at_end(), blender::dna::TokenStream::consume(), blender::dna::Token::kind, and skip_balanced().

Referenced by parse_enum_declaration(), parse_paren_declaration(), and skip_balanced().

◆ skip_initializer()

void blender::dna::skip_initializer ( TokenStream & stream)
static

Skip member default initializer from = until ;.

Definition at line 397 of file dna_parse.cc.

References blender::dna::TokenStream::advance(), blender::dna::TokenStream::at_end(), ELEM, blender::dna::TokenStream::kind(), and skip_initializer().

Referenced by parse_struct_body(), and skip_initializer().

◆ skip_struct_body()

void blender::dna::skip_struct_body ( TokenStream & stream)
static

Skip the body of a struct by consuming tokens up to the matching }.

Definition at line 583 of file dna_parse.cc.

References blender::dna::TokenStream::at_end(), blender::dna::TokenStream::consume(), blender::dna::Token::kind, and skip_struct_body().

Referenced by parse_dna_header(), and skip_struct_body().

◆ strip_ignored_tokens()

◆ substitute_cpp_types()

◆ substitute_enum()

◆ substitute_listbase_t()

void blender::dna::substitute_listbase_t ( ParsedMember & member)
static

ListBaseT<...> -> ListBase.

Definition at line 725 of file dna_parse.cc.

References substitute_listbase_t(), and blender::dna::ParsedMember::type_name.

Referenced by substitute_cpp_types(), and substitute_listbase_t().

◆ substitute_sdna_integer_type()

void blender::dna::substitute_sdna_integer_type ( ParsedMember & member)
static

Map modern C integer type names to old SDNA names.

Definition at line 815 of file dna_parse.cc.

References substitute_sdna_integer_type(), and blender::dna::ParsedMember::type_name.

Referenced by substitute_cpp_types(), and substitute_sdna_integer_type().

◆ substitute_vector_or_matrix()

◆ TEST_F() [1/5]

blender::dna::TEST_F ( SDNATest ,
basic  )

Definition at line 80 of file makesdna_test.cc.

References blender::EXPECT_EQ(), and TEST_F().

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ TEST_F() [2/5]

◆ TEST_F() [3/5]

blender::dna::TEST_F ( SDNATest ,
struct_member_offset_by_name_without_alias  )

◆ TEST_F() [4/5]

◆ TEST_F() [5/5]

◆ tokenize_dna_header()

TokenStream blender::dna::tokenize_dna_header ( StringRef source)
static

Turn a DNA header into a token stream for parsing. Tokens will reference the source string data so it must be kept alive.

Definition at line 189 of file dna_parse.cc.

References blender::dna::TokenStream::append(), blender::begin(), blender::blender::StringRefBase::begin(), ELEM, blender::blender::StringRefBase::end(), is_identifier_continuation(), is_identifier_start(), blender::StringRef::StringRef(), TOKEN_IDENTIFIER, TOKEN_NUMBER, and tokenize_dna_header().

Referenced by parse_dna_header(), and tokenize_dna_header().

Variable Documentation

◆ cpp_array_type_mappings

const CppVectorMatrixTypeMap blender::dna::cpp_array_type_mappings[]
static
Initial value:
= {
{"int2", "int", {2, 0}, alignof(blender::int2)},
{"int3", "int", {3, 0}, alignof(blender::int3)},
{"int4", "int", {4, 0}, alignof(blender::int4)},
{"float2", "float", {2, 0}, alignof(blender::float2)},
{"float3", "float", {3, 0}, alignof(blender::float3)},
{"float4", "float", {4, 0}, alignof(blender::float4)},
{"float2x2", "float", {2, 2}, alignof(blender::float2x2)},
{"float3x3", "float", {3, 3}, alignof(blender::float3x3)},
{"float4x4", "float", {4, 4}, alignof(blender::float4x4)},
}
VecBase< float, 2 > float2
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3
VecBase< int32_t, 4 > int4
VecBase< float, 4 > float4
MatBase< float, 2, 2 > float2x2
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 3 > int3
MatBase< float, 3, 3 > float3x3

Definition at line 740 of file dna_parse.cc.

Referenced by substitute_vector_or_matrix().

◆ kListBaseStructId

int blender::dna::kListBaseStructId = 1
constexpr

Definition at line 75 of file makesdna_test.cc.

Referenced by TEST_F(), and TEST_F().

◆ kRawDataStructId

int blender::dna::kRawDataStructId = 0
constexpr

Definition at line 74 of file makesdna_test.cc.

Referenced by TEST_F().

◆ kStructWithEnumMembersId

int blender::dna::kStructWithEnumMembersId = 4
constexpr

Definition at line 78 of file makesdna_test.cc.

Referenced by TEST_F(), and TEST_F().

◆ kStructWithVectorMatrixTypesId

int blender::dna::kStructWithVectorMatrixTypesId = 3
constexpr

Definition at line 77 of file makesdna_test.cc.

Referenced by TEST_F(), and TEST_F().

◆ kTestStructId

int blender::dna::kTestStructId = 2
constexpr

Definition at line 76 of file makesdna_test.cc.

Referenced by TEST_F(), and TEST_F().

◆ TOKEN_END

TokenKind blender::dna::TOKEN_END = 258
constexpr

◆ TOKEN_IDENTIFIER

◆ TOKEN_NUMBER

TokenKind blender::dna::TOKEN_NUMBER = 257
constexpr

Definition at line 81 of file dna_parse.cc.

Referenced by tokenize_dna_header().