rticonnextdds-connector 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -26,22 +26,13 @@ The `examples/nodejs` directory provides several examples:
26
26
  ## Dependencies
27
27
 
28
28
  RTI Connector for JavaScript has the following dependencies, which are also listed in `package.json`:
29
- * [ref-napi](https://www.npmjs.com/package/ref-napi): turns Buffer instances into "pointers"
30
- * [ref-struct-napi](https://www.npmjs.com/package/ref-struct-napi): create ABI-compilant "Struct" instances on top of Buffers
31
- * [ffi-napi](https://www.npmjs.com/package/ffi-napi): used for loading and calling dynamic libraries using pure JavaScript
29
+ * [koffi](https://koffi.dev/): used for loading and calling dynamic libraries using pure JavaScript
32
30
  * [events](https://www.npmjs.com/package/events): used for the 'EventEmitter' (legacy implementation of RTI Connector)
33
31
 
34
32
  Additionally to run the `web_socket` example, [socket.io](https://github.com/Automattic/socket.io) and [OpenLayers](https://openlayers.org) are required.
35
33
 
36
34
  Additional dependencies are required to run the unit tests and some of the examples. Please see the README files in the appropriate directory.
37
35
 
38
- ### Python dependency
39
-
40
- Some of the dependencies are shipped as source code and use [node-gyp](https://github.com/nodejs/node-gyp) to be compiled locally. `node-gyp` requires Python 2.7 and does not work with Python 3. The requirements for `node-gyp` can be found at:
41
- * [unix](https://github.com/nodejs/node-gyp#on-unix)
42
- * [darwin](https://github.com/nodejs/node-gyp#on-macos)
43
- * [windows](https://github.com/nodejs/node-gyp#on-windows)
44
-
45
36
  ### C/C++ compiler dependency
46
37
 
47
38
  The dependency [ref](https://www.npmjs.com/package/ref) is shipped as source code and requires a C++11 compiler.
package/README.rst CHANGED
@@ -34,11 +34,7 @@ Dependencies
34
34
 
35
35
  RTI Connector for JavaScript has the following dependencies, which are
36
36
  also listed in ``package.json``: \*
37
- `ref-napi <https://www.npmjs.com/package/ref-napi>`__: turns Buffer
38
- instances into "pointers" \*
39
- `ref-struct-napi <https://www.npmjs.com/package/ref-struct-napi>`__:
40
- create ABI-compilant "Struct" instances on top of Buffers \*
41
- `ffi-napi <https://www.npmjs.com/package/ffi-napi>`__: used for loading
37
+ `koffi <https://koffi.dev/>`__: used for loading
42
38
  and calling dynamic libraries using pure JavaScript \*
43
39
  `events <https://www.npmjs.com/package/events>`__: used for the
44
40
  'EventEmitter' (legacy implementation of RTI Connector)
@@ -50,17 +46,6 @@ Additionally to run the ``web_socket`` example,
50
46
  Additional dependencies are required to run the unit tests and some of
51
47
  the examples. Please see the README files in the appropriate directory.
52
48
 
53
- Python dependency
54
- ~~~~~~~~~~~~~~~~~
55
-
56
- Some of the dependencies are shipped as source code and use
57
- `node-gyp <https://github.com/nodejs/node-gyp>`__ to be compiled
58
- locally. ``node-gyp`` requires Python 2.7 and does not work with Python
59
- 3. The requirements for ``node-gyp`` can be found at: \*
60
- `unix <https://github.com/nodejs/node-gyp#on-unix>`__ \*
61
- `darwin <https://github.com/nodejs/node-gyp#on-macos>`__ \*
62
- `windows <https://github.com/nodejs/node-gyp#on-windows>`__
63
-
64
49
  C/C++ compiler dependency
65
50
  ~~~~~~~~~~~~~~~~~~~~~~~~~
66
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rticonnextdds-connector",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "RTI Connector for JavaScript",
5
5
  "main": "rticonnextdds-connector.js",
6
6
  "files": [
@@ -14,9 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "events": "^3.2.0",
17
- "ffi-napi": "^3.1.0",
18
- "ref-napi": "^3.0.1",
19
- "ref-struct-di": "^1.1.1"
17
+ "koffi": "^2.8.9"
20
18
  },
21
19
  "scripts": {
22
20
  "test": "mocha ./test/nodejs/",
@@ -7,25 +7,16 @@
7
7
  ******************************************************************************/
8
8
 
9
9
  const os = require('os')
10
- const ref = require('ref-napi')
11
- const ffi = require('ffi-napi')
12
10
  const path = require('path')
13
- const StructType = require('ref-struct-di')(ref)
11
+ const koffi = require('koffi');
14
12
  const EventEmitter = require('events').EventEmitter
15
13
 
16
- /**
17
- * The Node.js representation of the RTI_Connector_Options structure within
18
- * the core.
19
- *
20
- * We define it here using the module ref-struct (require above). This allows
21
- * us to pass it by value into the Core when creating a :class:`Connector` object.
22
- *
23
- * @private
24
- */
25
- const _ConnectorOptions = StructType({
26
- enable_on_data_event: ref.types.int,
27
- one_based_sequence_indexing: ref.types.int
28
- })
14
+ const _ConnectorOptions = koffi.struct('RTI_Connector_Options', {
15
+ enable_on_data_event: 'int',
16
+ one_based_sequence_indexing: 'int'
17
+ });
18
+
19
+ const RTI_HANDLE = koffi.pointer('RTI_HANDLE', koffi.opaque());
29
20
 
30
21
  // We ignore the loading of the libraries in code coverage since it is
31
22
  // not easily testable
@@ -70,7 +61,6 @@ class _ConnectorBinding {
70
61
  case 'win32':
71
62
  libDir = 'win-x64'
72
63
  libName = 'rtiddsconnector.dll'
73
- additionalLib = 'vcruntime140.dll'
74
64
  isWindows = true
75
65
  break
76
66
  default:
@@ -85,95 +75,66 @@ class _ConnectorBinding {
85
75
  console.log('Warning: 32-bit ' + os.platform() + ' is not supported')
86
76
  }
87
77
 
88
- if (additionalLib !== null) {
89
- try {
90
- ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', additionalLib))
91
- } catch (_) {
92
- // ignore this error and try to run without explicitly loading the VC++ runtime
93
- }
94
- }
78
+ this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', libName)
95
79
 
96
- // On Windows we need to explicitly load the dependent libraries
97
- if (isWindows) {
98
- ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddscore.dll'))
99
- ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddsc.dll'))
100
- }
80
+ this.api = koffi.load(this.library);
101
81
 
102
- this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', libName)
103
82
  // Obtain FFI'd methods for all of the APIs which we require from the binding,
104
83
  // specifying the argument types and return types. If any of the types are
105
84
  // not builtin Node types then we have to use the ref module to represent them.
106
- this.api = ffi.Library(this.library, {
107
- RTI_Connector_new: ['pointer', ['string', 'string', ref.refType(_ConnectorOptions)]],
108
- RTI_Connector_delete: ['void', ['pointer']],
109
- RTI_Connector_get_datawriter: ['pointer', ['pointer', 'string']],
110
- RTI_Connector_get_datareader: ['pointer', ['pointer', 'string']],
111
- RTI_Connector_get_native_sample: ['pointer', ['pointer', 'string', 'int']],
112
- RTI_Connector_set_number_into_samples: ['int', ['pointer', 'string', 'string', 'double']],
113
- RTI_Connector_set_boolean_into_samples: ['int', ['pointer', 'string', 'string', 'int']],
114
- RTI_Connector_set_string_into_samples: ['int', ['pointer', 'string', 'string', 'string']],
115
- RTI_Connector_clear_member: ['int', ['pointer', 'string', 'string']],
116
- RTI_Connector_write: ['int', ['pointer', 'string', 'string']],
117
- RTI_Connector_wait_for_acknowledgments: ['int', ['pointer', 'int']],
118
- RTI_Connector_read: ['int', ['pointer', 'string']],
119
- RTI_Connector_take: ['int', ['pointer', 'string']],
120
- RTI_Connector_wait_for_data: ['int', ['pointer', 'int']],
121
- RTI_Connector_wait_for_data_on_reader: ['int', ['pointer', 'int']],
122
- RTI_Connector_wait_for_matched_publication: ['int', ['pointer', 'int', 'pointer']],
123
- RTI_Connector_wait_for_matched_subscription: ['int', ['pointer', 'int', 'pointer']],
124
- RTI_Connector_get_matched_subscriptions: ['int', ['pointer', ref.refType('char *')]],
125
- RTI_Connector_get_matched_publications: ['int', ['pointer', ref.refType('char *')]],
126
- RTI_Connector_clear: ['int', ['pointer', 'string']],
127
- RTI_Connector_get_boolean_from_infos: ['int', ['pointer', ref.refType('int'), 'string', 'int', 'string']],
128
- RTI_Connector_get_json_from_infos: ['int', ['pointer', 'string', 'int', 'string', ref.refType('char *')]],
129
- RTI_Connector_get_sample_count: ['int', ['pointer', 'string', ref.refType('double')]],
130
- RTI_Connector_get_number_from_sample: ['int', ['pointer', ref.refType('double'), 'string', 'int', 'string']],
131
- RTI_Connector_get_boolean_from_sample: ['int', ['pointer', ref.refType('int'), 'string', 'int', 'string']],
132
- RTI_Connector_get_string_from_sample: ['int', ['pointer', ref.refType('char *'), 'string', 'int', 'string']],
133
- RTI_Connector_get_any_from_sample: ['int', ['pointer', ref.refType('double'), ref.refType('int'), ref.refType('char *'), ref.refType('int'), 'string', 'int', 'string']],
134
- RTI_Connector_get_any_from_info: ['int', ['pointer', ref.refType('double'), ref.refType('int'), ref.refType('char *'), ref.refType('int'), 'string', 'int', 'string']],
135
- RTI_Connector_get_json_sample: ['int', ['pointer', 'string', 'int', ref.refType('char *')]],
136
- RTI_Connector_get_json_member: ['int', ['pointer', 'string', 'int', 'string', ref.refType('char *')]],
137
- RTI_Connector_set_json_instance: ['int', ['pointer', 'string', 'string']],
138
- RTI_Connector_get_last_error_message: ['char *', []],
139
- RTI_Connector_get_native_instance: ['int', ['pointer', 'string', ref.refType('pointer')]],
140
- RTI_Connector_free_string: ['void', ['char *']],
141
- RTIDDSConnector_getJSONInstance: ['char *', ['pointer', 'string']],
85
+
86
+ const RTI_Connector_free_string = this.api.func('RTI_Connector_free_string', 'void', ['char *']);
87
+ const AllocatedString = koffi.disposable('AllocatedString', 'string', RTI_Connector_free_string);
88
+
89
+ this.RTI_Connector_new = this.api.func('RTI_Connector_new', RTI_HANDLE, ['string', 'string', koffi.pointer(_ConnectorOptions)]);
90
+ this.RTI_Connector_delete = this.api.func('RTI_Connector_delete', 'void', ['RTI_HANDLE']);
91
+ this.RTI_Connector_get_datawriter = this.api.func('RTI_Connector_get_datawriter', 'RTI_HANDLE', ['RTI_HANDLE', 'string']);
92
+ this.RTI_Connector_get_datareader = this.api.func('RTI_Connector_get_datareader', 'RTI_HANDLE', ['RTI_HANDLE', 'string']);
93
+ this.RTI_Connector_get_native_sample = this.api.func('RTI_Connector_get_native_sample', 'RTI_HANDLE', ['RTI_HANDLE', 'string', 'int']);
94
+ this.RTI_Connector_set_number_into_samples = this.api.func('RTI_Connector_set_number_into_samples', 'int', ['RTI_HANDLE', 'string', 'string', 'double']);
95
+ this.RTI_Connector_set_boolean_into_samples = this.api.func('RTI_Connector_set_boolean_into_samples', 'int', ['RTI_HANDLE', 'string', 'string', 'bool']);
96
+ this.RTI_Connector_set_string_into_samples = this.api.func('RTI_Connector_set_string_into_samples', 'int', ['RTI_HANDLE', 'string', 'string', 'string']);
97
+ this.RTI_Connector_clear_member = this.api.func('RTI_Connector_clear_member', 'int', ['RTI_HANDLE', 'string', 'string']);
98
+ this.RTI_Connector_write = this.api.func('RTI_Connector_write', 'int', ['RTI_HANDLE', 'string', 'string']);
99
+ this.RTI_Connector_wait_for_acknowledgments = this.api.func('RTI_Connector_wait_for_acknowledgments', 'int', ['RTI_HANDLE', 'int']);
100
+ this.RTI_Connector_read = this.api.func('RTI_Connector_read', 'int', ['RTI_HANDLE', 'string']);
101
+ this.RTI_Connector_take = this.api.func('RTI_Connector_take', 'int', ['RTI_HANDLE', 'string']);
102
+ this.RTI_Connector_wait_for_data = this.api.func('RTI_Connector_wait_for_data', 'int', ['RTI_HANDLE', 'int']);
103
+ this.RTI_Connector_wait_for_data_on_reader = this.api.func('RTI_Connector_wait_for_data_on_reader', 'int', ['RTI_HANDLE', 'int']);
104
+ this.RTI_Connector_wait_for_matched_publication = this.api.func('RTI_Connector_wait_for_matched_publication', 'int', ['RTI_HANDLE', 'int', koffi.out(koffi.pointer('int'))]);
105
+ this.RTI_Connector_wait_for_matched_subscription = this.api.func('RTI_Connector_wait_for_matched_subscription', 'int', ['RTI_HANDLE', 'int', koffi.out(koffi.pointer('int'))]);
106
+ this.RTI_Connector_get_matched_subscriptions = this.api.func('RTI_Connector_get_matched_subscriptions', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer(AllocatedString))]);
107
+ this.RTI_Connector_get_matched_publications = this.api.func('RTI_Connector_get_matched_publications', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer(AllocatedString))]);
108
+ this.RTI_Connector_clear = this.api.func('RTI_Connector_clear', 'int', ['RTI_HANDLE', 'string']);
109
+ this.RTI_Connector_get_boolean_from_infos = this.api.func('RTI_Connector_get_boolean_from_infos', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('bool')), 'string', 'int', 'string']);
110
+ this.RTI_Connector_get_json_from_infos = this.api.func('RTI_Connector_get_json_from_infos', 'int', ['RTI_HANDLE', 'string', 'int', 'string', koffi.out(koffi.pointer(AllocatedString))]);
111
+ this.RTI_Connector_get_sample_count = this.api.func('RTI_Connector_get_sample_count', 'int', ['RTI_HANDLE', 'string', koffi.out(koffi.pointer('double'))]);
112
+ this.RTI_Connector_get_number_from_sample = this.api.func('RTI_Connector_get_number_from_sample', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('double')), 'string', 'int', 'string']);
113
+ this.RTI_Connector_get_boolean_from_sample = this.api.func('RTI_Connector_get_boolean_from_sample', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('int')), 'string', 'int', 'string']);
114
+ this.RTI_Connector_get_string_from_sample = this.api.func('RTI_Connector_get_string_from_sample', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer(AllocatedString)), 'string', 'int', 'string']);
115
+ this.RTI_Connector_get_any_from_sample = this.api.func('RTI_Connector_get_any_from_sample', 'int', ['RTI_HANDLE',koffi.out(koffi.pointer('double')), koffi.out(koffi.pointer('int')), koffi.out(koffi.pointer(AllocatedString)), koffi.out(koffi.pointer('int')), 'string', 'int', 'string']);
116
+ this.RTI_Connector_get_any_from_info = this.api.func('RTI_Connector_get_any_from_info', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('double')), koffi.out(koffi.pointer('int')), koffi.out(koffi.pointer(AllocatedString)), koffi.out(koffi.pointer('int')), 'string', 'int', 'string']);
117
+ this.RTI_Connector_get_json_sample = this.api.func('RTI_Connector_get_json_sample', 'int', ['RTI_HANDLE', 'string', 'int', koffi.out(koffi.pointer(AllocatedString))]);
118
+ this.RTI_Connector_get_json_member = this.api.func('RTI_Connector_get_json_member', 'int', ['RTI_HANDLE', 'string', 'int', 'string', koffi.out(koffi.pointer(AllocatedString))]);
119
+ this.RTI_Connector_set_json_instance = this.api.func('RTI_Connector_set_json_instance', 'int', ['RTI_HANDLE', 'string', 'string']);
120
+ this.RTI_Connector_get_last_error_message = this.api.func('RTI_Connector_get_last_error_message', AllocatedString, []);
121
+ this.RTI_Connector_get_native_instance = this.api.func('RTI_Connector_get_native_instance', 'int', ['RTI_HANDLE', 'string', koffi.out(koffi.pointer(RTI_HANDLE))]);
122
+ this.RTIDDSConnector_getJSONInstance = this.api.func('RTIDDSConnector_getJSONInstance', AllocatedString, ['RTI_HANDLE', 'string']);
142
123
  // This API is only used in the unit tests
143
- RTI_Connector_create_test_scenario: ['int', ['pointer', 'int', 'pointer']],
144
- RTI_Connector_get_build_versions: ['int', [ref.refType('char *'), ref.refType('char *')]]
145
- })
124
+ this.RTI_Connector_create_test_scenario = this.api.func('RTI_Connector_create_test_scenario', 'int', ['RTI_HANDLE', 'int', 'RTI_HANDLE']);
125
+ this.RTI_Connector_get_build_versions = this.api.func('RTI_Connector_get_build_versions', 'int', [koffi.out(koffi.pointer('string')), koffi.out(koffi.pointer('string'))]);
146
126
  }
147
127
  }
148
128
 
149
129
  // Create an instance of the connectorBinding class, allowing us to call the FFI'd methods
150
130
  const connectorBinding = new _ConnectorBinding()
151
131
 
152
- /**
153
- * Copies a natively allocated string into a Node.js string and frees the
154
- * native memory.
155
- *
156
- * @param {Buffer} cstring - The string returned by the core
157
- *
158
- * @private
159
- */
160
- function _moveCString (cstring) {
161
- const ret = ref.readCString(cstring)
162
- connectorBinding.api.RTI_Connector_free_string(cstring)
163
- return ret
164
- }
165
-
166
132
  /**
167
133
  * Obtains the last error message from the *RTI Connext DDS* Core
168
134
  * @private
169
135
  */
170
136
  function _getLastDdsErrorMessage () {
171
- const cStr = connectorBinding.api.RTI_Connector_get_last_error_message()
172
- if (cStr !== null) {
173
- return _moveCString(cStr)
174
- } else {
175
- return ''
176
- }
137
+ return connectorBinding.RTI_Connector_get_last_error_message()
177
138
  }
178
139
 
179
140
  /**
@@ -297,10 +258,10 @@ function _isNumber (value) {
297
258
  * @private
298
259
  */
299
260
  function _getAnyValue (getter, connector, inputName, index, fieldName) {
300
- const numberVal = ref.alloc('double')
301
- const boolVal = ref.alloc('int')
302
- const stringVal = ref.alloc('char *')
303
- let selection = ref.alloc('int')
261
+ let numberVal = [null]
262
+ let boolVal = [null]
263
+ let stringVal = [null]
264
+ let selection = [null]
304
265
  const retcode = getter(
305
266
  connector,
306
267
  numberVal,
@@ -314,13 +275,13 @@ function _getAnyValue (getter, connector, inputName, index, fieldName) {
314
275
  if (retcode === _ReturnCodes.noData) {
315
276
  return null
316
277
  }
317
- selection = selection.deref()
278
+ selection = selection[0]
318
279
  if (selection === _AnyValueKind.connector_number) {
319
- return numberVal.deref()
280
+ return numberVal[0]
320
281
  } else if (selection === _AnyValueKind.connector_boolean) {
321
- return !!boolVal.deref()
282
+ return !!boolVal[0]
322
283
  } else if (selection === _AnyValueKind.connector_string) {
323
- const nodeStr = _moveCString(stringVal.deref())
284
+ const nodeStr = stringVal[0]
324
285
  // If this is NOT a numeric string, try to convert the returned string to a
325
286
  // JSON object. We can now return one of two things:
326
287
  // - An actual string (if the JSON.parse call fails)
@@ -358,13 +319,13 @@ class Infos {
358
319
  * @private
359
320
  */
360
321
  getLength () {
361
- const length = ref.alloc('double')
362
- const retcode = connectorBinding.api.RTI_Connector_get_sample_count(
322
+ let length = [null];
323
+ const retcode = connectorBinding.RTI_Connector_get_sample_count(
363
324
  this.input.connector.native,
364
325
  this.input.name,
365
326
  length)
366
327
  _checkRetcode(retcode)
367
- return length.deref()
328
+ return length[0]
368
329
  }
369
330
 
370
331
  /**
@@ -381,8 +342,8 @@ class Infos {
381
342
  } else {
382
343
  // Increment index since Lua arrays are 1-indexed
383
344
  index += 1
384
- const value = ref.alloc('int')
385
- const retcode = connectorBinding.api.RTI_Connector_get_boolean_from_infos(
345
+ let value = [null]
346
+ const retcode = connectorBinding.RTI_Connector_get_boolean_from_infos(
386
347
  this.input.connector.native,
387
348
  value,
388
349
  this.input.name,
@@ -392,7 +353,7 @@ class Infos {
392
353
  if (retcode === _ReturnCodes.noData) {
393
354
  return null
394
355
  }
395
- return value.deref()
356
+ return value[0]
396
357
  }
397
358
  }
398
359
  }
@@ -427,7 +388,7 @@ class SampleIterator {
427
388
  * contains valid data.
428
389
  * @property {SampleInfo} infos - The meta-data associated with the
429
390
  * current sample.
430
- * @property {pointer} native - A native handle that allows accessing
391
+ * @property {RTI_HANDLE} native - A native handle that allows accessing
431
392
  * additional *Connext DDS* APIs in C.
432
393
  */
433
394
  constructor (input, index) {
@@ -553,9 +514,9 @@ class SampleIterator {
553
514
  }
554
515
 
555
516
  /**
556
- * The native pointer to the DynamicData sample.
517
+ * The native RTI_HANDLE to the DynamicData sample.
557
518
  *
558
- * @type {pointer}
519
+ * @type {RTI_HANDLE}
559
520
  * @private
560
521
  */
561
522
  get native () {
@@ -774,8 +735,8 @@ class Samples {
774
735
  * @private
775
736
  */
776
737
  getLength () {
777
- const length = ref.alloc('double')
778
- const retcode = connectorBinding.api.RTI_Connector_get_sample_count(
738
+ let length = [null]
739
+ const retcode = connectorBinding.RTI_Connector_get_sample_count(
779
740
  this.input.connector.native,
780
741
  this.input.name,
781
742
  length)
@@ -783,7 +744,7 @@ class Samples {
783
744
  // We use ~~ to convert from double -> int. This is required to allow:
784
745
  // for (var i =0; i < input.samples.getLength(); ++i)
785
746
  // It works since we are doing a bitwise complement (double not).
786
- return ~~length.deref()
747
+ return ~~length[0]
787
748
  }
788
749
 
789
750
  /**
@@ -803,8 +764,8 @@ class Samples {
803
764
  } else {
804
765
  // Increment index since C API is based on Lua with 1-based indexes
805
766
  index += 1
806
- const value = ref.alloc('double')
807
- const retcode = connectorBinding.api.RTI_Connector_get_number_from_sample(
767
+ let value = [null]
768
+ const retcode = connectorBinding.RTI_Connector_get_number_from_sample(
808
769
  this.input.connector.native,
809
770
  value,
810
771
  this.input.name,
@@ -815,7 +776,7 @@ class Samples {
815
776
  if (retcode === _ReturnCodes.noData) {
816
777
  return null
817
778
  } else {
818
- return value.deref()
779
+ return value[0]
819
780
  }
820
781
  }
821
782
  }
@@ -837,8 +798,8 @@ class Samples {
837
798
  } else {
838
799
  // Increment index since C API is based on Lua with 1-based indexes
839
800
  index += 1
840
- const value = ref.alloc('int')
841
- const retcode = connectorBinding.api.RTI_Connector_get_boolean_from_sample(
801
+ let value = [null]
802
+ const retcode = connectorBinding.RTI_Connector_get_boolean_from_sample(
842
803
  this.input.connector.native,
843
804
  value,
844
805
  this.input.name,
@@ -849,7 +810,7 @@ class Samples {
849
810
  if (retcode === _ReturnCodes.noData) {
850
811
  return null
851
812
  } else {
852
- return value.deref()
813
+ return value[0]
853
814
  }
854
815
  }
855
816
  }
@@ -871,8 +832,8 @@ class Samples {
871
832
  } else {
872
833
  // Increment index since C API is based on Lua with 1-based indexes
873
834
  index += 1
874
- const value = ref.alloc('char *')
875
- const retcode = connectorBinding.api.RTI_Connector_get_string_from_sample(
835
+ let value = [null]
836
+ const retcode = connectorBinding.RTI_Connector_get_string_from_sample(
876
837
  this.input.connector.native,
877
838
  value,
878
839
  this.input.name,
@@ -882,7 +843,7 @@ class Samples {
882
843
  if (retcode === _ReturnCodes.noData) {
883
844
  return null
884
845
  } else {
885
- return _moveCString(value.deref())
846
+ return value[0]
886
847
  }
887
848
  }
888
849
  }
@@ -905,7 +866,7 @@ class Samples {
905
866
  throw new TypeError('fieldName must be a string')
906
867
  } else {
907
868
  return _getAnyValue(
908
- connectorBinding.api.RTI_Connector_get_any_from_sample,
869
+ connectorBinding.RTI_Connector_get_any_from_sample,
909
870
  this.input.connector.native,
910
871
  this.input.name,
911
872
  index,
@@ -930,7 +891,7 @@ class Samples {
930
891
  } else {
931
892
  // Increment index since Lua arrays are 1-indexed
932
893
  index += 1
933
- const cStr = ref.alloc('char *')
894
+ let str = [null]
934
895
  let retcode = _ReturnCodes.noData
935
896
  // memberName is "optional" - if supplied we will get the JSON object for
936
897
  // a specific complex member in the sample
@@ -938,25 +899,25 @@ class Samples {
938
899
  if (!_isString(memberName)) {
939
900
  throw new TypeError('memberName must be a string')
940
901
  } else {
941
- retcode = connectorBinding.api.RTI_Connector_get_json_member(
902
+ retcode = connectorBinding.RTI_Connector_get_json_member(
942
903
  this.input.connector.native,
943
904
  this.input.name,
944
905
  index,
945
906
  memberName,
946
- cStr)
907
+ str)
947
908
  }
948
909
  } else {
949
- retcode = connectorBinding.api.RTI_Connector_get_json_sample(
910
+ retcode = connectorBinding.RTI_Connector_get_json_sample(
950
911
  this.input.connector.native,
951
912
  this.input.name,
952
913
  index,
953
- cStr)
914
+ str)
954
915
  }
955
916
  _checkRetcode(retcode)
956
917
  if (retcode === _ReturnCodes.noData) {
957
918
  return null
958
919
  }
959
- return JSON.parse(_moveCString(cStr.deref()))
920
+ return JSON.parse(str[0])
960
921
  }
961
922
  }
962
923
 
@@ -965,8 +926,8 @@ class Samples {
965
926
  * additional *Connext DDS* APIs in C.
966
927
  *
967
928
  * @param {number} index The index of the sample for which to obtain
968
- * the native pointer.
969
- * @returns {pointer} A native pointer to the sample.
929
+ * the native RTI_HANDLE.
930
+ * @returns {RTI_HANDLE} A native RTI_HANDLE to the sample.
970
931
  */
971
932
  getNative (index) {
972
933
  if (!_isValidIndex(index)) {
@@ -974,7 +935,7 @@ class Samples {
974
935
  } else {
975
936
  // Increment index since Lua arrays are 1-indexed
976
937
  index += 1
977
- return connectorBinding.api.RTI_Connector_get_native_sample(
938
+ return connectorBinding.RTI_Connector_get_native_sample(
978
939
  this.input.connector.native,
979
940
  this.input.name,
980
941
  index)
@@ -1035,7 +996,7 @@ class SampleInfo {
1035
996
  throw new TypeError('fieldName must be a string')
1036
997
  } else {
1037
998
  return _getAnyValue(
1038
- connectorBinding.api.RTI_Connector_get_any_from_info,
999
+ connectorBinding.RTI_Connector_get_any_from_info,
1039
1000
  this.input.connector.native,
1040
1001
  this.input.name,
1041
1002
  this.index,
@@ -1057,7 +1018,7 @@ class Input {
1057
1018
  * * connector (:class:`Connector`) - The Connector creates this Input.
1058
1019
  * * name (string) - The name of the Input (the name used in
1059
1020
  * :meth:`Connector.getInput`).
1060
- * * native (pointer) - A native handle that allows accessing additional
1021
+ * * native (RTI_HANDLE) - A native handle that allows accessing additional
1061
1022
  * *Connext DDS* APIs in C.
1062
1023
  * * matchedPublications (JSON) - A JSON object containing information
1063
1024
  * about all the publications currently matched with this Input.
@@ -1065,10 +1026,10 @@ class Input {
1065
1026
  constructor (connector, name) {
1066
1027
  this.connector = connector
1067
1028
  this.name = name
1068
- this.native = connectorBinding.api.RTI_Connector_get_datareader(
1029
+ this.native = connectorBinding.RTI_Connector_get_datareader(
1069
1030
  this.connector.native,
1070
1031
  this.name)
1071
- if (this.native.isNull()) {
1032
+ if (this.native == null) {
1072
1033
  throw new Error('Invalid Subscription::DataReader name')
1073
1034
  }
1074
1035
  // We use the '_' since samples is the name of the property and we want
@@ -1092,7 +1053,7 @@ class Input {
1092
1053
  * operation has been called.
1093
1054
  */
1094
1055
  read () {
1095
- _checkRetcode(connectorBinding.api.RTI_Connector_read(
1056
+ _checkRetcode(connectorBinding.RTI_Connector_read(
1096
1057
  this.connector.native,
1097
1058
  this.name))
1098
1059
  }
@@ -1104,7 +1065,7 @@ class Input {
1104
1065
  * :meth:`Input.samples`.
1105
1066
  */
1106
1067
  take () {
1107
- _checkRetcode(connectorBinding.api.RTI_Connector_take(
1068
+ _checkRetcode(connectorBinding.RTI_Connector_take(
1108
1069
  this.connector.native,
1109
1070
  this.name))
1110
1071
  }
@@ -1152,8 +1113,8 @@ class Input {
1152
1113
  throw new Error('Can not concurrently wait on the same Input')
1153
1114
  } else {
1154
1115
  this.waitSetBusy = true
1155
- const currentChangeCount = ref.alloc('int')
1156
- connectorBinding.api.RTI_Connector_wait_for_matched_publication.async(
1116
+ let currentChangeCount = [null]
1117
+ connectorBinding.RTI_Connector_wait_for_matched_publication.async(
1157
1118
  this.native,
1158
1119
  timeout,
1159
1120
  currentChangeCount,
@@ -1162,7 +1123,7 @@ class Input {
1162
1123
  if (err) {
1163
1124
  return reject(err)
1164
1125
  } else if (res === _ReturnCodes.ok) {
1165
- return resolve(currentChangeCount.deref())
1126
+ return resolve(currentChangeCount[0])
1166
1127
  } else if (res === _ReturnCodes.timeout) {
1167
1128
  return reject(new TimeoutError('Timeout error'))
1168
1129
  } else {
@@ -1191,12 +1152,12 @@ class Input {
1191
1152
  * @type {JSON}
1192
1153
  */
1193
1154
  get matchedPublications () {
1194
- const cStr = ref.alloc('char *')
1195
- const retcode = connectorBinding.api.RTI_Connector_get_matched_publications(
1155
+ let str = [null]
1156
+ const retcode = connectorBinding.RTI_Connector_get_matched_publications(
1196
1157
  this.native,
1197
- cStr)
1158
+ str)
1198
1159
  _checkRetcode(retcode)
1199
- return JSON.parse(_moveCString(cStr.deref()))
1160
+ return JSON.parse(str[0])
1200
1161
  }
1201
1162
 
1202
1163
  /**
@@ -1224,7 +1185,7 @@ class Input {
1224
1185
  throw new Error('Can not concurrently wait on the same Input')
1225
1186
  } else {
1226
1187
  this.waitSetBusy = true
1227
- connectorBinding.api.RTI_Connector_wait_for_data_on_reader.async(
1188
+ connectorBinding.RTI_Connector_wait_for_data_on_reader.async(
1228
1189
  this.native,
1229
1190
  timeout,
1230
1191
  (err, res) => {
@@ -1258,7 +1219,7 @@ class Instance {
1258
1219
  * Attributes:
1259
1220
  * * ``output`` (:class:`Output`) - The :class:`Output` that owns
1260
1221
  * this Instance.
1261
- * * ``native`` (pointer) - Native handle to this Instance that allows
1222
+ * * ``native`` (RTI_HANDLE) - Native handle to this Instance that allows
1262
1223
  * for additional *Connext DDS Pro* C APIs to be called.
1263
1224
  */
1264
1225
  constructor (output) {
@@ -1277,7 +1238,7 @@ class Instance {
1277
1238
  if (!_isString(fieldName)) {
1278
1239
  throw new TypeError('fieldName must be a string')
1279
1240
  } else {
1280
- const retcode = connectorBinding.api.RTI_Connector_clear_member(
1241
+ const retcode = connectorBinding.RTI_Connector_clear_member(
1281
1242
  this.output.connector.native,
1282
1243
  this.output.name,
1283
1244
  fieldName)
@@ -1307,7 +1268,7 @@ class Instance {
1307
1268
  throw new TypeError('value must be a number')
1308
1269
  }
1309
1270
  } else {
1310
- _checkRetcode(connectorBinding.api.RTI_Connector_set_number_into_samples(
1271
+ _checkRetcode(connectorBinding.RTI_Connector_set_number_into_samples(
1311
1272
  this.output.connector.native,
1312
1273
  this.output.name,
1313
1274
  fieldName,
@@ -1332,7 +1293,7 @@ class Instance {
1332
1293
  throw new TypeError('value must be a boolean')
1333
1294
  }
1334
1295
  } else {
1335
- const retcode = connectorBinding.api.RTI_Connector_set_boolean_into_samples(
1296
+ const retcode = connectorBinding.RTI_Connector_set_boolean_into_samples(
1336
1297
  this.output.connector.native,
1337
1298
  this.output.name,
1338
1299
  fieldName,
@@ -1358,7 +1319,7 @@ class Instance {
1358
1319
  throw new TypeError('value must be a boolean')
1359
1320
  }
1360
1321
  } else {
1361
- const retcode = connectorBinding.api.RTI_Connector_set_string_into_samples(
1322
+ const retcode = connectorBinding.RTI_Connector_set_string_into_samples(
1362
1323
  this.output.connector.native,
1363
1324
  this.output.name,
1364
1325
  fieldName,
@@ -1387,7 +1348,7 @@ class Instance {
1387
1348
  * (field names) and values (values for the fields).
1388
1349
  */
1389
1350
  setFromJson (jsonObj) {
1390
- _checkRetcode(connectorBinding.api.RTI_Connector_set_json_instance(
1351
+ _checkRetcode(connectorBinding.RTI_Connector_set_json_instance(
1391
1352
  this.output.connector.native,
1392
1353
  this.output.name,
1393
1354
  JSON.stringify(jsonObj)))
@@ -1442,14 +1403,13 @@ class Instance {
1442
1403
  * @returns {JSON} The value of this instance as a JSON object.
1443
1404
  */
1444
1405
  getJson () {
1445
- const nativeStr = connectorBinding.api.RTIDDSConnector_getJSONInstance(
1406
+ const result = connectorBinding.RTIDDSConnector_getJSONInstance(
1446
1407
  this.output.connector.native,
1447
1408
  this.output.name)
1448
- // Now move the native string
1449
- if (nativeStr === null) {
1409
+ if (result === null) {
1450
1410
  throw new Error('Failed to create JSON object of instance')
1451
1411
  } else {
1452
- return JSON.parse(_moveCString(nativeStr))
1412
+ return JSON.parse(result)
1453
1413
  }
1454
1414
  }
1455
1415
 
@@ -1467,16 +1427,16 @@ class Instance {
1467
1427
  * The native C object.
1468
1428
  *
1469
1429
  * This property allows accessing additional *Connext DDS* APIs in C.
1470
- * @type {pointer}
1430
+ * @type {RTI_HANDLE}
1471
1431
  */
1472
1432
  get native () {
1473
- const nativePointer = ref.alloc('pointer')
1474
- const retcode = connectorBinding.api.RTI_Connector_get_native_instance(
1433
+ let nativePointer = [null]
1434
+ const retcode = connectorBinding.RTI_Connector_get_native_instance(
1475
1435
  this.output.connector.native,
1476
1436
  this.output.name,
1477
1437
  nativePointer)
1478
1438
  _checkRetcode(retcode)
1479
- return nativePointer.deref()
1439
+ return nativePointer[0]
1480
1440
  }
1481
1441
  }
1482
1442
 
@@ -1496,7 +1456,7 @@ class Output {
1496
1456
  * that created this object.
1497
1457
  * * ``name`` (str) - The name of this Output (the name used in
1498
1458
  * :meth:`Connector.getOutput`).
1499
- * * ``native`` (pointer) - The native handle that allows accessing
1459
+ * * ``native`` (RTI_HANDLE) - The native handle that allows accessing
1500
1460
  * additional *Connext DDS* APIs in C.
1501
1461
  * * ``matchedSubscriptions`` (JSON) - Information about matched
1502
1462
  * subscriptions (see below).
@@ -1505,10 +1465,10 @@ class Output {
1505
1465
  constructor (connector, name) {
1506
1466
  this.connector = connector
1507
1467
  this.name = name
1508
- this.native = connectorBinding.api.RTI_Connector_get_datawriter(
1468
+ this.native = connectorBinding.RTI_Connector_get_datawriter(
1509
1469
  this.connector.native,
1510
1470
  this.name)
1511
- if (this.native.isNull()) {
1471
+ if (this.native == null) {
1512
1472
  throw new Error('Invalid Publisher::DataWriter name')
1513
1473
  }
1514
1474
  this.instance = new Instance(this)
@@ -1551,16 +1511,16 @@ class Output {
1551
1511
  * throws :class:`TimeoutError`.
1552
1512
  */
1553
1513
  write (params) {
1554
- let cStr
1514
+ let str
1555
1515
  if (params === undefined) {
1556
- cStr = null
1516
+ str = null
1557
1517
  } else {
1558
- cStr = JSON.stringify(params)
1518
+ str = JSON.stringify(params)
1559
1519
  }
1560
- _checkRetcode(connectorBinding.api.RTI_Connector_write(
1520
+ _checkRetcode(connectorBinding.RTI_Connector_write(
1561
1521
  this.connector.native,
1562
1522
  this.name,
1563
- cStr))
1523
+ str))
1564
1524
  }
1565
1525
 
1566
1526
  /**
@@ -1577,7 +1537,7 @@ class Output {
1577
1537
  * y = 0
1578
1538
  */
1579
1539
  clearMembers () {
1580
- _checkRetcode(connectorBinding.api.RTI_Connector_clear(
1540
+ _checkRetcode(connectorBinding.RTI_Connector_clear(
1581
1541
  this.connector.native,
1582
1542
  this.name))
1583
1543
  }
@@ -1607,7 +1567,7 @@ class Output {
1607
1567
  } else if (!_isNumber(timeout)) {
1608
1568
  throw new TypeError('timeout must be a number')
1609
1569
  }
1610
- connectorBinding.api.RTI_Connector_wait_for_acknowledgments.async(
1570
+ connectorBinding.RTI_Connector_wait_for_acknowledgments.async(
1611
1571
  this.native,
1612
1572
  timeout,
1613
1573
  (err, res) => {
@@ -1655,9 +1615,9 @@ class Output {
1655
1615
  if (this.waitsetBusy) {
1656
1616
  throw new Error('Can not concurrently wait on the same Output')
1657
1617
  } else {
1658
- const currentChangeCount = ref.alloc('int')
1618
+ let currentChangeCount = [null]
1659
1619
  this.waitsetBusy = true
1660
- connectorBinding.api.RTI_Connector_wait_for_matched_subscription.async(
1620
+ connectorBinding.RTI_Connector_wait_for_matched_subscription.async(
1661
1621
  this.native,
1662
1622
  timeout,
1663
1623
  currentChangeCount,
@@ -1666,7 +1626,7 @@ class Output {
1666
1626
  if (err) {
1667
1627
  return reject(err)
1668
1628
  } else if (res === _ReturnCodes.ok) {
1669
- return resolve(currentChangeCount.deref())
1629
+ return resolve(currentChangeCount[0])
1670
1630
  } else if (res === _ReturnCodes.timeout) {
1671
1631
  return reject(new TimeoutError('Timeout error'))
1672
1632
  } else {
@@ -1694,12 +1654,12 @@ class Output {
1694
1654
  * @type {JSON}
1695
1655
  */
1696
1656
  get matchedSubscriptions () {
1697
- const cStr = ref.alloc('char *')
1698
- const retcode = connectorBinding.api.RTI_Connector_get_matched_subscriptions(
1657
+ let str = [null]
1658
+ const retcode = connectorBinding.RTI_Connector_get_matched_subscriptions(
1699
1659
  this.native,
1700
- cStr)
1660
+ str)
1701
1661
  _checkRetcode(retcode)
1702
- return JSON.parse(_moveCString(cStr.deref()))
1662
+ return JSON.parse(str[0])
1703
1663
  }
1704
1664
 
1705
1665
  /* istanbul ignore next */
@@ -1753,14 +1713,15 @@ class Connector extends EventEmitter {
1753
1713
  */
1754
1714
  constructor (configName, url) {
1755
1715
  super()
1756
- const options = new _ConnectorOptions()
1757
- options.one_based_sequence_indexing = 0
1758
- options.enable_on_data_event = 1
1759
- this.native = connectorBinding.api.RTI_Connector_new(
1716
+ const options = {
1717
+ one_based_sequence_indexing: 0,
1718
+ enable_on_data_event: 1
1719
+ };
1720
+ this.native = connectorBinding.RTI_Connector_new(
1760
1721
  configName,
1761
1722
  url,
1762
- options.ref())
1763
- if (this.native.isNull()) {
1723
+ options)
1724
+ if (this.native == null) {
1764
1725
  throw new Error('Invalid participant profile, xml path or xml profile')
1765
1726
  }
1766
1727
  this.on('newListener', this.newListenerCallBack)
@@ -1798,7 +1759,7 @@ class Connector extends EventEmitter {
1798
1759
  // is also used by the waitForCallbackFinalization API, and in that case we
1799
1760
  // should not delete anything
1800
1761
  if (cleanup) {
1801
- connectorBinding.api.RTI_Connector_delete(this.native)
1762
+ connectorBinding.RTI_Connector_delete(this.native)
1802
1763
  this.native = null
1803
1764
  }
1804
1765
  // Call the resolve() callback of the passed promise
@@ -1965,7 +1926,7 @@ class Connector extends EventEmitter {
1965
1926
  throw new Error('Can not concurrently wait on the same Connector object')
1966
1927
  } else {
1967
1928
  this.waitSetBusy = true
1968
- connectorBinding.api.RTI_Connector_wait_for_data.async(
1929
+ connectorBinding.RTI_Connector_wait_for_data.async(
1969
1930
  this.native,
1970
1931
  timeout,
1971
1932
  (err, res) => {
@@ -2103,17 +2064,17 @@ class Connector extends EventEmitter {
2103
2064
  // Parse numbers out of string
2104
2065
  const versionNumbers = versionString.split('.')
2105
2066
  // Now get the build IDs of the native libraries
2106
- const nativeConnectorVersion = ref.alloc('char *')
2107
- const nativeCoreCVersion = ref.alloc('char *')
2108
- _checkRetcode(connectorBinding.api.RTI_Connector_get_build_versions(
2067
+ let nativeConnectorVersion = [null]
2068
+ let nativeCoreCVersion = [null]
2069
+ _checkRetcode(connectorBinding.RTI_Connector_get_build_versions(
2109
2070
  nativeCoreCVersion,
2110
2071
  nativeConnectorVersion))
2111
2072
 
2112
2073
  // Now create the string containing all of the above information
2113
2074
  let versionStr = 'RTI Connector for JavaScript, version ' +
2114
2075
  versionNumbers[0] + '.' + versionNumbers[1] + '.' + versionNumbers[2] + '\n'
2115
- versionStr += ref.readCString(nativeCoreCVersion.deref()) + '\n'
2116
- versionStr += ref.readCString(nativeConnectorVersion.deref())
2076
+ versionStr += nativeCoreCVersion[0] + '\n'
2077
+ versionStr += nativeConnectorVersion[0]
2117
2078
  return versionStr
2118
2079
  }
2119
2080
  }