@ifc-lite/codegen 1.18.1 → 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 +26 -6
- 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-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/package.json +4 -4
- package/schemas/attribute-renames.json +28 -0
package/README.md
CHANGED
|
@@ -36,6 +36,21 @@ node dist/cli.js schemas/IFC4X3.exp --rust \
|
|
|
36
36
|
--rust-supplemental-schema schemas/IFC4_ADD2_TC1.exp schemas/IFC2X3_TC1.exp
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
To also emit the typed attribute slots (`slots.rs`, consumed as `ifc_lite_core::slot`), pass
|
|
40
|
+
every other bundled release with `--rust-slot-schema` and the same-position rename table with
|
|
41
|
+
`--rust-slot-renames`. Slots are named by the canonical attribute name, stable positions become
|
|
42
|
+
`Slot<Kind>` consts and positions that move between releases become `SchemaSlot<Kind>`; every
|
|
43
|
+
row of `schemas/attribute-renames.json` is validated against the schemas and a rename whose names
|
|
44
|
+
sit at different positions fails generation. `scripts/check-codegen-sync.mjs` regenerates the
|
|
45
|
+
committed file:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
node dist/cli.js schemas/IFC4X3.exp --rust \
|
|
49
|
+
--rust-supplemental-schema schemas/IFC4_ADD2_TC1.exp schemas/IFC2X3_TC1.exp \
|
|
50
|
+
--rust-slot-schema schemas/IFC2X3_TC1.exp schemas/IFC4_ADD2_TC1.exp schemas/IFC4X1.exp schemas/IFC4X2.exp \
|
|
51
|
+
--rust-slot-renames schemas/attribute-renames.json
|
|
52
|
+
```
|
|
53
|
+
|
|
39
54
|
Generated files (one per output directory, e.g. `./generated/ifc4`):
|
|
40
55
|
|
|
41
56
|
```text
|
package/dist/cli.js
CHANGED
|
@@ -21,6 +21,8 @@ program
|
|
|
21
21
|
.option('--rust-dir <dir>', 'Rust output subdirectory (relative to output)', 'rust')
|
|
22
22
|
.option('--rust-crate-private', 'Keep generated Rust types crate-private', false)
|
|
23
23
|
.option('--rust-supplemental-schema <path...>', 'Additional EXPRESS schemas whose entity names extend the Rust IfcType universe')
|
|
24
|
+
.option('--rust-slot-schema <path...>', 'Every bundled EXPRESS release other than the input; their attribute positions feed generated slots.rs')
|
|
25
|
+
.option('--rust-slot-renames <path>', 'attribute-renames.json for the slot generator')
|
|
24
26
|
.option('--skip-collision-check', 'Skip CRC32 collision check', false)
|
|
25
27
|
.option('-v, --verbose', 'Verbose output', false)
|
|
26
28
|
.action((schemaPath, options) => {
|
|
@@ -42,6 +44,8 @@ program
|
|
|
42
44
|
rustDir: options.rustDir,
|
|
43
45
|
rustCratePrivate: options.rustCratePrivate,
|
|
44
46
|
rustSupplementalSchemaPaths: options.rustSupplementalSchema,
|
|
47
|
+
rustSlotSchemaPaths: options.rustSlotSchema,
|
|
48
|
+
rustSlotRenamesPath: options.rustSlotRenames,
|
|
45
49
|
skipCollisionCheck: options.skipCollisionCheck,
|
|
46
50
|
};
|
|
47
51
|
generateFromFile(schemaPath, options.output, genOptions);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;+DAE+D;AAE/D;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAEzE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,4DAA4D,CAAC;KACzE,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,QAAQ,CAAC,UAAU,EAAE,oCAAoC,CAAC;KAC1D,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,CAAC;KAC/D,MAAM,CAAC,YAAY,EAAE,oBAAoB,EAAE,KAAK,CAAC;KACjD,MAAM,CAAC,kBAAkB,EAAE,+CAA+C,EAAE,MAAM,CAAC;KACnF,MAAM,CAAC,sBAAsB,EAAE,yCAAyC,EAAE,KAAK,CAAC;KAChF,MAAM,CACL,sCAAsC,EACtC,gFAAgF,CACjF;KACA,MAAM,CAAC,wBAAwB,EAAE,4BAA4B,EAAE,KAAK,CAAC;KACrE,MAAM,CAAC,eAAe,EAAE,gBAAgB,EAAE,KAAK,CAAC;KAChD,MAAM,CACL,CACE,UAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;+DAE+D;AAE/D;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAEzE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,4DAA4D,CAAC;KACzE,OAAO,CAAC,OAAO,CAAC,CAAC;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YACnC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,2BAA2B,EAAE,OAAO,CAAC,sBAAsB;YAC3D,mBAAmB,EAAE,OAAO,CAAC,cAAc;YAC3C,mBAAmB,EAAE,OAAO,CAAC,eAAe;YAC5C,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;SAC/C,CAAC;QAEF,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,sBAAsB,OAAO,IAAI,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CACF,CAAC;AAEJ,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/generator.d.ts
CHANGED
|
@@ -12,6 +12,15 @@ export interface GeneratorOptions {
|
|
|
12
12
|
rustCratePrivate?: boolean;
|
|
13
13
|
/** Additional EXPRESS files whose entity names extend the Rust IfcType universe. */
|
|
14
14
|
rustSupplementalSchemaPaths?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Additional EXPRESS files (every bundled release other than the canonical
|
|
17
|
+
* one) whose attribute positions feed the generated Rust slots
|
|
18
|
+
* (`slots.rs`). Slots are emitted only when this and
|
|
19
|
+
* `rustSlotRenamesPath` are both given, and never for a crate-private run.
|
|
20
|
+
*/
|
|
21
|
+
rustSlotSchemaPaths?: string[];
|
|
22
|
+
/** The same-position rename table for the slot generator. */
|
|
23
|
+
rustSlotRenamesPath?: string;
|
|
15
24
|
/** Skip type ID collision check */
|
|
16
25
|
skipCollisionCheck?: boolean;
|
|
17
26
|
}
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AASnF,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oFAAoF;IACpF,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mCAAmC;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,gBAAqB,GAC7B,iBAAiB,CAMnB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,gBAAqB,GAC7B,iBAAiB,CA8PnB;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gBAAqB,GAC7B,IAAI,CAoBN"}
|
package/dist/generator.js
CHANGED
|
@@ -19,7 +19,9 @@ import { generateTypeIds } from './type-ids-generator.js';
|
|
|
19
19
|
import { generateSerializers } from './serialization-generator.js';
|
|
20
20
|
import { generateRust } from './rust-generator.js';
|
|
21
21
|
import { findCollisions } from './crc32.js';
|
|
22
|
-
import { entityCatalogSchema } from './rust-schema-queries.js';
|
|
22
|
+
import { entityCatalogSchema, mergeTypeUniverse } from './rust-schema-queries.js';
|
|
23
|
+
import { generateSlots, slotSchemaOf } from './rust-slot-emitter.js';
|
|
24
|
+
import { parseRenames } from './rust-slot-renames.js';
|
|
23
25
|
/**
|
|
24
26
|
* Generate all code from an EXPRESS schema file
|
|
25
27
|
*/
|
|
@@ -137,6 +139,23 @@ export * from './serializers.js';
|
|
|
137
139
|
console.log(` ✓ ${rustDir}/type_ids.rs`);
|
|
138
140
|
writeFileSync(`${rustDir}/schema.rs`, rustCode.schema);
|
|
139
141
|
console.log(` ✓ ${rustDir}/schema.rs`);
|
|
142
|
+
const emitSlots = !options.rustCratePrivate && !!options.rustSlotSchemaPaths?.length && !!options.rustSlotRenamesPath;
|
|
143
|
+
if (options.rustSlotSchemaPaths?.length && !options.rustSlotRenamesPath) {
|
|
144
|
+
throw new Error('--rust-slot-schema needs --rust-slot-renames');
|
|
145
|
+
}
|
|
146
|
+
if (emitSlots) {
|
|
147
|
+
const others = options.rustSlotSchemaPaths.map((path) => {
|
|
148
|
+
const parsed = parseExpressSchema(readFileSync(path, 'utf-8').replace(/\r\n?/g, '\n'));
|
|
149
|
+
return { version: slotSchemaOf(parsed.name), schema: parsed };
|
|
150
|
+
});
|
|
151
|
+
const renames = parseRenames(JSON.parse(readFileSync(options.rustSlotRenamesPath, 'utf-8')));
|
|
152
|
+
const universe = mergeTypeUniverse(schema, rustSupplementalSchemas);
|
|
153
|
+
const slots = generateSlots({ version: slotSchemaOf(schema.name), schema }, others, universe.entities, renames);
|
|
154
|
+
writeFileSync(`${rustDir}/slots.rs`, slots.slots);
|
|
155
|
+
console.log(` ✓ ${rustDir}/slots.rs`);
|
|
156
|
+
writeFileSync(`${rustDir}/slots_table.rs`, slots.table);
|
|
157
|
+
console.log(` ✓ ${rustDir}/slots_table.rs`);
|
|
158
|
+
}
|
|
140
159
|
// Write mod.rs
|
|
141
160
|
const modContent = options.rustCratePrivate
|
|
142
161
|
? `// This Source Code Form is subject to the terms of the Mozilla Public
|
|
@@ -167,18 +186,19 @@ pub(crate) use schema::*;
|
|
|
167
186
|
//!
|
|
168
187
|
//! DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
|
|
169
188
|
|
|
170
|
-
mod ifc2x3;
|
|
171
|
-
mod ifc4;
|
|
172
|
-
mod ifc4x1;
|
|
173
|
-
mod ifc4x2;
|
|
189
|
+
pub(crate) mod ifc2x3;
|
|
190
|
+
pub(crate) mod ifc4;
|
|
191
|
+
pub(crate) mod ifc4x1;
|
|
192
|
+
pub(crate) mod ifc4x2;
|
|
174
193
|
mod schema;
|
|
175
194
|
pub(crate) mod schema_registry;
|
|
176
|
-
mod type_ids;
|
|
195
|
+
${options.rustSlotSchemaPaths?.length ? 'pub(crate) mod slots;\n#[cfg(test)]\npub(crate) mod slots_table;\n' : ''}mod type_ids;
|
|
177
196
|
|
|
178
197
|
pub use type_ids::*;
|
|
179
198
|
pub use schema::{IfcType, UnknownIfcType, ALL as IFC_TYPES};
|
|
180
199
|
pub use schema_registry::{
|
|
181
200
|
attribute_names_for_schema, entity_info_for_schema, is_subtype_of_for_schema, SchemaEntityInfo,
|
|
201
|
+
SchemaVersion,
|
|
182
202
|
};
|
|
183
203
|
`;
|
|
184
204
|
writeFileSync(`${rustDir}/mod.rs`, modContent);
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/gener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te per attribute, parallel to `attribute_names()`:
|
|
5
|
+
*
|
|
6
|
+
* bits 0-3 value kind (the KIND_* codes below; mirrored by
|
|
7
|
+
* `AttrKind` in rust/core/src/attribute_slot.rs)
|
|
8
|
+
* bit 4 AGGREGATE: the value may be written as a STEP list
|
|
9
|
+
* bit 5 OPTIONAL: the EXPRESS declaration says OPTIONAL
|
|
10
|
+
*
|
|
11
|
+
* The kind is resolved through defined types and selects, recursively:
|
|
12
|
+
* an entity, or a select of entities only, is a Ref; an aggregate of those is
|
|
13
|
+
* a RefList; any other aggregate is a List; REAL/NUMBER, INTEGER, STRING,
|
|
14
|
+
* ENUMERATION, BOOLEAN/LOGICAL and BINARY map to their scalar kinds; a select
|
|
15
|
+
* that mixes entities with value types is a Select. AGGREGATE is set for a
|
|
16
|
+
* LIST/SET/ARRAY, for a defined type that is one, and for a select with such
|
|
17
|
+
* an alternative (IfcPropertySetDefinitionSelect admits a SET of definitions
|
|
18
|
+
* written inline as `(#20,#21)`).
|
|
19
|
+
*
|
|
20
|
+
* A name that resolves to nothing is a generation error, never a silent
|
|
21
|
+
* default: a wrong flag reads as a wrong attribute at runtime.
|
|
22
|
+
*/
|
|
23
|
+
import type { AttributeDefinition, ExpressSchema } from './express-parser.js';
|
|
24
|
+
/** Mirrors `AttrKind` in rust/core/src/attribute_slot.rs. */
|
|
25
|
+
export declare const KIND: {
|
|
26
|
+
readonly Ref: 0;
|
|
27
|
+
readonly RefList: 1;
|
|
28
|
+
readonly List: 2;
|
|
29
|
+
readonly Real: 3;
|
|
30
|
+
readonly Int: 4;
|
|
31
|
+
readonly Text: 5;
|
|
32
|
+
readonly Enum: 6;
|
|
33
|
+
readonly Logical: 7;
|
|
34
|
+
readonly Binary: 8;
|
|
35
|
+
readonly Select: 9;
|
|
36
|
+
};
|
|
37
|
+
export type Kind = (typeof KIND)[keyof typeof KIND];
|
|
38
|
+
export declare const FLAG_AGGREGATE = 16;
|
|
39
|
+
export declare const FLAG_OPTIONAL = 32;
|
|
40
|
+
/** Resolves EXPRESS type names against one schema. */
|
|
41
|
+
export declare class AttributeKindResolver {
|
|
42
|
+
private readonly entities;
|
|
43
|
+
private readonly types;
|
|
44
|
+
private readonly enums;
|
|
45
|
+
private readonly selects;
|
|
46
|
+
private readonly memo;
|
|
47
|
+
constructor(schema: ExpressSchema);
|
|
48
|
+
/** The flag byte for one attribute. */
|
|
49
|
+
flagByte(attribute: AttributeDefinition): number;
|
|
50
|
+
private attribute;
|
|
51
|
+
private aggregateKind;
|
|
52
|
+
private resolve;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=rust-attribute-flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-attribute-flags.d.ts","sourceRoot":"","sources":["../src/rust-attribute-flags.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9E,6DAA6D;AAC7D,eAAO,MAAM,IAAI;;;;;;;;;;;CAWP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC;AAEpD,eAAO,MAAM,cAAc,KAAO,CAAC;AACnC,eAAO,MAAM,aAAa,KAAO,CAAC;AASlC,sDAAsD;AACtD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;IAChE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA+B;gBAExC,MAAM,EAAE,aAAa;IAOjC,uCAAuC;IACvC,QAAQ,CAAC,SAAS,EAAE,mBAAmB,GAAG,MAAM;IAKhD,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;CAoChB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
/** Mirrors `AttrKind` in rust/core/src/attribute_slot.rs. */
|
|
5
|
+
export const KIND = {
|
|
6
|
+
Ref: 0,
|
|
7
|
+
RefList: 1,
|
|
8
|
+
List: 2,
|
|
9
|
+
Real: 3,
|
|
10
|
+
Int: 4,
|
|
11
|
+
Text: 5,
|
|
12
|
+
Enum: 6,
|
|
13
|
+
Logical: 7,
|
|
14
|
+
Binary: 8,
|
|
15
|
+
Select: 9,
|
|
16
|
+
};
|
|
17
|
+
export const FLAG_AGGREGATE = 0x10;
|
|
18
|
+
export const FLAG_OPTIONAL = 0x20;
|
|
19
|
+
const AGGREGATE_TYPE = /^(?:LIST|ARRAY|SET)\s*(?:\[[^\]]*\])?\s+OF\s+(?:OPTIONAL\s+)?(?:UNIQUE\s+)?([\s\S]*)$/;
|
|
20
|
+
/** Resolves EXPRESS type names against one schema. */
|
|
21
|
+
export class AttributeKindResolver {
|
|
22
|
+
entities;
|
|
23
|
+
types = new Map();
|
|
24
|
+
enums;
|
|
25
|
+
selects = new Map();
|
|
26
|
+
memo = new Map();
|
|
27
|
+
constructor(schema) {
|
|
28
|
+
this.entities = new Set(schema.entities.map((e) => e.name.toLowerCase()));
|
|
29
|
+
for (const t of schema.types)
|
|
30
|
+
this.types.set(t.name.toLowerCase(), t.underlyingType);
|
|
31
|
+
this.enums = new Set(schema.enums.map((e) => e.name.toLowerCase()));
|
|
32
|
+
for (const s of schema.selects)
|
|
33
|
+
this.selects.set(s.name.toLowerCase(), s.types);
|
|
34
|
+
}
|
|
35
|
+
/** The flag byte for one attribute. */
|
|
36
|
+
flagByte(attribute) {
|
|
37
|
+
const { kind, aggregate } = this.attribute(attribute);
|
|
38
|
+
return kind | (aggregate ? FLAG_AGGREGATE : 0) | (attribute.optional ? FLAG_OPTIONAL : 0);
|
|
39
|
+
}
|
|
40
|
+
attribute(attribute) {
|
|
41
|
+
if (!(attribute.isList || attribute.isArray || attribute.isSet)) {
|
|
42
|
+
return this.resolve(attribute.type, new Set());
|
|
43
|
+
}
|
|
44
|
+
// The parser keeps nested aggregates as "X[]"; those are never RefList.
|
|
45
|
+
if (attribute.type.endsWith('[]'))
|
|
46
|
+
return { kind: KIND.List, aggregate: true };
|
|
47
|
+
return { kind: this.aggregateKind(this.resolve(attribute.type, new Set())), aggregate: true };
|
|
48
|
+
}
|
|
49
|
+
aggregateKind(element) {
|
|
50
|
+
return element.kind === KIND.Ref && !element.aggregate ? KIND.RefList : KIND.List;
|
|
51
|
+
}
|
|
52
|
+
resolve(rawName, visiting) {
|
|
53
|
+
const name = rawName.trim();
|
|
54
|
+
const aggregateElement = name.match(AGGREGATE_TYPE);
|
|
55
|
+
if (aggregateElement) {
|
|
56
|
+
return { kind: this.aggregateKind(this.resolve(aggregateElement[1], visiting)), aggregate: true };
|
|
57
|
+
}
|
|
58
|
+
const base = name.toUpperCase().match(/^(REAL|NUMBER|INTEGER|STRING|BOOLEAN|LOGICAL|BINARY)\b/);
|
|
59
|
+
if (base)
|
|
60
|
+
return { kind: BASE_KIND[base[1]], aggregate: false };
|
|
61
|
+
const key = name.toLowerCase();
|
|
62
|
+
const cached = this.memo.get(key);
|
|
63
|
+
if (cached)
|
|
64
|
+
return cached;
|
|
65
|
+
if (visiting.has(key))
|
|
66
|
+
throw new Error(`cyclic EXPRESS type definition at ${name}`);
|
|
67
|
+
visiting.add(key);
|
|
68
|
+
let result;
|
|
69
|
+
if (this.entities.has(key)) {
|
|
70
|
+
result = { kind: KIND.Ref, aggregate: false };
|
|
71
|
+
}
|
|
72
|
+
else if (this.enums.has(key)) {
|
|
73
|
+
result = { kind: KIND.Enum, aggregate: false };
|
|
74
|
+
}
|
|
75
|
+
else if (this.selects.has(key)) {
|
|
76
|
+
const members = this.selects.get(key).map((member) => this.resolve(member, visiting));
|
|
77
|
+
const refsOnly = members.every((m) => m.kind === KIND.Ref && !m.aggregate);
|
|
78
|
+
result = {
|
|
79
|
+
kind: refsOnly ? KIND.Ref : KIND.Select,
|
|
80
|
+
aggregate: members.some((m) => m.aggregate),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else if (this.types.has(key)) {
|
|
84
|
+
result = this.resolve(this.types.get(key), visiting);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error(`cannot classify EXPRESS type "${name}"`);
|
|
88
|
+
}
|
|
89
|
+
visiting.delete(key);
|
|
90
|
+
this.memo.set(key, result);
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const BASE_KIND = {
|
|
95
|
+
REAL: KIND.Real,
|
|
96
|
+
NUMBER: KIND.Real,
|
|
97
|
+
INTEGER: KIND.Int,
|
|
98
|
+
STRING: KIND.Text,
|
|
99
|
+
BOOLEAN: KIND.Logical,
|
|
100
|
+
LOGICAL: KIND.Logical,
|
|
101
|
+
BINARY: KIND.Binary,
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=rust-attribute-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-attribute-flags.js","sourceRoot":"","sources":["../src/rust-attribute-flags.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA2B/D,6DAA6D;AAC7D,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;IACV,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACD,CAAC;AAGX,MAAM,CAAC,MAA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appings":"AAIA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rust-schema-queries.d.ts","sourceRoot":"","sources":["../src/rust-schema-queries.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI3E,+EAA+E;AAC/E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,aAAa,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAClD,aAAa,CAef;AAED,wEAAwE;AACxE,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,aAAa,EACxB,YAAY,EAAE,SAAS,aAAa,EAAE,GACrC,aAAa,CAgBf;AAED,mEAAmE;AACnE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EACrB,YAAY,GAAE,SAAS,gBAAgB,EAAoB,EAC3D,UAAU,SAAQ,GACjB,MAAM,CAwER"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
import { getAllAttributes } from './express-parser.js';
|
|
5
|
+
import { AttributeKindResolver } from './rust-attribute-flags.js';
|
|
5
6
|
/** Adapt class-shaped IFC catalog rows into a name-only EXPRESS supplement. */
|
|
6
7
|
export function entityCatalogSchema(name, catalog, excludedTypes) {
|
|
7
8
|
const excludedNames = new Set(excludedTypes.map((type) => type.name.toUpperCase()));
|
|
@@ -37,6 +38,7 @@ export function mergeTypeUniverse(canonical, supplemental) {
|
|
|
37
38
|
/** Emitted inside `impl IfcType { … }`, closing the impl block. */
|
|
38
39
|
export function generateSchemaQueries(schema, typeUniverse = schema.entities, visibility = 'pub') {
|
|
39
40
|
const canonicalNames = new Set(schema.entities.map((entity) => entity.name));
|
|
41
|
+
const resolver = new AttributeKindResolver(schema);
|
|
40
42
|
return ` /// This entity's attributes, in STEP declaration order.
|
|
41
43
|
///
|
|
42
44
|
/// Supertype attributes come FIRST, which is what makes the position here
|
|
@@ -57,12 +59,18 @@ ${typeUniverse.map((e) => canonicalNames.has(e.name)
|
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
///
|
|
62
|
+
/// One flag byte per attribute, parallel to \`attribute_names()\`.
|
|
61
63
|
///
|
|
62
|
-
///
|
|
63
|
-
///
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
/// Bits 0-3 are the value kind (\`AttrKind\`), bit 4 is AGGREGATE (the
|
|
65
|
+
/// value may be a STEP list) and bit 5 is OPTIONAL. Decode with
|
|
66
|
+
/// \`SchemaVersion::attribute\`, never by hand.
|
|
67
|
+
pub fn attribute_flags(&self) -> &'static [u8] {
|
|
68
|
+
match self {
|
|
69
|
+
${typeUniverse.map((e) => canonicalNames.has(e.name)
|
|
70
|
+
? ` Self::${e.name} => &[${getAllAttributes(e, schema).map((a) => resolver.flagByte(a)).join(', ')}],`
|
|
71
|
+
: ` Self::${e.name} => &[],`).join('\n')}
|
|
72
|
+
Self::Unknown(_) => &[],
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
/// Whether ${schema.name} itself declares this class.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust-schema-queries.js","sourceRoot":"","sources":["../src/rust-schema-queries.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rust-schema-queries.js","source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CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;CAEjE,CAAC;AACF,CAAC"}
|
|
@@ -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
|
+
};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UxE,IAAI;;;CAGL,CAAC;AACF,CAAC;AASD,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAC3B,SAA0B,EAC1B,MAAkC,EAClC,YAAyC,EACzC,KAAkB;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,IAA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}
|
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": "^6.
|
|
50
|
+
"@ifc-lite/data": "^6.3.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^26.6.
|
|
53
|
+
"@types/node": "^26.6.4",
|
|
54
54
|
"typescript": "^6.0.3",
|
|
55
|
-
"vitest": "^5.0.
|
|
55
|
+
"vitest": "^5.0.3"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"comment": [
|
|
3
|
+
"Same-position attribute renames between bundled IFC releases (F3e-0b, #7780).",
|
|
4
|
+
"The slot generator (src/rust-slot-emitter.ts) names a slot by its canonical IFC4X3 name and treats a listed older spelling as the SAME attribute.",
|
|
5
|
+
"Every row is validated: a row whose names sit at different positions in two schemas fails generation, so a rename can never cover a move.",
|
|
6
|
+
"A row applies to the listed entities and all of their subtypes.",
|
|
7
|
+
"Semantic replacements are NOT renames and stay out of this file: CompositionType -> PredefinedType (IfcBuildingElementProxy), InteriorOrExteriorSpace -> PredefinedType (IfcSpace), ShapeType -> PredefinedType (IfcRamp, IfcRoof, IfcStair), BarRole -> PredefinedType (IfcReinforcingBar) and OperationType -> PredefinedType (IfcTransportElement) each name a different enumeration. They stay moving slots and read as absent in IFC2X3.",
|
|
8
|
+
"UrlReference -> URLReference (IfcImageTexture) is also not a rename: IFC4 inserted attributes before it, so it moved (4 -> 5).",
|
|
9
|
+
"Such a moved attribute whose old spelling would give the same slot name as the new one is listed under \"omit\": it gets no slot, and the texture readers pin IFC4 (D6)."
|
|
10
|
+
],
|
|
11
|
+
"omit": [
|
|
12
|
+
{ "entity": "IfcImageTexture", "attribute": "UrlReference" }
|
|
13
|
+
],
|
|
14
|
+
"renames": [
|
|
15
|
+
{ "name": "Specification", "aliases": ["Description"], "entities": ["IfcProperty", "IfcComplexProperty"] },
|
|
16
|
+
{ "name": "Specification", "aliases": ["Location"], "entities": ["IfcClassification"] },
|
|
17
|
+
{ "name": "Identification", "aliases": ["ItemReference"], "entities": ["IfcExternalReference"] },
|
|
18
|
+
{ "name": "Identification", "aliases": ["Id"], "entities": ["IfcOrganization", "IfcPerson"] },
|
|
19
|
+
{ "name": "Identification", "aliases": ["DocumentId"], "entities": ["IfcDocumentInformation"] },
|
|
20
|
+
{ "name": "Mode", "aliases": ["TextureType"], "entities": ["IfcSurfaceTexture"] },
|
|
21
|
+
{ "name": "NumberOfRisers", "aliases": ["NumberOfRiser"], "entities": ["IfcStairFlight"] },
|
|
22
|
+
{ "name": "RelatingSpace", "aliases": ["RelatedSpace"], "entities": ["IfcRelCoversSpaces"] },
|
|
23
|
+
{ "name": "DeltaTConstant", "aliases": ["DeltaT_Constant"], "entities": ["IfcStructuralLoadTemperature"] },
|
|
24
|
+
{ "name": "DeltaTY", "aliases": ["DeltaT_Y"], "entities": ["IfcStructuralLoadTemperature"] },
|
|
25
|
+
{ "name": "DeltaTZ", "aliases": ["DeltaT_Z"], "entities": ["IfcStructuralLoadTemperature"] },
|
|
26
|
+
{ "name": "ModelOrDraughting", "aliases": ["ModelorDraughting"], "entities": ["IfcFillAreaStyle"] }
|
|
27
|
+
]
|
|
28
|
+
}
|