koffi 0.9.30 → 0.9.33
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/package.json +1 -1
- package/src/call.hh +2 -1
- package/src/call_arm32.cc +27 -15
- package/src/call_arm64.cc +4 -9
- package/src/call_x64_sysv.cc +4 -9
- package/src/call_x64_sysv_fwd.S +13 -3
- package/src/call_x64_win.cc +4 -9
- package/src/call_x86.cc +18 -16
- package/src/ffi.cc +93 -46
- package/src/ffi.hh +11 -6
- package/src/util.cc +35 -1
- package/src/util.hh +2 -0
- package/test/tests/misc.c +62 -1
- package/test/tests/misc.js +49 -1
- package/vendor/node-addon-api/CHANGELOG.md +57 -0
- package/vendor/node-addon-api/README.md +3 -3
- package/vendor/node-addon-api/doc/array_buffer.md +2 -2
- package/vendor/node-addon-api/doc/buffer.md +2 -2
- package/vendor/node-addon-api/doc/class_property_descriptor.md +13 -5
- package/vendor/node-addon-api/doc/env.md +5 -5
- package/vendor/node-addon-api/doc/object.md +12 -33
- package/vendor/node-addon-api/doc/object_reference.md +1 -1
- package/vendor/node-addon-api/doc/object_wrap.md +27 -0
- package/vendor/node-addon-api/doc/reference.md +2 -2
- package/vendor/node-addon-api/doc/threadsafe_function.md +3 -3
- package/vendor/node-addon-api/doc/typed_threadsafe_function.md +2 -2
- package/vendor/node-addon-api/napi-inl.h +111 -61
- package/vendor/node-addon-api/napi.h +79 -59
- package/vendor/node-addon-api/package.json +22 -6
- package/vendor/node-addon-api/test/async_context.cc +15 -0
- package/vendor/node-addon-api/test/async_context.js +69 -33
- package/vendor/node-addon-api/test/binding.cc +2 -0
- package/vendor/node-addon-api/test/binding.gyp +7 -0
- package/vendor/node-addon-api/test/common/index.js +23 -22
- package/vendor/node-addon-api/test/common/test_helper.h +10 -0
- package/vendor/node-addon-api/test/error_terminating_environment.js +1 -0
- package/vendor/node-addon-api/test/function.cc +29 -0
- package/vendor/node-addon-api/test/function.js +35 -23
- package/vendor/node-addon-api/test/index.js +40 -17
- package/vendor/node-addon-api/test/object/object.cc +2 -0
- package/vendor/node-addon-api/test/object/set_property.cc +8 -0
- package/vendor/node-addon-api/test/object/set_property.js +6 -5
- package/vendor/node-addon-api/test/object/subscript_operator.cc +19 -3
- package/vendor/node-addon-api/test/objectwrap_function.cc +45 -0
- package/vendor/node-addon-api/test/objectwrap_function.js +22 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +1 -1
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +2 -2
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.cc +1 -1
- package/vendor/node-addon-api/tools/clang-format.js +4 -1
- package/vendor/node-addon-api/unit-test/README.md +28 -0
- package/vendor/node-addon-api/unit-test/binding-file-template.js +39 -0
- package/vendor/node-addon-api/unit-test/binding.gyp +72 -0
- package/vendor/node-addon-api/unit-test/exceptions.js +32 -0
- package/vendor/node-addon-api/unit-test/generate-binding-cc.js +61 -0
- package/vendor/node-addon-api/unit-test/injectTestParams.js +101 -0
- package/vendor/node-addon-api/unit-test/listOfTestModules.js +88 -0
- package/vendor/node-addon-api/unit-test/matchModules.js +65 -0
- package/vendor/node-addon-api/unit-test/setup.js +13 -0
- package/vendor/node-addon-api/unit-test/spawnTask.js +26 -0
- package/vendor/node-addon-api/unit-test/test.js +30 -0
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
|
|
19
19
|
namespace Napi {
|
|
20
20
|
|
|
21
|
+
#ifdef NAPI_CPP_CUSTOM_NAMESPACE
|
|
22
|
+
namespace NAPI_CPP_CUSTOM_NAMESPACE {
|
|
23
|
+
#endif
|
|
24
|
+
|
|
21
25
|
// Helpers to handle functions exposed from C++.
|
|
22
26
|
namespace details {
|
|
23
27
|
|
|
@@ -483,7 +487,7 @@ inline bool Env::IsExceptionPending() const {
|
|
|
483
487
|
return result;
|
|
484
488
|
}
|
|
485
489
|
|
|
486
|
-
inline Error Env::GetAndClearPendingException() {
|
|
490
|
+
inline Error Env::GetAndClearPendingException() const {
|
|
487
491
|
napi_value value;
|
|
488
492
|
napi_status status = napi_get_and_clear_last_exception(_env, &value);
|
|
489
493
|
if (status != napi_ok) {
|
|
@@ -493,16 +497,16 @@ inline Error Env::GetAndClearPendingException() {
|
|
|
493
497
|
return Error(_env, value);
|
|
494
498
|
}
|
|
495
499
|
|
|
496
|
-
inline MaybeOrValue<Value> Env::RunScript(const char* utf8script) {
|
|
500
|
+
inline MaybeOrValue<Value> Env::RunScript(const char* utf8script) const {
|
|
497
501
|
String script = String::New(_env, utf8script);
|
|
498
502
|
return RunScript(script);
|
|
499
503
|
}
|
|
500
504
|
|
|
501
|
-
inline MaybeOrValue<Value> Env::RunScript(const std::string& utf8script) {
|
|
505
|
+
inline MaybeOrValue<Value> Env::RunScript(const std::string& utf8script) const {
|
|
502
506
|
return RunScript(utf8script.c_str());
|
|
503
507
|
}
|
|
504
508
|
|
|
505
|
-
inline MaybeOrValue<Value> Env::RunScript(String script) {
|
|
509
|
+
inline MaybeOrValue<Value> Env::RunScript(String script) const {
|
|
506
510
|
napi_value result;
|
|
507
511
|
napi_status status = napi_run_script(_env, script, &result);
|
|
508
512
|
NAPI_RETURN_OR_THROW_IF_FAILED(
|
|
@@ -531,7 +535,7 @@ void Env::CleanupHook<Hook, Arg>::WrapperWithArg(void* data) NAPI_NOEXCEPT {
|
|
|
531
535
|
|
|
532
536
|
#if NAPI_VERSION > 5
|
|
533
537
|
template <typename T, Env::Finalizer<T> fini>
|
|
534
|
-
inline void Env::SetInstanceData(T* data) {
|
|
538
|
+
inline void Env::SetInstanceData(T* data) const {
|
|
535
539
|
napi_status status =
|
|
536
540
|
napi_set_instance_data(_env, data, [](napi_env env, void* data, void*) {
|
|
537
541
|
fini(env, static_cast<T*>(data));
|
|
@@ -542,7 +546,7 @@ inline void Env::SetInstanceData(T* data) {
|
|
|
542
546
|
template <typename DataType,
|
|
543
547
|
typename HintType,
|
|
544
548
|
Napi::Env::FinalizerWithHint<DataType, HintType> fini>
|
|
545
|
-
inline void Env::SetInstanceData(DataType* data, HintType* hint) {
|
|
549
|
+
inline void Env::SetInstanceData(DataType* data, HintType* hint) const {
|
|
546
550
|
napi_status status =
|
|
547
551
|
napi_set_instance_data(_env, data,
|
|
548
552
|
[](napi_env env, void* data, void* hint) {
|
|
@@ -552,7 +556,7 @@ inline void Env::SetInstanceData(DataType* data, HintType* hint) {
|
|
|
552
556
|
}
|
|
553
557
|
|
|
554
558
|
template <typename T>
|
|
555
|
-
inline T* Env::GetInstanceData() {
|
|
559
|
+
inline T* Env::GetInstanceData() const {
|
|
556
560
|
void* data = nullptr;
|
|
557
561
|
|
|
558
562
|
napi_status status = napi_get_instance_data(_env, &data);
|
|
@@ -1294,22 +1298,20 @@ inline Object::Object() : Value() {
|
|
|
1294
1298
|
inline Object::Object(napi_env env, napi_value value) : Value(env, value) {
|
|
1295
1299
|
}
|
|
1296
1300
|
|
|
1297
|
-
inline Object::PropertyLValue<std::string> Object::operator
|
|
1301
|
+
inline Object::PropertyLValue<std::string> Object::operator[](
|
|
1302
|
+
const char* utf8name) {
|
|
1298
1303
|
return PropertyLValue<std::string>(*this, utf8name);
|
|
1299
1304
|
}
|
|
1300
1305
|
|
|
1301
|
-
inline Object::PropertyLValue<std::string> Object::operator
|
|
1306
|
+
inline Object::PropertyLValue<std::string> Object::operator[](
|
|
1307
|
+
const std::string& utf8name) {
|
|
1302
1308
|
return PropertyLValue<std::string>(*this, utf8name);
|
|
1303
1309
|
}
|
|
1304
1310
|
|
|
1305
|
-
inline Object::PropertyLValue<uint32_t> Object::operator
|
|
1311
|
+
inline Object::PropertyLValue<uint32_t> Object::operator[](uint32_t index) {
|
|
1306
1312
|
return PropertyLValue<uint32_t>(*this, index);
|
|
1307
1313
|
}
|
|
1308
1314
|
|
|
1309
|
-
inline Object::PropertyLValue<Value> Object::operator[](Value index) {
|
|
1310
|
-
return PropertyLValue<Value>(*this, index);
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
1315
|
inline Object::PropertyLValue<Value> Object::operator[](Value index) const {
|
|
1314
1316
|
return PropertyLValue<Value>(*this, index);
|
|
1315
1317
|
}
|
|
@@ -1396,14 +1398,15 @@ inline MaybeOrValue<Value> Object::Get(const std::string& utf8name) const {
|
|
|
1396
1398
|
}
|
|
1397
1399
|
|
|
1398
1400
|
template <typename ValueType>
|
|
1399
|
-
inline MaybeOrValue<bool> Object::Set(napi_value key,
|
|
1401
|
+
inline MaybeOrValue<bool> Object::Set(napi_value key,
|
|
1402
|
+
const ValueType& value) const {
|
|
1400
1403
|
napi_status status =
|
|
1401
1404
|
napi_set_property(_env, _value, key, Value::From(_env, value));
|
|
1402
1405
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1403
1406
|
}
|
|
1404
1407
|
|
|
1405
1408
|
template <typename ValueType>
|
|
1406
|
-
inline MaybeOrValue<bool> Object::Set(Value key, const ValueType& value) {
|
|
1409
|
+
inline MaybeOrValue<bool> Object::Set(Value key, const ValueType& value) const {
|
|
1407
1410
|
napi_status status =
|
|
1408
1411
|
napi_set_property(_env, _value, key, Value::From(_env, value));
|
|
1409
1412
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
@@ -1411,7 +1414,7 @@ inline MaybeOrValue<bool> Object::Set(Value key, const ValueType& value) {
|
|
|
1411
1414
|
|
|
1412
1415
|
template <typename ValueType>
|
|
1413
1416
|
inline MaybeOrValue<bool> Object::Set(const char* utf8name,
|
|
1414
|
-
const ValueType& value) {
|
|
1417
|
+
const ValueType& value) const {
|
|
1415
1418
|
napi_status status =
|
|
1416
1419
|
napi_set_named_property(_env, _value, utf8name, Value::From(_env, value));
|
|
1417
1420
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
@@ -1419,27 +1422,27 @@ inline MaybeOrValue<bool> Object::Set(const char* utf8name,
|
|
|
1419
1422
|
|
|
1420
1423
|
template <typename ValueType>
|
|
1421
1424
|
inline MaybeOrValue<bool> Object::Set(const std::string& utf8name,
|
|
1422
|
-
const ValueType& value) {
|
|
1425
|
+
const ValueType& value) const {
|
|
1423
1426
|
return Set(utf8name.c_str(), value);
|
|
1424
1427
|
}
|
|
1425
1428
|
|
|
1426
|
-
inline MaybeOrValue<bool> Object::Delete(napi_value key) {
|
|
1429
|
+
inline MaybeOrValue<bool> Object::Delete(napi_value key) const {
|
|
1427
1430
|
bool result;
|
|
1428
1431
|
napi_status status = napi_delete_property(_env, _value, key, &result);
|
|
1429
1432
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, result, bool);
|
|
1430
1433
|
}
|
|
1431
1434
|
|
|
1432
|
-
inline MaybeOrValue<bool> Object::Delete(Value key) {
|
|
1435
|
+
inline MaybeOrValue<bool> Object::Delete(Value key) const {
|
|
1433
1436
|
bool result;
|
|
1434
1437
|
napi_status status = napi_delete_property(_env, _value, key, &result);
|
|
1435
1438
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, result, bool);
|
|
1436
1439
|
}
|
|
1437
1440
|
|
|
1438
|
-
inline MaybeOrValue<bool> Object::Delete(const char* utf8name) {
|
|
1441
|
+
inline MaybeOrValue<bool> Object::Delete(const char* utf8name) const {
|
|
1439
1442
|
return Delete(String::New(_env, utf8name));
|
|
1440
1443
|
}
|
|
1441
1444
|
|
|
1442
|
-
inline MaybeOrValue<bool> Object::Delete(const std::string& utf8name) {
|
|
1445
|
+
inline MaybeOrValue<bool> Object::Delete(const std::string& utf8name) const {
|
|
1443
1446
|
return Delete(String::New(_env, utf8name));
|
|
1444
1447
|
}
|
|
1445
1448
|
|
|
@@ -1456,13 +1459,14 @@ inline MaybeOrValue<Value> Object::Get(uint32_t index) const {
|
|
|
1456
1459
|
}
|
|
1457
1460
|
|
|
1458
1461
|
template <typename ValueType>
|
|
1459
|
-
inline MaybeOrValue<bool> Object::Set(uint32_t index,
|
|
1462
|
+
inline MaybeOrValue<bool> Object::Set(uint32_t index,
|
|
1463
|
+
const ValueType& value) const {
|
|
1460
1464
|
napi_status status =
|
|
1461
1465
|
napi_set_element(_env, _value, index, Value::From(_env, value));
|
|
1462
1466
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1463
1467
|
}
|
|
1464
1468
|
|
|
1465
|
-
inline MaybeOrValue<bool> Object::Delete(uint32_t index) {
|
|
1469
|
+
inline MaybeOrValue<bool> Object::Delete(uint32_t index) const {
|
|
1466
1470
|
bool result;
|
|
1467
1471
|
napi_status status = napi_delete_element(_env, _value, index, &result);
|
|
1468
1472
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, result, bool);
|
|
@@ -1475,21 +1479,21 @@ inline MaybeOrValue<Array> Object::GetPropertyNames() const {
|
|
|
1475
1479
|
}
|
|
1476
1480
|
|
|
1477
1481
|
inline MaybeOrValue<bool> Object::DefineProperty(
|
|
1478
|
-
const PropertyDescriptor& property) {
|
|
1482
|
+
const PropertyDescriptor& property) const {
|
|
1479
1483
|
napi_status status = napi_define_properties(_env, _value, 1,
|
|
1480
1484
|
reinterpret_cast<const napi_property_descriptor*>(&property));
|
|
1481
1485
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1482
1486
|
}
|
|
1483
1487
|
|
|
1484
1488
|
inline MaybeOrValue<bool> Object::DefineProperties(
|
|
1485
|
-
const std::initializer_list<PropertyDescriptor>& properties) {
|
|
1489
|
+
const std::initializer_list<PropertyDescriptor>& properties) const {
|
|
1486
1490
|
napi_status status = napi_define_properties(_env, _value, properties.size(),
|
|
1487
1491
|
reinterpret_cast<const napi_property_descriptor*>(properties.begin()));
|
|
1488
1492
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1489
1493
|
}
|
|
1490
1494
|
|
|
1491
1495
|
inline MaybeOrValue<bool> Object::DefineProperties(
|
|
1492
|
-
const std::vector<PropertyDescriptor>& properties) {
|
|
1496
|
+
const std::vector<PropertyDescriptor>& properties) const {
|
|
1493
1497
|
napi_status status = napi_define_properties(_env, _value, properties.size(),
|
|
1494
1498
|
reinterpret_cast<const napi_property_descriptor*>(properties.data()));
|
|
1495
1499
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
@@ -1503,7 +1507,7 @@ inline MaybeOrValue<bool> Object::InstanceOf(
|
|
|
1503
1507
|
}
|
|
1504
1508
|
|
|
1505
1509
|
template <typename Finalizer, typename T>
|
|
1506
|
-
inline void Object::AddFinalizer(Finalizer finalizeCallback, T* data) {
|
|
1510
|
+
inline void Object::AddFinalizer(Finalizer finalizeCallback, T* data) const {
|
|
1507
1511
|
details::FinalizeData<T, Finalizer>* finalizeData =
|
|
1508
1512
|
new details::FinalizeData<T, Finalizer>(
|
|
1509
1513
|
{std::move(finalizeCallback), nullptr});
|
|
@@ -1522,7 +1526,7 @@ inline void Object::AddFinalizer(Finalizer finalizeCallback, T* data) {
|
|
|
1522
1526
|
template <typename Finalizer, typename T, typename Hint>
|
|
1523
1527
|
inline void Object::AddFinalizer(Finalizer finalizeCallback,
|
|
1524
1528
|
T* data,
|
|
1525
|
-
Hint* finalizeHint) {
|
|
1529
|
+
Hint* finalizeHint) const {
|
|
1526
1530
|
details::FinalizeData<T, Finalizer, Hint>* finalizeData =
|
|
1527
1531
|
new details::FinalizeData<T, Finalizer, Hint>(
|
|
1528
1532
|
{std::move(finalizeCallback), finalizeHint});
|
|
@@ -1616,12 +1620,12 @@ Object::iterator::operator*() {
|
|
|
1616
1620
|
#endif // NAPI_CPP_EXCEPTIONS
|
|
1617
1621
|
|
|
1618
1622
|
#if NAPI_VERSION >= 8
|
|
1619
|
-
inline MaybeOrValue<bool> Object::Freeze() {
|
|
1623
|
+
inline MaybeOrValue<bool> Object::Freeze() const {
|
|
1620
1624
|
napi_status status = napi_object_freeze(_env, _value);
|
|
1621
1625
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1622
1626
|
}
|
|
1623
1627
|
|
|
1624
|
-
inline MaybeOrValue<bool> Object::Seal() {
|
|
1628
|
+
inline MaybeOrValue<bool> Object::Seal() const {
|
|
1625
1629
|
napi_status status = napi_object_seal(_env, _value);
|
|
1626
1630
|
NAPI_RETURN_OR_THROW_IF_FAILED(_env, status, status == napi_ok, bool);
|
|
1627
1631
|
}
|
|
@@ -2287,6 +2291,11 @@ inline MaybeOrValue<Value> Function::Call(
|
|
|
2287
2291
|
return Call(Env().Undefined(), args);
|
|
2288
2292
|
}
|
|
2289
2293
|
|
|
2294
|
+
inline MaybeOrValue<Value> Function::Call(
|
|
2295
|
+
const std::vector<Value>& args) const {
|
|
2296
|
+
return Call(Env().Undefined(), args);
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2290
2299
|
inline MaybeOrValue<Value> Function::Call(size_t argc,
|
|
2291
2300
|
const napi_value* args) const {
|
|
2292
2301
|
return Call(Env().Undefined(), argc, args);
|
|
@@ -2302,6 +2311,27 @@ inline MaybeOrValue<Value> Function::Call(
|
|
|
2302
2311
|
return Call(recv, args.size(), args.data());
|
|
2303
2312
|
}
|
|
2304
2313
|
|
|
2314
|
+
inline MaybeOrValue<Value> Function::Call(
|
|
2315
|
+
napi_value recv, const std::vector<Value>& args) const {
|
|
2316
|
+
const size_t argc = args.size();
|
|
2317
|
+
const size_t stackArgsCount = 6;
|
|
2318
|
+
napi_value stackArgs[stackArgsCount];
|
|
2319
|
+
std::vector<napi_value> heapArgs;
|
|
2320
|
+
napi_value* argv;
|
|
2321
|
+
if (argc <= stackArgsCount) {
|
|
2322
|
+
argv = stackArgs;
|
|
2323
|
+
} else {
|
|
2324
|
+
heapArgs.resize(argc);
|
|
2325
|
+
argv = heapArgs.data();
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
for (size_t index = 0; index < argc; index++) {
|
|
2329
|
+
argv[index] = static_cast<napi_value>(args[index]);
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
return Call(recv, argc, argv);
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2305
2335
|
inline MaybeOrValue<Value> Function::Call(napi_value recv,
|
|
2306
2336
|
size_t argc,
|
|
2307
2337
|
const napi_value* args) const {
|
|
@@ -2607,8 +2637,8 @@ inline Error::Error(napi_env env, napi_value value) : ObjectReference(env, nullp
|
|
|
2607
2637
|
|
|
2608
2638
|
// property flag that we attach to show the error object is wrapped
|
|
2609
2639
|
napi_property_descriptor wrapObjFlag = {
|
|
2610
|
-
ERROR_WRAP_VALUE, // Unique GUID identifier since Symbol isn't a
|
|
2611
|
-
|
|
2640
|
+
ERROR_WRAP_VALUE(), // Unique GUID identifier since Symbol isn't a
|
|
2641
|
+
// viable option
|
|
2612
2642
|
nullptr,
|
|
2613
2643
|
nullptr,
|
|
2614
2644
|
nullptr,
|
|
@@ -2648,15 +2678,17 @@ inline Object Error::Value() const {
|
|
|
2648
2678
|
// We are checking if the object is wrapped
|
|
2649
2679
|
bool isWrappedObject = false;
|
|
2650
2680
|
|
|
2651
|
-
status = napi_has_property(
|
|
2652
|
-
|
|
2681
|
+
status = napi_has_property(_env,
|
|
2682
|
+
refValue,
|
|
2683
|
+
String::From(_env, ERROR_WRAP_VALUE()),
|
|
2684
|
+
&isWrappedObject);
|
|
2653
2685
|
|
|
2654
2686
|
// Don't care about status
|
|
2655
2687
|
if (isWrappedObject) {
|
|
2656
2688
|
napi_value unwrappedValue;
|
|
2657
2689
|
status = napi_get_property(_env,
|
|
2658
2690
|
refValue,
|
|
2659
|
-
String::From(_env, ERROR_WRAP_VALUE),
|
|
2691
|
+
String::From(_env, ERROR_WRAP_VALUE()),
|
|
2660
2692
|
&unwrappedValue);
|
|
2661
2693
|
NAPI_THROW_IF_FAILED(_env, status, Object());
|
|
2662
2694
|
|
|
@@ -2772,6 +2804,10 @@ inline const char* Error::what() const NAPI_NOEXCEPT {
|
|
|
2772
2804
|
|
|
2773
2805
|
#endif // NAPI_CPP_EXCEPTIONS
|
|
2774
2806
|
|
|
2807
|
+
inline const char* Error::ERROR_WRAP_VALUE() NAPI_NOEXCEPT {
|
|
2808
|
+
return "4bda9e7e-4913-4dbc-95de-891cbf66598e-errorVal";
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2775
2811
|
template <typename TError>
|
|
2776
2812
|
inline TError Error::New(napi_env env,
|
|
2777
2813
|
const char* message,
|
|
@@ -2930,7 +2966,7 @@ inline T Reference<T>::Value() const {
|
|
|
2930
2966
|
}
|
|
2931
2967
|
|
|
2932
2968
|
template <typename T>
|
|
2933
|
-
inline uint32_t Reference<T>::Ref() {
|
|
2969
|
+
inline uint32_t Reference<T>::Ref() const {
|
|
2934
2970
|
uint32_t result;
|
|
2935
2971
|
napi_status status = napi_reference_ref(_env, _ref, &result);
|
|
2936
2972
|
NAPI_THROW_IF_FAILED(_env, status, 0);
|
|
@@ -2938,7 +2974,7 @@ inline uint32_t Reference<T>::Ref() {
|
|
|
2938
2974
|
}
|
|
2939
2975
|
|
|
2940
2976
|
template <typename T>
|
|
2941
|
-
inline uint32_t Reference<T>::Unref() {
|
|
2977
|
+
inline uint32_t Reference<T>::Unref() const {
|
|
2942
2978
|
uint32_t result;
|
|
2943
2979
|
napi_status status = napi_reference_unref(_env, _ref, &result);
|
|
2944
2980
|
NAPI_THROW_IF_FAILED(_env, status, 0);
|
|
@@ -3064,61 +3100,61 @@ inline MaybeOrValue<Napi::Value> ObjectReference::Get(
|
|
|
3064
3100
|
}
|
|
3065
3101
|
|
|
3066
3102
|
inline MaybeOrValue<bool> ObjectReference::Set(const char* utf8name,
|
|
3067
|
-
napi_value value) {
|
|
3103
|
+
napi_value value) const {
|
|
3068
3104
|
HandleScope scope(_env);
|
|
3069
3105
|
return Value().Set(utf8name, value);
|
|
3070
3106
|
}
|
|
3071
3107
|
|
|
3072
3108
|
inline MaybeOrValue<bool> ObjectReference::Set(const char* utf8name,
|
|
3073
|
-
Napi::Value value) {
|
|
3109
|
+
Napi::Value value) const {
|
|
3074
3110
|
HandleScope scope(_env);
|
|
3075
3111
|
return Value().Set(utf8name, value);
|
|
3076
3112
|
}
|
|
3077
3113
|
|
|
3078
3114
|
inline MaybeOrValue<bool> ObjectReference::Set(const char* utf8name,
|
|
3079
|
-
const char* utf8value) {
|
|
3115
|
+
const char* utf8value) const {
|
|
3080
3116
|
HandleScope scope(_env);
|
|
3081
3117
|
return Value().Set(utf8name, utf8value);
|
|
3082
3118
|
}
|
|
3083
3119
|
|
|
3084
3120
|
inline MaybeOrValue<bool> ObjectReference::Set(const char* utf8name,
|
|
3085
|
-
bool boolValue) {
|
|
3121
|
+
bool boolValue) const {
|
|
3086
3122
|
HandleScope scope(_env);
|
|
3087
3123
|
return Value().Set(utf8name, boolValue);
|
|
3088
3124
|
}
|
|
3089
3125
|
|
|
3090
3126
|
inline MaybeOrValue<bool> ObjectReference::Set(const char* utf8name,
|
|
3091
|
-
double numberValue) {
|
|
3127
|
+
double numberValue) const {
|
|
3092
3128
|
HandleScope scope(_env);
|
|
3093
3129
|
return Value().Set(utf8name, numberValue);
|
|
3094
3130
|
}
|
|
3095
3131
|
|
|
3096
3132
|
inline MaybeOrValue<bool> ObjectReference::Set(const std::string& utf8name,
|
|
3097
|
-
napi_value value) {
|
|
3133
|
+
napi_value value) const {
|
|
3098
3134
|
HandleScope scope(_env);
|
|
3099
3135
|
return Value().Set(utf8name, value);
|
|
3100
3136
|
}
|
|
3101
3137
|
|
|
3102
3138
|
inline MaybeOrValue<bool> ObjectReference::Set(const std::string& utf8name,
|
|
3103
|
-
Napi::Value value) {
|
|
3139
|
+
Napi::Value value) const {
|
|
3104
3140
|
HandleScope scope(_env);
|
|
3105
3141
|
return Value().Set(utf8name, value);
|
|
3106
3142
|
}
|
|
3107
3143
|
|
|
3108
3144
|
inline MaybeOrValue<bool> ObjectReference::Set(const std::string& utf8name,
|
|
3109
|
-
std::string& utf8value) {
|
|
3145
|
+
std::string& utf8value) const {
|
|
3110
3146
|
HandleScope scope(_env);
|
|
3111
3147
|
return Value().Set(utf8name, utf8value);
|
|
3112
3148
|
}
|
|
3113
3149
|
|
|
3114
3150
|
inline MaybeOrValue<bool> ObjectReference::Set(const std::string& utf8name,
|
|
3115
|
-
bool boolValue) {
|
|
3151
|
+
bool boolValue) const {
|
|
3116
3152
|
HandleScope scope(_env);
|
|
3117
3153
|
return Value().Set(utf8name, boolValue);
|
|
3118
3154
|
}
|
|
3119
3155
|
|
|
3120
3156
|
inline MaybeOrValue<bool> ObjectReference::Set(const std::string& utf8name,
|
|
3121
|
-
double numberValue) {
|
|
3157
|
+
double numberValue) const {
|
|
3122
3158
|
HandleScope scope(_env);
|
|
3123
3159
|
return Value().Set(utf8name, numberValue);
|
|
3124
3160
|
}
|
|
@@ -3140,36 +3176,37 @@ inline MaybeOrValue<Napi::Value> ObjectReference::Get(uint32_t index) const {
|
|
|
3140
3176
|
}
|
|
3141
3177
|
|
|
3142
3178
|
inline MaybeOrValue<bool> ObjectReference::Set(uint32_t index,
|
|
3143
|
-
napi_value value) {
|
|
3179
|
+
napi_value value) const {
|
|
3144
3180
|
HandleScope scope(_env);
|
|
3145
3181
|
return Value().Set(index, value);
|
|
3146
3182
|
}
|
|
3147
3183
|
|
|
3148
3184
|
inline MaybeOrValue<bool> ObjectReference::Set(uint32_t index,
|
|
3149
|
-
Napi::Value value) {
|
|
3185
|
+
Napi::Value value) const {
|
|
3150
3186
|
HandleScope scope(_env);
|
|
3151
3187
|
return Value().Set(index, value);
|
|
3152
3188
|
}
|
|
3153
3189
|
|
|
3154
3190
|
inline MaybeOrValue<bool> ObjectReference::Set(uint32_t index,
|
|
3155
|
-
const char* utf8value) {
|
|
3191
|
+
const char* utf8value) const {
|
|
3156
3192
|
HandleScope scope(_env);
|
|
3157
3193
|
return Value().Set(index, utf8value);
|
|
3158
3194
|
}
|
|
3159
3195
|
|
|
3160
|
-
inline MaybeOrValue<bool> ObjectReference::Set(
|
|
3161
|
-
|
|
3196
|
+
inline MaybeOrValue<bool> ObjectReference::Set(
|
|
3197
|
+
uint32_t index, const std::string& utf8value) const {
|
|
3162
3198
|
HandleScope scope(_env);
|
|
3163
3199
|
return Value().Set(index, utf8value);
|
|
3164
3200
|
}
|
|
3165
3201
|
|
|
3166
|
-
inline MaybeOrValue<bool> ObjectReference::Set(uint32_t index,
|
|
3202
|
+
inline MaybeOrValue<bool> ObjectReference::Set(uint32_t index,
|
|
3203
|
+
bool boolValue) const {
|
|
3167
3204
|
HandleScope scope(_env);
|
|
3168
3205
|
return Value().Set(index, boolValue);
|
|
3169
3206
|
}
|
|
3170
3207
|
|
|
3171
3208
|
inline MaybeOrValue<bool> ObjectReference::Set(uint32_t index,
|
|
3172
|
-
double numberValue) {
|
|
3209
|
+
double numberValue) const {
|
|
3173
3210
|
HandleScope scope(_env);
|
|
3174
3211
|
return Value().Set(index, numberValue);
|
|
3175
3212
|
}
|
|
@@ -4451,6 +4488,15 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::StaticValue(Symbol name,
|
|
|
4451
4488
|
return desc;
|
|
4452
4489
|
}
|
|
4453
4490
|
|
|
4491
|
+
template <typename T>
|
|
4492
|
+
inline Value ObjectWrap<T>::OnCalledAsFunction(
|
|
4493
|
+
const Napi::CallbackInfo& callbackInfo) {
|
|
4494
|
+
NAPI_THROW(
|
|
4495
|
+
TypeError::New(callbackInfo.Env(),
|
|
4496
|
+
"Class constructors cannot be invoked without 'new'"),
|
|
4497
|
+
Napi::Value());
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4454
4500
|
template <typename T>
|
|
4455
4501
|
inline void ObjectWrap<T>::Finalize(Napi::Env /*env*/) {}
|
|
4456
4502
|
|
|
@@ -4464,8 +4510,8 @@ inline napi_value ObjectWrap<T>::ConstructorCallbackWrapper(
|
|
|
4464
4510
|
|
|
4465
4511
|
bool isConstructCall = (new_target != nullptr);
|
|
4466
4512
|
if (!isConstructCall) {
|
|
4467
|
-
|
|
4468
|
-
|
|
4513
|
+
return details::WrapCallback(
|
|
4514
|
+
[&] { return T::OnCalledAsFunction(CallbackInfo(env, info)); });
|
|
4469
4515
|
}
|
|
4470
4516
|
|
|
4471
4517
|
napi_value wrapper = details::WrapCallback([&] {
|
|
@@ -5323,7 +5369,7 @@ template <typename ContextType,
|
|
|
5323
5369
|
typename DataType,
|
|
5324
5370
|
void (*CallJs)(Napi::Env, Napi::Function, ContextType*, DataType*)>
|
|
5325
5371
|
inline napi_status
|
|
5326
|
-
TypedThreadSafeFunction<ContextType, DataType, CallJs>::Release() {
|
|
5372
|
+
TypedThreadSafeFunction<ContextType, DataType, CallJs>::Release() const {
|
|
5327
5373
|
return napi_release_threadsafe_function(_tsfn, napi_tsfn_release);
|
|
5328
5374
|
}
|
|
5329
5375
|
|
|
@@ -5331,7 +5377,7 @@ template <typename ContextType,
|
|
|
5331
5377
|
typename DataType,
|
|
5332
5378
|
void (*CallJs)(Napi::Env, Napi::Function, ContextType*, DataType*)>
|
|
5333
5379
|
inline napi_status
|
|
5334
|
-
TypedThreadSafeFunction<ContextType, DataType, CallJs>::Abort() {
|
|
5380
|
+
TypedThreadSafeFunction<ContextType, DataType, CallJs>::Abort() const {
|
|
5335
5381
|
return napi_release_threadsafe_function(_tsfn, napi_tsfn_abort);
|
|
5336
5382
|
}
|
|
5337
5383
|
|
|
@@ -5661,11 +5707,11 @@ inline napi_status ThreadSafeFunction::Acquire() const {
|
|
|
5661
5707
|
return napi_acquire_threadsafe_function(_tsfn);
|
|
5662
5708
|
}
|
|
5663
5709
|
|
|
5664
|
-
inline napi_status ThreadSafeFunction::Release() {
|
|
5710
|
+
inline napi_status ThreadSafeFunction::Release() const {
|
|
5665
5711
|
return napi_release_threadsafe_function(_tsfn, napi_tsfn_release);
|
|
5666
5712
|
}
|
|
5667
5713
|
|
|
5668
|
-
inline napi_status ThreadSafeFunction::Abort() {
|
|
5714
|
+
inline napi_status ThreadSafeFunction::Abort() const {
|
|
5669
5715
|
return napi_release_threadsafe_function(_tsfn, napi_tsfn_abort);
|
|
5670
5716
|
}
|
|
5671
5717
|
|
|
@@ -6204,6 +6250,10 @@ bool Env::CleanupHook<Hook, Arg>::IsEmpty() const {
|
|
|
6204
6250
|
}
|
|
6205
6251
|
#endif // NAPI_VERSION > 2
|
|
6206
6252
|
|
|
6253
|
+
#ifdef NAPI_CPP_CUSTOM_NAMESPACE
|
|
6254
|
+
} // namespace NAPI_CPP_CUSTOM_NAMESPACE
|
|
6255
|
+
#endif
|
|
6256
|
+
|
|
6207
6257
|
} // namespace Napi
|
|
6208
6258
|
|
|
6209
6259
|
#endif // SRC_NAPI_INL_H_
|