[Bf-blender-cvs] [60a786e711e] master: Refactor: use compile time dna struct ids in blenloader api
Jacques Lucke
noreply at git.blender.org
Fri Jun 5 13:56:17 CEST 2020
Commit: 60a786e711e9b821bb5c475ecffe24a67ccccd68
Author: Jacques Lucke
Date: Fri Jun 5 13:54:51 2020 +0200
Branches: master
https://developer.blender.org/rB60a786e711e9b821bb5c475ecffe24a67ccccd68
Refactor: use compile time dna struct ids in blenloader api
===================================================================
M source/blender/blenloader/BLO_read_write.h
M source/blender/blenloader/intern/writefile.c
===================================================================
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. */
More information about the Bf-blender-cvs
mailing list