@ifc-lite/codegen 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/generator.d.ts +9 -0
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +51 -3
- package/dist/generator.js.map +1 -1
- package/dist/rust-attribute-flags.d.ts +54 -0
- package/dist/rust-attribute-flags.d.ts.map +1 -0
- package/dist/rust-attribute-flags.js +103 -0
- package/dist/rust-attribute-flags.js.map +1 -0
- package/dist/rust-generator.d.ts.map +1 -1
- package/dist/rust-generator.js +30 -42
- package/dist/rust-generator.js.map +1 -1
- package/dist/rust-schema-queries.d.ts.map +1 -1
- package/dist/rust-schema-queries.js +13 -5
- package/dist/rust-schema-queries.js.map +1 -1
- package/dist/rust-slot-emitter.d.ts +70 -0
- package/dist/rust-slot-emitter.d.ts.map +1 -0
- package/dist/rust-slot-emitter.js +293 -0
- package/dist/rust-slot-emitter.js.map +1 -0
- package/dist/rust-slot-renames.d.ts +26 -0
- package/dist/rust-slot-renames.d.ts.map +1 -0
- package/dist/rust-slot-renames.js +34 -0
- package/dist/rust-slot-renames.js.map +1 -0
- package/dist/rust-type-id-generator.d.ts +4 -0
- package/dist/rust-type-id-generator.d.ts.map +1 -0
- package/dist/rust-type-id-generator.js +30 -0
- package/dist/rust-type-id-generator.js.map +1 -0
- package/dist/rust-type-name-parser.js +2 -2
- package/dist/rust-unknown-ifc-type.d.ts +3 -0
- package/dist/rust-unknown-ifc-type.d.ts.map +1 -0
- package/dist/rust-unknown-ifc-type.js +32 -0
- package/dist/rust-unknown-ifc-type.js.map +1 -0
- package/package.json +4 -4
- package/schemas/IFC4X1.exp +12630 -0
- package/schemas/IFC4X2.exp +12885 -0
- package/schemas/attribute-renames.json +28 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `rust/core/src/generated/slots.rs`: one typed attribute slot per
|
|
3
|
+
* (entity, attribute), flattened across the supertype chain (F3e-0b, #7780).
|
|
4
|
+
*
|
|
5
|
+
* The positions are not a second table. They are the positions the registries
|
|
6
|
+
* already emit as `IfcType::attribute_names()` (supertype attributes first),
|
|
7
|
+
* read per bundled schema, then classified:
|
|
8
|
+
*
|
|
9
|
+
* stable the same position in every schema that declares the entity;
|
|
10
|
+
* trailing the same position where present, and past the end of the
|
|
11
|
+
* record in every schema where the attribute is absent (reading it
|
|
12
|
+
* there yields None either way);
|
|
13
|
+
* moving everything else.
|
|
14
|
+
*
|
|
15
|
+
* A stable or trailing attribute becomes a `Slot<Kind>` const. A moving one
|
|
16
|
+
* becomes a `SchemaSlot<Kind>`, which has no `index()` and can only be read
|
|
17
|
+
* after it is resolved against a `SchemaVersion`.
|
|
18
|
+
*
|
|
19
|
+
* A slot is named by the canonical IFC4X3 attribute name (an entity that
|
|
20
|
+
* IFC4X3 does not declare uses the newest schema that does). Same-position
|
|
21
|
+
* renames between releases are listed in `schemas/attribute-renames.json`;
|
|
22
|
+
* every row is validated here, and a row whose names sit at different
|
|
23
|
+
* positions fails generation, so a rename can never cover a move. A semantic
|
|
24
|
+
* replacement (CompositionType -> PredefinedType, ...) is not a rename: it
|
|
25
|
+
* stays a moving slot and reads as absent in the older schema.
|
|
26
|
+
*/
|
|
27
|
+
import type { EntityDefinition, ExpressSchema } from './express-parser.js';
|
|
28
|
+
import type { RenameTable } from './rust-slot-renames.js';
|
|
29
|
+
/** Mirrors `SchemaVersion` (declaration order) in rust/core/src/generated/schema_registry.rs. */
|
|
30
|
+
export declare const SLOT_SCHEMAS: readonly ["Ifc2x3", "Ifc4", "Ifc4x1", "Ifc4x2", "Ifc4x3"];
|
|
31
|
+
export type SlotSchema = (typeof SLOT_SCHEMAS)[number];
|
|
32
|
+
/** Value of an absent `by_schema` entry (`ABSENT` in rust/core/src/slot.rs). */
|
|
33
|
+
export declare const ABSENT = 255;
|
|
34
|
+
export interface SlotSchemaInput {
|
|
35
|
+
readonly version: SlotSchema;
|
|
36
|
+
readonly schema: ExpressSchema;
|
|
37
|
+
}
|
|
38
|
+
export interface SlotAttribute {
|
|
39
|
+
/** SCREAMING_SNAKE const name. */
|
|
40
|
+
readonly constName: string;
|
|
41
|
+
/** Canonical attribute name. */
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly kind: string;
|
|
44
|
+
/** Canonical position (the position in `owner`'s newest declaring schema). */
|
|
45
|
+
readonly index: number;
|
|
46
|
+
/** `null` for a Slot; per-schema positions (ABSENT = 255) for a SchemaSlot. */
|
|
47
|
+
readonly bySchema: readonly number[] | null;
|
|
48
|
+
}
|
|
49
|
+
export interface SlotEntity {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly attributes: readonly SlotAttribute[];
|
|
52
|
+
}
|
|
53
|
+
/** Resolve a schema label ("IFC4_ADD2_TC1", "IFC4X3_DEV_…") to its `SlotSchema`. */
|
|
54
|
+
export declare function slotSchemaOf(schemaName: string): SlotSchema;
|
|
55
|
+
/** `URLReference` -> `URL_REFERENCE`, `UAxes` -> `U_AXES`, `DeltaT_Constant` -> `DELTA_T_CONSTANT`. */
|
|
56
|
+
export declare function screamingSnake(name: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Classify every (entity, attribute) of `entities` across the schemas.
|
|
59
|
+
* `canonical` is the IFC4X3 input; `others` are the older releases.
|
|
60
|
+
*/
|
|
61
|
+
export declare function classifySlots(canonical: SlotSchemaInput, others: readonly SlotSchemaInput[], table: RenameTable, entityFilter: (name: string) => boolean): SlotEntity[];
|
|
62
|
+
export interface GeneratedSlots {
|
|
63
|
+
/** `generated/slots.rs`. */
|
|
64
|
+
readonly slots: string;
|
|
65
|
+
/** `generated/slots_table.rs` (test-only). */
|
|
66
|
+
readonly table: string;
|
|
67
|
+
}
|
|
68
|
+
/** Emit `generated/slots.rs` and its test-only index. */
|
|
69
|
+
export declare function generateSlots(canonical: SlotSchemaInput, others: readonly SlotSchemaInput[], typeUniverse: readonly EntityDefinition[], table: RenameTable): GeneratedSlots;
|
|
70
|
+
//# sourceMappingURL=rust-slot-emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-slot-emitter.d.ts","sourceRoot":"","sources":["../src/rust-slot-emitter.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG3E,OAAO,KAAK,EAAsB,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE9E,iGAAiG;AACjG,eAAO,MAAM,YAAY,2DAA4D,CAAC;AACtF,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,gFAAgF;AAChF,eAAO,MAAM,MAAM,MAAM,CAAC;AAI1B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAS3D;AAED,uGAAuG;AACvG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMnD;AAyCD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,KAAK,EAAE,WAAW,EAClB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACtC,UAAU,EAAE,CA4Hd;AAiGD,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,YAAY,EAAE,SAAS,gBAAgB,EAAE,EACzC,KAAK,EAAE,WAAW,GACjB,cAAc,CAOhB"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { getAllAttributes } from './express-parser.js';
|
|
5
|
+
import { AttributeKindResolver, KIND } from './rust-attribute-flags.js';
|
|
6
|
+
/** Mirrors `SchemaVersion` (declaration order) in rust/core/src/generated/schema_registry.rs. */
|
|
7
|
+
export const SLOT_SCHEMAS = ['Ifc2x3', 'Ifc4', 'Ifc4x1', 'Ifc4x2', 'Ifc4x3'];
|
|
8
|
+
/** Value of an absent `by_schema` entry (`ABSENT` in rust/core/src/slot.rs). */
|
|
9
|
+
export const ABSENT = 255;
|
|
10
|
+
const KIND_NAMES = ['Ref', 'RefList', 'List', 'Real', 'Int', 'Text', 'Enum', 'Logical', 'Binary', 'Select'];
|
|
11
|
+
/** Resolve a schema label ("IFC4_ADD2_TC1", "IFC4X3_DEV_…") to its `SlotSchema`. */
|
|
12
|
+
export function slotSchemaOf(schemaName) {
|
|
13
|
+
const upper = schemaName.toUpperCase();
|
|
14
|
+
const family = (label) => upper === label || new RegExp(`^${label}(?![0-9A-Z])`).test(upper);
|
|
15
|
+
if (family('IFC4X3'))
|
|
16
|
+
return 'Ifc4x3';
|
|
17
|
+
if (family('IFC4X2'))
|
|
18
|
+
return 'Ifc4x2';
|
|
19
|
+
if (family('IFC4X1'))
|
|
20
|
+
return 'Ifc4x1';
|
|
21
|
+
if (family('IFC4'))
|
|
22
|
+
return 'Ifc4';
|
|
23
|
+
if (family('IFC2X3'))
|
|
24
|
+
return 'Ifc2x3';
|
|
25
|
+
throw new Error(`slot schema "${schemaName}" is not a bundled IFC family`);
|
|
26
|
+
}
|
|
27
|
+
/** `URLReference` -> `URL_REFERENCE`, `UAxes` -> `U_AXES`, `DeltaT_Constant` -> `DELTA_T_CONSTANT`. */
|
|
28
|
+
export function screamingSnake(name) {
|
|
29
|
+
return name
|
|
30
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
31
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
|
|
32
|
+
.replace(/__+/g, '_')
|
|
33
|
+
.toUpperCase();
|
|
34
|
+
}
|
|
35
|
+
function layoutOf(input) {
|
|
36
|
+
const resolver = new AttributeKindResolver(input.schema);
|
|
37
|
+
const names = new Map();
|
|
38
|
+
const kinds = new Map();
|
|
39
|
+
const parent = new Map();
|
|
40
|
+
for (const entity of input.schema.entities) {
|
|
41
|
+
const attributes = getAllAttributes(entity, input.schema);
|
|
42
|
+
names.set(entity.name, attributes.map((a) => a.name));
|
|
43
|
+
kinds.set(entity.name, attributes.map((a) => resolver.flagByte(a) & 0x0f));
|
|
44
|
+
parent.set(entity.name, entity.supertype);
|
|
45
|
+
}
|
|
46
|
+
return { version: input.version, names, kinds, parent };
|
|
47
|
+
}
|
|
48
|
+
/** The set of entities (with subtypes, across every schema) a rename row covers. */
|
|
49
|
+
function renameScope(row, schemas) {
|
|
50
|
+
const scope = new Set();
|
|
51
|
+
const roots = new Set(row.entities);
|
|
52
|
+
for (const schema of schemas) {
|
|
53
|
+
for (const entity of schema.names.keys()) {
|
|
54
|
+
for (let current = entity, depth = 0; current && depth < 64; depth++) {
|
|
55
|
+
if (roots.has(current)) {
|
|
56
|
+
scope.add(entity);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
current = schema.parent.get(current);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return scope;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Classify every (entity, attribute) of `entities` across the schemas.
|
|
67
|
+
* `canonical` is the IFC4X3 input; `others` are the older releases.
|
|
68
|
+
*/
|
|
69
|
+
export function classifySlots(canonical, others, table, entityFilter) {
|
|
70
|
+
const { renames, omit } = table;
|
|
71
|
+
const inputs = [canonical, ...others];
|
|
72
|
+
const omitted = new Set(omit.map((o) => `${o.entity}.${o.attribute}`));
|
|
73
|
+
const omitUsed = new Set();
|
|
74
|
+
const seenVersions = new Set();
|
|
75
|
+
for (const input of inputs) {
|
|
76
|
+
if (seenVersions.has(input.version))
|
|
77
|
+
throw new Error(`slot schema ${input.version} given twice`);
|
|
78
|
+
seenVersions.add(input.version);
|
|
79
|
+
}
|
|
80
|
+
const schemas = inputs.map(layoutOf);
|
|
81
|
+
// Newest first, so an entity IFC4X3 does not declare takes the next newest.
|
|
82
|
+
const byAge = [...schemas].sort((a, b) => SLOT_SCHEMAS.indexOf(b.version) - SLOT_SCHEMAS.indexOf(a.version));
|
|
83
|
+
const scopes = renames.map((row) => ({ row, scope: renameScope(row, schemas) }));
|
|
84
|
+
const resolveName = (entity, name) => {
|
|
85
|
+
for (const { row, scope } of scopes) {
|
|
86
|
+
if (scope.has(entity) && row.aliases.includes(name))
|
|
87
|
+
return row.name;
|
|
88
|
+
}
|
|
89
|
+
return name;
|
|
90
|
+
};
|
|
91
|
+
const allNames = new Set();
|
|
92
|
+
for (const schema of schemas)
|
|
93
|
+
for (const name of schema.names.keys())
|
|
94
|
+
allNames.add(name);
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const entity of [...allNames].sort()) {
|
|
97
|
+
if (!entityFilter(entity))
|
|
98
|
+
continue;
|
|
99
|
+
const declaring = byAge.filter((s) => s.names.has(entity));
|
|
100
|
+
const home = declaring[0];
|
|
101
|
+
const homeRaw = home.names.get(entity);
|
|
102
|
+
const homeKinds = home.kinds.get(entity);
|
|
103
|
+
const homeNames = homeRaw.map((n) => resolveName(entity, n));
|
|
104
|
+
assertUnique(entity, home.version, homeNames);
|
|
105
|
+
// Each declaring schema's normalised names, with alias positions validated.
|
|
106
|
+
const normalised = new Map();
|
|
107
|
+
for (const schema of declaring) {
|
|
108
|
+
const raw = schema.names.get(entity);
|
|
109
|
+
const names = raw.map((n) => resolveName(entity, n));
|
|
110
|
+
assertUnique(entity, schema.version, names);
|
|
111
|
+
normalised.set(schema.version, names);
|
|
112
|
+
}
|
|
113
|
+
for (const { row, scope } of scopes) {
|
|
114
|
+
if (!scope.has(entity))
|
|
115
|
+
continue;
|
|
116
|
+
for (const alias of row.aliases) {
|
|
117
|
+
for (const schema of declaring) {
|
|
118
|
+
const raw = schema.names.get(entity);
|
|
119
|
+
const at = raw.indexOf(alias);
|
|
120
|
+
if (at < 0)
|
|
121
|
+
continue;
|
|
122
|
+
const canonicalAt = homeNames.indexOf(row.name);
|
|
123
|
+
if (canonicalAt >= 0 && canonicalAt !== at) {
|
|
124
|
+
throw new Error(`rename ${alias} -> ${row.name} on ${entity}: ${alias} is at ${at} in ${schema.version} ` +
|
|
125
|
+
`but ${row.name} is at ${canonicalAt} in ${home.version}; a rename must keep the position`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Every attribute any schema declares: the home schema's, then names only
|
|
131
|
+
// an older release has (IfcAlignment.Axis exists in IFC4X1/4X2 alone), each
|
|
132
|
+
// at the position of the newest schema that has it.
|
|
133
|
+
const slotNames = homeNames.map((name, index) => ({
|
|
134
|
+
name,
|
|
135
|
+
index,
|
|
136
|
+
kind: homeKinds[index],
|
|
137
|
+
}));
|
|
138
|
+
for (const schema of declaring.slice(1)) {
|
|
139
|
+
normalised.get(schema.version).forEach((name, index) => {
|
|
140
|
+
if (omitted.has(`${entity}.${name}`)) {
|
|
141
|
+
omitUsed.add(`${entity}.${name}`);
|
|
142
|
+
}
|
|
143
|
+
else if (!slotNames.some((s) => s.name === name)) {
|
|
144
|
+
slotNames.push({ name, index, kind: schema.kinds.get(entity)[index] });
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const attributes = [];
|
|
149
|
+
const used = new Map();
|
|
150
|
+
for (const { name, index, kind: homeKind } of slotNames) {
|
|
151
|
+
if (index >= ABSENT)
|
|
152
|
+
throw new Error(`${entity}.${name} is at ${index}; a slot index must fit below ${ABSENT}`);
|
|
153
|
+
const bySchema = new Array(SLOT_SCHEMAS.length).fill(ABSENT);
|
|
154
|
+
let moving = false;
|
|
155
|
+
const kinds = new Set([homeKind]);
|
|
156
|
+
for (const schema of declaring) {
|
|
157
|
+
const names = normalised.get(schema.version);
|
|
158
|
+
const at = names.indexOf(name);
|
|
159
|
+
const slotIx = SLOT_SCHEMAS.indexOf(schema.version);
|
|
160
|
+
if (at === index) {
|
|
161
|
+
bySchema[slotIx] = index;
|
|
162
|
+
kinds.add(schema.kinds.get(entity)[at]);
|
|
163
|
+
}
|
|
164
|
+
else if (at < 0 && index >= names.length) {
|
|
165
|
+
// Trailing: past the end of this schema's record, absent either way.
|
|
166
|
+
bySchema[slotIx] = index;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
moving = true;
|
|
170
|
+
bySchema[slotIx] = at < 0 ? ABSENT : at;
|
|
171
|
+
if (at >= 0)
|
|
172
|
+
kinds.add(schema.kinds.get(entity)[at]);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const constName = screamingSnake(name);
|
|
176
|
+
const clash = used.get(constName);
|
|
177
|
+
if (clash)
|
|
178
|
+
throw new Error(`${entity}: ${name} and ${clash} both name the slot ${constName}`);
|
|
179
|
+
used.set(constName, name);
|
|
180
|
+
// A kind that differs between schemas is only safely read as Select.
|
|
181
|
+
const kind = kinds.size === 1 ? homeKind : KIND.Select;
|
|
182
|
+
attributes.push({
|
|
183
|
+
constName,
|
|
184
|
+
name,
|
|
185
|
+
kind: KIND_NAMES[kind],
|
|
186
|
+
index,
|
|
187
|
+
bySchema: moving ? bySchema : null,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
out.push({ name: entity, attributes });
|
|
191
|
+
}
|
|
192
|
+
for (const key of omitted) {
|
|
193
|
+
if (!omitUsed.has(key))
|
|
194
|
+
throw new Error(`attribute-renames.json: omit row ${key} matches no older-release attribute`);
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
function assertUnique(entity, version, names) {
|
|
199
|
+
const seen = new Set();
|
|
200
|
+
for (const name of names) {
|
|
201
|
+
if (seen.has(name))
|
|
202
|
+
throw new Error(`${entity} in ${version}: attribute ${name} appears twice after renames`);
|
|
203
|
+
seen.add(name);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function slotsSource(entities, canonicalName) {
|
|
207
|
+
const header = `// This Source Code Form is subject to the terms of the Mozilla Public
|
|
208
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
209
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
210
|
+
|
|
211
|
+
//! Auto-generated typed attribute slots.
|
|
212
|
+
//!
|
|
213
|
+
//! Generated from the bundled EXPRESS schemas (canonical: ${canonicalName}).
|
|
214
|
+
//! One zero-sized struct per entity, inherited attributes flattened in:
|
|
215
|
+
//! \`slot::IfcWall::OBJECT_PLACEMENT\`. A \`Slot\` has the same position in every
|
|
216
|
+
//! bundled schema that declares the entity; a \`SchemaSlot\` moves and must be
|
|
217
|
+
//! resolved against a \`SchemaVersion\` before it can be read.
|
|
218
|
+
//!
|
|
219
|
+
//! DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
|
|
220
|
+
|
|
221
|
+
#![allow(clippy::unreadable_literal)]
|
|
222
|
+
|
|
223
|
+
use super::type_ids as ids;
|
|
224
|
+
use crate::generated::IfcType;
|
|
225
|
+
#[allow(unused_imports)]
|
|
226
|
+
use crate::slot::kind::{Binary, Enum, Int, List, Logical, Real, Ref, RefList, Select, Text};
|
|
227
|
+
use crate::slot::{SchemaSlot, Slot, ABSENT};
|
|
228
|
+
|
|
229
|
+
`;
|
|
230
|
+
const body = entities
|
|
231
|
+
.map((entity) => {
|
|
232
|
+
const owner = `ids::${entity.name.toUpperCase()}`;
|
|
233
|
+
const consts = entity.attributes
|
|
234
|
+
.map((a) => a.bySchema === null
|
|
235
|
+
? ` pub const ${a.constName}: Slot<${a.kind}> = Slot::new(${a.index}, ${owner});`
|
|
236
|
+
: ` pub const ${a.constName}: SchemaSlot<${a.kind}> = SchemaSlot::new([${a.bySchema
|
|
237
|
+
.map((v) => (v === ABSENT ? 'ABSENT' : String(v)))
|
|
238
|
+
.join(', ')}], ${owner});`)
|
|
239
|
+
.join('\n');
|
|
240
|
+
return `/// \`${entity.name}\` attribute slots.
|
|
241
|
+
pub struct ${entity.name};
|
|
242
|
+
|
|
243
|
+
impl ${entity.name} {
|
|
244
|
+
/// The entity type these slots belong to.
|
|
245
|
+
pub const IFC_TYPE: IfcType = IfcType::${entity.name};
|
|
246
|
+
${consts}
|
|
247
|
+
}
|
|
248
|
+
`;
|
|
249
|
+
})
|
|
250
|
+
.join('\n');
|
|
251
|
+
return header + body;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* `generated/slots_table.rs`: every generated slot with its entity and attribute
|
|
255
|
+
* name, bound to the consts themselves, for the independent re-derivation in
|
|
256
|
+
* `rust/core/src/slot_tests.rs`. `#[cfg(test)]` and a file of its own, so a
|
|
257
|
+
* normal build neither reads nor parses it.
|
|
258
|
+
*/
|
|
259
|
+
function tableSource(entities, canonicalName) {
|
|
260
|
+
const rows = entities
|
|
261
|
+
.flatMap((entity) => entity.attributes.map((a) => ` ${a.bySchema === null ? 'fixed' : 'moving'}("${entity.name}", "${a.name}", ${entity.name}::${a.constName}),`))
|
|
262
|
+
.join('\n');
|
|
263
|
+
return `// This Source Code Form is subject to the terms of the Mozilla Public
|
|
264
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
265
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
266
|
+
|
|
267
|
+
//! Auto-generated test-only index of the typed attribute slots.
|
|
268
|
+
//!
|
|
269
|
+
//! Generated from the bundled EXPRESS schemas (canonical: ${canonicalName}).
|
|
270
|
+
//!
|
|
271
|
+
//! DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
|
|
272
|
+
|
|
273
|
+
use super::slots::*;
|
|
274
|
+
use crate::slot::tests::{fixed, moving, Row};
|
|
275
|
+
|
|
276
|
+
/// Every generated slot, for the tests that re-derive the classification.
|
|
277
|
+
pub(crate) fn table() -> Vec<Row> {
|
|
278
|
+
vec![
|
|
279
|
+
${rows}
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
`;
|
|
283
|
+
}
|
|
284
|
+
/** Emit `generated/slots.rs` and its test-only index. */
|
|
285
|
+
export function generateSlots(canonical, others, typeUniverse, table) {
|
|
286
|
+
const inUniverse = new Set(typeUniverse.map((e) => e.name));
|
|
287
|
+
const entities = classifySlots(canonical, others, table, (name) => inUniverse.has(name));
|
|
288
|
+
return {
|
|
289
|
+
slots: slotsSource(entities, canonical.schema.name),
|
|
290
|
+
table: tableSource(entities, canonical.schema.name),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=rust-slot-emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-slot-emitter.js","sourceRoot":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IAElB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACzF,OAAO;QACL,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;QACnD,KAAK,EAAE,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The same-position rename table behind the slot generator
|
|
3
|
+
* (`schemas/attribute-renames.json`, F3e-0b, #7780): its shape and validation.
|
|
4
|
+
* The semantic checks against the EXPRESS schemas live in the emitter.
|
|
5
|
+
*/
|
|
6
|
+
/** One row of `attribute-renames.json`. */
|
|
7
|
+
export interface AttributeRenameRow {
|
|
8
|
+
/** The canonical name every other spelling resolves to. */
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** Older spellings of the same attribute at the same position. */
|
|
11
|
+
readonly aliases: readonly string[];
|
|
12
|
+
/** The entities (and all their subtypes) the row applies to. */
|
|
13
|
+
readonly entities: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/** An older-release attribute that gets no slot (its name collides with the one it moved to). */
|
|
16
|
+
export interface AttributeOmitRow {
|
|
17
|
+
readonly entity: string;
|
|
18
|
+
readonly attribute: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RenameTable {
|
|
21
|
+
readonly renames: readonly AttributeRenameRow[];
|
|
22
|
+
readonly omit: readonly AttributeOmitRow[];
|
|
23
|
+
}
|
|
24
|
+
/** Validate a parsed `attribute-renames.json`. */
|
|
25
|
+
export declare function parseRenames(json: unknown): RenameTable;
|
|
26
|
+
//# sourceMappingURL=rust-slot-renames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-slot-renames.d.ts","sourceRoot":"","sources":["../src/rust-slot-renames.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,iGAAiG;AACjG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAC5C;AAED,kDAAkD;AAClD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CA4BvD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/** Validate a parsed `attribute-renames.json`. */
|
|
5
|
+
export function parseRenames(json) {
|
|
6
|
+
const doc = json;
|
|
7
|
+
const rows = doc?.renames;
|
|
8
|
+
if (!Array.isArray(rows))
|
|
9
|
+
throw new Error('attribute-renames.json: expected a "renames" array');
|
|
10
|
+
const omitRows = doc.omit ?? [];
|
|
11
|
+
if (!Array.isArray(omitRows))
|
|
12
|
+
throw new Error('attribute-renames.json: "omit" must be an array');
|
|
13
|
+
const omit = omitRows.map((row, i) => {
|
|
14
|
+
const { entity, attribute } = row;
|
|
15
|
+
if (typeof entity !== 'string' || typeof attribute !== 'string') {
|
|
16
|
+
throw new Error(`attribute-renames.json: omit row ${i} needs entity and attribute`);
|
|
17
|
+
}
|
|
18
|
+
return { entity, attribute };
|
|
19
|
+
});
|
|
20
|
+
const renames = rows.map((row, i) => {
|
|
21
|
+
const { name, aliases, entities } = row;
|
|
22
|
+
if (typeof name !== 'string' ||
|
|
23
|
+
!Array.isArray(aliases) ||
|
|
24
|
+
aliases.length === 0 ||
|
|
25
|
+
!Array.isArray(entities) ||
|
|
26
|
+
entities.length === 0 ||
|
|
27
|
+
![...aliases, ...entities].every((v) => typeof v === 'string')) {
|
|
28
|
+
throw new Error(`attribute-renames.json: row ${i} needs name, aliases[] and entities[]`);
|
|
29
|
+
}
|
|
30
|
+
return { name, aliases, entities };
|
|
31
|
+
});
|
|
32
|
+
return { renames, omit };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=rust-slot-renames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-slot-renames.js","sourceRoot":"","sources":["../src/rust-slot-renames.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA6B/D,kDAAkD;AAClD,MAAM,UAAU,YAAY,CAAC,IAAa;IACxC,MAAM,GAAG,GAAG,IAA6C,CAAC;IAC1D,MAAM,IAAI,GAAG,GAAG,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACjG,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACnC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAgC,CAAC;QAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,6BAA6B,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAClC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAkC,CAAC;QACvE,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YACvB,OAAO,CAAC,MAAM,KAAK,CAAC;YACpB,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACxB,QAAQ,CAAC,MAAM,KAAK,CAAC;YACrB,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAC9D,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,uCAAuC,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EntityDefinition, ExpressSchema } from './express-parser.js';
|
|
2
|
+
/** Render the generated CRC32 constants without coupling this to enum emission. */
|
|
3
|
+
export declare function generateTypeIdConstants(schema: ExpressSchema, cratePrivate: boolean, categorize: (schema: ExpressSchema) => Record<string, EntityDefinition[]>): string;
|
|
4
|
+
//# sourceMappingURL=rust-type-id-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-type-id-generator.d.ts","sourceRoot":"","sources":["../src/rust-type-id-generator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE3E,mFAAmF;AACnF,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,GACxE,MAAM,CAyBR"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { crc32 } from './crc32.js';
|
|
5
|
+
/** Render the generated CRC32 constants without coupling this to enum emission. */
|
|
6
|
+
export function generateTypeIdConstants(schema, cratePrivate, categorize) {
|
|
7
|
+
let code = `// This Source Code Form is subject to the terms of the Mozilla Public
|
|
8
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
9
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
10
|
+
|
|
11
|
+
//! Auto-generated IFC Type ID Constants
|
|
12
|
+
//!
|
|
13
|
+
//! CRC32 hashes for fast type identification.
|
|
14
|
+
//! Generated from EXPRESS schema: ${schema.name}
|
|
15
|
+
//!
|
|
16
|
+
//! DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
|
|
17
|
+
|
|
18
|
+
#![allow(dead_code)]
|
|
19
|
+
|
|
20
|
+
`;
|
|
21
|
+
for (const [category, entities] of Object.entries(categorize(schema))) {
|
|
22
|
+
code += `// ${category}\n`;
|
|
23
|
+
for (const entity of entities) {
|
|
24
|
+
code += `pub const ${entity.name.toUpperCase()}: u32 = ${crc32(entity.name)};\n`;
|
|
25
|
+
}
|
|
26
|
+
code += '\n';
|
|
27
|
+
}
|
|
28
|
+
return cratePrivate ? `${code.trimEnd()}\n` : code;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=rust-type-id-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-type-id-generator.js","sourceRoot":"","sources":["../src/rust-type-id-generator.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,mFAAmF;AACnF,MAAM,UAAU,uBAAuB,CACrC,MAAqB,EACrB,YAAqB,EACrB,UAAyE;IAEzE,IAAI,IAAI,GAAG;;;;;;;qCAOwB,MAAM,CAAC,IAAI;;;;;;CAM/C,CAAC;IAEA,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACtE,IAAI,IAAI,MAAM,QAAQ,IAAI,CAAC;QAC3B,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC9B,IAAI,IAAI,aAAa,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACnF,CAAC;QACD,IAAI,IAAI,IAAI,CAAC;IACf,CAAC;IAED,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC"}
|
|
@@ -8,12 +8,12 @@ export function generateTypeNameParser(schema) {
|
|
|
8
8
|
return known;
|
|
9
9
|
}
|
|
10
10
|
if s.bytes().all(|b| b.is_ascii() && !b.is_ascii_lowercase()) {
|
|
11
|
-
return Self::Unknown(
|
|
11
|
+
return Self::Unknown(UnknownIfcType::new(s.to_owned()));
|
|
12
12
|
}
|
|
13
13
|
// Keep Unicode uppercase expansion and the exact unknown-type CRC.
|
|
14
14
|
let upper = s.to_uppercase();
|
|
15
15
|
Self::from_canonical_name(&upper)
|
|
16
|
-
.unwrap_or_else(|| Self::Unknown(
|
|
16
|
+
.unwrap_or_else(|| Self::Unknown(UnknownIfcType::new(upper)))
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
fn from_canonical_name(s: &str) -> Option<Self> {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-unknown-ifc-type.d.ts","sourceRoot":"","sources":["../src/rust-unknown-ifc-type.ts"],"names":[],"mappings":"AAIA,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,KAAK,GAAG,YAAY,GAAG,MAAM,CA0B/E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/** Render the generated owned representation for unsupported IFC keywords. */
|
|
5
|
+
export function generateUnknownIfcType(visibility) {
|
|
6
|
+
return `/// A normalized IFC keyword not declared by the supported schema universe.
|
|
7
|
+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
8
|
+
${visibility} struct UnknownIfcType {
|
|
9
|
+
name: String,
|
|
10
|
+
id: u32,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
impl UnknownIfcType {
|
|
14
|
+
fn new(name: String) -> Self {
|
|
15
|
+
let id = crc32_hash(&name);
|
|
16
|
+
Self { name, id }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// Normalized uppercase STEP keyword.
|
|
20
|
+
${visibility} fn as_str(&self) -> &str {
|
|
21
|
+
&self.name
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// CRC32 identifier of the normalized keyword.
|
|
25
|
+
${visibility} fn id(&self) -> u32 {
|
|
26
|
+
self.id
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=rust-unknown-ifc-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-unknown-ifc-type.js","sourceRoot":"","sources":["../src/rust-unknown-ifc-type.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,8EAA8E;AAC9E,MAAM,UAAU,sBAAsB,CAAC,UAAgC;IACrE,OAAO;;EAEP,UAAU;;;;;;;;;;;;MAYN,UAAU;;;;;MAKV,UAAU;;;;;CAKf,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ifc-lite/codegen",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "TypeScript code generator from IFC EXPRESS schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"license": "MPL-2.0",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"commander": "^15.0.0",
|
|
50
|
-
"@ifc-lite/data": "^
|
|
50
|
+
"@ifc-lite/data": "^6.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^26.4
|
|
53
|
+
"@types/node": "^26.6.4",
|
|
54
54
|
"typescript": "^6.0.3",
|
|
55
|
-
"vitest": "^
|
|
55
|
+
"vitest": "^5.0.3"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|