@ifc-lite/codegen 1.0.0 ā 1.1.1
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/dist/cli.js +23 -5
- package/dist/cli.js.map +1 -1
- package/dist/crc32.d.ts +16 -0
- package/dist/crc32.d.ts.map +1 -0
- package/dist/crc32.js +69 -0
- package/dist/crc32.js.map +1 -0
- package/dist/generator.d.ts +20 -4
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +175 -19
- package/dist/generator.js.map +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/rust-generator.d.ts +20 -0
- package/dist/rust-generator.d.ts.map +1 -0
- package/dist/rust-generator.js +640 -0
- package/dist/rust-generator.js.map +1 -0
- package/dist/serialization-generator.d.ts +11 -0
- package/dist/serialization-generator.d.ts.map +1 -0
- package/dist/serialization-generator.js +333 -0
- package/dist/serialization-generator.js.map +1 -0
- package/dist/type-ids-generator.d.ts +11 -0
- package/dist/type-ids-generator.d.ts.map +1 -0
- package/dist/type-ids-generator.js +153 -0
- package/dist/type-ids-generator.js.map +1 -0
- package/generated/ifc4x3/entities.ts +9 -13
- package/generated/ifc4x3/enums.ts +0 -4
- package/generated/ifc4x3/index.ts +4 -2
- package/generated/ifc4x3/schema-registry.ts +326 -2718
- package/generated/ifc4x3/selects.ts +0 -4
- package/generated/ifc4x3/serializers.ts +322 -0
- package/generated/ifc4x3/test-compile.ts +49 -0
- package/generated/ifc4x3/type-ids.ts +1882 -0
- package/generated/ifc4x3/types.ts +0 -4
- package/package.json +1 -1
- package/src/cli.ts +49 -18
- package/src/crc32.ts +77 -0
- package/src/generator.ts +213 -21
- package/src/index.ts +28 -2
- package/src/rust-generator.ts +715 -0
- package/src/serialization-generator.ts +343 -0
- package/src/type-ids-generator.ts +166 -0
- package/tsconfig.json +1 -0
package/dist/cli.js
CHANGED
|
@@ -4,25 +4,43 @@
|
|
|
4
4
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
5
5
|
/**
|
|
6
6
|
* CLI for IFC code generation
|
|
7
|
+
*
|
|
8
|
+
* Generates TypeScript and optionally Rust code from IFC EXPRESS schemas.
|
|
7
9
|
*/
|
|
8
10
|
import { Command } from 'commander';
|
|
9
11
|
import { generateFromFile } from './generator.js';
|
|
10
12
|
const program = new Command();
|
|
11
13
|
program
|
|
12
14
|
.name('ifc-codegen')
|
|
13
|
-
.description('Generate TypeScript code from IFC EXPRESS schemas')
|
|
14
|
-
.version('0.
|
|
15
|
+
.description('Generate TypeScript and Rust code from IFC EXPRESS schemas')
|
|
16
|
+
.version('0.2.0');
|
|
15
17
|
program
|
|
16
18
|
.argument('<schema>', 'Path to EXPRESS schema file (.exp)')
|
|
17
19
|
.option('-o, --output <dir>', 'Output directory', './generated')
|
|
20
|
+
.option('-r, --rust', 'Generate Rust code', false)
|
|
21
|
+
.option('--rust-dir <dir>', 'Rust output subdirectory (relative to output)', 'rust')
|
|
22
|
+
.option('--skip-collision-check', 'Skip CRC32 collision check', false)
|
|
18
23
|
.option('-v, --verbose', 'Verbose output', false)
|
|
19
24
|
.action((schemaPath, options) => {
|
|
20
25
|
try {
|
|
21
|
-
console.log('š IFC
|
|
26
|
+
console.log('š IFC Code Generator\n');
|
|
22
27
|
console.log(`Schema: ${schemaPath}`);
|
|
23
|
-
console.log(`Output: ${options.output}
|
|
28
|
+
console.log(`Output: ${options.output}`);
|
|
29
|
+
if (options.rust) {
|
|
30
|
+
// Check if rustDir is absolute or relative for display
|
|
31
|
+
const rustDisplay = options.rustDir.startsWith('/')
|
|
32
|
+
? options.rustDir
|
|
33
|
+
: `${options.output}/${options.rustDir}`;
|
|
34
|
+
console.log(`Rust: ${rustDisplay}`);
|
|
35
|
+
}
|
|
36
|
+
console.log();
|
|
24
37
|
const start = Date.now();
|
|
25
|
-
|
|
38
|
+
const genOptions = {
|
|
39
|
+
rust: options.rust,
|
|
40
|
+
rustDir: options.rustDir,
|
|
41
|
+
skipCollisionCheck: options.skipCollisionCheck,
|
|
42
|
+
};
|
|
43
|
+
generateFromFile(schemaPath, options.output, genOptions);
|
|
26
44
|
const elapsed = Date.now() - start;
|
|
27
45
|
console.log(`\nā±ļø Completed in ${elapsed}ms`);
|
|
28
46
|
}
|
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
|
|
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,wBAAwB,EAAE,4BAA4B,EAAE,KAAK,CAAC;KACrE,MAAM,CAAC,eAAe,EAAE,gBAAgB,EAAE,KAAK,CAAC;KAChD,MAAM,CACL,CACE,UAAkB,EAClB,OAMC,EACD,EAAE;IACF,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,WAAW,UAAU,EAAE,CAA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ash for a string
|
|
3
|
+
* @param str Input string (will be uppercased)
|
|
4
|
+
* @returns 32-bit unsigned integer hash
|
|
5
|
+
*/
|
|
6
|
+
export declare function crc32(str: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* Generate type IDs for all entities in a schema
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateTypeIds(entityNames: string[]): Map<string, number>;
|
|
11
|
+
/**
|
|
12
|
+
* Check for CRC32 collisions in a list of names
|
|
13
|
+
* @returns Map of hash -> names[] for any collisions
|
|
14
|
+
*/
|
|
15
|
+
export declare function findCollisions(names: string[]): Map<number, string[]>;
|
|
16
|
+
//# sourceMappingURL=crc32.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32.d.ts","sourceRoot":"","sources":["../src/crc32.ts"],"names":[],"mappings":"AA4BA;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOzC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAM1E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAmBrE"}
|
package/dist/crc32.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* CRC32 Type ID Generator
|
|
6
|
+
*
|
|
7
|
+
* Generates consistent CRC32 hashes for IFC type names.
|
|
8
|
+
* Used for fast O(1) type lookup in both TypeScript and Rust.
|
|
9
|
+
*
|
|
10
|
+
* This matches the algorithm used by web-ifc for compatibility.
|
|
11
|
+
*/
|
|
12
|
+
// Pre-computed CRC32 lookup table (IEEE polynomial)
|
|
13
|
+
const CRC32_TABLE = buildCRC32Table();
|
|
14
|
+
function buildCRC32Table() {
|
|
15
|
+
const table = new Uint32Array(256);
|
|
16
|
+
for (let i = 0; i < 256; i++) {
|
|
17
|
+
let c = i;
|
|
18
|
+
for (let j = 0; j < 8; j++) {
|
|
19
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
20
|
+
}
|
|
21
|
+
table[i] = c >>> 0;
|
|
22
|
+
}
|
|
23
|
+
return table;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calculate CRC32 hash for a string
|
|
27
|
+
* @param str Input string (will be uppercased)
|
|
28
|
+
* @returns 32-bit unsigned integer hash
|
|
29
|
+
*/
|
|
30
|
+
export function crc32(str) {
|
|
31
|
+
const upper = str.toUpperCase();
|
|
32
|
+
let crc = 0xffffffff;
|
|
33
|
+
for (let i = 0; i < upper.length; i++) {
|
|
34
|
+
crc = CRC32_TABLE[(crc ^ upper.charCodeAt(i)) & 0xff] ^ (crc >>> 8);
|
|
35
|
+
}
|
|
36
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate type IDs for all entities in a schema
|
|
40
|
+
*/
|
|
41
|
+
export function generateTypeIds(entityNames) {
|
|
42
|
+
const ids = new Map();
|
|
43
|
+
for (const name of entityNames) {
|
|
44
|
+
ids.set(name, crc32(name));
|
|
45
|
+
}
|
|
46
|
+
return ids;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Check for CRC32 collisions in a list of names
|
|
50
|
+
* @returns Map of hash -> names[] for any collisions
|
|
51
|
+
*/
|
|
52
|
+
export function findCollisions(names) {
|
|
53
|
+
const hashToNames = new Map();
|
|
54
|
+
for (const name of names) {
|
|
55
|
+
const hash = crc32(name);
|
|
56
|
+
const existing = hashToNames.get(hash) || [];
|
|
57
|
+
existing.push(name);
|
|
58
|
+
hashToNames.set(hash, existing);
|
|
59
|
+
}
|
|
60
|
+
// Filter to only collisions
|
|
61
|
+
const collisions = new Map();
|
|
62
|
+
for (const [hash, nameList] of hashToNames) {
|
|
63
|
+
if (nameList.length > 1) {
|
|
64
|
+
collisions.set(hash, nameList);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return collisions;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=crc32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crc32.js","sourceRoot":"","sources":["../src/crc32.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;GAOG;AAEH,oDAAoD;AACpD,MAAM,WAAW,GAAG,eAAe,EAAE,CAAC;AAEtC,SAAS,eAAe;IACtB,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAChC,IAAI,GAAG,GAAG,UAAU,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAA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,CAAC;AACpB,CAAC"}
|
package/dist/generator.d.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import { type GeneratedCode } from './typescript-generator.js';
|
|
2
|
+
export interface FullGeneratedCode extends GeneratedCode {
|
|
3
|
+
typeIds: string;
|
|
4
|
+
serializers: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GeneratorOptions {
|
|
7
|
+
/** Generate Rust output */
|
|
8
|
+
rust?: boolean;
|
|
9
|
+
/** Rust output directory (relative to outputDir or absolute) */
|
|
10
|
+
rustDir?: string;
|
|
11
|
+
/** Skip type ID collision check */
|
|
12
|
+
skipCollisionCheck?: boolean;
|
|
13
|
+
}
|
|
2
14
|
/**
|
|
3
|
-
* Generate
|
|
15
|
+
* Generate all code from an EXPRESS schema file
|
|
4
16
|
*/
|
|
5
|
-
export declare function generateFromFile(schemaPath: string, outputDir: string):
|
|
17
|
+
export declare function generateFromFile(schemaPath: string, outputDir: string, options?: GeneratorOptions): FullGeneratedCode;
|
|
6
18
|
/**
|
|
7
|
-
* Generate
|
|
19
|
+
* Generate all code from EXPRESS schema content
|
|
8
20
|
*/
|
|
9
|
-
export declare function generateFromSchema(schemaContent: string, outputDir: string):
|
|
21
|
+
export declare function generateFromSchema(schemaContent: string, outputDir: string, options?: GeneratorOptions): FullGeneratedCode;
|
|
22
|
+
/**
|
|
23
|
+
* Generate code for both IFC4 and IFC4X3 schemas
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateAll(schemasDir: string, outputBaseDir: string, options?: GeneratorOptions): void;
|
|
10
26
|
//# sourceMappingURL=generator.d.ts.map
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAMnF,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,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,CAyLnB;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,gBAAqB,GAC7B,IAAI,CAmBN"}
|
package/dist/generator.js
CHANGED
|
@@ -2,24 +2,35 @@
|
|
|
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
|
/**
|
|
5
|
-
* High-level
|
|
5
|
+
* High-level Code Generator
|
|
6
|
+
*
|
|
7
|
+
* Orchestrates code generation from EXPRESS schemas to:
|
|
8
|
+
* - TypeScript interfaces and types
|
|
9
|
+
* - TypeScript type IDs (CRC32)
|
|
10
|
+
* - TypeScript serialization helpers
|
|
11
|
+
* - Rust types and type IDs
|
|
6
12
|
*/
|
|
7
|
-
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
13
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
14
|
+
import { join, isAbsolute } from 'node:path';
|
|
8
15
|
import { parseExpressSchema } from './express-parser.js';
|
|
9
16
|
import { generateTypeScript } from './typescript-generator.js';
|
|
17
|
+
import { generateTypeIds } from './type-ids-generator.js';
|
|
18
|
+
import { generateSerializers } from './serialization-generator.js';
|
|
19
|
+
import { generateRust } from './rust-generator.js';
|
|
20
|
+
import { findCollisions } from './crc32.js';
|
|
10
21
|
/**
|
|
11
|
-
* Generate
|
|
22
|
+
* Generate all code from an EXPRESS schema file
|
|
12
23
|
*/
|
|
13
|
-
export function generateFromFile(schemaPath, outputDir) {
|
|
24
|
+
export function generateFromFile(schemaPath, outputDir, options = {}) {
|
|
14
25
|
// Read schema file
|
|
15
26
|
const content = readFileSync(schemaPath, 'utf-8');
|
|
16
27
|
// Generate code
|
|
17
|
-
return generateFromSchema(content, outputDir);
|
|
28
|
+
return generateFromSchema(content, outputDir, options);
|
|
18
29
|
}
|
|
19
30
|
/**
|
|
20
|
-
* Generate
|
|
31
|
+
* Generate all code from EXPRESS schema content
|
|
21
32
|
*/
|
|
22
|
-
export function generateFromSchema(schemaContent, outputDir) {
|
|
33
|
+
export function generateFromSchema(schemaContent, outputDir, options = {}) {
|
|
23
34
|
console.log('š Parsing EXPRESS schema...');
|
|
24
35
|
const schema = parseExpressSchema(schemaContent);
|
|
25
36
|
console.log(`ā Parsed ${schema.name}`);
|
|
@@ -27,27 +38,52 @@ export function generateFromSchema(schemaContent, outputDir) {
|
|
|
27
38
|
console.log(` - ${schema.types.length} types`);
|
|
28
39
|
console.log(` - ${schema.enums.length} enums`);
|
|
29
40
|
console.log(` - ${schema.selects.length} selects`);
|
|
41
|
+
// Check for CRC32 collisions
|
|
42
|
+
if (!options.skipCollisionCheck) {
|
|
43
|
+
console.log('\nš Checking for CRC32 collisions...');
|
|
44
|
+
const entityNames = schema.entities.map((e) => e.name);
|
|
45
|
+
const collisions = findCollisions(entityNames);
|
|
46
|
+
if (collisions.size > 0) {
|
|
47
|
+
console.warn('ā ļø CRC32 collisions detected:');
|
|
48
|
+
for (const [hash, names] of collisions) {
|
|
49
|
+
console.warn(` ${hash}: ${names.join(', ')}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log(' ā No collisions');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
30
56
|
console.log('\nšØ Generating TypeScript code...');
|
|
31
|
-
const
|
|
32
|
-
|
|
57
|
+
const tsCode = generateTypeScript(schema);
|
|
58
|
+
const typeIds = generateTypeIds(schema);
|
|
59
|
+
const serializers = generateSerializers(schema);
|
|
60
|
+
console.log('š¾ Writing TypeScript files...');
|
|
33
61
|
// Create output directory
|
|
34
62
|
mkdirSync(outputDir, { recursive: true });
|
|
35
|
-
// Write files
|
|
36
|
-
writeFileSync(`${outputDir}/entities.ts`,
|
|
63
|
+
// Write TypeScript files
|
|
64
|
+
writeFileSync(`${outputDir}/entities.ts`, tsCode.entities);
|
|
37
65
|
console.log(` ā ${outputDir}/entities.ts`);
|
|
38
|
-
writeFileSync(`${outputDir}/types.ts`,
|
|
66
|
+
writeFileSync(`${outputDir}/types.ts`, tsCode.types);
|
|
39
67
|
console.log(` ā ${outputDir}/types.ts`);
|
|
40
|
-
writeFileSync(`${outputDir}/enums.ts`,
|
|
68
|
+
writeFileSync(`${outputDir}/enums.ts`, tsCode.enums);
|
|
41
69
|
console.log(` ā ${outputDir}/enums.ts`);
|
|
42
|
-
writeFileSync(`${outputDir}/selects.ts`,
|
|
70
|
+
writeFileSync(`${outputDir}/selects.ts`, tsCode.selects);
|
|
43
71
|
console.log(` ā ${outputDir}/selects.ts`);
|
|
44
|
-
writeFileSync(`${outputDir}/schema-registry.ts`,
|
|
72
|
+
writeFileSync(`${outputDir}/schema-registry.ts`, tsCode.schemaRegistry);
|
|
45
73
|
console.log(` ā ${outputDir}/schema-registry.ts`);
|
|
74
|
+
writeFileSync(`${outputDir}/type-ids.ts`, typeIds);
|
|
75
|
+
console.log(` ā ${outputDir}/type-ids.ts`);
|
|
76
|
+
writeFileSync(`${outputDir}/serializers.ts`, serializers);
|
|
77
|
+
console.log(` ā ${outputDir}/serializers.ts`);
|
|
46
78
|
// Write index file
|
|
47
|
-
const indexContent =
|
|
48
|
-
*
|
|
79
|
+
const indexContent = `/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
80
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
81
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generated IFC Schema: ${schema.name}
|
|
49
85
|
*
|
|
50
|
-
* DO NOT EDIT - This file is auto-generated
|
|
86
|
+
* DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
|
|
51
87
|
*/
|
|
52
88
|
|
|
53
89
|
export * from './entities.js';
|
|
@@ -55,10 +91,130 @@ export * from './types.js';
|
|
|
55
91
|
export * from './enums.js';
|
|
56
92
|
export * from './selects.js';
|
|
57
93
|
export * from './schema-registry.js';
|
|
94
|
+
export * from './type-ids.js';
|
|
95
|
+
export * from './serializers.js';
|
|
58
96
|
`;
|
|
59
97
|
writeFileSync(`${outputDir}/index.ts`, indexContent);
|
|
60
98
|
console.log(` ā ${outputDir}/index.ts`);
|
|
99
|
+
// Generate Rust code if requested
|
|
100
|
+
if (options.rust) {
|
|
101
|
+
console.log('\nš¦ Generating Rust code...');
|
|
102
|
+
const rustCode = generateRust(schema);
|
|
103
|
+
// Use absolute path directly, or join relative path with outputDir
|
|
104
|
+
const rustDir = options.rustDir
|
|
105
|
+
? isAbsolute(options.rustDir)
|
|
106
|
+
? options.rustDir
|
|
107
|
+
: join(outputDir, options.rustDir)
|
|
108
|
+
: join(outputDir, 'rust');
|
|
109
|
+
mkdirSync(rustDir, { recursive: true });
|
|
110
|
+
writeFileSync(`${rustDir}/type_ids.rs`, rustCode.typeIds);
|
|
111
|
+
console.log(` ā ${rustDir}/type_ids.rs`);
|
|
112
|
+
writeFileSync(`${rustDir}/schema.rs`, rustCode.schema);
|
|
113
|
+
console.log(` ā ${rustDir}/schema.rs`);
|
|
114
|
+
writeFileSync(`${rustDir}/geometry_categories.rs`, rustCode.geometryCategories);
|
|
115
|
+
console.log(` ā ${rustDir}/geometry_categories.rs`);
|
|
116
|
+
// Write mod.rs
|
|
117
|
+
const modContent = `// This Source Code Form is subject to the terms of the Mozilla Public
|
|
118
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
119
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
120
|
+
|
|
121
|
+
//! Auto-generated IFC Schema Types
|
|
122
|
+
//!
|
|
123
|
+
//! Generated from EXPRESS schema: ${schema.name}
|
|
124
|
+
//!
|
|
125
|
+
//! DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
|
|
126
|
+
|
|
127
|
+
mod type_ids;
|
|
128
|
+
mod schema;
|
|
129
|
+
mod geometry_categories;
|
|
130
|
+
|
|
131
|
+
pub use type_ids::*;
|
|
132
|
+
pub use schema::*;
|
|
133
|
+
pub use geometry_categories::*;
|
|
134
|
+
`;
|
|
135
|
+
writeFileSync(`${rustDir}/mod.rs`, modContent);
|
|
136
|
+
console.log(` ā ${rustDir}/mod.rs`);
|
|
137
|
+
}
|
|
138
|
+
// Write test-compile file
|
|
139
|
+
const testCompileContent = `/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
140
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
141
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Type-check test file
|
|
145
|
+
* This file is used to verify the generated types compile correctly.
|
|
146
|
+
*
|
|
147
|
+
* DO NOT EDIT - This file is auto-generated
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
import type { IfcWall, IfcProject, IfcExtrudedAreaSolid } from './entities.js';
|
|
151
|
+
import { TYPE_IDS, getTypeId, getTypeName } from './type-ids.js';
|
|
152
|
+
import { SCHEMA_REGISTRY, getEntityMetadata } from './schema-registry.js';
|
|
153
|
+
import { toStepLine, serializeValue, ref, enumVal, type StepEntity } from './serializers.js';
|
|
154
|
+
|
|
155
|
+
// Test type IDs
|
|
156
|
+
const wallId: number = TYPE_IDS.IfcWall;
|
|
157
|
+
const projectId: number = TYPE_IDS.IfcProject;
|
|
158
|
+
|
|
159
|
+
// Test ID lookup
|
|
160
|
+
const wallIdFromName = getTypeId('IfcWall');
|
|
161
|
+
const nameFromId = getTypeName(wallId);
|
|
162
|
+
|
|
163
|
+
// Test schema registry
|
|
164
|
+
const wallMeta = getEntityMetadata('IfcWall');
|
|
165
|
+
const wallAttrs = wallMeta?.allAttributes;
|
|
166
|
+
|
|
167
|
+
// Test serialization
|
|
168
|
+
const testEntity: StepEntity = {
|
|
169
|
+
expressId: 1,
|
|
170
|
+
type: 'IfcProject',
|
|
171
|
+
GlobalId: '0YvctVUKr0kugbFTf53O9L',
|
|
172
|
+
OwnerHistory: ref(2),
|
|
173
|
+
Name: 'Test Project',
|
|
174
|
+
Description: null,
|
|
175
|
+
ObjectType: null,
|
|
176
|
+
LongName: null,
|
|
177
|
+
Phase: null,
|
|
178
|
+
RepresentationContexts: [ref(3)],
|
|
179
|
+
UnitsInContext: ref(4),
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const stepLine = toStepLine(testEntity);
|
|
183
|
+
|
|
184
|
+
console.log('ā All types compile correctly');
|
|
185
|
+
console.log(' Wall ID:', wallId);
|
|
186
|
+
console.log(' Project ID:', projectId);
|
|
187
|
+
console.log(' STEP line:', stepLine);
|
|
188
|
+
`;
|
|
189
|
+
writeFileSync(`${outputDir}/test-compile.ts`, testCompileContent);
|
|
190
|
+
console.log(` ā ${outputDir}/test-compile.ts`);
|
|
61
191
|
console.log('\n⨠Code generation complete!');
|
|
62
|
-
return
|
|
192
|
+
return {
|
|
193
|
+
...tsCode,
|
|
194
|
+
typeIds,
|
|
195
|
+
serializers,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Generate code for both IFC4 and IFC4X3 schemas
|
|
200
|
+
*/
|
|
201
|
+
export function generateAll(schemasDir, outputBaseDir, options = {}) {
|
|
202
|
+
const schemas = [
|
|
203
|
+
{ name: 'IFC4', file: 'IFC4_ADD2_TC1.exp', dir: 'ifc4' },
|
|
204
|
+
{ name: 'IFC4X3', file: 'IFC4X3_ADD2.exp', dir: 'ifc4x3' },
|
|
205
|
+
];
|
|
206
|
+
for (const schema of schemas) {
|
|
207
|
+
const schemaPath = join(schemasDir, schema.file);
|
|
208
|
+
if (existsSync(schemaPath)) {
|
|
209
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
210
|
+
console.log(`Processing ${schema.name}...`);
|
|
211
|
+
console.log(`${'='.repeat(60)}\n`);
|
|
212
|
+
const outputDir = join(outputBaseDir, schema.dir);
|
|
213
|
+
generateFromFile(schemaPath, outputDir, options);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
console.warn(`ā ļø Schema file not found: ${schemaPath}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
63
219
|
}
|
|
64
220
|
//# sourceMappingURL=generator.js.map
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAsB,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAsB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CA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EAAE;QACxD,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,QAAQ,EAAE;KAC3D,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAEnC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YAClD,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,8BAA8B,UAAU,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @ifc-lite/codegen
|
|
3
3
|
*
|
|
4
|
-
* TypeScript
|
|
4
|
+
* IFC Code Generator - TypeScript and Rust from EXPRESS schemas
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - TypeScript interfaces from EXPRESS entities
|
|
8
|
+
* - CRC32 type IDs for fast O(1) lookup
|
|
9
|
+
* - Serialization support for IFC writing
|
|
10
|
+
* - Rust type generation
|
|
11
|
+
* - Schema metadata registry
|
|
5
12
|
*/
|
|
6
13
|
export { parseExpressSchema, getAllAttributes, getInheritanceChain, type ExpressSchema, type EntityDefinition, type AttributeDefinition, type TypeDefinition, type EnumDefinition, type SelectDefinition, type DerivedAttribute, type InverseAttribute, } from './express-parser.js';
|
|
7
14
|
export { generateTypeScript, writeGeneratedFiles, type GeneratedCode, } from './typescript-generator.js';
|
|
8
|
-
export {
|
|
15
|
+
export { generateTypeIds } from './type-ids-generator.js';
|
|
16
|
+
export { crc32, generateTypeIds as generateTypeIdMap, findCollisions } from './crc32.js';
|
|
17
|
+
export { generateSerializers } from './serialization-generator.js';
|
|
18
|
+
export { generateRust, type RustGeneratedCode } from './rust-generator.js';
|
|
19
|
+
export { generateFromFile, generateFromSchema, generateAll, type FullGeneratedCode, type GeneratorOptions, } from './generator.js';
|
|
9
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,aAAa,GACnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,eAAe,IAAI,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG3E,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,26 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @ifc-lite/codegen
|
|
6
6
|
*
|
|
7
|
-
* TypeScript
|
|
7
|
+
* IFC Code Generator - TypeScript and Rust from EXPRESS schemas
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - TypeScript interfaces from EXPRESS entities
|
|
11
|
+
* - CRC32 type IDs for fast O(1) lookup
|
|
12
|
+
* - Serialization support for IFC writing
|
|
13
|
+
* - Rust type generation
|
|
14
|
+
* - Schema metadata registry
|
|
8
15
|
*/
|
|
16
|
+
// Core parser
|
|
9
17
|
export { parseExpressSchema, getAllAttributes, getInheritanceChain, } from './express-parser.js';
|
|
18
|
+
// TypeScript generation
|
|
10
19
|
export { generateTypeScript, writeGeneratedFiles, } from './typescript-generator.js';
|
|
11
|
-
|
|
20
|
+
// Type IDs (CRC32)
|
|
21
|
+
export { generateTypeIds } from './type-ids-generator.js';
|
|
22
|
+
export { crc32, generateTypeIds as generateTypeIdMap, findCollisions } from './crc32.js';
|
|
23
|
+
// Serialization
|
|
24
|
+
export { generateSerializers } from './serialization-generator.js';
|
|
25
|
+
// Rust generation
|
|
26
|
+
export { generateRust } from './rust-generator.js';
|
|
27
|
+
// High-level generator
|
|
28
|
+
export { generateFromFile, generateFromSchema, generateAll, } from './generator.js';
|
|
12
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;GAWG;AAEH,cAAc;AACd,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GASpB,MAAM,qBAAqB,CAAC;AAE7B,wBAAwB;AACxB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AAEnC,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,eAAe,IAAI,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzF,gBAAgB;AAChB,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAA0B,MAAM,qBAAqB,CAAC;AAE3E,uBAAuB;AACvB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,GAGZ,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust Code Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates Rust types from EXPRESS schema for:
|
|
5
|
+
* - Type IDs (CRC32 constants)
|
|
6
|
+
* - IfcType enum with all variants
|
|
7
|
+
* - Geometry category classification
|
|
8
|
+
* - Type conversion functions
|
|
9
|
+
*/
|
|
10
|
+
import type { ExpressSchema } from './express-parser.js';
|
|
11
|
+
export interface RustGeneratedCode {
|
|
12
|
+
typeIds: string;
|
|
13
|
+
schema: string;
|
|
14
|
+
geometryCategories: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Generate all Rust code from EXPRESS schema
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateRust(schema: ExpressSchema): RustGeneratedCode;
|
|
20
|
+
//# sourceMappingURL=rust-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust-generator.d.ts","sourceRoot":"","sources":["../src/rust-generator.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,qBAAqB,CAAC;AAI3E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAMrE"}
|