diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-12 17:06:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-12 17:06:17 +0300 |
commit | c234a35ab006dbc6c59bd980c925739d8035f936 (patch) | |
tree | 610c9df4ee4150c4eb34386c9f01517d7bdeb142 | |
parent | 5040c77bdbc9ef94dbc378e4c0606d7c5bb4f7c6 (diff) |
Use new struct names in versioning_dna.c
-rw-r--r-- | source/blender/blenloader/intern/versioning_dna.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/intern/dna_utils.c | 18 | ||||
-rwxr-xr-x | version_update_D4342_utility.py | 3 |
3 files changed, 15 insertions, 12 deletions
diff --git a/source/blender/blenloader/intern/versioning_dna.c b/source/blender/blenloader/intern/versioning_dna.c index 78c14c65f8c..dccc41f354f 100644 --- a/source/blender/blenloader/intern/versioning_dna.c +++ b/source/blender/blenloader/intern/versioning_dna.c @@ -46,11 +46,11 @@ /** * Included in DNA versioning code. * - * Currently use 'old' names when replacing struct members. + * Currently use 'new' names when replacing struct members. */ DNA_STRUCT_REPLACE(Lamp, Light) -DNA_STRUCT_MEMBER_REPLACE(Lamp, clipsta, clip_start) -DNA_STRUCT_MEMBER_REPLACE(Lamp, clipend, clip_end) +DNA_STRUCT_MEMBER_REPLACE(Light, clipsta, clip_start) +DNA_STRUCT_MEMBER_REPLACE(Light, clipend, clip_end) DNA_STRUCT_MEMBER_REPLACE(LightProbe, clipsta, clip_start) DNA_STRUCT_MEMBER_REPLACE(LightProbe, clipend, clip_end) DNA_STRUCT_MEMBER_REPLACE(Camera, clipsta, clip_start) diff --git a/source/blender/makesdna/intern/dna_utils.c b/source/blender/makesdna/intern/dna_utils.c index 690ec42e321..bc849417e21 100644 --- a/source/blender/makesdna/intern/dna_utils.c +++ b/source/blender/makesdna/intern/dna_utils.c @@ -200,8 +200,8 @@ void DNA_softupdate_maps( enum eDNAVersionDir version_dir, GHash **r_struct_map, GHash **r_elem_map) { - - if (r_struct_map != NULL) { + GHash *struct_map_local; + if (r_struct_map) { const char *data[][2] = { #define DNA_STRUCT_REPLACE(old, new) {#old, #new}, #define DNA_STRUCT_MEMBER_REPLACE(struct_name, old, new) @@ -214,18 +214,22 @@ void DNA_softupdate_maps( if (version_dir == DNA_VERSION_RUNTIME_FROM_STATIC) { elem_key = 0; elem_val = 1; - } else { elem_key = 1; elem_val = 0; } - GHash *struct_map = BLI_ghash_str_new_ex(__func__, ARRAY_SIZE(data)); for (int i = 0; i < ARRAY_SIZE(data); i++) { BLI_ghash_insert(struct_map, (void *)data[i][elem_key], (void *)data[i][elem_val]); } *r_struct_map = struct_map; + + /* We know the direction of this, for local use. */ + struct_map_local = BLI_ghash_str_new_ex(__func__, ARRAY_SIZE(data)); + for (int i = 0; i < ARRAY_SIZE(data); i++) { + BLI_ghash_insert(struct_map_local, (void *)data[i][1], (void *)data[i][0]); + } } if (r_elem_map != NULL) { @@ -241,7 +245,6 @@ void DNA_softupdate_maps( if (version_dir == DNA_VERSION_RUNTIME_FROM_STATIC) { elem_key = 1; elem_val = 2; - } else { elem_key = 2; @@ -249,10 +252,13 @@ void DNA_softupdate_maps( } GHash *elem_map = BLI_ghash_new_ex(strhash_pair_p, strhash_pair_cmp, __func__, ARRAY_SIZE(data)); for (int i = 0; i < ARRAY_SIZE(data); i++) { - dna_softupdate_ghash_add_pair(elem_map, data[i][0], data[i][elem_key], (void *)data[i][elem_val]); + const char *struct_old = BLI_ghash_lookup_default(struct_map_local, data[i][0], (void *)data[i][0]); + dna_softupdate_ghash_add_pair(elem_map, struct_old, data[i][elem_key], (void *)data[i][elem_val]); } *r_elem_map = elem_map; } + + BLI_ghash_free(struct_map_local, NULL, NULL); } #undef DNA_MAKESDNA diff --git a/version_update_D4342_utility.py b/version_update_D4342_utility.py index d901c52cf7f..69e2f3e3601 100755 --- a/version_update_D4342_utility.py +++ b/version_update_D4342_utility.py @@ -19,7 +19,6 @@ replace_tables = ( replace_all, ) - replace_tables_re = [ [(src, dst) for src, dst in table] for table in replace_tables @@ -52,8 +51,6 @@ def source_files(path): if filename.endswith("versioning_dna.c"): continue - # if ext.lower() in {".py"}: - # if ext.lower() in {".c", ".cc", ".cxx", ".cpp", ".h", ".hxx", ".hpp", ".py"}: if ext.lower() in {".c", ".cc", ".cxx", ".cpp", ".h", ".hxx", ".hpp"}: yield os.path.join(dirpath, filename) |