corba.js 0.1.20 → 0.2.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/lib/idl/idl.cjs +139 -55
- package/lib/idl/idl.cjs.map +1 -1
- package/lib/idl/src/idl/cc/typeIDLtoGIOPCC.d.ts +1 -1
- package/lib/idl/src/idl/idl-node.d.ts +7 -6
- package/lib/src/idl/cc/typeIDLtoGIOPCC.d.ts +1 -1
- package/lib/src/idl/cc/typeIDLtoGIOPCC.js +6 -6
- package/lib/src/idl/cc/typeIDLtoGIOPCC.js.map +1 -1
- package/lib/src/idl/cc/write-code.js +2 -2
- package/lib/src/idl/cc/write-code.js.map +1 -1
- package/lib/src/idl/idl-node.d.ts +7 -6
- package/lib/src/idl/idl-node.js +8 -6
- package/lib/src/idl/idl-node.js.map +1 -1
- package/lib/src/idl/idl-parser.js +79 -28
- package/lib/src/idl/idl-parser.js.map +1 -1
- package/lib/src/idl/ts/typeIDLtoGIOPTS.js +13 -4
- package/lib/src/idl/ts/typeIDLtoGIOPTS.js.map +1 -1
- package/lib/src/idl/ts/typeIDLtoTS.js +31 -9
- package/lib/src/idl/ts/typeIDLtoTS.js.map +1 -1
- package/package.json +1 -1
package/lib/idl/idl.cjs
CHANGED
|
@@ -106,12 +106,13 @@ var Type;
|
|
|
106
106
|
Type[Type["SYN_OPERATION_DECLARATION"] = 80] = "SYN_OPERATION_DECLARATION";
|
|
107
107
|
Type[Type["SYN_PARAMETER_DECLARATIONS"] = 81] = "SYN_PARAMETER_DECLARATIONS";
|
|
108
108
|
Type[Type["SYN_PARAMETER_DECLARATION"] = 82] = "SYN_PARAMETER_DECLARATION";
|
|
109
|
-
Type[Type["
|
|
110
|
-
Type[Type["
|
|
111
|
-
Type[Type["
|
|
112
|
-
Type[Type["
|
|
113
|
-
Type[Type["
|
|
114
|
-
Type[Type["
|
|
109
|
+
Type[Type["SYN_ANNOTAION"] = 83] = "SYN_ANNOTAION";
|
|
110
|
+
Type[Type["SYN_TYPENAME"] = 84] = "SYN_TYPENAME";
|
|
111
|
+
Type[Type["SYN_LONGLONG"] = 85] = "SYN_LONGLONG";
|
|
112
|
+
Type[Type["SYN_UNSIGNED_SHORT"] = 86] = "SYN_UNSIGNED_SHORT";
|
|
113
|
+
Type[Type["SYN_UNSIGNED_LONG"] = 87] = "SYN_UNSIGNED_LONG";
|
|
114
|
+
Type[Type["SYN_UNSIGNED_LONGLONG"] = 88] = "SYN_UNSIGNED_LONGLONG";
|
|
115
|
+
Type[Type["SYN_LONG_DOUBLE"] = 89] = "SYN_LONG_DOUBLE";
|
|
115
116
|
})(Type || (Type = {}));
|
|
116
117
|
class Node {
|
|
117
118
|
constructor(type, text) {
|
|
@@ -204,6 +205,7 @@ class Node {
|
|
|
204
205
|
case Type.SYN_OPERATION_DECLARATION: return "SYN_OPERATION_DECLARATION";
|
|
205
206
|
case Type.SYN_PARAMETER_DECLARATIONS: return "SYN_PARAMETER_DECLARATIONS";
|
|
206
207
|
case Type.SYN_PARAMETER_DECLARATION: return "SYN_PARAMETER_DECLARATION";
|
|
208
|
+
case Type.SYN_ANNOTAION: return "SYN_ANNOTATION";
|
|
207
209
|
case Type.SYN_TYPENAME: return "SYN_TYPENAME";
|
|
208
210
|
case Type.SYN_LONGLONG: return "long long";
|
|
209
211
|
case Type.SYN_UNSIGNED_SHORT: return "unsigned short";
|
|
@@ -1377,32 +1379,32 @@ function except_dcl() {
|
|
|
1377
1379
|
return t0;
|
|
1378
1380
|
}
|
|
1379
1381
|
function op_dcl() {
|
|
1380
|
-
const
|
|
1381
|
-
const
|
|
1382
|
-
if (
|
|
1383
|
-
lexer.unlex(
|
|
1382
|
+
const node_attribute = op_attribute();
|
|
1383
|
+
const node_type = op_type_spec();
|
|
1384
|
+
if (node_type === undefined) {
|
|
1385
|
+
lexer.unlex(node_attribute);
|
|
1384
1386
|
return undefined;
|
|
1385
1387
|
}
|
|
1386
|
-
const
|
|
1387
|
-
if (
|
|
1388
|
-
throw Error(`expected identifier after '${
|
|
1388
|
+
const node_identifier = identifier();
|
|
1389
|
+
if (node_identifier === undefined) {
|
|
1390
|
+
throw Error(`expected identifier after '${node_type.toString()}'`);
|
|
1389
1391
|
}
|
|
1390
|
-
const
|
|
1391
|
-
if (
|
|
1392
|
-
lexer.unlex(
|
|
1393
|
-
if (
|
|
1394
|
-
throw Error("expected parameter declaration after " +
|
|
1392
|
+
const node_parameter_dcls = parameter_dcls();
|
|
1393
|
+
if (node_parameter_dcls === undefined) {
|
|
1394
|
+
lexer.unlex(node_identifier);
|
|
1395
|
+
if (node_type.child.length != 0) {
|
|
1396
|
+
throw Error("expected parameter declaration after " + node_identifier.toString());
|
|
1395
1397
|
}
|
|
1396
|
-
lexer.unlex(
|
|
1397
|
-
lexer.unlex(
|
|
1398
|
+
lexer.unlex(node_type);
|
|
1399
|
+
lexer.unlex(node_attribute);
|
|
1398
1400
|
return undefined;
|
|
1399
1401
|
}
|
|
1400
1402
|
const t4 = raises_expr();
|
|
1401
1403
|
let node = new Node(Type.SYN_OPERATION_DECLARATION);
|
|
1402
|
-
node.append(
|
|
1403
|
-
node.append(
|
|
1404
|
-
node.append(
|
|
1405
|
-
node.append(
|
|
1404
|
+
node.append(node_attribute);
|
|
1405
|
+
node.append(node_type);
|
|
1406
|
+
node.append(node_identifier);
|
|
1407
|
+
node.append(node_parameter_dcls);
|
|
1406
1408
|
node.append(t4);
|
|
1407
1409
|
node.append(undefined);
|
|
1408
1410
|
return node;
|
|
@@ -1419,8 +1421,9 @@ function op_attribute() {
|
|
|
1419
1421
|
}
|
|
1420
1422
|
function op_type_spec() {
|
|
1421
1423
|
let t0 = param_type_spec();
|
|
1422
|
-
if (t0 !== undefined)
|
|
1424
|
+
if (t0 !== undefined) {
|
|
1423
1425
|
return t0;
|
|
1426
|
+
}
|
|
1424
1427
|
t0 = lexer.lex();
|
|
1425
1428
|
if (t0 !== undefined && t0.type === Type.TKN_VOID)
|
|
1426
1429
|
return t0;
|
|
@@ -1456,6 +1459,7 @@ function parameter_dcls() {
|
|
|
1456
1459
|
return declarations;
|
|
1457
1460
|
}
|
|
1458
1461
|
function param_dcl() {
|
|
1462
|
+
let annotation = annotation_appl();
|
|
1459
1463
|
let t0 = param_attribute();
|
|
1460
1464
|
if (t0 === undefined)
|
|
1461
1465
|
return undefined;
|
|
@@ -1475,6 +1479,9 @@ function param_dcl() {
|
|
|
1475
1479
|
declaration.append(t0);
|
|
1476
1480
|
declaration.append(t1);
|
|
1477
1481
|
declaration.append(t2);
|
|
1482
|
+
if (annotation) {
|
|
1483
|
+
t1.append(annotation);
|
|
1484
|
+
}
|
|
1478
1485
|
return declaration;
|
|
1479
1486
|
}
|
|
1480
1487
|
function param_attribute() {
|
|
@@ -1522,16 +1529,16 @@ function raises_expr() {
|
|
|
1522
1529
|
}
|
|
1523
1530
|
function param_type_spec() {
|
|
1524
1531
|
let t0;
|
|
1532
|
+
const annotation = annotation_appl();
|
|
1525
1533
|
t0 = base_type_spec();
|
|
1526
|
-
if (t0
|
|
1527
|
-
|
|
1528
|
-
t0
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
return undefined;
|
|
1534
|
+
if (t0 === undefined)
|
|
1535
|
+
t0 = template_type_spec();
|
|
1536
|
+
if (t0 === undefined)
|
|
1537
|
+
t0 = scoped_name();
|
|
1538
|
+
if (t0 !== undefined && annotation) {
|
|
1539
|
+
t0.append(annotation);
|
|
1540
|
+
}
|
|
1541
|
+
return t0;
|
|
1535
1542
|
}
|
|
1536
1543
|
function readonly_attr_spec() {
|
|
1537
1544
|
let t0 = lexer.lex();
|
|
@@ -1606,6 +1613,52 @@ function attr_declarator() {
|
|
|
1606
1613
|
}
|
|
1607
1614
|
}
|
|
1608
1615
|
}
|
|
1616
|
+
function annotation_appl() {
|
|
1617
|
+
let t0 = lexer.lex();
|
|
1618
|
+
if (t0?.text !== "@") {
|
|
1619
|
+
lexer.unlex(t0);
|
|
1620
|
+
return undefined;
|
|
1621
|
+
}
|
|
1622
|
+
const t1 = identifier();
|
|
1623
|
+
if (t1 === undefined) {
|
|
1624
|
+
throw Error("expeced identifier after @");
|
|
1625
|
+
}
|
|
1626
|
+
expect("(");
|
|
1627
|
+
const t3 = annotation_appl_params();
|
|
1628
|
+
expect(")");
|
|
1629
|
+
t1.append(t3);
|
|
1630
|
+
t1.type = Type.SYN_ANNOTAION;
|
|
1631
|
+
return t1;
|
|
1632
|
+
}
|
|
1633
|
+
function annotation_appl_params() {
|
|
1634
|
+
const params = new Node(Type.SYN_PARAMETER_DECLARATIONS);
|
|
1635
|
+
while (true) {
|
|
1636
|
+
const param = annotation_appl_param();
|
|
1637
|
+
if (param === undefined) {
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
params.append(param);
|
|
1641
|
+
const t1 = lexer.lex();
|
|
1642
|
+
if (t1?.text !== ',') {
|
|
1643
|
+
lexer.unlex(t1);
|
|
1644
|
+
break;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
return params;
|
|
1648
|
+
}
|
|
1649
|
+
function annotation_appl_param() {
|
|
1650
|
+
const id = identifier();
|
|
1651
|
+
if (id === undefined) {
|
|
1652
|
+
throw Error(`expected identifier`);
|
|
1653
|
+
}
|
|
1654
|
+
expect("=");
|
|
1655
|
+
const val = identifier();
|
|
1656
|
+
if (val === undefined) {
|
|
1657
|
+
throw Error(`expected value`);
|
|
1658
|
+
}
|
|
1659
|
+
id.append(val);
|
|
1660
|
+
return id;
|
|
1661
|
+
}
|
|
1609
1662
|
function identifier() {
|
|
1610
1663
|
let t0 = lexer.lex();
|
|
1611
1664
|
if (t0 !== undefined && t0.type === Type.TKN_IDENTIFIER) {
|
|
@@ -1716,6 +1769,10 @@ function typeIDLtoTS(type, filetype = FileType.NONE) {
|
|
|
1716
1769
|
let identifierType = type.child[type.child.length - 1];
|
|
1717
1770
|
let relativeName = "";
|
|
1718
1771
|
for (let x of type.child) {
|
|
1772
|
+
if (x === undefined) {
|
|
1773
|
+
type.printTree();
|
|
1774
|
+
throw Error("undefined child unexpected");
|
|
1775
|
+
}
|
|
1719
1776
|
relativeName = `${relativeName}.${x.text}`;
|
|
1720
1777
|
}
|
|
1721
1778
|
relativeName = relativeName.substring(1);
|
|
@@ -1786,16 +1843,34 @@ function typeIDLtoTS(type, filetype = FileType.NONE) {
|
|
|
1786
1843
|
case Type.SYN_UNSIGNED_LONGLONG:
|
|
1787
1844
|
return "bigint";
|
|
1788
1845
|
case Type.TKN_SEQUENCE:
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
return `Array<${typeIDLtoTS(type.child[0], filetype)}>`;
|
|
1846
|
+
let specialType;
|
|
1847
|
+
if (type.child[2]?.type === Type.SYN_ANNOTAION) {
|
|
1848
|
+
const annotation = type.child[2];
|
|
1849
|
+
if (annotation.text === "js_mapping") {
|
|
1850
|
+
if (annotation.child[0]?.child[0]?.text === "type") {
|
|
1851
|
+
specialType = annotation.child[0]?.child[0]?.child[0]?.text;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1798
1854
|
}
|
|
1855
|
+
if (specialType) {
|
|
1856
|
+
let typedArray;
|
|
1857
|
+
switch (type.child[0].type) {
|
|
1858
|
+
case Type.TKN_OCTET:
|
|
1859
|
+
typedArray = "Uint8Array";
|
|
1860
|
+
break;
|
|
1861
|
+
case Type.TKN_FLOAT:
|
|
1862
|
+
typedArray = "Float32Array";
|
|
1863
|
+
break;
|
|
1864
|
+
case Type.TKN_DOUBLE:
|
|
1865
|
+
typedArray = "Float64Array";
|
|
1866
|
+
break;
|
|
1867
|
+
}
|
|
1868
|
+
if (specialType !== typedArray) {
|
|
1869
|
+
throw Error(`unsupported js mapping ${specialType} for sequence<...>`);
|
|
1870
|
+
}
|
|
1871
|
+
return typedArray;
|
|
1872
|
+
}
|
|
1873
|
+
return `Array<${typeIDLtoTS(type.child[0], filetype)}>`;
|
|
1799
1874
|
default:
|
|
1800
1875
|
throw Error(`no mapping from IDL type to TS type for ${type.toString()}`);
|
|
1801
1876
|
}
|
|
@@ -1958,14 +2033,23 @@ function typeIDLtoGIOPTS(type, arg = undefined, filetype = FileType.NONE) {
|
|
|
1958
2033
|
case Type.SYN_LONG_DOUBLE:
|
|
1959
2034
|
throw Error("long double is not supported yet");
|
|
1960
2035
|
case Type.TKN_SEQUENCE:
|
|
1961
|
-
|
|
1962
|
-
|
|
2036
|
+
let specialType;
|
|
2037
|
+
if (type.child[2]?.type === Type.SYN_ANNOTAION) {
|
|
2038
|
+
const annotation = type.child[2];
|
|
2039
|
+
if (annotation.text === "js_mapping") {
|
|
2040
|
+
if (annotation.child[0]?.child[0]?.text === "type") {
|
|
2041
|
+
specialType = annotation.child[0]?.child[0]?.child[0]?.text;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
switch (specialType) {
|
|
2046
|
+
case "Uint8Array":
|
|
1963
2047
|
name = "sequenceOctet";
|
|
1964
2048
|
break;
|
|
1965
|
-
case
|
|
2049
|
+
case "Float32Array":
|
|
1966
2050
|
name = "sequenceFloat";
|
|
1967
2051
|
break;
|
|
1968
|
-
case
|
|
2052
|
+
case "Float64Array":
|
|
1969
2053
|
name = "sequenceDouble";
|
|
1970
2054
|
break;
|
|
1971
2055
|
default:
|
|
@@ -3069,14 +3153,14 @@ function typeIDLtoCC(type, direction) {
|
|
|
3069
3153
|
}
|
|
3070
3154
|
}
|
|
3071
3155
|
|
|
3072
|
-
function typeIDLtoGIOPCC(type, arg, direction) {
|
|
3156
|
+
function typeIDLtoGIOPCC(type, arg, direction, struct = false) {
|
|
3073
3157
|
if (type === undefined)
|
|
3074
3158
|
throw Error("internal error: parser delivered no type information");
|
|
3075
3159
|
let name;
|
|
3076
3160
|
switch (type.type) {
|
|
3077
3161
|
case Type.TKN_IDENTIFIER:
|
|
3078
3162
|
case Type.TKN_MODULE:
|
|
3079
|
-
return typeIDLtoGIOPCC(type.child[0], arg, direction);
|
|
3163
|
+
return typeIDLtoGIOPCC(type.child[0], arg, direction, struct);
|
|
3080
3164
|
case Type.TKN_VALUETYPE:
|
|
3081
3165
|
return arg === undefined ? `decoder.value("${type.text}")` : `encoder.value(${arg})`;
|
|
3082
3166
|
case Type.SYN_INTERFACE:
|
|
@@ -3084,13 +3168,13 @@ function typeIDLtoGIOPCC(type, arg, direction) {
|
|
|
3084
3168
|
case Direction.IN:
|
|
3085
3169
|
return arg === undefined ? `${type.text}::_narrow(decoder.readObject(obj->get_ORB()))` : `encoder.writeObject(${arg}.get())`;
|
|
3086
3170
|
case Direction.OUT:
|
|
3087
|
-
return arg === undefined ? `${type.text}::_narrow(decoder.readObject(get_ORB()))` : `encoder.writeObject(${arg}.get())`;
|
|
3171
|
+
return arg === undefined ? `${type.text}::_narrow(decoder.readObject(${struct ? "orb" : "get_ORB()"}))` : `encoder.writeObject(${arg}.get())`;
|
|
3088
3172
|
}
|
|
3089
3173
|
case Type.TKN_UNION:
|
|
3090
3174
|
throw Error("union is not implemented yet");
|
|
3091
3175
|
case Type.TKN_STRUCT: {
|
|
3092
3176
|
return arg === undefined
|
|
3093
|
-
? `_decode${type.text}(decoder)`
|
|
3177
|
+
? `_decode${type.text}(get_ORB(), decoder)`
|
|
3094
3178
|
: `_encode${type.text}(encoder,${arg})`;
|
|
3095
3179
|
}
|
|
3096
3180
|
case Type.TKN_NATIVE:
|
|
@@ -3193,8 +3277,8 @@ function typeIDLtoGIOPCC(type, arg, direction) {
|
|
|
3193
3277
|
}
|
|
3194
3278
|
default:
|
|
3195
3279
|
return arg === undefined
|
|
3196
|
-
? `decoder.readSequence<${typeIDLtoCC(type.child[0], Direction.NESTED)}>([&] { return ${typeIDLtoGIOPCC(type.child[0], undefined, direction)}; })`
|
|
3197
|
-
: `encoder.writeSequence<${typeIDLtoCC(type.child[0], Direction.NESTED)}>(${arg}, [&](auto item) { ${typeIDLtoGIOPCC(type.child[0], "item", direction)}; })`;
|
|
3280
|
+
? `decoder.readSequence<${typeIDLtoCC(type.child[0], Direction.NESTED)}>([&] { return ${typeIDLtoGIOPCC(type.child[0], undefined, direction, struct)}; })`
|
|
3281
|
+
: `encoder.writeSequence<${typeIDLtoCC(type.child[0], Direction.NESTED)}>(${arg}, [&](auto item) { ${typeIDLtoGIOPCC(type.child[0], "item", direction, struct)}; })`;
|
|
3198
3282
|
}
|
|
3199
3283
|
default:
|
|
3200
3284
|
type.printTree();
|
|
@@ -3802,7 +3886,7 @@ function writeCCCodeDefinitions(out, specification, prefix = "", indent = 0) {
|
|
|
3802
3886
|
case Type.TKN_STRUCT: {
|
|
3803
3887
|
let struct_type = definition;
|
|
3804
3888
|
let identifier = struct_type.text;
|
|
3805
|
-
out.write(`static ${identifier} _decode${identifier}(CORBA::GIOPDecoder &decoder) {\n`);
|
|
3889
|
+
out.write(`static ${identifier} _decode${identifier}(std::shared_ptr<CORBA::ORB> orb, CORBA::GIOPDecoder &decoder) {\n`);
|
|
3806
3890
|
out.write(` return {\n`);
|
|
3807
3891
|
for (let i = 0; i < struct_type.child.length; ++i) {
|
|
3808
3892
|
const member = struct_type.child[i];
|
|
@@ -3811,7 +3895,7 @@ function writeCCCodeDefinitions(out, specification, prefix = "", indent = 0) {
|
|
|
3811
3895
|
let declarators = member.child[1];
|
|
3812
3896
|
for (let declarator of declarators.child) {
|
|
3813
3897
|
writeIndent(out, indent + 2);
|
|
3814
|
-
out.write("." + declarator.text + " = " + typeIDLtoGIOPCC(type, undefined, Direction.OUT) + ",\n");
|
|
3898
|
+
out.write("." + declarator.text + " = " + typeIDLtoGIOPCC(type, undefined, Direction.OUT, true) + ",\n");
|
|
3815
3899
|
}
|
|
3816
3900
|
}
|
|
3817
3901
|
}
|