Comparing version 2.0.3 to 2.0.4
@@ -154,4 +154,11 @@ | ||
consume(OTHER, "]") || error("Unterminated array type"); | ||
if (!obj.array) obj.array = 1; | ||
else obj.array++; | ||
if (!obj.array) { | ||
obj.array = 1; | ||
obj.nullableArray = [obj.nullable]; | ||
} | ||
else { | ||
obj.array++; | ||
obj.nullableArray.push(obj.nullable); | ||
} | ||
obj.nullable = false; | ||
} | ||
@@ -158,0 +165,0 @@ else return; |
{ | ||
"name": "webidl2" | ||
, "description": "A WebIDL Parser" | ||
, "version": "2.0.3" | ||
, "version": "2.0.4" | ||
, "author": "Robin Berjon <robin@berjon.com>" | ||
@@ -6,0 +6,0 @@ , "dependencies": { |
@@ -110,2 +110,35 @@ | ||
#### Interactions between `nullable` and `array` | ||
A more complex data model for our AST would likely represent `Foo[][][]` as a series of | ||
nested types four levels deep with three anonymous array types eventually containing a | ||
`Foo` type. But experience shows that such structures are cumbersome to use, and so we | ||
have a simpler model in which the depth of the array is specified with the `array` field. | ||
This is all fine and well, and in the vast majority of cases is actually simpler. But it | ||
does run afoul of cases in which it is necessary to distinguish between `Foo[][][]?`, | ||
`Foo?[][][]`, `Foo[][]?[]`, or even `Foo?[]?[]?[]?`. | ||
For this, when a type is an array type an additional `nullableArray` field is made available | ||
that captures which of the arrays contain nullable elements. It contains booleans that are | ||
true if the given array depth contains nullable elements, and false otherwise (mapping that to | ||
the syntax, and item is true if there is a `?` preceding the `[]`). These examples ought to | ||
clarify the model: | ||
Foo[][][]? | ||
-> nullable: true | ||
-> nullableArray: [false, false, false] | ||
Foo?[][][] | ||
-> nullable: false | ||
-> nullableArray: [true, false, false] | ||
Foo[][]?[] | ||
-> nullable: false | ||
-> nullableArray: [false, false, true] | ||
Foo?[]?[]?[]? | ||
-> nullable: true | ||
-> nullableArray: [true, true, true] | ||
Of particular importance, please note that the overall type is only `nullable` if there is | ||
a `?` at the end. | ||
### Interface | ||
@@ -112,0 +145,0 @@ Interfaces look like this: |
@@ -17,2 +17,3 @@ [ | ||
"array": 2, | ||
"nullableArray": [false, false], | ||
"union": false, | ||
@@ -19,0 +20,0 @@ "idlType": "unsigned short" |
@@ -38,2 +38,3 @@ [ | ||
"array": 1, | ||
"nullableArray": [false], | ||
"union": false, | ||
@@ -40,0 +41,0 @@ "idlType": "DOMString" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
812237
6235
706
0