-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathschemaInit.h
More file actions
362 lines (322 loc) · 11.4 KB
/
Copy pathschemaInit.h
File metadata and controls
362 lines (322 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#ifndef SCHEMAINIT_H
#define SCHEMAINIT_H
#include <stddef.h>
#include "sc_export.h"
#include "clstepcore/attrDescriptor.h"
#include "clstepcore/aggrTypeDescriptor.h"
#include "clstepcore/dictSchema.h"
#include "clstepcore/entityDescriptor.h"
#include "clstepcore/enumTypeDescriptor.h"
#include "clstepcore/selectTypeDescriptor.h"
#include "clstepcore/schemaModule.h"
class Derived_attribute;
class Inverse_attribute;
class ComplexCollect;
class Registry;
/** Compact records used by API v2 generated schema initialization. */
struct SC_CORE_EXPORT SchemaInitRecord {
Schema ** slot;
const char * name;
ModelContentsCreator modelContentsCreator;
};
struct SC_CORE_EXPORT EntityDescriptorInitRecord {
EntityDescriptor ** slot;
const char * name;
Schema ** schemaSlot;
Logical abstractEntity;
Logical externalMapping;
Creator creator;
};
struct SC_CORE_EXPORT EntitySupertypeInitRecord {
EntityDescriptor * supertype;
};
enum TypeDescriptorInitKind {
TypeDescriptorInit_Base,
TypeDescriptorInit_Enum,
TypeDescriptorInit_Select,
TypeDescriptorInit_Aggregate,
TypeDescriptorInit_Array,
TypeDescriptorInit_List,
TypeDescriptorInit_Set,
TypeDescriptorInit_Bag
};
struct SC_CORE_EXPORT TypeDescriptorInitRecord {
void * slot;
TypeDescriptorInitKind kind;
const char * name;
PrimitiveType fundamentalType;
Schema ** schemaSlot;
const char * description;
int uniqueElements;
SelectCreator selectCreator;
EnumCreator enumCreator;
AggregateCreator aggregateCreator;
TypeDescriptorInitRecord( TypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription );
TypeDescriptorInitRecord( EnumTypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription,
EnumCreator creator );
TypeDescriptorInitRecord( SelectTypeDescriptor ** descriptorSlot,
int unique, const char * typeName,
PrimitiveType type, Schema ** schema,
const char * typeDescription,
SelectCreator creator );
TypeDescriptorInitRecord( AggrTypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription,
AggregateCreator creator );
TypeDescriptorInitRecord( ArrayTypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription,
AggregateCreator creator );
TypeDescriptorInitRecord( ListTypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription,
AggregateCreator creator );
TypeDescriptorInitRecord( SetTypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription,
AggregateCreator creator );
TypeDescriptorInitRecord( BagTypeDescriptor ** descriptorSlot,
const char * typeName, PrimitiveType type,
Schema ** schema, const char * typeDescription,
AggregateCreator creator );
};
/**
* Attribute descriptor record. The overloaded constructors preserve the
* concrete type of generated descriptor slots without templates or casts in
* generated translation units.
*/
struct SC_CORE_EXPORT AttributeInitRecord {
AttrDescriptor ** attributeSlot;
Derived_attribute ** derivedSlot;
Inverse_attribute ** inverseSlot;
const char * name;
const TypeDescriptor * domain;
Logical optional;
Logical unique;
AttrType_Enum attrType;
const char * initializer;
const char * invertedAttribute;
const char * invertedEntity;
AttributeInitRecord( AttrDescriptor ** slot, const char * attrName,
const TypeDescriptor * domainType, Logical isOptional,
Logical isUnique, AttrType_Enum type,
const char * init = 0 );
AttributeInitRecord( Derived_attribute ** slot, const char * attrName,
const TypeDescriptor * domainType, Logical isOptional,
Logical isUnique, AttrType_Enum type,
const char * init = 0 );
AttributeInitRecord( Inverse_attribute ** slot, const char * attrName,
const TypeDescriptor * domainType, Logical isOptional,
Logical isUnique, const char * invertedAttr,
const char * invertedEnt );
};
enum ComplexNodeInitKind {
ComplexNodeInit_Simple,
ComplexNodeInit_And,
ComplexNodeInit_Or,
ComplexNodeInit_AndOr
};
struct SC_CORE_EXPORT ComplexNodeInitRecord {
ComplexNodeInitKind kind;
const char * name;
size_t firstChild;
size_t nextSibling;
};
struct SC_CORE_EXPORT ComplexListInitRecord {
size_t rootNode;
};
struct SC_CORE_EXPORT GlobalRuleInitRecord {
const char * name;
const char * text;
};
enum SchemaImageDescriptorRefKind {
SchemaImageRef_None,
SchemaImageRef_Entity,
SchemaImageRef_Type,
SchemaImageRef_Builtin,
SchemaImageRef_Aggregate
};
struct SC_CORE_EXPORT SchemaImageDescriptorRef {
uint32_t kind;
uint32_t schema;
uint32_t index;
};
struct SC_CORE_EXPORT SchemaImageSchemaRecord {
uint32_t name;
uint32_t firstEntity;
uint32_t entityCount;
uint32_t firstType;
uint32_t typeCount;
};
struct SC_CORE_EXPORT SchemaImageEntityRecord {
uint32_t schema;
uint32_t name;
uint32_t flags;
uint32_t supertypeStatement;
uint32_t firstSupertype;
uint32_t supertypeCount;
uint32_t firstAttribute;
uint32_t attributeCount;
uint32_t firstWhereRule;
uint32_t whereRuleCount;
uint32_t firstUniqueRule;
uint32_t uniqueRuleCount;
};
enum SchemaImageEntityFlags {
SchemaImageEntity_Abstract = 1u << 0,
SchemaImageEntity_ExternalMapping = 1u << 1
};
struct SC_CORE_EXPORT SchemaImageTypeRecord {
uint32_t schema;
uint32_t name;
uint32_t description;
uint32_t fundamentalType;
uint32_t descriptorKind;
int32_t uniqueElements;
SchemaImageDescriptorRef referent;
uint32_t aggregate;
uint32_t firstSelectElement;
uint32_t selectElementCount;
uint32_t firstWhereRule;
uint32_t whereRuleCount;
uint32_t firstEnumElement;
uint32_t enumElementCount;
};
struct SC_CORE_EXPORT SchemaImageAttributeRecord {
uint32_t name;
SchemaImageDescriptorRef domain;
uint32_t optional;
uint32_t unique;
uint32_t attrType;
uint32_t initializer;
uint32_t invertedAttribute;
uint32_t invertedEntity;
};
struct SC_CORE_EXPORT SchemaImageAggregateRecord {
uint32_t schema;
uint32_t description;
uint32_t fundamentalType;
SchemaImageDescriptorRef referent;
uint32_t bound1Type;
int32_t bound1;
uint32_t bound1Text;
uint32_t bound2Type;
int32_t bound2;
uint32_t bound2Text;
uint32_t optionalElements;
uint32_t uniqueElements;
};
struct SC_CORE_EXPORT SchemaImageRuleRecord {
uint32_t text;
};
enum SchemaImageSchemaTextKind {
SchemaImageText_GlobalRule,
SchemaImageText_Function,
SchemaImageText_Procedure
};
struct SC_CORE_EXPORT SchemaImageSchemaTextRecord {
uint32_t schema;
uint32_t kind;
uint32_t name;
uint32_t text;
};
struct SC_CORE_EXPORT SchemaImageRenameRecord {
SchemaImageDescriptorRef descriptor;
uint32_t schema;
uint32_t name;
};
struct SC_CORE_EXPORT SchemaImageSchemaBinding {
Schema ** schemaSlot;
ModelContentsCreator modelContentsCreator;
SchemaModule * module;
};
struct SC_CORE_EXPORT SchemaImageTypeBinding {
void * slot;
SelectCreator selectCreator;
EnumCreator enumCreator;
AggregateCreator aggregateCreator;
};
enum SchemaLoadError {
SchemaLoad_Ok,
SchemaLoad_UnsupportedVersion,
SchemaLoad_TruncatedImage,
SchemaLoad_InvalidOffset,
SchemaLoad_InvalidString,
SchemaLoad_InvalidReference,
SchemaLoad_CountMismatch,
SchemaLoad_MissingBinding,
SchemaLoad_ModuleFailure
};
struct SC_CORE_EXPORT SchemaLoadResult {
SchemaLoadError error;
uint32_t record;
bool Succeeded() const {
return error == SchemaLoad_Ok;
}
const char * Message() const;
};
SC_CORE_EXPORT SchemaLoadResult InitializeSchemaFromImage(
Registry & registry, const SchemaModuleImage & image,
const SchemaImageSchemaBinding * schemaBindings,
size_t schemaBindingCount,
const SchemaImageTypeBinding * typeBindings,
size_t typeBindingCount, SchemaLoadContext & context );
enum PackedComplexImageVersion {
PackedComplexImageVersion_1 = 1
};
struct SC_CORE_EXPORT PackedComplexImage {
uint32_t version;
uint32_t byteSize;
uint32_t stringOffset;
uint32_t stringBytes;
uint32_t nodeOffset;
uint32_t nodeCount;
uint32_t listOffset;
uint32_t listCount;
};
struct SC_CORE_EXPORT PackedComplexNode {
uint32_t kind;
uint32_t name;
uint32_t firstChild;
uint32_t nextSibling;
};
struct SC_CORE_EXPORT PackedComplexList {
uint32_t rootNode;
};
SC_CORE_EXPORT ComplexCollect * InitializePackedComplexSupport(
const PackedComplexImage & image, SchemaLoadResult * result = 0 );
SC_CORE_EXPORT void InitializeSchemas( Registry & reg,
const SchemaInitRecord * records,
size_t count );
SC_CORE_EXPORT void InitializeSchemaModuleImages(
const SchemaInitRecord * records, size_t count );
SC_CORE_EXPORT void InitializeEntityDescriptors(
const EntityDescriptorInitRecord * records, size_t count );
SC_CORE_EXPORT void InitializeTypeDescriptors(
const TypeDescriptorInitRecord * records, size_t count );
SC_CORE_EXPORT void InitializeTypeMetadata(
Registry & reg, Schema & schema, TypeDescriptor & type,
const TypeDescriptor * referent,
const TypeDescriptor * const * selectElements, size_t selectElementCount );
SC_CORE_EXPORT void InitializeEntityMetadata(
Registry & reg, EntityDescriptor & entity, Schema & schema,
const EntitySupertypeInitRecord * supertypes, size_t supertypeCount,
const AttributeInitRecord * attributes, size_t attributeCount );
SC_CORE_EXPORT void InitializeWhereRules(
TypeDescriptor & owner, const char * const * rules, size_t count );
SC_CORE_EXPORT void InitializeUniquenessRules(
EntityDescriptor & owner, const char * const * rules, size_t count );
SC_CORE_EXPORT void InitializeGlobalRules(
Schema & schema, const GlobalRuleInitRecord * rules, size_t count );
SC_CORE_EXPORT void InitializeFunctions(
Schema & schema, const char * const * functions, size_t count );
SC_CORE_EXPORT void InitializeProcedures(
Schema & schema, const char * const * procedures, size_t count );
SC_CORE_EXPORT ComplexCollect * InitializeComplexSupport(
const ComplexNodeInitRecord * nodes, size_t nodeCount,
const ComplexListInitRecord * lists, size_t listCount );
#endif