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:
authorJacques Lucke <jacques@blender.org>2020-06-05 14:54:51 +0300
committerJacques Lucke <jacques@blender.org>2020-06-05 14:55:45 +0300
commit60a786e711e9b821bb5c475ecffe24a67ccccd68 (patch)
tree97030a50acdb535ccc36930caac44f531e40596c
parent5ed2ed28ab308ed65290c3a36f0ff652cb710e94 (diff)
Refactor: use compile time dna struct ids in blenloader api
-rw-r--r--source/blender/blenloader/BLO_read_write.h8
-rw-r--r--source/blender/blenloader/intern/writefile.c3
2 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h
index e5d973b9ef8..1b86b5668cc 100644
--- a/source/blender/blenloader/BLO_read_write.h
+++ b/source/blender/blenloader/BLO_read_write.h
@@ -41,6 +41,9 @@
#ifndef __BLO_READ_WRITE_H__
#define __BLO_READ_WRITE_H__
+/* for SDNA_TYPE_FROM_STRUCT() macro */
+#include "dna_type_offsets.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -65,8 +68,7 @@ typedef struct BlendExpander BlendExpander;
*
* DNA struct types can be identified in different ways:
* - Run-time Name: The name is provided as const char *.
- * - Compile-time Name: The name is provided at compile time. This can be more efficient. Note
- * that this optimization is not implemented currently.
+ * - Compile-time Name: The name is provided at compile time. This is more efficient.
* - Struct ID: Every DNA struct type has an integer ID that can be queried with
* BLO_get_struct_id_by_name. Providing this ID can be a useful optimization when many structs
* of the same type are stored AND if those structs are not in a continuous array.
@@ -88,7 +90,7 @@ typedef struct BlendExpander BlendExpander;
/* Mapping between names and ids. */
int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name);
-#define BLO_get_struct_id(writer, struct_name) BLO_get_struct_id_by_name(writer, #struct_name)
+#define BLO_get_struct_id(writer, struct_name) SDNA_TYPE_FROM_STRUCT(struct_name)
/* Write single struct. */
void BLO_write_struct_by_name(BlendWriter *writer, const char *struct_name, const void *data_ptr);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8cb407a30f2..0620557e5b8 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -184,9 +184,6 @@
#include "readfile.h"
-/* for SDNA_TYPE_FROM_STRUCT() macro */
-#include "dna_type_offsets.h"
-
#include <errno.h>
/* Make preferences read-only. */