|
Blender
V2.59
|
Struct muncher for making SDNA. More...
#include <string.h>#include <stdlib.h>#include <stdio.h>#include "MEM_guardedalloc.h"#include "DNA_sdna_types.h"#include "BLO_sys_types.h"#include "DNA_listBase.h"#include "DNA_vec_types.h"#include "DNA_ID.h"#include "DNA_ipo_types.h"#include "DNA_key_types.h"#include "DNA_text_types.h"#include "DNA_packedFile_types.h"#include "DNA_camera_types.h"#include "DNA_image_types.h"#include "DNA_texture_types.h"#include "DNA_lamp_types.h"#include "DNA_material_types.h"#include "DNA_vfont_types.h"#include "DNA_meta_types.h"#include "DNA_curve_types.h"#include "DNA_mesh_types.h"#include "DNA_meshdata_types.h"#include "DNA_modifier_types.h"#include "DNA_lattice_types.h"#include "DNA_object_types.h"#include "DNA_object_force.h"#include "DNA_object_fluidsim.h"#include "DNA_world_types.h"#include "DNA_scene_types.h"#include "DNA_view3d_types.h"#include "DNA_view2d_types.h"#include "DNA_space_types.h"#include "DNA_userdef_types.h"#include "DNA_screen_types.h"#include "DNA_fileglobal_types.h"#include "DNA_sequence_types.h"#include "DNA_effect_types.h"#include "DNA_outliner_types.h"#include "DNA_property_types.h"#include "DNA_sensor_types.h"#include "DNA_controller_types.h"#include "DNA_actuator_types.h"#include "DNA_sound_types.h"#include "DNA_group_types.h"#include "DNA_armature_types.h"#include "DNA_action_types.h"#include "DNA_constraint_types.h"#include "DNA_nla_types.h"#include "DNA_node_types.h"#include "DNA_color_types.h"#include "DNA_brush_types.h"#include "DNA_customdata_types.h"#include "DNA_particle_types.h"#include "DNA_cloth_types.h"#include "DNA_gpencil_types.h"#include "DNA_windowmanager_types.h"#include "DNA_anim_types.h"#include "DNA_boid_types.h"#include "DNA_smoke_types.h"Go to the source code of this file.
Defines | |
| #define | DNA_VERSION_DATE "$Id: makesdna.c 37613 2011-06-18 03:14:24Z campbellbarton $" |
| #define | SDNA_MAX_FILENAME_LENGTH 255 |
| #define | MAX_DNA_LINE_LENGTH 20 |
| #define | BASE_HEADER "../" |
Functions | |
| int | add_type (const char *str, int len) |
| int | add_name (char *str) |
| short * | add_struct (int namecode) |
| int | preprocess_include (char *maindata, int len) |
| int | convert_include (char *filename) |
| int | arraysize (char *astr, int len) |
| static int | calculate_structlens (int) |
| void | dna_write (FILE *file, void *pntr, int size) |
| void | printStructLenghts (void) |
| static void * | read_file_data (char *filename, int *len_r) |
| int | make_structDNA (char *baseDirectory, FILE *file) |
| static void | make_bad_file (char *file, int line) |
| int | main (int argc, char **argv) |
Variables | |
| const char * | includefiles [] |
| int | maxdata = 500000 |
| int | maxnr = 50000 |
| int | nr_names = 0 |
| int | nr_types = 0 |
| int | nr_structs = 0 |
| char ** | names |
| char * | namedata |
| char ** | types |
| char * | typedata |
| short * | typelens |
| short * | alphalens |
| short ** | structs |
| short * | structdata |
| int | debugSDNA = 0 |
| int | additional_slen_offset |
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 1099 of file makesdna.c.
Referenced by main().
| #define DNA_VERSION_DATE "$Id: makesdna.c 37613 2011-06-18 03:14:24Z campbellbarton $" |
Definition at line 53 of file makesdna.c.
Referenced by make_structDNA().
| #define MAX_DNA_LINE_LENGTH 20 |
Definition at line 847 of file makesdna.c.
Referenced by dna_write().
| #define SDNA_MAX_FILENAME_LENGTH 255 |
Definition at line 64 of file makesdna.c.
Referenced by make_structDNA().
| int add_name | ( | char * | str | ) |
Add variable str to
| str | 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 271 of file makesdna.c.
References additional_slen_offset, debugSDNA, i, maxnr, namedata, names, nr_names, NULL, and str.
Referenced by convert_include().
| short * add_struct | ( | int | namecode | ) |
Search whether this structure type was already found, and if not, add it.
Definition at line 400 of file makesdna.c.
References maxnr, nr_structs, structdata, and structs.
Referenced by convert_include().
| int add_type | ( | const char * | str, |
| int | len | ||
| ) |
Add type str to struct indexed by len, if it was not yet found.
| str | char |
| len | int |
Definition at line 225 of file makesdna.c.
References alphalens, maxnr, nr_types, typedata, typelens, and types.
Referenced by convert_include(), and make_structDNA().
| int arraysize | ( | char * | astr, |
| int | len | ||
| ) |
Determine how many bytes are needed for an array.
Definition at line 660 of file makesdna.c.
References mul(), NULL, and str.
Referenced by calculate_structlens().
| static int calculate_structlens | ( | int | firststruct | ) | [static] |
Determine how many bytes are needed for each struct.
Definition at line 682 of file makesdna.c.
References alphalens, arraysize(), debugSDNA, mul(), names, nr_structs, structs, typelens, and types.
Referenced by make_structDNA().
| int convert_include | ( | char * | filename | ) |
Scan this file for serializable types.
Definition at line 523 of file makesdna.c.
References add_name(), add_struct(), add_type(), additional_slen_offset, debugSDNA, MEM_freeN(), names, NULL, preprocess_include(), read_file_data(), and types.
Referenced by make_structDNA().
| void dna_write | ( | FILE * | file, |
| void * | pntr, | ||
| int | size | ||
| ) |
Construct the DNA.c file
Definition at line 849 of file makesdna.c.
References i, MAX_DNA_LINE_LENGTH, and size().
Referenced by make_structDNA().
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 1102 of file makesdna.c.
References BASE_HEADER, make_bad_file(), and make_structDNA().
Referenced by blo_split_main(), KX_BlenderSceneConverter::FreeBlendFile(), KX_BlenderSceneConverter::GetBlenderSceneForName(), RNA_main_pointer_create(), write_libraries(), and KX_BlenderSceneConverter::~KX_BlenderSceneConverter().
| static void make_bad_file | ( | char * | file, |
| int | line | ||
| ) | [static] |
Definition at line 1091 of file makesdna.c.
Referenced by main().
| int make_structDNA | ( | char * | baseDirectory, |
| FILE * | file | ||
| ) |
Definition at line 892 of file makesdna.c.
References add_type(), alphalens, calculate_structlens(), convert_include(), debugSDNA, DNA_VERSION_DATE, dna_write(), i, includefiles, maxdata, maxnr, MEM_callocN(), MEM_freeN(), namedata, names, nr_names, nr_structs, nr_types, NULL, SDNA_MAX_FILENAME_LENGTH, str, structdata, structs, typedata, typelens, and types.
Referenced by main().
| int preprocess_include | ( | char * | maindata, |
| int | len | ||
| ) |
Remove comments from this buffer. Assumes that the buffer refers to ascii-code text.
Definition at line 426 of file makesdna.c.
References MEM_freeN(), and MEM_mallocN().
Referenced by convert_include().
| void printStructLenghts | ( | void | ) |
Report all structures found so far, and print their lengths.
Definition at line 868 of file makesdna.c.
References nr_structs, structs, typelens, and types.
| static void* read_file_data | ( | char * | filename, |
| int * | len_r | ||
| ) | [static] |
Definition at line 487 of file makesdna.c.
References L, MEM_freeN(), MEM_mallocN(), and NULL.
Referenced by convert_include().
Definition at line 161 of file makesdna.c.
Referenced by add_name(), and convert_include().
| short* alphalens |
Definition at line 147 of file makesdna.c.
Referenced by add_type(), calculate_structlens(), and make_structDNA().
| int debugSDNA = 0 |
Variable to control debug output of makesdna. debugSDNA:
Definition at line 160 of file makesdna.c.
Referenced by add_name(), calculate_structlens(), convert_include(), and make_structDNA().
| const char* includefiles[] |
Definition at line 69 of file makesdna.c.
Referenced by make_structDNA().
| int maxdata = 500000 |
Definition at line 140 of file makesdna.c.
Referenced by make_structDNA().
| int maxnr = 50000 |
Definition at line 140 of file makesdna.c.
Referenced by add_name(), add_struct(), add_type(), and make_structDNA().
| char * namedata |
Definition at line 144 of file makesdna.c.
Referenced by add_name(), and make_structDNA().
| char** names |
Definition at line 144 of file makesdna.c.
Referenced by _bpy_names(), add_name(), BLO_blendhandle_get_datablock_names(), BLO_blendhandle_get_linkable_groups(), calculate_structlens(), convert_include(), do_view3d_region_buttons(), filelist_from_library(), gpu_shader_math(), gpu_shader_mix_rgb(), gpu_shader_vect_math(), KX_BlenderSceneConverter::LinkBlendFile(), make_structDNA(), make_unique_prop_names(), and ramp_blend().
| int nr_names = 0 |
Definition at line 141 of file makesdna.c.
Referenced by add_name(), init_structDNA(), and make_structDNA().
| int nr_structs = 0 |
Definition at line 143 of file makesdna.c.
Referenced by add_struct(), calculate_structlens(), init_structDNA(), make_structDNA(), and printStructLenghts().
| int nr_types = 0 |
Definition at line 142 of file makesdna.c.
Referenced by add_type(), init_structDNA(), and make_structDNA().
| short * structdata |
Definition at line 148 of file makesdna.c.
Referenced by add_struct(), and make_structDNA().
| short** structs |
Definition at line 148 of file makesdna.c.
Referenced by add_struct(), calculate_structlens(), make_structDNA(), and printStructLenghts().
| char * typedata |
Definition at line 145 of file makesdna.c.
Referenced by add_type(), and make_structDNA().
| short* typelens |
Definition at line 146 of file makesdna.c.
Referenced by add_type(), calculate_structlens(), make_structDNA(), and printStructLenghts().
| char** types |
Definition at line 145 of file makesdna.c.
Referenced by add_type(), BLI_adddirstrings(), calculate_structlens(), convert_include(), make_structDNA(), modifierType_getInfo(), printStructLenghts(), and DocumentImporter::translate_anim_recursive().