corba.js 0.1.15 → 0.1.17

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 CHANGED
@@ -306,10 +306,10 @@ JSON to be lightweight and efficient with some inspiration from JSON-RPC and EJS
306
306
 
307
307
  All build stages are setup to run in watch mode for performance reasons.
308
308
 
309
- * I ususally run `npm dev:build` in Visual Studio Code's terminal window to
309
+ * I ususally run `npm run dev:build` in Visual Studio Code's terminal window to
310
310
  be able to jump from compiler errors directly into the source code.
311
311
 
312
- * `npm dev:test` runs all tests in watch mode.
312
+ * `npm run dev:test` runs all tests in watch mode.
313
313
 
314
- * `npm dev:test --file=lib/test/valuetype.spec.js` runs a single test file
314
+ * `npm run dev:test --file=lib/test/valuetype.spec.js` runs a single test file
315
315
  in watch mode.
package/lib/idl/idl.cjs CHANGED
@@ -1698,23 +1698,28 @@ function typeIDLtoTS(type, filetype = FileType.NONE) {
1698
1698
  let name;
1699
1699
  switch (identifierType.type) {
1700
1700
  case Type.TKN_VALUETYPE:
1701
- if (filetype !== FileType.VALUETYPE && filetype !== FileType.VALUE)
1701
+ if (filetype !== FileType.VALUETYPE && filetype !== FileType.VALUE) {
1702
1702
  name = `valuetype${absolutePrefix}.${relativeName}`;
1703
- else
1703
+ }
1704
+ else {
1704
1705
  name = absolutePrefix.length == 0 ? relativeName : `${absolutePrefix.substring(1)}.${relativeName}`;
1706
+ }
1705
1707
  break;
1706
1708
  case Type.SYN_INTERFACE:
1707
1709
  case Type.TKN_ENUM:
1708
1710
  case Type.TKN_UNION:
1709
- if (filetype !== FileType.INTERFACE)
1711
+ if (filetype !== FileType.INTERFACE) {
1710
1712
  name = `_interface${absolutePrefix}.${relativeName}`;
1711
- else
1713
+ }
1714
+ else {
1712
1715
  name = absolutePrefix.length == 0 ? relativeName : `${absolutePrefix.substring(1)}.${relativeName}`;
1716
+ }
1713
1717
  break;
1714
1718
  case Type.TKN_STRUCT:
1715
1719
  name = type.text;
1716
- if (filetype !== FileType.INTERFACE)
1720
+ if (filetype !== FileType.INTERFACE) {
1717
1721
  name = `_interface${absolutePrefix}.${name}`;
1722
+ }
1718
1723
  break;
1719
1724
  case Type.TKN_NATIVE:
1720
1725
  name = absolutePrefix.length == 0 ? relativeName : `${absolutePrefix.substring(1)}.${relativeName}`;
@@ -3730,8 +3735,19 @@ function writeCCCodeDefinitions(out, specification, prefix = "", indent = 0) {
3730
3735
  out.write(` return std::shared_ptr<${if_identifier}>();\n`);
3731
3736
  out.write(` }\n`);
3732
3737
  out.write(` std::shared_ptr<CORBA::ORB> orb = ref->get_ORB();\n`);
3738
+ out.write(` auto servant = orb->_narrow_servant(ref);\n`);
3739
+ out.write(` if (servant) {\n`);
3740
+ out.write(` auto impl = std::dynamic_pointer_cast<${if_identifier}>(servant);\n`);
3741
+ out.write(` if (impl) {\n`);
3742
+ out.write(` return impl;\n`);
3743
+ out.write(` }\n`);
3744
+ out.write(` }\n`);
3733
3745
  out.write(` auto conn = orb->getConnection(ref->host, ref->port);\n`);
3734
- out.write(` auto stub = std::make_shared<${if_identifier}_stub>(orb, CORBA::blob_view(ref->objectKey), conn);\n`);
3746
+ out.write(` auto stub = conn->stubsById[ref->objectKey];\n`);
3747
+ out.write(` if (!stub) {\n`);
3748
+ out.write(` stub = std::make_shared<${if_identifier}_stub>(orb, CORBA::blob_view(ref->objectKey), conn);\n`);
3749
+ out.write(` conn->stubsById[ref->objectKey] = stub;\n`);
3750
+ out.write(` }\n`);
3735
3751
  out.write(` return std::dynamic_pointer_cast<${if_identifier}>(stub);\n`);
3736
3752
  out.write(` }\n`);
3737
3753
  out.write(` auto obj = dynamic_cast<${if_identifier}*>(ptr);\n`);