Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesdna/intern/dna_genfile.c')
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c52
1 files changed, 8 insertions, 44 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 4f19e819625..99ab29fbdcc 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -43,6 +43,7 @@
#include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN
#include "BLI_utildefines.h"
+#include "BLI_endian_switch.h"
#ifdef WITH_DNA_GHASH
# include "BLI_ghash.h"
@@ -1126,7 +1127,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
*/
int a, mul, elemcount, elen, elena, firststructtypenr;
const short *spo, *spc;
- char *cpo, *cur, cval;
+ char *cur;
const char *type, *name;
if (oldSDNAnr == -1) return;
@@ -1148,9 +1149,9 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
/* test: is type a struct? */
if (spc[0] >= firststructtypenr && !ispointer(name)) {
- /* struct field type */
+ /* struct field type */
/* where does the old data start (is there one?) */
- cpo = find_elem(oldsdna, type, name, spo, data, NULL);
+ char *cpo = find_elem(oldsdna, type, name, spo, data, NULL);
if (cpo) {
oldSDNAnr = DNA_struct_find_nr(oldsdna, type);
@@ -1167,18 +1168,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
/* non-struct field type */
if (ispointer(name)) {
if (oldsdna->pointerlen == 8) {
-
- mul = DNA_elem_array_size(name);
- cpo = cur;
- while (mul--) {
- cval = cpo[0]; cpo[0] = cpo[7]; cpo[7] = cval;
- cval = cpo[1]; cpo[1] = cpo[6]; cpo[6] = cval;
- cval = cpo[2]; cpo[2] = cpo[5]; cpo[5] = cval;
- cval = cpo[3]; cpo[3] = cpo[4]; cpo[4] = cval;
-
- cpo += 8;
- }
-
+ BLI_endian_switch_int64_array((int64_t *)cur, DNA_elem_array_size(name));
}
}
else {
@@ -1191,14 +1181,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
}
if (skip == false) {
- mul = DNA_elem_array_size(name);
- cpo = cur;
- while (mul--) {
- cval = cpo[0];
- cpo[0] = cpo[1];
- cpo[1] = cval;
- cpo += 2;
- }
+ BLI_endian_switch_int16_array((int16_t *)cur, DNA_elem_array_size(name));
}
}
else if (ELEM(spc[0], SDNA_TYPE_INT, SDNA_TYPE_FLOAT)) {
@@ -1206,29 +1189,10 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
* but turns out we only used for runtime vars and
* only once for a struct type thats no longer used. */
- mul = DNA_elem_array_size(name);
- cpo = cur;
- while (mul--) {
- cval = cpo[0];
- cpo[0] = cpo[3];
- cpo[3] = cval;
- cval = cpo[1];
- cpo[1] = cpo[2];
- cpo[2] = cval;
- cpo += 4;
- }
+ BLI_endian_switch_int32_array((int32_t *)cur, DNA_elem_array_size(name));
}
else if (ELEM(spc[0], SDNA_TYPE_INT64, SDNA_TYPE_UINT64, SDNA_TYPE_DOUBLE)) {
- mul = DNA_elem_array_size(name);
- cpo = cur;
- while (mul--) {
- cval = cpo[0]; cpo[0] = cpo[7]; cpo[7] = cval;
- cval = cpo[1]; cpo[1] = cpo[6]; cpo[6] = cval;
- cval = cpo[2]; cpo[2] = cpo[5]; cpo[5] = cval;
- cval = cpo[3]; cpo[3] = cpo[4]; cpo[4] = cval;
-
- cpo += 8;
- }
+ BLI_endian_switch_int64_array((int64_t *)cur, DNA_elem_array_size(name));
}
}
}