@bldrs-ai/conway 1.488.1413 → 1.493.1414
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/compiled/examples/browser-bundled.cjs +14 -2
- package/compiled/examples/cli-bundled.cjs +14 -2
- package/compiled/examples/cli-step-bundled.cjs +14 -2
- package/compiled/examples/validator-bundled.cjs +14 -2
- package/compiled/src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.d.ts.map +1 -1
- package/compiled/src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.js +2 -2
- package/compiled/src/AP214E3_2010/ap214_typed_select_enum.test.d.ts +2 -0
- package/compiled/src/AP214E3_2010/ap214_typed_select_enum.test.d.ts.map +1 -0
- package/compiled/src/AP214E3_2010/ap214_typed_select_enum.test.js +65 -0
- package/compiled/src/ifc/ifc4_gen/IfcPresentationStyleAssignment.gen.d.ts.map +1 -1
- package/compiled/src/ifc/ifc4_gen/IfcPresentationStyleAssignment.gen.js +2 -2
- package/compiled/src/ifc/ifc_typed_select_enum.test.d.ts +2 -0
- package/compiled/src/ifc/ifc_typed_select_enum.test.d.ts.map +1 -0
- package/compiled/src/ifc/ifc_typed_select_enum.test.js +60 -0
- package/compiled/src/step/parsing/step_deserialization_functions.d.ts +29 -0
- package/compiled/src/step/parsing/step_deserialization_functions.d.ts.map +1 -1
- package/compiled/src/step/parsing/step_deserialization_functions.js +45 -0
- package/compiled/src/step/parsing/step_deserialization_functions.test.js +59 -1
- package/compiled/src/version/version.js +1 -1
- package/compiled/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ var import_node_process = require("node:process");
|
|
|
30
30
|
var readline = __toESM(require("node:readline"), 1);
|
|
31
31
|
|
|
32
32
|
// compiled/src/version/version.js
|
|
33
|
-
var versionString = "Conway v1.
|
|
33
|
+
var versionString = "Conway v1.493.1414";
|
|
34
34
|
|
|
35
35
|
// compiled/dependencies/conway-geom/interface/conway_geometry.js
|
|
36
36
|
var wasmType = "";
|
|
@@ -2263,6 +2263,18 @@ function* stepExtractArray(buffer, cursor, endCursor) {
|
|
|
2263
2263
|
throw new Error("Unterminated array");
|
|
2264
2264
|
}
|
|
2265
2265
|
}
|
|
2266
|
+
function stepEnterTypedValue(buffer, cursor, endCursor, typeName) {
|
|
2267
|
+
const identifierEnd = identifierParser.match(buffer, cursor, endCursor);
|
|
2268
|
+
if (identifierEnd === void 0 || identifierEnd - cursor !== typeName.length) {
|
|
2269
|
+
return cursor;
|
|
2270
|
+
}
|
|
2271
|
+
for (let where = 0; where < typeName.length; ++where) {
|
|
2272
|
+
if (buffer[cursor + where] !== typeName.charCodeAt(where)) {
|
|
2273
|
+
return cursor;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
return stepExtractInlineElemement(buffer, cursor, endCursor) ?? cursor;
|
|
2277
|
+
}
|
|
2266
2278
|
function stepExtractInlineElemement(buffer, cursor, endCursor) {
|
|
2267
2279
|
const identifier = identifierParser.match(buffer, cursor, endCursor);
|
|
2268
2280
|
if (identifier === void 0) {
|
|
@@ -12848,7 +12860,7 @@ var IfcPresentationStyleAssignment = class extends StepEntityBase {
|
|
|
12848
12860
|
let signedCursor0 = stepExtractArrayBegin(buffer, cursor, endCursor);
|
|
12849
12861
|
cursor = Math.abs(signedCursor0);
|
|
12850
12862
|
while (signedCursor0 >= 0) {
|
|
12851
|
-
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, cursor, endCursor);
|
|
12863
|
+
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, stepEnterTypedValue(buffer, cursor, endCursor, "IFCNULLSTYLE"), endCursor);
|
|
12852
12864
|
if (!(value1Untyped instanceof IfcCurveStyle) && !(value1Untyped instanceof IfcFillAreaStyle) && !(value1Untyped instanceof IfcSurfaceStyle) && !(value1Untyped instanceof IfcTextStyle) && value1Untyped !== IfcNullStyle.NULL) {
|
|
12853
12865
|
throw new Error("Value in select must be populated");
|
|
12854
12866
|
}
|
|
@@ -14965,7 +14965,7 @@ ${t5.join("\n")}` : "";
|
|
|
14965
14965
|
var import_process = require("process");
|
|
14966
14966
|
|
|
14967
14967
|
// compiled/src/version/version.js
|
|
14968
|
-
var versionString = "Conway v1.
|
|
14968
|
+
var versionString = "Conway v1.493.1414";
|
|
14969
14969
|
|
|
14970
14970
|
// compiled/dependencies/conway-geom/interface/conway_geometry.js
|
|
14971
14971
|
function pThreadsAllowed() {
|
|
@@ -18077,6 +18077,18 @@ function* stepExtractArray(buffer, cursor, endCursor) {
|
|
|
18077
18077
|
throw new Error("Unterminated array");
|
|
18078
18078
|
}
|
|
18079
18079
|
}
|
|
18080
|
+
function stepEnterTypedValue(buffer, cursor, endCursor, typeName) {
|
|
18081
|
+
const identifierEnd = identifierParser.match(buffer, cursor, endCursor);
|
|
18082
|
+
if (identifierEnd === void 0 || identifierEnd - cursor !== typeName.length) {
|
|
18083
|
+
return cursor;
|
|
18084
|
+
}
|
|
18085
|
+
for (let where = 0; where < typeName.length; ++where) {
|
|
18086
|
+
if (buffer[cursor + where] !== typeName.charCodeAt(where)) {
|
|
18087
|
+
return cursor;
|
|
18088
|
+
}
|
|
18089
|
+
}
|
|
18090
|
+
return stepExtractInlineElemement(buffer, cursor, endCursor) ?? cursor;
|
|
18091
|
+
}
|
|
18080
18092
|
function stepExtractInlineElemement(buffer, cursor, endCursor) {
|
|
18081
18093
|
const identifier = identifierParser.match(buffer, cursor, endCursor);
|
|
18082
18094
|
if (identifier === void 0) {
|
|
@@ -28701,7 +28713,7 @@ var IfcPresentationStyleAssignment = class extends StepEntityBase {
|
|
|
28701
28713
|
let signedCursor0 = stepExtractArrayBegin(buffer, cursor, endCursor);
|
|
28702
28714
|
cursor = Math.abs(signedCursor0);
|
|
28703
28715
|
while (signedCursor0 >= 0) {
|
|
28704
|
-
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, cursor, endCursor);
|
|
28716
|
+
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, stepEnterTypedValue(buffer, cursor, endCursor, "IFCNULLSTYLE"), endCursor);
|
|
28705
28717
|
if (!(value1Untyped instanceof IfcCurveStyle) && !(value1Untyped instanceof IfcFillAreaStyle) && !(value1Untyped instanceof IfcSurfaceStyle) && !(value1Untyped instanceof IfcTextStyle) && value1Untyped !== IfcNullStyle.NULL) {
|
|
28706
28718
|
throw new Error("Value in select must be populated");
|
|
28707
28719
|
}
|
|
@@ -15943,7 +15943,7 @@ var ParsingBuffer = class {
|
|
|
15943
15943
|
};
|
|
15944
15944
|
|
|
15945
15945
|
// compiled/src/version/version.js
|
|
15946
|
-
var versionString = "Conway v1.
|
|
15946
|
+
var versionString = "Conway v1.493.1414";
|
|
15947
15947
|
|
|
15948
15948
|
// compiled/dependencies/conway-geom/interface/conway_geometry.js
|
|
15949
15949
|
function pThreadsAllowed() {
|
|
@@ -17985,6 +17985,18 @@ function* stepExtractArray(buffer, cursor, endCursor) {
|
|
|
17985
17985
|
throw new Error("Unterminated array");
|
|
17986
17986
|
}
|
|
17987
17987
|
}
|
|
17988
|
+
function stepEnterTypedValue(buffer, cursor, endCursor, typeName) {
|
|
17989
|
+
const identifierEnd = identifierParser.match(buffer, cursor, endCursor);
|
|
17990
|
+
if (identifierEnd === void 0 || identifierEnd - cursor !== typeName.length) {
|
|
17991
|
+
return cursor;
|
|
17992
|
+
}
|
|
17993
|
+
for (let where = 0; where < typeName.length; ++where) {
|
|
17994
|
+
if (buffer[cursor + where] !== typeName.charCodeAt(where)) {
|
|
17995
|
+
return cursor;
|
|
17996
|
+
}
|
|
17997
|
+
}
|
|
17998
|
+
return stepExtractInlineElemement(buffer, cursor, endCursor) ?? cursor;
|
|
17999
|
+
}
|
|
17988
18000
|
function stepExtractInlineElemement(buffer, cursor, endCursor) {
|
|
17989
18001
|
const identifier2 = identifierParser.match(buffer, cursor, endCursor);
|
|
17990
18002
|
if (identifier2 === void 0) {
|
|
@@ -38232,7 +38244,7 @@ var presentation_style_assignment = class _presentation_style_assignment extends
|
|
|
38232
38244
|
let signedCursor0 = stepExtractArrayBegin(buffer, cursor, endCursor);
|
|
38233
38245
|
cursor = Math.abs(signedCursor0);
|
|
38234
38246
|
while (signedCursor0 >= 0) {
|
|
38235
|
-
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? null_styleDeserializeStep(buffer, cursor, endCursor);
|
|
38247
|
+
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? null_styleDeserializeStep(buffer, stepEnterTypedValue(buffer, cursor, endCursor, "NULL_STYLE"), endCursor);
|
|
38236
38248
|
if (!(value1Untyped instanceof pre_defined_presentation_style) && !(value1Untyped instanceof point_style) && !(value1Untyped instanceof curve_style) && !(value1Untyped instanceof surface_style_usage) && !(value1Untyped instanceof symbol_style) && !(value1Untyped instanceof fill_area_style) && !(value1Untyped instanceof text_style) && !(value1Untyped instanceof approximation_tolerance) && !(value1Untyped instanceof externally_defined_style) && value1Untyped !== null_style.NULL) {
|
|
38237
38249
|
throw new Error("Value in select must be populated");
|
|
38238
38250
|
}
|
|
@@ -944,7 +944,7 @@ var EntityTypesIfcCount = 909;
|
|
|
944
944
|
var entity_types_ifc_gen_default = EntityTypesIfc;
|
|
945
945
|
|
|
946
946
|
// compiled/src/version/version.js
|
|
947
|
-
var versionString = "Conway v1.
|
|
947
|
+
var versionString = "Conway v1.493.1414";
|
|
948
948
|
|
|
949
949
|
// compiled/dependencies/conway-geom/interface/conway_geometry.js
|
|
950
950
|
var wasmType = "";
|
|
@@ -3177,6 +3177,18 @@ function* stepExtractArray(buffer, cursor, endCursor) {
|
|
|
3177
3177
|
throw new Error("Unterminated array");
|
|
3178
3178
|
}
|
|
3179
3179
|
}
|
|
3180
|
+
function stepEnterTypedValue(buffer, cursor, endCursor, typeName) {
|
|
3181
|
+
const identifierEnd = identifierParser.match(buffer, cursor, endCursor);
|
|
3182
|
+
if (identifierEnd === void 0 || identifierEnd - cursor !== typeName.length) {
|
|
3183
|
+
return cursor;
|
|
3184
|
+
}
|
|
3185
|
+
for (let where = 0; where < typeName.length; ++where) {
|
|
3186
|
+
if (buffer[cursor + where] !== typeName.charCodeAt(where)) {
|
|
3187
|
+
return cursor;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
return stepExtractInlineElemement(buffer, cursor, endCursor) ?? cursor;
|
|
3191
|
+
}
|
|
3180
3192
|
function stepExtractInlineElemement(buffer, cursor, endCursor) {
|
|
3181
3193
|
const identifier = identifierParser.match(buffer, cursor, endCursor);
|
|
3182
3194
|
if (identifier === void 0) {
|
|
@@ -12846,7 +12858,7 @@ var IfcPresentationStyleAssignment = class extends StepEntityBase {
|
|
|
12846
12858
|
let signedCursor0 = stepExtractArrayBegin(buffer, cursor, endCursor);
|
|
12847
12859
|
cursor = Math.abs(signedCursor0);
|
|
12848
12860
|
while (signedCursor0 >= 0) {
|
|
12849
|
-
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, cursor, endCursor);
|
|
12861
|
+
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, stepEnterTypedValue(buffer, cursor, endCursor, "IFCNULLSTYLE"), endCursor);
|
|
12850
12862
|
if (!(value1Untyped instanceof IfcCurveStyle) && !(value1Untyped instanceof IfcFillAreaStyle) && !(value1Untyped instanceof IfcSurfaceStyle) && !(value1Untyped instanceof IfcTextStyle) && value1Untyped !== IfcNullStyle.NULL) {
|
|
12851
12863
|
throw new Error("Value in select must be populated");
|
|
12852
12864
|
}
|
package/compiled/src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation_style_assignment.gen.d.ts","sourceRoot":"","sources":["../../../../src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,UAAU,EAA6B,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"presentation_style_assignment.gen.d.ts","sourceRoot":"","sources":["../../../../src/AP214E3_2010/AP214E3_2010_gen/presentation_style_assignment.gen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,UAAU,EAA6B,MAAM,SAAS,CAAA;AAU/D,OAAO,gBAAgB,MAAM,0BAA0B,CAAA;AACvD,OAAO,2BAA2B,MAAM,2CAA2C,CAAA;AACnF,OAAO,cAAc,MAAM,6BAA6B,CAAA;AACxD,OAAO,aAAa,MAAM,4BAA4B,CAAA;AAItD,qBAAc,6BAA8B,SAAQ,YAAY;IAC9D,IAAW,IAAI,IAAI,gBAAgB,CAElC;IACD,OAAO,CAAC,OAAO,CAAC,CAA0M;IAE1N,IAAW,MAAM,IAAK,KAAK,CAAC,8BAA8B,GAAG,WAAW,GAAG,WAAW,GAAG,mBAAmB,GAAG,YAAY,GAAG,eAAe,GAAG,UAAU,GAAG,uBAAuB,GAAG,wBAAwB,GAAG,UAAU,CAAC,CAsC5N;gBAEC,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,2BAA2B,CAAE,gBAAgB,CAAE,EAClE,KAAK,EAAE,aAAa,CAAE,gBAAgB,EAAE,cAAc,CAAE,gBAAgB,CAAE,CAAE,EAC5E,cAAc,CAAC,EAAE,2BAA2B,CAAE,gBAAgB,CAAE,EAAE;IAqBpE,gBAAuB,KAAK,qBACwB;IAEpD,gBAAuB,YAAY,EAAE,gBAAgB,CACL;CACjD"}
|
|
@@ -9,7 +9,7 @@ import { text_style } from "./index.js";
|
|
|
9
9
|
import { approximation_tolerance } from "./index.js";
|
|
10
10
|
import { externally_defined_style } from "./index.js";
|
|
11
11
|
import { null_style, null_styleDeserializeStep } from "./index.js";
|
|
12
|
-
import { stepExtractOptional, stepExtractArrayToken, stepExtractArrayBegin, skipValue, } from "../../step/parsing/step_deserialization_functions.js";
|
|
12
|
+
import { stepExtractOptional, stepEnterTypedValue, stepExtractArrayToken, stepExtractArrayBegin, skipValue, } from "../../step/parsing/step_deserialization_functions.js";
|
|
13
13
|
/* This is generated code, don't modify */
|
|
14
14
|
import EntityTypesAP214 from "./entity_types_ap214.gen.js";
|
|
15
15
|
///**
|
|
@@ -30,7 +30,7 @@ export class presentation_style_assignment extends founded_item {
|
|
|
30
30
|
let signedCursor0 = stepExtractArrayBegin(buffer, cursor, endCursor);
|
|
31
31
|
cursor = Math.abs(signedCursor0);
|
|
32
32
|
while (signedCursor0 >= 0) {
|
|
33
|
-
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? null_styleDeserializeStep(buffer, cursor, endCursor);
|
|
33
|
+
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? null_styleDeserializeStep(buffer, stepEnterTypedValue(buffer, cursor, endCursor, "NULL_STYLE"), endCursor);
|
|
34
34
|
if (!(value1Untyped instanceof pre_defined_presentation_style) && !(value1Untyped instanceof point_style) && !(value1Untyped instanceof curve_style) && !(value1Untyped instanceof surface_style_usage) && !(value1Untyped instanceof symbol_style) && !(value1Untyped instanceof fill_area_style) && !(value1Untyped instanceof text_style) && !(value1Untyped instanceof approximation_tolerance) && !(value1Untyped instanceof externally_defined_style) && value1Untyped !== null_style.NULL) {
|
|
35
35
|
throw new Error("Value in select must be populated");
|
|
36
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ap214_typed_select_enum.test.d.ts","sourceRoot":"","sources":["../../../src/AP214E3_2010/ap214_typed_select_enum.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// A select member whose type is an enum may be written bare or in its typed
|
|
2
|
+
// form - `.NULL.` or `NULL_STYLE(.NULL.)`. Inside a SELECT the typed form is
|
|
3
|
+
// how a reader tells which member the value is, so exporters use it, and the
|
|
4
|
+
// NIST AP242 set uses it throughout.
|
|
5
|
+
//
|
|
6
|
+
// Reading the typed form used to throw 'Value in select must be populated',
|
|
7
|
+
// because the generated getter's enum fallback is a bare parse starting at
|
|
8
|
+
// the cursor and the wrapper made it fail. Entity-valued members were never
|
|
9
|
+
// affected - the parser indexes an inline TYPENAME(...) entity and
|
|
10
|
+
// extractBufferReference resolves it by address - so this was specific to
|
|
11
|
+
// enum members, and `null_style` is the only enum inside a select in either
|
|
12
|
+
// schema. It accounted for 274 of the public regression baseline's error
|
|
13
|
+
// rows, every one of them a lost styled item. See bldrs-ai/conway#489.
|
|
14
|
+
import { beforeAll, describe, expect, test } from "@jest/globals";
|
|
15
|
+
import AP214StepParser from "./ap214_step_parser.js";
|
|
16
|
+
import ParsingBuffer from "../parsing/parsing_buffer.js";
|
|
17
|
+
import { ParseResult } from "../step/parsing/step_parser.js";
|
|
18
|
+
import { null_style, presentation_style_assignment } from "./AP214E3_2010_gen/index.js";
|
|
19
|
+
import { ConwayGeometry } from "../../dependencies/conway-geom/index.js";
|
|
20
|
+
const conwayGeom = new ConwayGeometry();
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the wasm.
|
|
23
|
+
*/
|
|
24
|
+
async function initializeWasm() {
|
|
25
|
+
await conwayGeom.initialize();
|
|
26
|
+
}
|
|
27
|
+
const parser = AP214StepParser.Instance;
|
|
28
|
+
// Lifted from nist_stc_06_asme1_ap242-e3.stp, which produces 82 of these.
|
|
29
|
+
// The surrounding ANNOTATION_PLANE is what actually got dropped in the
|
|
30
|
+
// corpus: the throw escaped the styled-item extraction and was caught per
|
|
31
|
+
// representation item.
|
|
32
|
+
const TYPED_STYLE = `#10028 = PRESENTATION_STYLE_ASSIGNMENT((NULL_STYLE(.NULL.)));`;
|
|
33
|
+
// The same value written bare, which always worked. Kept alongside so a
|
|
34
|
+
// change that fixes one by breaking the other cannot pass.
|
|
35
|
+
const BARE_STYLE = `#10028 = PRESENTATION_STYLE_ASSIGNMENT((.NULL.));`;
|
|
36
|
+
const STYLE_EXPRESS_ID = 10028;
|
|
37
|
+
/**
|
|
38
|
+
* Parse one PRESENTATION_STYLE_ASSIGNMENT and read back its styles.
|
|
39
|
+
*
|
|
40
|
+
* @param source The STEP text to parse.
|
|
41
|
+
* @return {Array<unknown>} The resolved styles array.
|
|
42
|
+
*/
|
|
43
|
+
function stylesOf(source) {
|
|
44
|
+
const [result, model] = parser.parseDataToModel(new ParsingBuffer(new TextEncoder().encode(source)));
|
|
45
|
+
if (model === void 0 ||
|
|
46
|
+
(result !== ParseResult.COMPLETE && result !== ParseResult.INCOMPLETE)) {
|
|
47
|
+
throw new Error(`parse failed with result ${result}`);
|
|
48
|
+
}
|
|
49
|
+
const assignment = model.getElementByExpressID(STYLE_EXPRESS_ID);
|
|
50
|
+
if (!(assignment instanceof presentation_style_assignment)) {
|
|
51
|
+
throw new Error("expected a presentation_style_assignment");
|
|
52
|
+
}
|
|
53
|
+
return assignment.styles;
|
|
54
|
+
}
|
|
55
|
+
beforeAll(async () => {
|
|
56
|
+
await initializeWasm();
|
|
57
|
+
});
|
|
58
|
+
describe("a typed enum in a select", () => {
|
|
59
|
+
test("NULL_STYLE(.NULL.) resolves instead of throwing", () => {
|
|
60
|
+
expect(stylesOf(TYPED_STYLE)).toEqual([null_style.NULL]);
|
|
61
|
+
});
|
|
62
|
+
test("the bare form still resolves", () => {
|
|
63
|
+
expect(stylesOf(BARE_STYLE)).toEqual([null_style.NULL]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IfcPresentationStyleAssignment.gen.d.ts","sourceRoot":"","sources":["../../../../src/ifc/ifc4_gen/IfcPresentationStyleAssignment.gen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,YAAY,EAA+B,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"IfcPresentationStyleAssignment.gen.d.ts","sourceRoot":"","sources":["../../../../src/ifc/ifc4_gen/IfcPresentationStyleAssignment.gen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,YAAY,EAA+B,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAUtC,OAAO,cAAc,MAAM,wBAAwB,CAAA;AACnD,OAAO,2BAA2B,MAAM,2CAA2C,CAAA;AACnF,OAAO,cAAc,MAAM,6BAA6B,CAAA;AACxD,OAAO,aAAa,MAAM,4BAA4B,CAAA;AAItD,qBAAc,8BAA+B,SAAQ,cAAc,CAAE,cAAc,CAAE;IACnF,IAAW,IAAI,IAAI,cAAc,CAEhC;IACD,OAAO,CAAC,OAAO,CAAC,CAA0F;IAE1G,IAAW,MAAM,IAAK,KAAK,CAAC,aAAa,GAAG,gBAAgB,GAAG,YAAY,GAAG,eAAe,GAAG,YAAY,CAAC,CAsC5G;gBAEC,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,2BAA2B,CAAE,cAAc,CAAE,EAChE,KAAK,EAAE,aAAa,CAAE,cAAc,EAAE,cAAc,CAAE,cAAc,CAAE,CAAE,EACxE,cAAc,CAAC,EAAE,2BAA2B,CAAE,cAAc,CAAE,EAAE;IAKlE,gBAAuB,KAAK,mBACuB;IAEnD,gBAAuB,YAAY,EAAE,cAAc,CACJ;CAChD"}
|
|
@@ -3,7 +3,7 @@ import { IfcFillAreaStyle } from "./index.js";
|
|
|
3
3
|
import { IfcNullStyle, IfcNullStyleDeserializeStep } from "./index.js";
|
|
4
4
|
import { IfcSurfaceStyle } from "./index.js";
|
|
5
5
|
import { IfcTextStyle } from "./index.js";
|
|
6
|
-
import { stepExtractOptional, stepExtractArrayToken, stepExtractArrayBegin, skipValue, } from "../../step/parsing/step_deserialization_functions.js";
|
|
6
|
+
import { stepExtractOptional, stepEnterTypedValue, stepExtractArrayToken, stepExtractArrayBegin, skipValue, } from "../../step/parsing/step_deserialization_functions.js";
|
|
7
7
|
/* This is generated code, don't modify */
|
|
8
8
|
import EntityTypesIfc from "./entity_types_ifc.gen.js";
|
|
9
9
|
import StepEntityBase from "../../step/step_entity_base.js";
|
|
@@ -25,7 +25,7 @@ export class IfcPresentationStyleAssignment extends StepEntityBase {
|
|
|
25
25
|
let signedCursor0 = stepExtractArrayBegin(buffer, cursor, endCursor);
|
|
26
26
|
cursor = Math.abs(signedCursor0);
|
|
27
27
|
while (signedCursor0 >= 0) {
|
|
28
|
-
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, cursor, endCursor);
|
|
28
|
+
const value1Untyped = this.extractBufferReference(buffer, cursor, endCursor) ?? IfcNullStyleDeserializeStep(buffer, stepEnterTypedValue(buffer, cursor, endCursor, "IFCNULLSTYLE"), endCursor);
|
|
29
29
|
if (!(value1Untyped instanceof IfcCurveStyle) && !(value1Untyped instanceof IfcFillAreaStyle) && !(value1Untyped instanceof IfcSurfaceStyle) && !(value1Untyped instanceof IfcTextStyle) && value1Untyped !== IfcNullStyle.NULL) {
|
|
30
30
|
throw new Error("Value in select must be populated");
|
|
31
31
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc_typed_select_enum.test.d.ts","sourceRoot":"","sources":["../../../src/ifc/ifc_typed_select_enum.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// A select member whose type is an enum may be written bare or in its typed
|
|
2
|
+
// form - `.NULL.` or `NULL_STYLE(.NULL.)`. Inside a SELECT the typed form is
|
|
3
|
+
// how a reader tells which member the value is, so exporters use it, and the
|
|
4
|
+
// NIST AP242 set uses it throughout.
|
|
5
|
+
//
|
|
6
|
+
// Reading the typed form used to throw 'Value in select must be populated',
|
|
7
|
+
// because the generated getter's enum fallback is a bare parse starting at
|
|
8
|
+
// the cursor and the wrapper made it fail. Entity-valued members were never
|
|
9
|
+
// affected - the parser indexes an inline TYPENAME(...) entity and
|
|
10
|
+
// extractBufferReference resolves it by address - so this was specific to
|
|
11
|
+
// enum members, and `null_style` / `IfcNullStyle` is the only enum inside a
|
|
12
|
+
// select in either schema. It accounted for 274 of the public regression
|
|
13
|
+
// baseline's error rows, every one of them a lost styled item. See
|
|
14
|
+
// bldrs-ai/conway#489.
|
|
15
|
+
//
|
|
16
|
+
// Both schemas are covered: the fix is emitted by the generator at two sites,
|
|
17
|
+
// one per schema, and a regeneration that reverted either would otherwise
|
|
18
|
+
// ship green. scripts/code-gen.cjs clones the generator unpinned, so that is
|
|
19
|
+
// not a hypothetical.
|
|
20
|
+
//
|
|
21
|
+
// Parser-only, so no geometry wasm is initialized here - importing it would
|
|
22
|
+
// make this fail at import in a checkout without the Dist built, for a
|
|
23
|
+
// dependency it never uses.
|
|
24
|
+
import { describe, expect, test } from "@jest/globals";
|
|
25
|
+
import IfcStepParser from "./ifc_step_parser.js";
|
|
26
|
+
import ParsingBuffer from "../parsing/parsing_buffer.js";
|
|
27
|
+
import { ParseResult } from "../step/parsing/step_parser.js";
|
|
28
|
+
import { IfcNullStyle, IfcPresentationStyleAssignment } from "./ifc4_gen/index.js";
|
|
29
|
+
const parser = IfcStepParser.Instance;
|
|
30
|
+
const TYPED_STYLE = `#10028 = IFCPRESENTATIONSTYLEASSIGNMENT((IFCNULLSTYLE(.NULL.)));`;
|
|
31
|
+
// The same value written bare, which always worked. Kept alongside so a
|
|
32
|
+
// change that fixes one by breaking the other cannot pass.
|
|
33
|
+
const BARE_STYLE = `#10028 = IFCPRESENTATIONSTYLEASSIGNMENT((.NULL.));`;
|
|
34
|
+
const STYLE_EXPRESS_ID = 10028;
|
|
35
|
+
/**
|
|
36
|
+
* Parse one IFCPRESENTATIONSTYLEASSIGNMENT and read back its styles.
|
|
37
|
+
*
|
|
38
|
+
* @param source The STEP text to parse.
|
|
39
|
+
* @return {Array<unknown>} The resolved styles array.
|
|
40
|
+
*/
|
|
41
|
+
function stylesOf(source) {
|
|
42
|
+
const [result, model] = parser.parseDataToModel(new ParsingBuffer(new TextEncoder().encode(source)));
|
|
43
|
+
if (model === void 0 ||
|
|
44
|
+
(result !== ParseResult.COMPLETE && result !== ParseResult.INCOMPLETE)) {
|
|
45
|
+
throw new Error(`parse failed with result ${result}`);
|
|
46
|
+
}
|
|
47
|
+
const assignment = model.getElementByExpressID(STYLE_EXPRESS_ID);
|
|
48
|
+
if (!(assignment instanceof IfcPresentationStyleAssignment)) {
|
|
49
|
+
throw new Error("expected an IfcPresentationStyleAssignment");
|
|
50
|
+
}
|
|
51
|
+
return assignment.Styles;
|
|
52
|
+
}
|
|
53
|
+
describe("a typed enum in an IFC select", () => {
|
|
54
|
+
test("IFCNULLSTYLE(.NULL.) resolves instead of throwing", () => {
|
|
55
|
+
expect(stylesOf(TYPED_STYLE)).toEqual([IfcNullStyle.NULL]);
|
|
56
|
+
});
|
|
57
|
+
test("the bare form still resolves", () => {
|
|
58
|
+
expect(stylesOf(BARE_STYLE)).toEqual([IfcNullStyle.NULL]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -118,6 +118,35 @@ export declare function stepExtractArrayToken(buffer: Uint8Array, cursor: number
|
|
|
118
118
|
* @return {IterableIterator} Lazy iterator to extract value.
|
|
119
119
|
*/
|
|
120
120
|
export declare function stepExtractArray(buffer: Uint8Array, cursor: number, endCursor: number): IterableIterator<number>;
|
|
121
|
+
/**
|
|
122
|
+
* Step past a `TYPENAME(` wrapper to the value inside it, when the value at
|
|
123
|
+
* the cursor is written in its typed form and the type name matches.
|
|
124
|
+
*
|
|
125
|
+
* A select member may be written either bare or typed — `.NULL.` or
|
|
126
|
+
* `NULL_STYLE(.NULL.)` — and inside a SELECT the typed form is how a reader
|
|
127
|
+
* tells which member it is, so exporters legitimately use it. Entity-valued
|
|
128
|
+
* members already handle both, because the parser indexes an inline
|
|
129
|
+
* `TYPENAME(...)` entity and `extractBufferReference` resolves it by address.
|
|
130
|
+
* A member whose type is an enum has no entity to index, so its deserializer
|
|
131
|
+
* is a bare parse starting at the cursor, and the wrapper makes it fail.
|
|
132
|
+
* That cost 274 of the public regression baseline's error rows — every
|
|
133
|
+
* `PRESENTATION_STYLE_ASSIGNMENT((NULL_STYLE(.NULL.)))` in the corpus threw
|
|
134
|
+
* and lost its styled item. See bldrs-ai/conway#489.
|
|
135
|
+
*
|
|
136
|
+
* The type name is verified rather than skipped past, so this accepts only
|
|
137
|
+
* the value's own typed form: a mismatched wrapper stays a type error
|
|
138
|
+
* instead of being silently read as the member it isn't.
|
|
139
|
+
*
|
|
140
|
+
* @param buffer The buffer to read from.
|
|
141
|
+
* @param cursor The position the value starts at.
|
|
142
|
+
* @param endCursor The last position accessible for this read in the buffer.
|
|
143
|
+
* @param typeName The expected STEP type name of the wrapper, upper case —
|
|
144
|
+
* StepEntityIdentifierParser matches `[A-Z][A-Z0-9_]*`, so a lower-case
|
|
145
|
+
* spelling is not an identifier here and never reaches the comparison.
|
|
146
|
+
* @return {number} The position just inside the wrapper's parenthesis, or
|
|
147
|
+
* `cursor` unchanged when the value is not this type's typed form.
|
|
148
|
+
*/
|
|
149
|
+
export declare function stepEnterTypedValue(buffer: Uint8Array, cursor: number, endCursor: number, typeName: string): number;
|
|
121
150
|
/**
|
|
122
151
|
* Extracts an inline element and returns its cursor, or none if it can't be found.
|
|
123
152
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step_deserialization_functions.d.ts","sourceRoot":"","sources":["../../../../src/step/parsing/step_deserialization_functions.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAGD;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAI,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,YAAY,EAAE,CAAC,GAAI,CAAC,CAE9E;AAGD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAE,CAAC,EAAI,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GAAI,MAAM,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAI,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GAAI,MAAM,CAEvE;AAGD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAUvC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAM1C;AAGD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,OAAO,GAAG,IAAI,GAAG,SAAS,CAwBlD;AAGD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,OAAO,GAAG,SAAS,CAgB3C;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAK,MAAM,CA2E/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,CA0B9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,CA0C9B;AAED;;;;;;;;;GASG;AACH,wBAAiB,gBAAgB,CAC7B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,gBAAgB,CAAE,MAAM,CAAE,CAkGlD;AAGD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CA4C1C;AAID;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAK,MAAM,GAAG,SAAS,CAsC3C;AAED,QAAA,MAAM,eAAe,8JAAkC,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,QAAA,MAAM,iBAAiB,iGAAoC,CAAA;AAE3D,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B,QAAA,MAAM,iBAAiB,4FAAiC,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"step_deserialization_functions.d.ts","sourceRoot":"","sources":["../../../../src/step/parsing/step_deserialization_functions.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAGD;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAE,CAAC,EAAI,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,YAAY,EAAE,CAAC,GAAI,CAAC,CAE9E;AAGD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAE,CAAC,EAAI,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GAAI,MAAM,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAE,CAAC,EAAI,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GAAI,MAAM,CAEvE;AAGD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAUvC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAM1C;AAGD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,OAAO,GAAG,IAAI,GAAG,SAAS,CAwBlD;AAGD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,OAAO,GAAG,SAAS,CAgB3C;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACrB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAK,MAAM,CA2E/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,CA0B9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,CA0C9B;AAED;;;;;;;;;GASG;AACH,wBAAiB,gBAAgB,CAC7B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,gBAAgB,CAAE,MAAM,CAAE,CAkGlD;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GAAI,MAAM,CAqB7B;AAGD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CA4C1C;AAID;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAAK,MAAM,GAAG,SAAS,CAsC3C;AAED,QAAA,MAAM,eAAe,8JAAkC,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,CAAA;AAE1B,QAAA,MAAM,iBAAiB,iGAAoC,CAAA;AAE3D,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B,QAAA,MAAM,iBAAiB,4FAAiC,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -367,6 +367,51 @@ export function* stepExtractArray(buffer, cursor, endCursor) {
|
|
|
367
367
|
throw new Error("Unterminated array");
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Step past a `TYPENAME(` wrapper to the value inside it, when the value at
|
|
372
|
+
* the cursor is written in its typed form and the type name matches.
|
|
373
|
+
*
|
|
374
|
+
* A select member may be written either bare or typed — `.NULL.` or
|
|
375
|
+
* `NULL_STYLE(.NULL.)` — and inside a SELECT the typed form is how a reader
|
|
376
|
+
* tells which member it is, so exporters legitimately use it. Entity-valued
|
|
377
|
+
* members already handle both, because the parser indexes an inline
|
|
378
|
+
* `TYPENAME(...)` entity and `extractBufferReference` resolves it by address.
|
|
379
|
+
* A member whose type is an enum has no entity to index, so its deserializer
|
|
380
|
+
* is a bare parse starting at the cursor, and the wrapper makes it fail.
|
|
381
|
+
* That cost 274 of the public regression baseline's error rows — every
|
|
382
|
+
* `PRESENTATION_STYLE_ASSIGNMENT((NULL_STYLE(.NULL.)))` in the corpus threw
|
|
383
|
+
* and lost its styled item. See bldrs-ai/conway#489.
|
|
384
|
+
*
|
|
385
|
+
* The type name is verified rather than skipped past, so this accepts only
|
|
386
|
+
* the value's own typed form: a mismatched wrapper stays a type error
|
|
387
|
+
* instead of being silently read as the member it isn't.
|
|
388
|
+
*
|
|
389
|
+
* @param buffer The buffer to read from.
|
|
390
|
+
* @param cursor The position the value starts at.
|
|
391
|
+
* @param endCursor The last position accessible for this read in the buffer.
|
|
392
|
+
* @param typeName The expected STEP type name of the wrapper, upper case —
|
|
393
|
+
* StepEntityIdentifierParser matches `[A-Z][A-Z0-9_]*`, so a lower-case
|
|
394
|
+
* spelling is not an identifier here and never reaches the comparison.
|
|
395
|
+
* @return {number} The position just inside the wrapper's parenthesis, or
|
|
396
|
+
* `cursor` unchanged when the value is not this type's typed form.
|
|
397
|
+
*/
|
|
398
|
+
export function stepEnterTypedValue(buffer, cursor, endCursor, typeName) {
|
|
399
|
+
const identifierEnd = identifierParser.match(buffer, cursor, endCursor);
|
|
400
|
+
if (identifierEnd === void 0 || (identifierEnd - cursor) !== typeName.length) {
|
|
401
|
+
return cursor;
|
|
402
|
+
}
|
|
403
|
+
for (let where = 0; where < typeName.length; ++where) {
|
|
404
|
+
if (buffer[cursor + where] !== typeName.charCodeAt(where)) {
|
|
405
|
+
return cursor;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
// Delegate the rest to the inline-element reader rather than repeating its
|
|
409
|
+
// identifier/whitespace/comment/paren walk. Sharing it is not just less
|
|
410
|
+
// code: entity-valued select members reach their value through that exact
|
|
411
|
+
// function, so a divergence here would mean the two kinds of member in the
|
|
412
|
+
// SAME select disagreed about where a typed value begins.
|
|
413
|
+
return stepExtractInlineElemement(buffer, cursor, endCursor) ?? cursor;
|
|
414
|
+
}
|
|
370
415
|
/**
|
|
371
416
|
* Extracts an inline element and returns its cursor, or none if it can't be found.
|
|
372
417
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// unreachable after spill + release, where before it was retained via
|
|
8
8
|
// Context[parsingBufferReusable] → ParsingBuffer.buffer).
|
|
9
9
|
import { describe, expect, test } from "@jest/globals";
|
|
10
|
-
import { releaseScratchParsingBuffer, stepExtractNumber, } from "./step_deserialization_functions.js";
|
|
10
|
+
import { releaseScratchParsingBuffer, stepEnterTypedValue, stepExtractNumber, } from "./step_deserialization_functions.js";
|
|
11
11
|
const REAL_VALUE = 42.5;
|
|
12
12
|
const INT_VALUE = 7;
|
|
13
13
|
describe("releaseScratchParsingBuffer", () => {
|
|
@@ -25,3 +25,61 @@ describe("releaseScratchParsingBuffer", () => {
|
|
|
25
25
|
expect(stepExtractNumber(bytes, 0, bytes.length)).toBe(REAL_VALUE);
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
describe("stepEnterTypedValue", () => {
|
|
29
|
+
/**
|
|
30
|
+
* Encode and enter, returning both the cursor and what it points at, so a
|
|
31
|
+
* failed expectation says which byte the function landed on.
|
|
32
|
+
*
|
|
33
|
+
* @param text The STEP text to read from position 0.
|
|
34
|
+
* @param typeName The expected wrapper type name.
|
|
35
|
+
* @return {[number, string]} The returned cursor and the character there.
|
|
36
|
+
*/
|
|
37
|
+
const enter = (text, typeName) => {
|
|
38
|
+
const bytes = new TextEncoder().encode(text);
|
|
39
|
+
const cursor = stepEnterTypedValue(bytes, 0, bytes.length, typeName);
|
|
40
|
+
return [cursor, text[cursor] ?? ""];
|
|
41
|
+
};
|
|
42
|
+
test("enters a matching wrapper, landing on the value", () => {
|
|
43
|
+
// The case from bldrs-ai/conway#489: 274 occurrences in the public
|
|
44
|
+
// regression baseline, every one of them throwing and losing its
|
|
45
|
+
// styled item because the enum parse started on the 'N'.
|
|
46
|
+
// Positions derived rather than written out, so the expectation says
|
|
47
|
+
// "just past the wrapper" rather than asserting an opaque index.
|
|
48
|
+
expect(enter("NULL_STYLE(.NULL.)", "NULL_STYLE"))
|
|
49
|
+
.toEqual(["NULL_STYLE(".length, "."]);
|
|
50
|
+
expect(enter("IFCNULLSTYLE(.NULL.)", "IFCNULLSTYLE"))
|
|
51
|
+
.toEqual(["IFCNULLSTYLE(".length, "."]);
|
|
52
|
+
});
|
|
53
|
+
test("leaves a bare value alone", () => {
|
|
54
|
+
// Both forms are legal for a select member, so entering must be a no-op
|
|
55
|
+
// on the bare one rather than a precondition.
|
|
56
|
+
expect(enter(".NULL.", "NULL_STYLE")).toEqual([0, "."]);
|
|
57
|
+
});
|
|
58
|
+
test("does not treat a lower-case spelling as the type name", () => {
|
|
59
|
+
// Not a policy choice here: StepEntityIdentifierParser matches
|
|
60
|
+
// `[A-Z][A-Z0-9_]*`, so a lower-case wrapper is not an identifier at all
|
|
61
|
+
// and the value is left to be read bare (where it then fails as the
|
|
62
|
+
// malformed input it is).
|
|
63
|
+
expect(enter("null_style(.NULL.)", "NULL_STYLE")).toEqual([0, "n"]);
|
|
64
|
+
});
|
|
65
|
+
test("skips whitespace and comments before and after the paren", () => {
|
|
66
|
+
const spaced = "NULL_STYLE /* c */ ( /* d */ .NULL.)";
|
|
67
|
+
expect(enter(spaced, "NULL_STYLE")).toEqual([spaced.indexOf(".NULL."), "."]);
|
|
68
|
+
});
|
|
69
|
+
test("refuses a wrapper that is not this type", () => {
|
|
70
|
+
// The point of verifying the name rather than skipping any identifier:
|
|
71
|
+
// a mismatched wrapper stays a type error instead of being silently
|
|
72
|
+
// read as the member it is not.
|
|
73
|
+
expect(enter("SOME_OTHER_TYPE(.NULL.)", "NULL_STYLE")).toEqual([0, "S"]);
|
|
74
|
+
// A prefix must not match either - length is checked before the bytes.
|
|
75
|
+
expect(enter("NULL_STYLE_EXTRA(.NULL.)", "NULL_STYLE")).toEqual([0, "N"]);
|
|
76
|
+
});
|
|
77
|
+
test("refuses an identifier with no parenthesis", () => {
|
|
78
|
+
expect(enter("NULL_STYLE", "NULL_STYLE")).toEqual([0, "N"]);
|
|
79
|
+
expect(enter("NULL_STYLE.NULL.", "NULL_STYLE")).toEqual([0, "N"]);
|
|
80
|
+
});
|
|
81
|
+
test("refuses a reference or a bare number", () => {
|
|
82
|
+
expect(enter("#4085", "NULL_STYLE")).toEqual([0, "#"]);
|
|
83
|
+
expect(enter("0.7", "NULL_STYLE")).toEqual([0, "0"]);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
// only the first segment (major) is meaningful and is the one CI carries forward.
|
|
6
6
|
// Must stay in `vN.N.N` shape: the CI stamp regex, scripts/updateVersion.mjs, and
|
|
7
7
|
// statistics.ts all match `v\d+\.\d+\.\d+`.
|
|
8
|
-
const versionString = 'Conway v1.
|
|
8
|
+
const versionString = 'Conway v1.493.1414';
|
|
9
9
|
export { versionString };
|