|
Blender
V2.93
|
Struct muncher for making SDNA. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "MEM_guardedalloc.h"#include "BLI_alloca.h"#include "BLI_ghash.h"#include "BLI_memarena.h"#include "BLI_sys_types.h"#include "BLI_system.h"#include "BLI_utildefines.h"#include "dna_utils.h"#include "DNA_ID.h"#include "DNA_action_types.h"#include "DNA_anim_types.h"#include "DNA_armature_types.h"#include "DNA_asset_types.h"#include "DNA_boid_types.h"#include "DNA_brush_types.h"#include "DNA_cachefile_types.h"#include "DNA_camera_types.h"#include "DNA_cloth_types.h"#include "DNA_collection_types.h"#include "DNA_color_types.h"#include "DNA_constraint_types.h"#include "DNA_curve_types.h"#include "DNA_curveprofile_types.h"#include "DNA_customdata_types.h"#include "DNA_dynamicpaint_types.h"#include "DNA_effect_types.h"#include "DNA_fileglobal_types.h"#include "DNA_fluid_types.h"#include "DNA_freestyle_types.h"#include "DNA_gpencil_modifier_types.h"#include "DNA_gpencil_types.h"#include "DNA_hair_types.h"#include "DNA_image_types.h"#include "DNA_ipo_types.h"#include "DNA_key_types.h"#include "DNA_lattice_types.h"#include "DNA_layer_types.h"#include "DNA_light_types.h"#include "DNA_lightprobe_types.h"#include "DNA_lineart_types.h"#include "DNA_linestyle_types.h"#include "DNA_listBase.h"#include "DNA_mask_types.h"#include "DNA_material_types.h"#include "DNA_mesh_types.h"#include "DNA_meshdata_types.h"#include "DNA_meta_types.h"#include "DNA_modifier_types.h"#include "DNA_movieclip_types.h"#include "DNA_nla_types.h"#include "DNA_node_types.h"#include "DNA_object_fluidsim_types.h"#include "DNA_object_force_types.h"#include "DNA_object_types.h"#include "DNA_outliner_types.h"#include "DNA_packedFile_types.h"#include "DNA_particle_types.h"#include "DNA_pointcache_types.h"#include "DNA_pointcloud_types.h"#include "DNA_rigidbody_types.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "DNA_sdna_types.h"#include "DNA_sequence_types.h"#include "DNA_session_uuid_types.h"#include "DNA_shader_fx_types.h"#include "DNA_simulation_types.h"#include "DNA_sound_types.h"#include "DNA_space_types.h"#include "DNA_speaker_types.h"#include "DNA_text_types.h"#include "DNA_texture_types.h"#include "DNA_tracking_types.h"#include "DNA_userdef_types.h"#include "DNA_vec_types.h"#include "DNA_vfont_types.h"#include "DNA_view2d_types.h"#include "DNA_view3d_types.h"#include "DNA_volume_types.h"#include "DNA_windowmanager_types.h"#include "DNA_workspace_types.h"#include "DNA_world_types.h"#include "DNA_xr_types.h"#include "dna_rename_defs.h"Go to the source code of this file.
Macros | |
| #define | DNA_DEPRECATED_ALLOW |
| #define | SDNA_MAX_FILENAME_LENGTH 255 |
| #define | DNA_STRUCT_RENAME(old, new) (void)sizeof(new); |
| #define | DNA_STRUCT_RENAME_ELEM(struct_name, old, new) (void)offsetof(struct_name, new); |
Functions | |
Function Declarations | |
| static int | add_type (const char *str, int size) |
| static int | add_name (const char *str) |
| static short * | add_struct (int namecode) |
| static int | preprocess_include (char *maindata, const int maindata_len) |
| static int | convert_include (const char *filename) |
| static int | calculate_struct_sizes (int firststruct, FILE *file_verify, const char *base_directory) |
| static void | dna_write (FILE *file, const void *pntr, const int size) |
| void | print_struct_sizes (void) |
DNA Renaming Sanity Check | |
Disable types:
Only valid use would be as a runtime variable if an API expected a long, but so far we don't have this happening. Without this it's possible to reference struct members that don't exist, breaking backward & forward compatibility. | |
| static void UNUSED_FUNCTION() | dna_rename_defs_ensure (void) |
Variables | |
| static const char * | includefiles [] |
Variables | |
| #define | DEBUG_PRINTF(debug_level, ...) |
| static MemArena * | mem_arena = NULL |
| static int | max_data_size = 500000 |
| static int | max_array_len = 50000 |
| static int | names_len = 0 |
| static int | types_len = 0 |
| static int | structs_len = 0 |
| static char ** | names |
| static char ** | types |
| static short * | types_size_native |
| static short * | types_align_32 |
| static short * | types_align_64 |
| static short * | types_size_32 |
| static short * | types_size_64 |
| static short ** | structs |
| static short * | structdata |
| struct { | |
| GHash * struct_map_alias_from_static | |
| GHash * struct_map_static_from_alias | |
| GHash * elem_map_alias_from_static | |
| GHash * elem_map_static_from_alias | |
| } | g_version_data = {NULL} |
| static int | debugSDNA = 0 |
| static int | additional_slen_offset |
| void | BLI_system_backtrace (FILE *fp) |
Implementation | |
| #define | MAX_DNA_LINE_LENGTH 20 |
| static const char * | version_struct_static_from_alias (const char *str) |
| static const char * | version_struct_alias_from_static (const char *str) |
| static const char * | version_elem_static_from_alias (const int strct, const char *elem_alias_full) |
| static bool | is_name_legal (const char *name) |
| static void * | read_file_data (const char *filename, int *r_len) |
| static bool | check_field_alignment (int firststruct, int structtype, int type, int len, const char *name, const char *detail) |
| static int | make_structDNA (const char *base_directory, FILE *file, FILE *file_offsets, FILE *file_verify) |
Main Function | |
| #define | BASE_HEADER "../" |
| static void | make_bad_file (const char *file, int line) |
| int | main (int argc, char **argv) |
Struct muncher for making SDNA.
Originally by Ton, some mods by Frank, and some cleaning and extension by Nzc.
Makesdna creates a .c file with a long string of numbers that encode the Blender file format. It is fast, because it is basically a binary dump. There are some details to mind when reconstructing the file (endianness and byte-alignment).
This little program scans all structs that need to be serialized, and determined the names and types of all members. It calculates how much memory (on disk or in ram) is needed to store that struct, and the offsets for reaching a particular one.
There is a facility to get verbose output from sdna. Search for debugSDNA. This int can be set to 0 (no output) to some int. Higher numbers give more output.
Definition in file makesdna.c.
| #define BASE_HEADER "../" |
Definition at line 1482 of file makesdna.c.
| #define DEBUG_PRINTF | ( | debug_level, | |
| ... | |||
| ) |
Definition at line 202 of file makesdna.c.
| #define DNA_DEPRECATED_ALLOW |
Definition at line 44 of file makesdna.c.
| #define MAX_DNA_LINE_LENGTH 20 |
Definition at line 1173 of file makesdna.c.
| #define SDNA_MAX_FILENAME_LENGTH 255 |
Definition at line 61 of file makesdna.c.
|
static |
Ensure str is int the names array.
| str | Struct member name which may include pointer prefix & array size. |
Because of the weird way of tokenizing, we have to 'cast' function pointers to ... (*f)(), whatever the original signature. In fact, we add name and type at the same time... There are two special cases, unfortunately. These are explicitly checked.
Definition at line 413 of file makesdna.c.
References additional_slen_offset, BLI_memarena_alloc(), DEBUG_PRINTF, is_name_legal(), max_array_len, mem_arena, names, names_len, NULL, str, and STREQ.
Referenced by convert_include().
|
static |
Search whether this structure type was already found, and if not, add it.
Definition at line 552 of file makesdna.c.
References len, max_array_len, structdata, structs, and structs_len.
Referenced by convert_include().
|
static |
Ensure type str to is in the types array.
| str | Struct name without any qualifiers. |
| size | The struct size in bytes. |
Definition at line 360 of file makesdna.c.
References BLI_memarena_alloc(), max_array_len, mem_arena, size(), str, STREQ, types, types_align_32, types_align_64, types_len, types_size_32, types_size_64, types_size_native, and version_struct_static_from_alias().
Referenced by convert_include(), and make_structDNA().
| void BLI_system_backtrace | ( | FILE * | fp | ) |
Write a backtrace into a file for systems which support it.
Definition at line 212 of file makesdna.c.
|
static |
Determine how many bytes are needed for each struct.
Definition at line 899 of file makesdna.c.
References Freestyle::a, BLI_assert, BLI_ghash_lookup(), check_field_alignment(), debugSDNA, DNA_elem_array_size(), DNA_elem_id_strip_copy(), ELEM, g_version_data, includefiles, MAX2, mul(), names, structs, structs_len, type, types, types_align_32, types_align_64, types_size_32, types_size_64, types_size_native, and version_struct_alias_from_static().
Referenced by make_structDNA().
|
static |
Definition at line 865 of file makesdna.c.
References len, result, type, types, and types_size_native.
Referenced by calculate_struct_sizes().
|
static |
Scan this file for serializable types.
Definition at line 687 of file makesdna.c.
References add_name(), add_struct(), add_type(), additional_slen_offset, count, DEBUG_PRINTF, ELEM, MEM_freeN, names, NULL, preprocess_include(), read_file_data(), type, types, and version_elem_static_from_alias().
Referenced by make_structDNA().
|
static |
Definition at line 1663 of file makesdna.c.
|
static |
Construct the DNA.c file
Definition at line 1175 of file makesdna.c.
References data, file, MAX_DNA_LINE_LENGTH, and size().
Referenced by make_structDNA().
|
static |
Enforce '_pad123' naming convention, disallow 'pad123' or 'pad_123', special exception for [a-z] after since there is a 'pad_rot_angle' preference.
Definition at line 321 of file makesdna.c.
References Freestyle::c, and DNA_elem_id_strip_copy().
Referenced by add_name().
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 1485 of file makesdna.c.
References BASE_HEADER, ELEM, make_bad_file(), make_structDNA(), and NULL.
|
static |
|
static |
Insertion of all known types.
Definition at line 1209 of file makesdna.c.
References Freestyle::a, add_type(), BLI_ghash_free(), BLI_gset_add(), BLI_gset_clear(), BLI_gset_free(), BLI_gset_str_new_ex(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, calculate_struct_sizes(), convert_include(), DEBUG_PRINTF, debugSDNA, DNA_alias_maps(), DNA_elem_id_strip(), DNA_RENAME_ALIAS_FROM_STATIC, DNA_RENAME_STATIC_FROM_ALIAS, dna_write(), file, g_version_data, includefiles, len, max_array_len, max_data_size, mem_arena, MEM_callocN, MEM_freeN, names, names_len, NULL, SDNA_MAX_FILENAME_LENGTH, str, structdata, structs, structs_len, types, types_align_32, types_align_64, types_len, types_size_32, types_size_64, types_size_native, and version_struct_alias_from_static().
Referenced by main().
|
static |
Remove comments from this buffer. Assumes that the buffer refers to ascii-code text.
Definition at line 575 of file makesdna.c.
References Freestyle::a, MEM_freeN, and MEM_mallocN.
Referenced by convert_include().
| void print_struct_sizes | ( | void | ) |
Report all structures found so far, and print their lengths.
Definition at line 1190 of file makesdna.c.
References Freestyle::a, structs, structs_len, types, and types_size_native.
|
static |
Definition at line 646 of file makesdna.c.
References data, L, MEM_freeN, MEM_mallocN, and NULL.
Referenced by convert_include().
|
static |
Definition at line 297 of file makesdna.c.
References BLI_ghash_lookup(), DNA_elem_id_offset_start(), DNA_elem_id_rename(), DNA_elem_id_strip_copy(), g_version_data, mem_arena, NULL, and types.
Referenced by convert_include().
|
static |
Definition at line 288 of file makesdna.c.
References BLI_ghash_lookup(), g_version_data, NULL, and str.
Referenced by calculate_struct_sizes(), and make_structDNA().
|
static |
Definition at line 279 of file makesdna.c.
References BLI_ghash_lookup(), g_version_data, NULL, and str.
Referenced by add_type().
|
static |
Definition at line 200 of file makesdna.c.
Referenced by add_name(), and convert_include().
|
static |
Variable to control debug output of makesdna. debugSDNA:
Definition at line 199 of file makesdna.c.
Referenced by calculate_struct_sizes(), and make_structDNA().
| GHash* elem_map_alias_from_static |
Definition at line 187 of file makesdna.c.
Referenced by DNA_sdna_alias_data_ensure(), and dna_sdna_alias_from_static_elem_full().
| GHash* elem_map_static_from_alias |
Definition at line 188 of file makesdna.c.
| struct { ... } g_version_data |
Versioning data
Referenced by calculate_struct_sizes(), make_structDNA(), version_elem_static_from_alias(), version_struct_alias_from_static(), and version_struct_static_from_alias().
|
static |
Definition at line 65 of file makesdna.c.
Referenced by calculate_struct_sizes(), and make_structDNA().
|
static |
Definition at line 157 of file makesdna.c.
Referenced by add_name(), add_struct(), add_type(), and make_structDNA().
|
static |
Definition at line 157 of file makesdna.c.
Referenced by make_structDNA().
Definition at line 155 of file makesdna.c.
Referenced by add_name(), add_new_bound_vert(), add_type(), adj_vmesh(), BM_face_split_edgenet_connect_islands(), build_boundary(), build_boundary_terminal_edge(), DNA_elem_id_rename(), edbm_face_split_by_edges_exec(), ghash_insert_face_edge_link(), ghash_insert_link(), make_cube_corner_adj_vmesh(), make_cube_corner_square(), make_cube_corner_square_in(), make_structDNA(), new_adj_vmesh(), and version_elem_static_from_alias().
|
static |
At address names[a] is string a.
Definition at line 162 of file makesdna.c.
Referenced by _bpy_names(), add_name(), BKE_image_add_generated(), BKE_sound_get_device_names(), BLO_blendhandle_get_datablock_names(), BLO_blendhandle_get_linkable_groups(), BLO_main_validate_libraries(), bpy_pydriver_create_dict(), calculate_struct_sizes(), convert_include(), blender::compositor::OutputStereoOperation::deinitExecution(), driver_compile_simple_expr_impl(), elem_exists_impl(), filelist_readjob_list_lib(), blender::nodes::find_all_attribute_names(), blender::compositor::OutputStereoOperation::get_handle(), blender::nodes::GeoNodeExecParams::get_highest_priority_input_domain(), gpu_shader_mapping(), gpu_shader_mix_rgb(), gpu_shader_tex_white_noise(), image_save_single(), image_update_views_format(), IMB_thumb_load_blend(), make_structDNA(), node_shader_gpu_tex_environment(), node_shader_gpu_tex_musgrave(), node_shader_gpu_tex_noise(), node_shader_gpu_tex_voronoi(), parse_for_eval(), RE_WriteRenderViewsImage(), RE_WriteRenderViewsMovie(), sequencer_draw_preview(), TEST(), SocketType::type_name(), uilist_filter_items_default(), and view3d_stereo3d_setup().
|
static |
Definition at line 158 of file makesdna.c.
Referenced by add_name(), driver_compile_simple_expr_impl(), and make_structDNA().
| GHash* struct_map_alias_from_static |
Definition at line 185 of file makesdna.c.
Referenced by DNA_sdna_alias_data_ensure().
| GHash* struct_map_static_from_alias |
Definition at line 186 of file makesdna.c.
|
static |
Definition at line 181 of file makesdna.c.
Referenced by add_struct(), and make_structDNA().
|
static |
At sp = structs[a] is the first address of a struct definition:
sp[0] is type number.sp[1] is the length of the element array (next).sp[2] sp[3] is [(type_index, name_index), ..] (number of pairs is defined by sp[1]), Definition at line 181 of file makesdna.c.
Referenced by add_struct(), calculate_struct_sizes(), dna_struct_find_nr_ex_impl(), make_structDNA(), and print_struct_sizes().
|
static |
Definition at line 160 of file makesdna.c.
Referenced by add_struct(), calculate_struct_sizes(), dna_struct_find_nr_ex_impl(), make_structDNA(), and print_struct_sizes().
|
static |
At address types[a] is string a.
Definition at line 164 of file makesdna.c.
Referenced by add_type(), Device::available_types(), BLI_filelist_entry_mode_to_string(), calculate_struct_sizes(), check_field_alignment(), convert_include(), curve_render_data_create(), data_offer_offer(), dna_struct_find_nr_ex_impl(), elem_exists_impl(), AnimationImporter::get_animation_type(), lattice_render_data_create(), lineart_gpencil_generate(), lineart_rb_edge_types(), main(), make_structDNA(), options_parse(), print_struct_sizes(), AnimationImporter::setAnimType(), sort_bmelem_flag(), DocumentImporter::translate_anim_recursive(), and version_elem_static_from_alias().
|
static |
Contains align requirements for a struct on 32 bit systems.
Definition at line 168 of file makesdna.c.
Referenced by add_type(), calculate_struct_sizes(), and make_structDNA().
|
static |
Contains align requirements for a struct on 64 bit systems.
Definition at line 170 of file makesdna.c.
Referenced by add_type(), calculate_struct_sizes(), and make_structDNA().
|
static |
Definition at line 159 of file makesdna.c.
Referenced by add_type(), and make_structDNA().
|
static |
Contains sizes as they are calculated on 32 bit systems.
Definition at line 172 of file makesdna.c.
Referenced by add_type(), calculate_struct_sizes(), and make_structDNA().
|
static |
Contains sizes as they are calculated on 64 bit systems.
Definition at line 174 of file makesdna.c.
Referenced by add_type(), calculate_struct_sizes(), and make_structDNA().
|
static |
At types_size[a] is the size of type a on this systems bitness (32 or 64).
Definition at line 166 of file makesdna.c.
Referenced by add_type(), calculate_struct_sizes(), check_field_alignment(), make_structDNA(), and print_struct_sizes().