rclnodejs 0.20.1 → 0.21.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/README.md +2 -2
- package/package.json +11 -9
- package/rosidl_gen/deallocator.js +6 -1
- package/rosidl_gen/primitive_types.js +2 -2
- package/rosidl_gen/templates/message.dot +6 -4
- package/scripts/build.sh +1 -1
- package/scripts/cpplint.js +1 -1
- package/scripts/npmjs-readme.md +2 -2
- package/src/executor.hpp +0 -2
- package/src/rcl_bindings.cpp +22 -11
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ rclnodejs.init().then(() => {
|
|
|
18
18
|
|
|
19
19
|
**Node.js**
|
|
20
20
|
|
|
21
|
-
- [Node.js](https://nodejs.org/en/) version between
|
|
21
|
+
- [Node.js](https://nodejs.org/en/) version between 10.23 - 16.x.
|
|
22
22
|
|
|
23
23
|
**ROS 2 SDK**
|
|
24
24
|
|
|
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
|
|
|
45
45
|
|
|
46
46
|
| RCLNODEJS Version | Compatible ROS 2 Release |
|
|
47
47
|
| :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
48
|
-
| [0.
|
|
48
|
+
| [0.21.0 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.0) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.0/index.html)) | [Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716) / [Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211) / [Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
|
|
49
49
|
| [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
|
|
50
50
|
|
|
51
51
|
## Documentation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rclnodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "ROS2.0 JavaScript client with Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -43,35 +43,37 @@
|
|
|
43
43
|
"clang-format": "^1.4.0",
|
|
44
44
|
"commander": "^6.0.0",
|
|
45
45
|
"deep-equal": "^1.1.1",
|
|
46
|
-
"dtslint": "^4.1
|
|
46
|
+
"dtslint": "^4.2.1",
|
|
47
47
|
"eslint": "^7.5.0",
|
|
48
48
|
"eslint-config-prettier": "^6.11.0",
|
|
49
49
|
"eslint-plugin-prettier": "^3.1.4",
|
|
50
50
|
"husky": "^4.2.5",
|
|
51
|
+
"jsdoc": "^3.6.7",
|
|
51
52
|
"lint-staged": "^10.2.11",
|
|
52
53
|
"mocha": "^8.0.1",
|
|
53
54
|
"prettier": "^2.0.5",
|
|
55
|
+
"rimraf": "^3.0.2",
|
|
54
56
|
"sinon": "^9.0.2",
|
|
55
57
|
"tree-kill": "^1.2.2",
|
|
56
58
|
"typescript": "^4.0.3"
|
|
57
59
|
},
|
|
58
60
|
"dependencies": {
|
|
61
|
+
"@rclnodejs/ref-array-di": "^1.2.2",
|
|
62
|
+
"@rclnodejs/ref-napi": "^4.0.0",
|
|
63
|
+
"@rclnodejs/ref-struct-di": "^1.1.1",
|
|
64
|
+
"array.prototype.flat": "^1.2.4",
|
|
59
65
|
"bindings": "^1.5.0",
|
|
60
66
|
"compare-versions": "^3.6.0",
|
|
61
67
|
"debug": "^4.1.1",
|
|
62
68
|
"dot": "^1.1.3",
|
|
63
69
|
"fs-extra": "^10.0.0",
|
|
70
|
+
"int64-napi": "^1.0.2",
|
|
64
71
|
"is-close": "^1.3.3",
|
|
65
72
|
"mkdirp": "^1.0.4",
|
|
66
73
|
"mz": "^2.7.0",
|
|
67
74
|
"nan": "^2.14.2",
|
|
68
|
-
"ref-napi": "^3.0.0",
|
|
69
|
-
"ref-array-di": "^1.2.2",
|
|
70
|
-
"ref-struct-di": "^1.1.1",
|
|
71
|
-
"walk": "^2.3.14",
|
|
72
75
|
"uuid": "^8.2.0",
|
|
73
|
-
"
|
|
74
|
-
"array.prototype.flat": "^1.2.4"
|
|
76
|
+
"walk": "^2.3.14"
|
|
75
77
|
},
|
|
76
78
|
"husky": {
|
|
77
79
|
"hooks": {
|
|
@@ -87,6 +89,6 @@
|
|
|
87
89
|
]
|
|
88
90
|
},
|
|
89
91
|
"engines": {
|
|
90
|
-
"node": ">= 10.23.1 <
|
|
92
|
+
"node": ">= 10.23.1 <18.0.0"
|
|
91
93
|
}
|
|
92
94
|
}
|
|
@@ -24,7 +24,12 @@ let deallocator = {
|
|
|
24
24
|
);
|
|
25
25
|
},
|
|
26
26
|
freeStructMember(refObj, type, name) {
|
|
27
|
-
|
|
27
|
+
if (refObj.ref().length !== 0) {
|
|
28
|
+
rclnodejs.freeMemeoryAtOffset(
|
|
29
|
+
refObj.ref().hexAddress(),
|
|
30
|
+
type.fields[name].offset
|
|
31
|
+
);
|
|
32
|
+
}
|
|
28
33
|
},
|
|
29
34
|
};
|
|
30
35
|
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const ref = require('ref-napi');
|
|
18
|
-
const StructType = require('ref-struct-di')(ref);
|
|
17
|
+
const ref = require('@rclnodejs/ref-napi');
|
|
18
|
+
const StructType = require('@rclnodejs/ref-struct-di')(ref);
|
|
19
19
|
const rclnodejs = require('bindings')('rclnodejs');
|
|
20
20
|
|
|
21
21
|
/* eslint-disable camelcase */
|
|
@@ -219,9 +219,9 @@ function extractMemberNames(fields) {
|
|
|
219
219
|
{{? usePlainTypedArray}}
|
|
220
220
|
const rclnodejs = require('bindings')('rclnodejs');
|
|
221
221
|
{{?}}
|
|
222
|
-
const ref = require('ref-napi');
|
|
223
|
-
const StructType = require('ref-struct-di')(ref);
|
|
224
|
-
const ArrayType = require('ref-array-di')(ref);
|
|
222
|
+
const ref = require('@rclnodejs/ref-napi');
|
|
223
|
+
const StructType = require('@rclnodejs/ref-struct-di')(ref);
|
|
224
|
+
const ArrayType = require('@rclnodejs/ref-array-di')(ref);
|
|
225
225
|
const primitiveTypes = require('../../rosidl_gen/primitive_types.js');
|
|
226
226
|
const deallocator = require('../../rosidl_gen/deallocator.js');
|
|
227
227
|
const translator = require('../../rosidl_gen/message_translator.js');
|
|
@@ -750,7 +750,9 @@ class {{=arrayWrapper}} {
|
|
|
750
750
|
{{? usePlainTypedArray}}
|
|
751
751
|
const byteLen = refObject.size * ref.types.{{=currentTypedArrayElementType}}.size;
|
|
752
752
|
// An ArrayBuffer object that doesn't hold the ownership of the address
|
|
753
|
-
const arrayBuffer =
|
|
753
|
+
const arrayBuffer = refObject.data.length !== 0 ?
|
|
754
|
+
rclnodejs.createArrayBufferFromAddress(refObject.data.hexAddress(), byteLen) :
|
|
755
|
+
Buffer.alloc(0);
|
|
754
756
|
this._wrappers = new {{=currentTypedArray}}(arrayBuffer);
|
|
755
757
|
{{?? true}}
|
|
756
758
|
let refObjectArray = this._refObject.data;
|
package/scripts/build.sh
CHANGED
package/scripts/cpplint.js
CHANGED
|
@@ -20,7 +20,7 @@ const cmd = 'wget -nc ';
|
|
|
20
20
|
const cpplintUrl =
|
|
21
21
|
'https://raw.githubusercontent.com/google/styleguide' +
|
|
22
22
|
'/gh-pages/cpplint/cpplint.py';
|
|
23
|
-
const root = `${__dirname}/../src
|
|
23
|
+
const root = `${__dirname}/../src`;
|
|
24
24
|
const args = `--extensions=cpp,h,hpp,cc ${root}/*`;
|
|
25
25
|
|
|
26
26
|
console.log('Downloading the cpplint...');
|
package/scripts/npmjs-readme.md
CHANGED
|
@@ -18,7 +18,7 @@ rclnodejs.init().then(() => {
|
|
|
18
18
|
|
|
19
19
|
**Node.js**
|
|
20
20
|
|
|
21
|
-
- [Node.js](https://nodejs.org/en/) version between
|
|
21
|
+
- [Node.js](https://nodejs.org/en/) version between 10.23 - 16.x.
|
|
22
22
|
|
|
23
23
|
**ROS 2 SDK**
|
|
24
24
|
|
|
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
|
|
|
45
45
|
|
|
46
46
|
| RCLNODEJS Version | Compatible ROS 2 Release |
|
|
47
47
|
| :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
48
|
-
| [0.
|
|
48
|
+
| [0.21.0 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.0) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.0/index.html)) | [Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716) / [Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211) / [Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
|
|
49
49
|
| [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
|
|
50
50
|
|
|
51
51
|
## Documentation
|
package/src/executor.hpp
CHANGED
package/src/rcl_bindings.cpp
CHANGED
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
#include <memory>
|
|
40
40
|
#include <string>
|
|
41
41
|
#include <vector>
|
|
42
|
+
#if NODE_MAJOR_VERSION > 12
|
|
43
|
+
#include <utility>
|
|
44
|
+
#endif
|
|
42
45
|
|
|
43
46
|
#include "handle_manager.hpp"
|
|
44
47
|
#include "macros.hpp"
|
|
@@ -1292,18 +1295,14 @@ inline char* GetBufAddr(v8::Local<v8::Value> buf) {
|
|
|
1292
1295
|
}
|
|
1293
1296
|
|
|
1294
1297
|
NAN_METHOD(FreeMemeoryAtOffset) {
|
|
1295
|
-
v8::Local<v8::
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1298
|
+
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
1299
|
+
std::string addr_str(
|
|
1300
|
+
*Nan::Utf8String(info[0]->ToString(currentContent).ToLocalChecked()));
|
|
1301
|
+
int64_t result = std::stoull(addr_str, 0, 16);
|
|
1302
|
+
char* addr = reinterpret_cast<char*>(result);
|
|
1300
1303
|
int64_t offset =
|
|
1301
1304
|
info[1]->IsNumber() ? Nan::To<int64_t>(info[1]).FromJust() : 0;
|
|
1302
|
-
auto ptr =
|
|
1303
|
-
|
|
1304
|
-
if (ptr == nullptr) {
|
|
1305
|
-
return Nan::ThrowError("Cannot read from NULL pointer");
|
|
1306
|
-
}
|
|
1305
|
+
auto ptr = addr + offset;
|
|
1307
1306
|
|
|
1308
1307
|
char* val = *reinterpret_cast<char**>(ptr);
|
|
1309
1308
|
free(val);
|
|
@@ -1311,15 +1310,27 @@ NAN_METHOD(FreeMemeoryAtOffset) {
|
|
|
1311
1310
|
}
|
|
1312
1311
|
|
|
1313
1312
|
NAN_METHOD(CreateArrayBufferFromAddress) {
|
|
1314
|
-
|
|
1313
|
+
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
1314
|
+
std::string addr_str(
|
|
1315
|
+
*Nan::Utf8String(info[0]->ToString(currentContent).ToLocalChecked()));
|
|
1316
|
+
int64_t result = std::stoull(addr_str, 0, 16);
|
|
1317
|
+
char* addr = reinterpret_cast<char*>(result);
|
|
1315
1318
|
int32_t length = Nan::To<int32_t>(info[1]).FromJust();
|
|
1316
1319
|
|
|
1317
1320
|
// We will create an ArrayBuffer with mode of
|
|
1318
1321
|
// ArrayBufferCreationMode::kInternalized and copy data starting from |addr|,
|
|
1319
1322
|
// thus the memory block will be collected by the garbage collector.
|
|
1323
|
+
#if NODE_MAJOR_VERSION <= 12
|
|
1320
1324
|
v8::Local<v8::ArrayBuffer> array_buffer =
|
|
1321
1325
|
v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), addr, length,
|
|
1322
1326
|
v8::ArrayBufferCreationMode::kInternalized);
|
|
1327
|
+
#else
|
|
1328
|
+
std::unique_ptr<v8::BackingStore> backing =
|
|
1329
|
+
v8::ArrayBuffer::NewBackingStore(v8::Isolate::GetCurrent(), length);
|
|
1330
|
+
memcpy(backing->Data(), addr, length);
|
|
1331
|
+
auto array_buffer =
|
|
1332
|
+
v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), std::move(backing));
|
|
1333
|
+
#endif
|
|
1323
1334
|
|
|
1324
1335
|
info.GetReturnValue().Set(array_buffer);
|
|
1325
1336
|
}
|