33
44#include " datadescriptor.h"
55
6+ #ifndef DLLEXPORT
7+ #ifdef _MSC_VER
8+ #define DLLEXPORT __declspec (dllexport)
9+ #else
10+ #define DLLEXPORT __attribute__ ((visibility (" default" )))
11+ #endif // _MSC_VER
12+ #endif // DLLEXPORT
13+
614// begin blob definition
715
816extern " C"
@@ -52,7 +60,8 @@ struct GlobalStringSpec
5260#define MAKE_GLOBALVALUELEN_NAME (globalname ) CONCAT(cdac_string_pool_globalvalue__, globalname)
5361
5462// used to stringify the result of a macros expansion
55- #define STRINGIFY (x ) #x
63+ // __VA_ARGS__ is the argument list comma separated
64+ #define STRINGIFY (...) #__VA_ARGS__
5665
5766// define a struct where the size of each field is the length of some string. we will use offsetof to get
5867// the offset of each struct element, which will be equal to the offset of the beginning of that string in the
@@ -68,6 +77,7 @@ struct CDacStringPoolSizes
6877#define CDAC_GLOBAL_STRING (name, stringval ) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof (#name)) \
6978 DECL_LEN (MAKE_GLOBALVALUELEN_NAME(name), sizeof (STRINGIFY(stringval)))
7079#define CDAC_GLOBAL_POINTER (name,value ) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof (#name))
80+ #define CDAC_GLOBAL_SUB_DESCRIPTOR (name,value ) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof (#name))
7181#define CDAC_GLOBAL (name,tyname,value ) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof (#name)) \
7282 DECL_LEN (MAKE_GLOBALTYPELEN_NAME(name), sizeof (#tyname))
7383#include " wrappeddatadescriptor.inc"
@@ -129,6 +139,15 @@ enum
129139#include " wrappeddatadescriptor.inc"
130140};
131141
142+ // count the global sub-descriptors
143+ enum
144+ {
145+ CDacBlobGlobalSubDescriptorsCount =
146+ #define CDAC_GLOBALS_BEGIN () 0
147+ #define CDAC_GLOBAL_SUB_DESCRIPTOR (name,value ) + 1
148+ #include " wrappeddatadescriptor.inc"
149+ };
150+
132151
133152#define MAKE_TYPEFIELDS_TYNAME (tyname ) CONCAT(CDacFieldsPoolTypeStart__, tyname)
134153
@@ -178,6 +197,7 @@ struct CDacGlobalPointerIndex
178197#define DECL_LEN (membername ) char membername;
179198#define CDAC_GLOBALS_BEGIN () DECL_LEN(cdac_global_pointer_index_start_placeholder__)
180199#define CDAC_GLOBAL_POINTER (name,value ) DECL_LEN(CONCAT(cdac_global_pointer_index__, name))
200+ #define CDAC_GLOBAL_SUB_DESCRIPTOR (name,value ) DECL_LEN(CONCAT(cdac_global_pointer_index__, name))
181201#include " wrappeddatadescriptor.inc"
182202#undef DECL_LEN
183203};
@@ -204,6 +224,8 @@ struct BinaryBlobDataDescriptor
204224
205225 uint32_t GlobalPointersStart;
206226 uint32_t GlobalStringValuesStart;
227+
228+ uint32_t GlobalSubDescriptorsStart;
207229 uint32_t NamesPoolStart;
208230
209231 uint32_t TypeCount;
@@ -212,6 +234,7 @@ struct BinaryBlobDataDescriptor
212234 uint32_t GlobalLiteralValuesCount;
213235 uint32_t GlobalPointerValuesCount;
214236 uint32_t GlobalStringValuesCount;
237+ uint32_t GlobalSubDescriptorsCount;
215238
216239 uint32_t NamesPoolCount;
217240
@@ -223,11 +246,13 @@ struct BinaryBlobDataDescriptor
223246 } Directory;
224247 uint32_t PlatformFlags;
225248 uint32_t BaselineName;
226- struct TypeSpec Types[CDacBlobTypesCount];
227- struct FieldSpec FieldsPool[CDacBlobFieldsPoolCount];
228- struct GlobalLiteralSpec GlobalLiteralValues[CDacBlobGlobalLiteralsCount];
229- struct GlobalPointerSpec GlobalPointerValues[CDacBlobGlobalPointersCount];
230- struct GlobalStringSpec GlobalStringValues[CDacBlobGlobalStringsCount];
249+ // cpp does not allow zero-length arrays, so we add one extra element to allow having zero of a given type of descriptor
250+ struct TypeSpec Types[CDacBlobTypesCount + 1 ];
251+ struct FieldSpec FieldsPool[CDacBlobFieldsPoolCount + 1 ];
252+ struct GlobalLiteralSpec GlobalLiteralValues[CDacBlobGlobalLiteralsCount + 1 ];
253+ struct GlobalPointerSpec GlobalPointerValues[CDacBlobGlobalPointersCount + 1 ];
254+ struct GlobalStringSpec GlobalStringValues[CDacBlobGlobalStringsCount + 1 ];
255+ struct GlobalPointerSpec GlobalSubDescriptorValues[CDacBlobGlobalSubDescriptorsCount + 1 ];
231256 uint8_t NamesPool[sizeof (struct CDacStringPoolSizes )];
232257 uint8_t EndMagic[4 ];
233258};
@@ -253,12 +278,14 @@ struct MagicAndBlob BlobDataDescriptor = {
253278 /* .GlobalLiteralValuesStart = */ offsetof (struct BinaryBlobDataDescriptor , GlobalLiteralValues),
254279 /* .GlobalPointersStart = */ offsetof (struct BinaryBlobDataDescriptor , GlobalPointerValues),
255280 /* .GlobalStringValuesStart = */ offsetof (struct BinaryBlobDataDescriptor , GlobalStringValues),
281+ /* .GlobalSubDescriptorsStart = */ offsetof (struct BinaryBlobDataDescriptor , GlobalSubDescriptorValues),
256282 /* .NamesPoolStart = */ offsetof (struct BinaryBlobDataDescriptor , NamesPool),
257283 /* .TypeCount = */ CDacBlobTypesCount,
258284 /* .FieldsPoolCount = */ CDacBlobFieldsPoolCount,
259285 /* .GlobalLiteralValuesCount = */ CDacBlobGlobalLiteralsCount,
260286 /* .GlobalPointerValuesCount = */ CDacBlobGlobalPointersCount,
261287 /* .GlobalStringValuesCount = */ CDacBlobGlobalStringsCount,
288+ /* .GlobalSubDescriptorsCount = */ CDacBlobGlobalSubDescriptorsCount,
262289 /* .NamesPoolCount = */ sizeof (struct CDacStringPoolSizes ),
263290 /* .TypeSpecSize = */ sizeof (struct TypeSpec ),
264291 /* .FieldSpecSize = */ sizeof (struct FieldSpec ),
@@ -305,12 +332,18 @@ struct MagicAndBlob BlobDataDescriptor = {
305332#include " wrappeddatadescriptor.inc"
306333 },
307334
335+ /* .GlobalSubDescriptorValues = */ {
336+ #define CDAC_GLOBAL_SUB_DESCRIPTOR (name,value ) { /* .Name = */ GET_GLOBAL_NAME (name), /* .PointerDataIndex = */ GET_GLOBAL_POINTER_INDEX (name) },
337+ #include " wrappeddatadescriptor.inc"
338+ },
339+
308340 /* .NamesPool = */ (" \0 " // starts with a nul
309341#define CDAC_BASELINE (name ) name " \0 "
310342#define CDAC_TYPE_BEGIN (name ) #name " \0 "
311343#define CDAC_TYPE_FIELD (tyname,membertyname,membername,offset ) #membername " \0 " #membertyname " \0 "
312344#define CDAC_GLOBAL_STRING (name,value ) #name " \0 " STRINGIFY(value) " \0 "
313345#define CDAC_GLOBAL_POINTER (name,value ) #name " \0 "
346+ #define CDAC_GLOBAL_SUB_DESCRIPTOR (name,value ) #name " \0 "
314347#define CDAC_GLOBAL (name,tyname,value ) #name " \0 " #tyname " \0 "
315348#include " wrappeddatadescriptor.inc"
316349 ),
0 commit comments