harperdb 3.2.0 → 3.3.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 +20 -11
- package/bin/BinObjects.jsc +0 -0
- package/bin/harperdb.jsc +0 -0
- package/bin/install.jsc +0 -0
- package/bin/register.jsc +0 -0
- package/bin/run.jsc +0 -0
- package/bin/stop.jsc +0 -0
- package/bin/upgrade.jsc +0 -0
- package/bin/utility.jsc +0 -0
- package/bin/version.jsc +0 -0
- package/coverage/lcov.info +6624 -6141
- package/data_layer/CreateAttributeObject.jsc +0 -0
- package/data_layer/CreateTableObject.jsc +0 -0
- package/data_layer/DataLayerObjects.jsc +0 -0
- package/data_layer/DeleteBeforeObject.jsc +0 -0
- package/data_layer/DeleteObject.jsc +0 -0
- package/data_layer/DropAttributeObject.jsc +0 -0
- package/data_layer/InsertObject.jsc +0 -0
- package/data_layer/ReadTransactionLogObject.jsc +0 -0
- package/data_layer/SQLSearch.jsc +0 -0
- package/data_layer/SearchByConditionsObject.jsc +0 -0
- package/data_layer/SearchByHashObject.jsc +0 -0
- package/data_layer/SearchObject.jsc +0 -0
- package/data_layer/SqlSearchObject.jsc +0 -0
- package/data_layer/UpdateObject.jsc +0 -0
- package/data_layer/UpsertObject.jsc +0 -0
- package/data_layer/bulkLoad.jsc +0 -0
- package/data_layer/data_objects/BulkLoadObjects.jsc +0 -0
- package/data_layer/data_objects/UpsertObject.jsc +0 -0
- package/data_layer/delete.jsc +0 -0
- package/data_layer/export.jsc +0 -0
- package/data_layer/harperBridge/BridgeMethods.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/checkForNewAttr.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/convertOperationToTransaction.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/evaluateTableGetAttributes.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/insertUpdateReturnObj.jsc +0 -0
- package/data_layer/harperBridge/bridgeUtility/insertUpdateValidate.jsc +0 -0
- package/data_layer/harperBridge/harperBridge.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/LMDBBridge.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/DeleteTransactionsBeforeResults.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecordsBefore.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteTransactionLogsBefore.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadTransactionLog.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBDeleteTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBInsertTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpdateTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpsertTransactionObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/ThreadSearchObject.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsEnvironment.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbDropAllAttributes.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbThreadSearch.jsc +0 -0
- package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.jsc +0 -0
- package/data_layer/hdbInfoController.jsc +0 -0
- package/data_layer/insert.jsc +0 -0
- package/data_layer/readTransactionLog.jsc +0 -0
- package/data_layer/schema.jsc +0 -0
- package/data_layer/schemaDescribe.jsc +0 -0
- package/data_layer/search.jsc +0 -0
- package/data_layer/update.jsc +0 -0
- package/events/ClusterStatusEmitter.jsc +0 -0
- package/events/SioServerStoppedEvent.jsc +0 -0
- package/events/SocketClusterStatusEmitter.jsc +0 -0
- package/license/LICENSE +91 -1
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/README.md +1 -0
- package/node_modules/{node-addon-api/src/nothing.c → @msgpackr-extract/msgpackr-extract-linux-x64/index.js} +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi93.glibc.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi93.musl.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node +0 -0
- package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json +53 -0
- package/node_modules/{msgpackr-extract → lmdb-store}/.github/workflows/prebuild.yml +9 -10
- package/node_modules/lmdb-store/.idea/lmdb-store.iml +12 -0
- package/node_modules/lmdb-store/.idea/misc.xml +6 -0
- package/node_modules/lmdb-store/.idea/modules.xml +8 -0
- package/node_modules/lmdb-store/.idea/workspace.xml +4 -0
- package/node_modules/lmdb-store/README.md +393 -388
- package/node_modules/lmdb-store/benchmark/index.js +162 -162
- package/node_modules/lmdb-store/binding.gyp +79 -88
- package/node_modules/lmdb-store/caching.js +113 -113
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/COPYRIGHT +20 -20
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/Doxyfile +1631 -1631
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/LICENSE +47 -47
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.c +183 -183
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.h +14 -14
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/crypto.c +121 -121
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/intro.doc +192 -192
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.c +12125 -12125
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_copy.1 +74 -74
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_copy.c +106 -106
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_drop.1 +53 -53
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_drop.c +154 -154
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_dump.1 +94 -94
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_dump.c +333 -333
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_load.1 +97 -97
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_load.c +530 -530
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_stat.1 +83 -83
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_stat.c +276 -276
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.c +452 -452
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.h +208 -208
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/module.c +101 -101
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/module.h +16 -16
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest.c +178 -178
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest2.c +124 -124
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest3.c +133 -133
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest4.c +168 -168
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest5.c +135 -135
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest6.c +141 -141
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_enc.c +190 -190
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_enc2.c +189 -189
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_remap.c +177 -177
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/sample-bdb.txt +73 -73
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/sample-mdb.txt +62 -62
- package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/tooltag +27 -27
- package/node_modules/lmdb-store/dependencies/lz4/LICENSE +11 -11
- package/node_modules/lmdb-store/dependencies/lz4/lib/README.md +137 -137
- package/node_modules/lmdb-store/dependencies/lz4/lib/dll/example/README.md +69 -69
- package/node_modules/lmdb-store/dependencies/lz4/lib/lz4frame.c +1899 -1899
- package/node_modules/lmdb-store/dependencies/lz4/lib/xxhash.c +1030 -1030
- package/node_modules/lmdb-store/dependencies/lz4/lib/xxhash.h +328 -328
- package/node_modules/lmdb-store/dist/index.cjs +2591 -0
- package/node_modules/lmdb-store/dist/index.cjs.map +1 -0
- package/node_modules/lmdb-store/index.d.ts +323 -323
- package/node_modules/lmdb-store/index.js +1274 -1274
- package/node_modules/lmdb-store/index.mjs +3 -3
- package/node_modules/lmdb-store/package.json +16 -11
- package/node_modules/lmdb-store/prebuilds/darwin-arm64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-arm64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-arm64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-arm64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-arm64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-arm64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi83.musl.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi93.musl.node +0 -0
- package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/electron.abi98.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi83.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi93.node +0 -0
- package/node_modules/lmdb-store/src/compression.cpp +181 -181
- package/node_modules/lmdb-store/src/cursor.cpp +407 -407
- package/node_modules/lmdb-store/src/dbi.cpp +354 -354
- package/node_modules/lmdb-store/src/env.cpp +1134 -1134
- package/node_modules/lmdb-store/src/misc.cpp +528 -528
- package/node_modules/lmdb-store/src/node-lmdb.cpp +44 -44
- package/node_modules/lmdb-store/src/node-lmdb.h +965 -965
- package/node_modules/lmdb-store/src/ordered-binary.cpp +337 -337
- package/node_modules/lmdb-store/src/txn.cpp +513 -513
- package/node_modules/lmdb-store/src/v8-fast-api-calls.h +419 -419
- package/node_modules/lmdb-store/src/windows.c +30 -30
- package/node_modules/lmdb-store/test/index.test.js +584 -584
- package/node_modules/lmdb-store/test/node-lmdb.test.js +1525 -1525
- package/node_modules/lmdb-store/test/threads.js +100 -100
- package/node_modules/lmdb-store/util/ArrayLikeIterable.js +136 -136
- package/node_modules/lmdb-store/util/WeakValueMap.js +40 -40
- package/node_modules/lmdb-store/util/upgrade-lmdb.js +46 -46
- package/node_modules/lmdb-store/util/when.js +8 -8
- package/node_modules/microtime/.github/workflows/release.yml +76 -0
- package/node_modules/microtime/.github/workflows/test.yml +46 -0
- package/node_modules/microtime/README.md +0 -2
- package/node_modules/microtime/binding.gyp +28 -10
- package/node_modules/microtime/package.json +25 -20
- package/node_modules/microtime/prebuilds/darwin-x64+arm64/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/node.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-ia32/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-ia32/node.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/electron.napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/node.napi.node +0 -0
- package/node_modules/msgpackr/dist/index.js +1929 -1917
- package/node_modules/msgpackr/dist/index.min.js +67 -68
- package/node_modules/msgpackr/dist/node.cjs +1994 -1980
- package/node_modules/msgpackr/dist/test.js +683 -1235
- package/node_modules/msgpackr/index.d.ts +23 -12
- package/node_modules/msgpackr/node-index.js +23 -21
- package/node_modules/msgpackr/pack.js +935 -931
- package/node_modules/msgpackr/package.json +24 -12
- package/node_modules/msgpackr/unpack.d.ts +52 -50
- package/node_modules/msgpackr/unpack.js +1061 -1053
- package/node_modules/msgpackr-extract/bin/download-prebuilds.js +11 -0
- package/node_modules/msgpackr-extract/binding.gyp +22 -5
- package/node_modules/msgpackr-extract/index.js +1 -1
- package/node_modules/msgpackr-extract/package.json +46 -21
- package/node_modules/msgpackr-extract/src/.vs/ProjectSettings.json +3 -0
- package/node_modules/msgpackr-extract/src/.vs/VSWorkspaceState.json +7 -0
- package/node_modules/msgpackr-extract/src/.vs/slnx.sqlite +0 -0
- package/node_modules/msgpackr-extract/src/.vs/src/v16/.suo +0 -0
- package/node_modules/msgpackr-extract/src/.vs/src/v16/Browse.VC.db +0 -0
- package/node_modules/msgpackr-extract/{prebuilds/darwin-x64/node.abi72.node → src/.vs/src/v16/Browse.VC.db-shm} +0 -0
- package/node_modules/msgpackr-extract/src/.vs/src/v16/Browse.VC.db-wal +0 -0
- package/node_modules/msgpackr-extract/src/extract.cpp +272 -269
- package/node_modules/nan/package.json +0 -1
- package/node_modules/node-addon-api/README.md +146 -53
- package/node_modules/node-addon-api/common.gypi +21 -0
- package/node_modules/node-addon-api/except.gypi +25 -0
- package/node_modules/node-addon-api/index.js +7 -41
- package/node_modules/node-addon-api/napi-inl.deprecated.h +8 -8
- package/node_modules/node-addon-api/napi-inl.h +2795 -633
- package/node_modules/node-addon-api/napi.h +1547 -597
- package/node_modules/node-addon-api/node_api.gyp +9 -0
- package/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/node_modules/node-addon-api/nothing.c +0 -0
- package/node_modules/node-addon-api/package-support.json +21 -0
- package/node_modules/node-addon-api/package.json +203 -13
- package/node_modules/node-addon-api/tools/README.md +12 -6
- package/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/node_modules/node-addon-api/tools/conversion.js +4 -8
- package/node_modules/node-addon-api/tools/eslint-format.js +71 -0
- package/node_modules/node-gyp-build/README.md +17 -14
- package/node_modules/node-gyp-build/bin.js +28 -15
- package/node_modules/node-gyp-build/index.js +145 -34
- package/node_modules/node-gyp-build/package.json +18 -15
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/LICENSE +0 -0
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/README.md +0 -0
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/bin.js +1 -1
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/build-test.js +0 -0
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/index.js +17 -11
- package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/optional.js +0 -0
- package/node_modules/{msgpackr-extract/node_modules/node-gyp-build → node-gyp-build-optional-packages}/package.json +17 -17
- package/package.json +12 -11
- package/security/JWTObjects.jsc +0 -0
- package/security/auth.jsc +0 -0
- package/security/cryptoHash.jsc +0 -0
- package/security/data_objects/PermissionAttributeResponseObject.jsc +0 -0
- package/security/data_objects/PermissionResponseObject.jsc +0 -0
- package/security/data_objects/PermissionTableResponseObject.jsc +0 -0
- package/security/permissionsTranslator.jsc +0 -0
- package/security/role.jsc +0 -0
- package/security/tokenAuthentication.jsc +0 -0
- package/security/user.jsc +0 -0
- package/server/ClusteringOriginObject.jsc +0 -0
- package/server/JobObject.jsc +0 -0
- package/server/clustering/ClusterStatusObject.jsc +0 -0
- package/server/clustering/NodeObject.jsc +0 -0
- package/server/clustering/clusterUtilities.jsc +0 -0
- package/server/configuration.jsc +0 -0
- package/server/customFunctions/customFunctionsServer.jsc +0 -0
- package/server/customFunctions/helpers/getCORSOptions.jsc +0 -0
- package/server/customFunctions/helpers/getHeaderTimeoutConfig.jsc +0 -0
- package/server/customFunctions/helpers/getServerOptions.jsc +0 -0
- package/server/customFunctions/operations.jsc +0 -0
- package/server/customFunctions/operationsValidation.jsc +0 -0
- package/server/harperdb/hdbServer.jsc +0 -0
- package/server/ipc/IPCClient.jsc +0 -0
- package/server/ipc/hdbIpcServer.jsc +0 -0
- package/server/ipc/serverHandlers.jsc +0 -0
- package/server/ipc/utility/IPCEventObject.jsc +0 -0
- package/server/ipc/utility/ipcUtils.jsc +0 -0
- package/server/jobRunner.jsc +0 -0
- package/server/jobThread.jsc +0 -0
- package/server/jobs.jsc +0 -0
- package/server/serverHelpers/OperationFunctionObject.jsc +0 -0
- package/server/serverHelpers/requestTimePlugin.jsc +0 -0
- package/server/serverHelpers/serverHandlers.jsc +0 -0
- package/server/serverHelpers/serverUtilities.jsc +0 -0
- package/server/socketcluster/Server.jsc +0 -0
- package/server/socketcluster/broker.jsc +0 -0
- package/server/socketcluster/connector/HDBSocketConnector.jsc +0 -0
- package/server/socketcluster/connector/InterNodeSocketConnector.jsc +0 -0
- package/server/socketcluster/connector/SocketConnector.jsc +0 -0
- package/server/socketcluster/connector/spawnSCConnection.jsc +0 -0
- package/server/socketcluster/decisionMatrix/CoreDecisionMatrix.jsc +0 -0
- package/server/socketcluster/decisionMatrix/DecisionMatrixIF.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/AssignToHdbChildWorkerRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/CallRoomMsgHandlerRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/CleanDataObjectRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/CommandCollection.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/DummyRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/RulesIF.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/StripHdbHeaderRule.jsc +0 -0
- package/server/socketcluster/decisionMatrix/rules/TestRule.jsc +0 -0
- package/server/socketcluster/handlers/NodeConnectionsHandler.jsc +0 -0
- package/server/socketcluster/handlers/SCServer.jsc +0 -0
- package/server/socketcluster/handlers/ServerSocket.jsc +0 -0
- package/server/socketcluster/interNodeConnectionLauncher.jsc +0 -0
- package/server/socketcluster/messageQueue/MessageQueueIF.jsc +0 -0
- package/server/socketcluster/middleware/AuthMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/ConnectionNameCheckMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/GenericMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/MessagePrepMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/MiddlewareFactory.jsc +0 -0
- package/server/socketcluster/middleware/MiddlewareIF.jsc +0 -0
- package/server/socketcluster/middleware/OriginatorCheckMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/RequestDataValidMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/StampOriginatorMiddleware.jsc +0 -0
- package/server/socketcluster/middleware/StampRequestMiddleware.jsc +0 -0
- package/server/socketcluster/observer/EventableIF.jsc +0 -0
- package/server/socketcluster/room/AddUserRoom.jsc +0 -0
- package/server/socketcluster/room/AlterUserRoom.jsc +0 -0
- package/server/socketcluster/room/CoreRoom.jsc +0 -0
- package/server/socketcluster/room/CreateAttributeRoom.jsc +0 -0
- package/server/socketcluster/room/CreateSchemaRoom.jsc +0 -0
- package/server/socketcluster/room/CreateTableRoom.jsc +0 -0
- package/server/socketcluster/room/DropUserRoom.jsc +0 -0
- package/server/socketcluster/room/HDBNodeRoom.jsc +0 -0
- package/server/socketcluster/room/RoomIF.jsc +0 -0
- package/server/socketcluster/room/RoomMessageObjects.jsc +0 -0
- package/server/socketcluster/room/UsersRoom.jsc +0 -0
- package/server/socketcluster/room/WatchHDBWorkersRoom.jsc +0 -0
- package/server/socketcluster/room/WorkerRoom.jsc +0 -0
- package/server/socketcluster/room/roomFactory.jsc +0 -0
- package/server/socketcluster/socketClusterObjects.jsc +0 -0
- package/server/socketcluster/types.jsc +0 -0
- package/server/socketcluster/util/clusterData.jsc +0 -0
- package/server/socketcluster/util/socketClusterUtils.jsc +0 -0
- package/server/socketcluster/worker/ClusterWorker.jsc +0 -0
- package/server/socketcluster/worker/WorkerIF.jsc +0 -0
- package/server/socketcluster/worker/WorkerObjects.jsc +0 -0
- package/server/transactToClusteringUtilities.jsc +0 -0
- package/sqlTranslator/SelectValidator.jsc +0 -0
- package/sqlTranslator/alasqlFunctionImporter.jsc +0 -0
- package/sqlTranslator/conditionPatterns.jsc +0 -0
- package/sqlTranslator/deleteTranslator.jsc +0 -0
- package/sqlTranslator/index.jsc +0 -0
- package/sqlTranslator/sql_statement_bucket.jsc +0 -0
- package/upgrade/EnvironmentVariable.jsc +0 -0
- package/upgrade/UpgradeDirective.jsc +0 -0
- package/upgrade/UpgradeObjects.jsc +0 -0
- package/upgrade/directives/3-0-0.jsc +0 -0
- package/upgrade/directives/3-1-0.jsc +0 -0
- package/upgrade/directives/directivesController.jsc +0 -0
- package/upgrade/directives/upgrade_scripts/3_0_0_reindex_script.jsc +0 -0
- package/upgrade/directivesManager.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/DBIDefinition.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/OpenDBIObject.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/OpenEnvironmentObject.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/commonErrors.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/commonUtility.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/environmentUtility.jsc +0 -0
- package/upgrade/lmdb/nodeLMDB/terms.jsc +0 -0
- package/upgrade/upgradePrompt.jsc +0 -0
- package/upgrade/upgradeUtilities.jsc +0 -0
- package/utility/AWS/AWSConnector.jsc +0 -0
- package/utility/OperationFunctionCaller.jsc +0 -0
- package/utility/common_utils.jsc +0 -0
- package/utility/environment/SystemInformationObject.jsc +0 -0
- package/utility/environment/SystemInformationOperation.jsc +0 -0
- package/utility/environment/environmentManager.jsc +0 -0
- package/utility/environment/systemInformation.jsc +0 -0
- package/utility/errors/commonErrors.jsc +0 -0
- package/utility/errors/hdbError.jsc +0 -0
- package/utility/functions/date/dateFunctions.jsc +0 -0
- package/utility/functions/geo.jsc +0 -0
- package/utility/functions/math/avg.jsc +0 -0
- package/utility/functions/math/count.jsc +0 -0
- package/utility/functions/sql/alaSQLExtension.jsc +0 -0
- package/utility/functions/string/compare.jsc +0 -0
- package/utility/globalSchema.jsc +0 -0
- package/utility/hdbTerms.jsc +0 -0
- package/utility/install/checkJWTTokensExist.jsc +0 -0
- package/utility/install/installer.jsc +0 -0
- package/utility/install_user_permission.jsc +0 -0
- package/utility/lmdb/DBIDefinition.jsc +0 -0
- package/utility/lmdb/DeleteRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/InsertRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/OpenDBIObject.jsc +0 -0
- package/utility/lmdb/OpenEnvironmentObject.jsc +0 -0
- package/utility/lmdb/UpdateRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/UpsertRecordsResponseObject.jsc +0 -0
- package/utility/lmdb/cleanLMDBMap.jsc +0 -0
- package/utility/lmdb/commonUtility.jsc +0 -0
- package/utility/lmdb/deleteUtility.jsc +0 -0
- package/utility/lmdb/environmentUtility.jsc +0 -0
- package/utility/lmdb/searchCursorFunctions.jsc +0 -0
- package/utility/lmdb/searchUtility.jsc +0 -0
- package/utility/lmdb/terms.jsc +0 -0
- package/utility/lmdb/writeUtility.jsc +0 -0
- package/utility/logging/harper_logger.jsc +0 -0
- package/utility/mount_hdb.jsc +0 -0
- package/utility/npmUtilities.jsc +0 -0
- package/utility/operation_authorization.jsc +0 -0
- package/utility/password.jsc +0 -0
- package/utility/pm2/servicesConfig.jsc +0 -0
- package/utility/pm2/utilityFunctions.jsc +0 -0
- package/utility/psList.jsc +0 -0
- package/utility/registration/hdb_license.jsc +0 -0
- package/utility/registration/licenseObjects.jsc +0 -0
- package/utility/registration/registrationHandler.jsc +0 -0
- package/utility/scripts/restartHdb.jsc +0 -0
- package/utility/signalling.jsc +0 -0
- package/utility/system_info.jsc +0 -0
- package/validation/bulkDeleteValidator.jsc +0 -0
- package/validation/check_permissions.jsc +0 -0
- package/validation/clustering/configureValidator.jsc +0 -0
- package/validation/common_validators.jsc +0 -0
- package/validation/conditionalDeleteValidator.jsc +0 -0
- package/validation/deleteValidator.jsc +0 -0
- package/validation/fileLoadValidator.jsc +0 -0
- package/validation/insertValidator.jsc +0 -0
- package/validation/nodeSubscriptionValidator.jsc +0 -0
- package/validation/nodeValidator.jsc +0 -0
- package/validation/readLogValidator.jsc +0 -0
- package/validation/registration/license_key_object.jsc +0 -0
- package/validation/role_validation.jsc +0 -0
- package/validation/schemaMetadataValidator.jsc +0 -0
- package/validation/schema_validator.jsc +0 -0
- package/validation/searchValidator.jsc +0 -0
- package/validation/user_validation.jsc +0 -0
- package/validation/validationWrapper.jsc +0 -0
- package/node_modules/lmdb-store/build/Makefile +0 -324
- package/node_modules/lmdb-store/build/Release/.deps/Release/lmdb-store.node.d +0 -1
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.o.d +0 -6
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.o.d +0 -8
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.o.d +0 -8
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lz4/lib/lz4.o.d +0 -5
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/compression.o.d +0 -72
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/cursor.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/dbi.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/env.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/misc.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/node-lmdb.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/ordered-binary.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/txn.o.d +0 -73
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/windows.o.d +0 -3
- package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store.node.d +0 -1
- package/node_modules/lmdb-store/build/Release/lmdb-store.node +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lz4/lib/lz4.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/compression.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/cursor.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/dbi.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/env.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/misc.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/node-lmdb.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/ordered-binary.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/txn.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/windows.o +0 -0
- package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store.node +0 -0
- package/node_modules/lmdb-store/build/binding.Makefile +0 -6
- package/node_modules/lmdb-store/build/config.gypi +0 -426
- package/node_modules/lmdb-store/build/lmdb-store.target.mk +0 -206
- package/node_modules/lmdb-store/node_modules/node-gyp-build/package.json +0 -60
- package/node_modules/lmdb-store/prebuilds/darwin-x64/electron.abi87.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi72.node +0 -0
- package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi88.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/electron.abi87.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi72.node +0 -0
- package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi88.node +0 -0
- package/node_modules/microtime/prebuilds/darwin-x64/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/darwin-x64/node-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-arm/node-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/linux-x64/node-napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/electron-napi.node +0 -0
- package/node_modules/microtime/prebuilds/win32-x64/node-napi.node +0 -0
- package/node_modules/msgpackr-extract/.circleci/config.yml +0 -19
- package/node_modules/msgpackr-extract/.travis.yml +0 -30
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/LICENSE +0 -21
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/README.md +0 -58
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/bin.js +0 -77
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/build-test.js +0 -19
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/index.js +0 -202
- package/node_modules/msgpackr-extract/node_modules/node-gyp-build/optional.js +0 -7
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi88.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi102.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi72.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi72.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi83.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi88.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi93.musl.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi93.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/electron.abi98.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi102.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi72.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi83.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi88.node +0 -0
- package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi93.node +0 -0
- package/node_modules/node-addon-api/.editorconfig +0 -8
- package/node_modules/node-addon-api/.travis.yml +0 -65
- package/node_modules/node-addon-api/CHANGELOG.md +0 -325
- package/node_modules/node-addon-api/CODE_OF_CONDUCT.md +0 -4
- package/node_modules/node-addon-api/CONTRIBUTING.md +0 -66
- package/node_modules/node-addon-api/appveyor.yml +0 -48
- package/node_modules/node-addon-api/doc/Doxyfile +0 -2450
- package/node_modules/node-addon-api/doc/array_buffer.md +0 -129
- package/node_modules/node-addon-api/doc/async_context.md +0 -76
- package/node_modules/node-addon-api/doc/async_operations.md +0 -31
- package/node_modules/node-addon-api/doc/async_worker.md +0 -397
- package/node_modules/node-addon-api/doc/basic_types.md +0 -415
- package/node_modules/node-addon-api/doc/bigint.md +0 -92
- package/node_modules/node-addon-api/doc/boolean.md +0 -64
- package/node_modules/node-addon-api/doc/buffer.md +0 -140
- package/node_modules/node-addon-api/doc/callback_scope.md +0 -54
- package/node_modules/node-addon-api/doc/callbackinfo.md +0 -97
- package/node_modules/node-addon-api/doc/checker-tool.md +0 -32
- package/node_modules/node-addon-api/doc/class_property_descriptor.md +0 -118
- package/node_modules/node-addon-api/doc/cmake-js.md +0 -19
- package/node_modules/node-addon-api/doc/conversion-tool.md +0 -28
- package/node_modules/node-addon-api/doc/creating_a_release.md +0 -62
- package/node_modules/node-addon-api/doc/dataview.md +0 -244
- package/node_modules/node-addon-api/doc/env.md +0 -63
- package/node_modules/node-addon-api/doc/error.md +0 -115
- package/node_modules/node-addon-api/doc/error_handling.md +0 -186
- package/node_modules/node-addon-api/doc/escapable_handle_scope.md +0 -82
- package/node_modules/node-addon-api/doc/external.md +0 -59
- package/node_modules/node-addon-api/doc/function.md +0 -294
- package/node_modules/node-addon-api/doc/function_reference.md +0 -238
- package/node_modules/node-addon-api/doc/generator.md +0 -13
- package/node_modules/node-addon-api/doc/handle_scope.md +0 -65
- package/node_modules/node-addon-api/doc/memory_management.md +0 -27
- package/node_modules/node-addon-api/doc/node-gyp.md +0 -82
- package/node_modules/node-addon-api/doc/number.md +0 -163
- package/node_modules/node-addon-api/doc/object.md +0 -202
- package/node_modules/node-addon-api/doc/object_lifetime_management.md +0 -83
- package/node_modules/node-addon-api/doc/object_reference.md +0 -117
- package/node_modules/node-addon-api/doc/object_wrap.md +0 -546
- package/node_modules/node-addon-api/doc/prebuild_tools.md +0 -16
- package/node_modules/node-addon-api/doc/promises.md +0 -74
- package/node_modules/node-addon-api/doc/property_descriptor.md +0 -231
- package/node_modules/node-addon-api/doc/range_error.md +0 -59
- package/node_modules/node-addon-api/doc/reference.md +0 -111
- package/node_modules/node-addon-api/doc/setup.md +0 -82
- package/node_modules/node-addon-api/doc/string.md +0 -89
- package/node_modules/node-addon-api/doc/symbol.md +0 -44
- package/node_modules/node-addon-api/doc/threadsafe_function.md +0 -303
- package/node_modules/node-addon-api/doc/type_error.md +0 -59
- package/node_modules/node-addon-api/doc/typed_array.md +0 -74
- package/node_modules/node-addon-api/doc/typed_array_of.md +0 -133
- package/node_modules/node-addon-api/doc/value.md +0 -269
- package/node_modules/node-addon-api/doc/version_management.md +0 -43
- package/node_modules/node-addon-api/doc/working_with_javascript_values.md +0 -14
- package/node_modules/node-addon-api/external-napi/node_api.h +0 -7
- package/node_modules/node-addon-api/src/node_api.cc +0 -3655
- package/node_modules/node-addon-api/src/node_api.gyp +0 -21
- package/node_modules/node-addon-api/src/node_api.h +0 -588
- package/node_modules/node-addon-api/src/node_api_types.h +0 -115
- package/node_modules/node-addon-api/src/node_internals.cc +0 -142
- package/node_modules/node-addon-api/src/node_internals.h +0 -157
- package/node_modules/node-addon-api/src/util-inl.h +0 -38
- package/node_modules/node-addon-api/src/util.h +0 -7
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <functional>
|
|
6
6
|
#include <initializer_list>
|
|
7
7
|
#include <memory>
|
|
8
|
+
#include <mutex>
|
|
8
9
|
#include <string>
|
|
9
10
|
#include <vector>
|
|
10
11
|
|
|
@@ -33,6 +34,13 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16
|
|
|
33
34
|
#endif
|
|
34
35
|
#endif
|
|
35
36
|
|
|
37
|
+
// If C++ NAPI_CPP_EXCEPTIONS are enabled, NODE_ADDON_API_ENABLE_MAYBE should
|
|
38
|
+
// not be set
|
|
39
|
+
#if defined(NAPI_CPP_EXCEPTIONS) && defined(NODE_ADDON_API_ENABLE_MAYBE)
|
|
40
|
+
#error NODE_ADDON_API_ENABLE_MAYBE should not be set when \
|
|
41
|
+
NAPI_CPP_EXCEPTIONS is defined.
|
|
42
|
+
#endif
|
|
43
|
+
|
|
36
44
|
#ifdef _NOEXCEPT
|
|
37
45
|
#define NAPI_NOEXCEPT _NOEXCEPT
|
|
38
46
|
#else
|
|
@@ -76,90 +84,210 @@ static_assert(sizeof(char16_t) == sizeof(wchar_t), "Size mismatch between char16
|
|
|
76
84
|
return; \
|
|
77
85
|
} while (0)
|
|
78
86
|
|
|
79
|
-
#define NAPI_THROW_IF_FAILED(env, status, ...)
|
|
80
|
-
if ((status) != napi_ok) {
|
|
81
|
-
Napi::Error::New(env).ThrowAsJavaScriptException();
|
|
82
|
-
return __VA_ARGS__;
|
|
87
|
+
#define NAPI_THROW_IF_FAILED(env, status, ...) \
|
|
88
|
+
if ((status) != napi_ok) { \
|
|
89
|
+
Napi::Error::New(env).ThrowAsJavaScriptException(); \
|
|
90
|
+
return __VA_ARGS__; \
|
|
83
91
|
}
|
|
84
92
|
|
|
85
|
-
#define NAPI_THROW_IF_FAILED_VOID(env, status)
|
|
86
|
-
if ((status) != napi_ok) {
|
|
87
|
-
Napi::Error::New(env).ThrowAsJavaScriptException();
|
|
88
|
-
return;
|
|
93
|
+
#define NAPI_THROW_IF_FAILED_VOID(env, status) \
|
|
94
|
+
if ((status) != napi_ok) { \
|
|
95
|
+
Napi::Error::New(env).ThrowAsJavaScriptException(); \
|
|
96
|
+
return; \
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
#endif // NAPI_CPP_EXCEPTIONS
|
|
92
100
|
|
|
93
|
-
#
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
#ifdef NODE_ADDON_API_ENABLE_MAYBE
|
|
102
|
+
#define NAPI_MAYBE_THROW_IF_FAILED(env, status, type) \
|
|
103
|
+
NAPI_THROW_IF_FAILED(env, status, Napi::Nothing<type>())
|
|
104
|
+
|
|
105
|
+
#define NAPI_RETURN_OR_THROW_IF_FAILED(env, status, result, type) \
|
|
106
|
+
NAPI_MAYBE_THROW_IF_FAILED(env, status, type); \
|
|
107
|
+
return Napi::Just<type>(result);
|
|
108
|
+
#else
|
|
109
|
+
#define NAPI_MAYBE_THROW_IF_FAILED(env, status, type) \
|
|
110
|
+
NAPI_THROW_IF_FAILED(env, status, type())
|
|
111
|
+
|
|
112
|
+
#define NAPI_RETURN_OR_THROW_IF_FAILED(env, status, result, type) \
|
|
113
|
+
NAPI_MAYBE_THROW_IF_FAILED(env, status, type); \
|
|
114
|
+
return result;
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
# define NAPI_DISALLOW_ASSIGN(CLASS) void operator=(const CLASS&) = delete;
|
|
118
|
+
# define NAPI_DISALLOW_COPY(CLASS) CLASS(const CLASS&) = delete;
|
|
119
|
+
|
|
120
|
+
#define NAPI_DISALLOW_ASSIGN_COPY(CLASS) \
|
|
121
|
+
NAPI_DISALLOW_ASSIGN(CLASS) \
|
|
122
|
+
NAPI_DISALLOW_COPY(CLASS)
|
|
123
|
+
|
|
124
|
+
#define NAPI_CHECK(condition, location, message) \
|
|
125
|
+
do { \
|
|
126
|
+
if (!(condition)) { \
|
|
127
|
+
Napi::Error::Fatal((location), (message)); \
|
|
128
|
+
} \
|
|
98
129
|
} while (0)
|
|
99
130
|
|
|
131
|
+
#define NAPI_FATAL_IF_FAILED(status, location, message) \
|
|
132
|
+
NAPI_CHECK((status) == napi_ok, location, message)
|
|
133
|
+
|
|
100
134
|
////////////////////////////////////////////////////////////////////////////////
|
|
101
|
-
///
|
|
135
|
+
/// Node-API C++ Wrapper Classes
|
|
102
136
|
///
|
|
103
|
-
/// These classes wrap the "
|
|
137
|
+
/// These classes wrap the "Node-API" ABI-stable C APIs for Node.js, providing a
|
|
104
138
|
/// C++ object model and C++ exception-handling semantics with low overhead.
|
|
105
139
|
/// The wrappers are all header-only so that they do not affect the ABI.
|
|
106
140
|
////////////////////////////////////////////////////////////////////////////////
|
|
107
141
|
namespace Napi {
|
|
108
142
|
|
|
143
|
+
#ifdef NAPI_CPP_CUSTOM_NAMESPACE
|
|
144
|
+
// NAPI_CPP_CUSTOM_NAMESPACE can be #define'd per-addon to avoid symbol
|
|
145
|
+
// conflicts between different instances of node-addon-api
|
|
146
|
+
|
|
147
|
+
// First dummy definition of the namespace to make sure that Napi::(name) still
|
|
148
|
+
// refers to the right things inside this file.
|
|
149
|
+
namespace NAPI_CPP_CUSTOM_NAMESPACE {}
|
|
150
|
+
using namespace NAPI_CPP_CUSTOM_NAMESPACE;
|
|
151
|
+
|
|
152
|
+
namespace NAPI_CPP_CUSTOM_NAMESPACE {
|
|
153
|
+
#endif
|
|
154
|
+
|
|
109
155
|
// Forward declarations
|
|
110
156
|
class Env;
|
|
111
157
|
class Value;
|
|
112
158
|
class Boolean;
|
|
113
159
|
class Number;
|
|
114
|
-
|
|
115
|
-
// released in once it is no longer experimental
|
|
116
|
-
#if (NAPI_VERSION > 2147483646)
|
|
160
|
+
#if NAPI_VERSION > 5
|
|
117
161
|
class BigInt;
|
|
118
|
-
#endif //
|
|
162
|
+
#endif // NAPI_VERSION > 5
|
|
163
|
+
#if (NAPI_VERSION > 4)
|
|
164
|
+
class Date;
|
|
165
|
+
#endif
|
|
119
166
|
class String;
|
|
120
167
|
class Object;
|
|
121
168
|
class Array;
|
|
169
|
+
class ArrayBuffer;
|
|
122
170
|
class Function;
|
|
123
|
-
template <typename T> class Buffer;
|
|
124
171
|
class Error;
|
|
125
172
|
class PropertyDescriptor;
|
|
126
173
|
class CallbackInfo;
|
|
127
|
-
template <typename T> class Reference;
|
|
128
174
|
class TypedArray;
|
|
129
175
|
template <typename T> class TypedArrayOf;
|
|
130
176
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
177
|
+
using Int8Array =
|
|
178
|
+
TypedArrayOf<int8_t>; ///< Typed-array of signed 8-bit integers
|
|
179
|
+
using Uint8Array =
|
|
180
|
+
TypedArrayOf<uint8_t>; ///< Typed-array of unsigned 8-bit integers
|
|
181
|
+
using Int16Array =
|
|
182
|
+
TypedArrayOf<int16_t>; ///< Typed-array of signed 16-bit integers
|
|
183
|
+
using Uint16Array =
|
|
184
|
+
TypedArrayOf<uint16_t>; ///< Typed-array of unsigned 16-bit integers
|
|
185
|
+
using Int32Array =
|
|
186
|
+
TypedArrayOf<int32_t>; ///< Typed-array of signed 32-bit integers
|
|
187
|
+
using Uint32Array =
|
|
188
|
+
TypedArrayOf<uint32_t>; ///< Typed-array of unsigned 32-bit integers
|
|
189
|
+
using Float32Array =
|
|
190
|
+
TypedArrayOf<float>; ///< Typed-array of 32-bit floating-point values
|
|
191
|
+
using Float64Array =
|
|
192
|
+
TypedArrayOf<double>; ///< Typed-array of 64-bit floating-point values
|
|
193
|
+
#if NAPI_VERSION > 5
|
|
194
|
+
using BigInt64Array =
|
|
195
|
+
TypedArrayOf<int64_t>; ///< Typed array of signed 64-bit integers
|
|
196
|
+
using BigUint64Array =
|
|
197
|
+
TypedArrayOf<uint64_t>; ///< Typed array of unsigned 64-bit integers
|
|
198
|
+
#endif // NAPI_VERSION > 5
|
|
199
|
+
|
|
200
|
+
/// Defines the signature of a Node-API C++ module's registration callback
|
|
201
|
+
/// (init) function.
|
|
202
|
+
using ModuleRegisterCallback = Object (*)(Env env, Object exports);
|
|
148
203
|
|
|
149
204
|
class MemoryManagement;
|
|
150
205
|
|
|
151
|
-
///
|
|
206
|
+
/// A simple Maybe type, representing an object which may or may not have a
|
|
207
|
+
/// value.
|
|
152
208
|
///
|
|
153
|
-
///
|
|
154
|
-
///
|
|
155
|
-
///
|
|
156
|
-
///
|
|
209
|
+
/// If an API method returns a Maybe<>, the API method can potentially fail
|
|
210
|
+
/// either because an exception is thrown, or because an exception is pending,
|
|
211
|
+
/// e.g. because a previous API call threw an exception that hasn't been
|
|
212
|
+
/// caught yet. In that case, a "Nothing" value is returned.
|
|
213
|
+
template <class T>
|
|
214
|
+
class Maybe {
|
|
215
|
+
public:
|
|
216
|
+
bool IsNothing() const;
|
|
217
|
+
bool IsJust() const;
|
|
218
|
+
|
|
219
|
+
/// Short-hand for Unwrap(), which doesn't return a value. Could be used
|
|
220
|
+
/// where the actual value of the Maybe is not needed like Object::Set.
|
|
221
|
+
/// If this Maybe is nothing (empty), node-addon-api will crash the
|
|
222
|
+
/// process.
|
|
223
|
+
void Check() const;
|
|
224
|
+
|
|
225
|
+
/// Return the value of type T contained in the Maybe. If this Maybe is
|
|
226
|
+
/// nothing (empty), node-addon-api will crash the process.
|
|
227
|
+
T Unwrap() const;
|
|
228
|
+
|
|
229
|
+
/// Return the value of type T contained in the Maybe, or using a default
|
|
230
|
+
/// value if this Maybe is nothing (empty).
|
|
231
|
+
T UnwrapOr(const T& default_value) const;
|
|
232
|
+
|
|
233
|
+
/// Converts this Maybe to a value of type T in the out. If this Maybe is
|
|
234
|
+
/// nothing (empty), `false` is returned and `out` is left untouched.
|
|
235
|
+
bool UnwrapTo(T* out) const;
|
|
236
|
+
|
|
237
|
+
bool operator==(const Maybe& other) const;
|
|
238
|
+
bool operator!=(const Maybe& other) const;
|
|
239
|
+
|
|
240
|
+
private:
|
|
241
|
+
Maybe();
|
|
242
|
+
explicit Maybe(const T& t);
|
|
243
|
+
|
|
244
|
+
bool _has_value;
|
|
245
|
+
T _value;
|
|
246
|
+
|
|
247
|
+
template <class U>
|
|
248
|
+
friend Maybe<U> Nothing();
|
|
249
|
+
template <class U>
|
|
250
|
+
friend Maybe<U> Just(const U& u);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
template <class T>
|
|
254
|
+
inline Maybe<T> Nothing();
|
|
255
|
+
|
|
256
|
+
template <class T>
|
|
257
|
+
inline Maybe<T> Just(const T& t);
|
|
258
|
+
|
|
259
|
+
#if defined(NODE_ADDON_API_ENABLE_MAYBE)
|
|
260
|
+
template <typename T>
|
|
261
|
+
using MaybeOrValue = Maybe<T>;
|
|
262
|
+
#else
|
|
263
|
+
template <typename T>
|
|
264
|
+
using MaybeOrValue = T;
|
|
265
|
+
#endif
|
|
266
|
+
|
|
267
|
+
/// Environment for Node-API values and operations.
|
|
268
|
+
///
|
|
269
|
+
/// All Node-API values and operations must be associated with an environment.
|
|
270
|
+
/// An environment instance is always provided to callback functions; that
|
|
271
|
+
/// environment must then be used for any creation of Node-API values or other
|
|
272
|
+
/// Node-API operations within the callback. (Many methods infer the
|
|
273
|
+
/// environment from the `this` instance that the method is called on.)
|
|
157
274
|
///
|
|
158
|
-
/// In the future, multiple environments per process may be supported,
|
|
159
|
-
/// implementations only support one environment per process.
|
|
275
|
+
/// In the future, multiple environments per process may be supported,
|
|
276
|
+
/// although current implementations only support one environment per process.
|
|
160
277
|
///
|
|
161
|
-
/// In the V8 JavaScript engine, a
|
|
278
|
+
/// In the V8 JavaScript engine, a Node-API environment approximately
|
|
279
|
+
/// corresponds to an Isolate.
|
|
162
280
|
class Env {
|
|
281
|
+
private:
|
|
282
|
+
#if NAPI_VERSION > 2
|
|
283
|
+
template <typename Hook, typename Arg = void>
|
|
284
|
+
class CleanupHook;
|
|
285
|
+
#endif // NAPI_VERSION > 2
|
|
286
|
+
#if NAPI_VERSION > 5
|
|
287
|
+
template <typename T> static void DefaultFini(Env, T* data);
|
|
288
|
+
template <typename DataType, typename HintType>
|
|
289
|
+
static void DefaultFiniWithHint(Env, DataType* data, HintType* hint);
|
|
290
|
+
#endif // NAPI_VERSION > 5
|
|
163
291
|
public:
|
|
164
292
|
Env(napi_env env);
|
|
165
293
|
|
|
@@ -170,11 +298,61 @@ namespace Napi {
|
|
|
170
298
|
Value Null() const;
|
|
171
299
|
|
|
172
300
|
bool IsExceptionPending() const;
|
|
173
|
-
Error GetAndClearPendingException();
|
|
301
|
+
Error GetAndClearPendingException() const;
|
|
302
|
+
|
|
303
|
+
MaybeOrValue<Value> RunScript(const char* utf8script) const;
|
|
304
|
+
MaybeOrValue<Value> RunScript(const std::string& utf8script) const;
|
|
305
|
+
MaybeOrValue<Value> RunScript(String script) const;
|
|
306
|
+
|
|
307
|
+
#if NAPI_VERSION > 2
|
|
308
|
+
template <typename Hook>
|
|
309
|
+
CleanupHook<Hook> AddCleanupHook(Hook hook);
|
|
310
|
+
|
|
311
|
+
template <typename Hook, typename Arg>
|
|
312
|
+
CleanupHook<Hook, Arg> AddCleanupHook(Hook hook, Arg* arg);
|
|
313
|
+
#endif // NAPI_VERSION > 2
|
|
314
|
+
|
|
315
|
+
#if NAPI_VERSION > 5
|
|
316
|
+
template <typename T>
|
|
317
|
+
T* GetInstanceData() const;
|
|
318
|
+
|
|
319
|
+
template <typename T> using Finalizer = void (*)(Env, T*);
|
|
320
|
+
template <typename T, Finalizer<T> fini = Env::DefaultFini<T>>
|
|
321
|
+
void SetInstanceData(T* data) const;
|
|
322
|
+
|
|
323
|
+
template <typename DataType, typename HintType>
|
|
324
|
+
using FinalizerWithHint = void (*)(Env, DataType*, HintType*);
|
|
325
|
+
template <typename DataType,
|
|
326
|
+
typename HintType,
|
|
327
|
+
FinalizerWithHint<DataType, HintType> fini =
|
|
328
|
+
Env::DefaultFiniWithHint<DataType, HintType>>
|
|
329
|
+
void SetInstanceData(DataType* data, HintType* hint) const;
|
|
330
|
+
#endif // NAPI_VERSION > 5
|
|
174
331
|
|
|
175
332
|
private:
|
|
176
333
|
napi_env _env;
|
|
334
|
+
|
|
335
|
+
#if NAPI_VERSION > 2
|
|
336
|
+
template <typename Hook, typename Arg>
|
|
337
|
+
class CleanupHook {
|
|
338
|
+
public:
|
|
339
|
+
CleanupHook(Env env, Hook hook, Arg* arg);
|
|
340
|
+
CleanupHook(Env env, Hook hook);
|
|
341
|
+
bool Remove(Env env);
|
|
342
|
+
bool IsEmpty() const;
|
|
343
|
+
|
|
344
|
+
private:
|
|
345
|
+
static inline void Wrapper(void* data) NAPI_NOEXCEPT;
|
|
346
|
+
static inline void WrapperWithArg(void* data) NAPI_NOEXCEPT;
|
|
347
|
+
|
|
348
|
+
void (*wrapper)(void* arg);
|
|
349
|
+
struct CleanupData {
|
|
350
|
+
Hook hook;
|
|
351
|
+
Arg* arg;
|
|
352
|
+
} * data;
|
|
353
|
+
};
|
|
177
354
|
};
|
|
355
|
+
#endif // NAPI_VERSION > 2
|
|
178
356
|
|
|
179
357
|
/// A JavaScript value of unknown type.
|
|
180
358
|
///
|
|
@@ -190,7 +368,8 @@ namespace Napi {
|
|
|
190
368
|
class Value {
|
|
191
369
|
public:
|
|
192
370
|
Value(); ///< Creates a new _empty_ Value instance.
|
|
193
|
-
Value(napi_env env,
|
|
371
|
+
Value(napi_env env,
|
|
372
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
194
373
|
|
|
195
374
|
/// Creates a JS value from a C++ primitive.
|
|
196
375
|
///
|
|
@@ -207,7 +386,7 @@ namespace Napi {
|
|
|
207
386
|
template <typename T>
|
|
208
387
|
static Value From(napi_env env, const T& value);
|
|
209
388
|
|
|
210
|
-
/// Converts to a
|
|
389
|
+
/// Converts to a Node-API value primitive.
|
|
211
390
|
///
|
|
212
391
|
/// If the instance is _empty_, this returns `nullptr`.
|
|
213
392
|
operator napi_value() const;
|
|
@@ -241,11 +420,12 @@ namespace Napi {
|
|
|
241
420
|
bool IsNull() const; ///< Tests if a value is a null JavaScript value.
|
|
242
421
|
bool IsBoolean() const; ///< Tests if a value is a JavaScript boolean.
|
|
243
422
|
bool IsNumber() const; ///< Tests if a value is a JavaScript number.
|
|
244
|
-
|
|
245
|
-
// released in once it is no longer experimental
|
|
246
|
-
#if (NAPI_VERSION > 2147483646)
|
|
423
|
+
#if NAPI_VERSION > 5
|
|
247
424
|
bool IsBigInt() const; ///< Tests if a value is a JavaScript bigint.
|
|
248
|
-
#endif //
|
|
425
|
+
#endif // NAPI_VERSION > 5
|
|
426
|
+
#if (NAPI_VERSION > 4)
|
|
427
|
+
bool IsDate() const; ///< Tests if a value is a JavaScript date.
|
|
428
|
+
#endif
|
|
249
429
|
bool IsString() const; ///< Tests if a value is a JavaScript string.
|
|
250
430
|
bool IsSymbol() const; ///< Tests if a value is a JavaScript symbol.
|
|
251
431
|
bool IsArray() const; ///< Tests if a value is a JavaScript array.
|
|
@@ -264,12 +444,16 @@ namespace Napi {
|
|
|
264
444
|
/// value type will throw `Napi::Error`.
|
|
265
445
|
template <typename T> T As() const;
|
|
266
446
|
|
|
267
|
-
Boolean ToBoolean()
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
447
|
+
MaybeOrValue<Boolean> ToBoolean()
|
|
448
|
+
const; ///< Coerces a value to a JavaScript boolean.
|
|
449
|
+
MaybeOrValue<Number> ToNumber()
|
|
450
|
+
const; ///< Coerces a value to a JavaScript number.
|
|
451
|
+
MaybeOrValue<String> ToString()
|
|
452
|
+
const; ///< Coerces a value to a JavaScript string.
|
|
453
|
+
MaybeOrValue<Object> ToObject()
|
|
454
|
+
const; ///< Coerces a value to a JavaScript object.
|
|
271
455
|
|
|
272
|
-
|
|
456
|
+
protected:
|
|
273
457
|
/// !cond INTERNAL
|
|
274
458
|
napi_env _env;
|
|
275
459
|
napi_value _value;
|
|
@@ -279,200 +463,255 @@ namespace Napi {
|
|
|
279
463
|
/// A JavaScript boolean value.
|
|
280
464
|
class Boolean : public Value {
|
|
281
465
|
public:
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
);
|
|
466
|
+
static Boolean New(napi_env env, ///< Node-API environment
|
|
467
|
+
bool value ///< Boolean value
|
|
468
|
+
);
|
|
286
469
|
|
|
287
|
-
|
|
288
|
-
|
|
470
|
+
Boolean(); ///< Creates a new _empty_ Boolean instance.
|
|
471
|
+
Boolean(napi_env env,
|
|
472
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
289
473
|
|
|
290
|
-
|
|
291
|
-
|
|
474
|
+
operator bool() const; ///< Converts a Boolean value to a boolean primitive.
|
|
475
|
+
bool Value() const; ///< Converts a Boolean value to a boolean primitive.
|
|
292
476
|
};
|
|
293
477
|
|
|
294
478
|
/// A JavaScript number value.
|
|
295
479
|
class Number : public Value {
|
|
296
480
|
public:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
481
|
+
static Number New(napi_env env, ///< Node-API environment
|
|
482
|
+
double value ///< Number value
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
Number(); ///< Creates a new _empty_ Number instance.
|
|
486
|
+
Number(napi_env env,
|
|
487
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
488
|
+
|
|
489
|
+
operator int32_t()
|
|
490
|
+
const; ///< Converts a Number value to a 32-bit signed integer value.
|
|
491
|
+
operator uint32_t()
|
|
492
|
+
const; ///< Converts a Number value to a 32-bit unsigned integer value.
|
|
493
|
+
operator int64_t()
|
|
494
|
+
const; ///< Converts a Number value to a 64-bit signed integer value.
|
|
495
|
+
operator float()
|
|
496
|
+
const; ///< Converts a Number value to a 32-bit floating-point value.
|
|
497
|
+
operator double()
|
|
498
|
+
const; ///< Converts a Number value to a 64-bit floating-point value.
|
|
499
|
+
|
|
500
|
+
int32_t Int32Value()
|
|
501
|
+
const; ///< Converts a Number value to a 32-bit signed integer value.
|
|
502
|
+
uint32_t Uint32Value()
|
|
503
|
+
const; ///< Converts a Number value to a 32-bit unsigned integer value.
|
|
504
|
+
int64_t Int64Value()
|
|
505
|
+
const; ///< Converts a Number value to a 64-bit signed integer value.
|
|
506
|
+
float FloatValue()
|
|
507
|
+
const; ///< Converts a Number value to a 32-bit floating-point value.
|
|
508
|
+
double DoubleValue()
|
|
509
|
+
const; ///< Converts a Number value to a 64-bit floating-point value.
|
|
316
510
|
};
|
|
317
511
|
|
|
318
|
-
|
|
319
|
-
// released in once it is no longer experimental
|
|
320
|
-
#if (NAPI_VERSION > 2147483646)
|
|
512
|
+
#if NAPI_VERSION > 5
|
|
321
513
|
/// A JavaScript bigint value.
|
|
322
514
|
class BigInt : public Value {
|
|
323
515
|
public:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
516
|
+
static BigInt New(napi_env env, ///< Node-API environment
|
|
517
|
+
int64_t value ///< Number value
|
|
518
|
+
);
|
|
519
|
+
static BigInt New(napi_env env, ///< Node-API environment
|
|
520
|
+
uint64_t value ///< Number value
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
/// Creates a new BigInt object using a specified sign bit and a
|
|
524
|
+
/// specified list of digits/words.
|
|
525
|
+
/// The resulting number is calculated as:
|
|
526
|
+
/// (-1)^sign_bit * (words[0] * (2^64)^0 + words[1] * (2^64)^1 + ...)
|
|
527
|
+
static BigInt New(napi_env env, ///< Node-API environment
|
|
528
|
+
int sign_bit, ///< Sign bit. 1 if negative.
|
|
529
|
+
size_t word_count, ///< Number of words in array
|
|
530
|
+
const uint64_t* words ///< Array of words
|
|
531
|
+
);
|
|
532
|
+
|
|
533
|
+
BigInt(); ///< Creates a new _empty_ BigInt instance.
|
|
534
|
+
BigInt(napi_env env,
|
|
535
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
536
|
+
|
|
537
|
+
int64_t Int64Value(bool* lossless)
|
|
538
|
+
const; ///< Converts a BigInt value to a 64-bit signed integer value.
|
|
539
|
+
uint64_t Uint64Value(bool* lossless)
|
|
540
|
+
const; ///< Converts a BigInt value to a 64-bit unsigned integer value.
|
|
541
|
+
|
|
542
|
+
size_t WordCount() const; ///< The number of 64-bit words needed to store
|
|
543
|
+
///< the result of ToWords().
|
|
544
|
+
|
|
545
|
+
/// Writes the contents of this BigInt to a specified memory location.
|
|
546
|
+
/// `sign_bit` must be provided and will be set to 1 if this BigInt is
|
|
547
|
+
/// negative.
|
|
548
|
+
/// `*word_count` has to be initialized to the length of the `words` array.
|
|
549
|
+
/// Upon return, it will be set to the actual number of words that would
|
|
550
|
+
/// be needed to store this BigInt (i.e. the return value of `WordCount()`).
|
|
551
|
+
void ToWords(int* sign_bit, size_t* word_count, uint64_t* words);
|
|
552
|
+
};
|
|
553
|
+
#endif // NAPI_VERSION > 5
|
|
346
554
|
|
|
347
|
-
|
|
348
|
-
|
|
555
|
+
#if (NAPI_VERSION > 4)
|
|
556
|
+
/// A JavaScript date value.
|
|
557
|
+
class Date : public Value {
|
|
558
|
+
public:
|
|
559
|
+
/// Creates a new Date value from a double primitive.
|
|
560
|
+
static Date New(napi_env env, ///< Node-API environment
|
|
561
|
+
double value ///< Number value
|
|
562
|
+
);
|
|
349
563
|
|
|
350
|
-
|
|
564
|
+
Date(); ///< Creates a new _empty_ Date instance.
|
|
565
|
+
Date(napi_env env, napi_value value); ///< Wraps a Node-API value primitive.
|
|
566
|
+
operator double() const; ///< Converts a Date value to double primitive
|
|
351
567
|
|
|
352
|
-
|
|
353
|
-
/// `sign_bit` must be provided and will be set to 1 if this BigInt is negative.
|
|
354
|
-
/// `*word_count` has to be initialized to the length of the `words` array.
|
|
355
|
-
/// Upon return, it will be set to the actual number of words that would
|
|
356
|
-
/// be needed to store this BigInt (i.e. the return value of `WordCount()`).
|
|
357
|
-
void ToWords(int* sign_bit, size_t* word_count, uint64_t* words);
|
|
568
|
+
double ValueOf() const; ///< Converts a Date value to a double primitive.
|
|
358
569
|
};
|
|
359
|
-
#endif
|
|
570
|
+
#endif
|
|
360
571
|
|
|
361
572
|
/// A JavaScript string or symbol value (that can be used as a property name).
|
|
362
573
|
class Name : public Value {
|
|
363
574
|
public:
|
|
364
575
|
Name(); ///< Creates a new _empty_ Name instance.
|
|
365
|
-
Name(napi_env env,
|
|
576
|
+
Name(napi_env env,
|
|
577
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
366
578
|
};
|
|
367
579
|
|
|
368
580
|
/// A JavaScript string value.
|
|
369
581
|
class String : public Name {
|
|
370
582
|
public:
|
|
371
583
|
/// Creates a new String value from a UTF-8 encoded C++ string.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
584
|
+
static String New(napi_env env, ///< Node-API environment
|
|
585
|
+
const std::string& value ///< UTF-8 encoded C++ string
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
/// Creates a new String value from a UTF-16 encoded C++ string.
|
|
589
|
+
static String New(napi_env env, ///< Node-API environment
|
|
590
|
+
const std::u16string& value ///< UTF-16 encoded C++ string
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
/// Creates a new String value from a UTF-8 encoded C string.
|
|
594
|
+
static String New(
|
|
595
|
+
napi_env env, ///< Node-API environment
|
|
596
|
+
const char* value ///< UTF-8 encoded null-terminated C string
|
|
597
|
+
);
|
|
598
|
+
|
|
599
|
+
/// Creates a new String value from a UTF-16 encoded C string.
|
|
600
|
+
static String New(
|
|
601
|
+
napi_env env, ///< Node-API environment
|
|
602
|
+
const char16_t* value ///< UTF-16 encoded null-terminated C string
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
/// Creates a new String value from a UTF-8 encoded C string with specified
|
|
606
|
+
/// length.
|
|
607
|
+
static String New(napi_env env, ///< Node-API environment
|
|
608
|
+
const char* value, ///< UTF-8 encoded C string (not
|
|
609
|
+
///< necessarily null-terminated)
|
|
610
|
+
size_t length ///< length of the string in bytes
|
|
611
|
+
);
|
|
612
|
+
|
|
613
|
+
/// Creates a new String value from a UTF-16 encoded C string with specified
|
|
614
|
+
/// length.
|
|
615
|
+
static String New(
|
|
616
|
+
napi_env env, ///< Node-API environment
|
|
617
|
+
const char16_t* value, ///< UTF-16 encoded C string (not necessarily
|
|
618
|
+
///< null-terminated)
|
|
619
|
+
size_t length ///< Length of the string in 2-byte code units
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
/// Creates a new String based on the original object's type.
|
|
623
|
+
///
|
|
624
|
+
/// `value` may be any of:
|
|
625
|
+
/// - const char* (encoded using UTF-8, null-terminated)
|
|
626
|
+
/// - const char16_t* (encoded using UTF-16-LE, null-terminated)
|
|
627
|
+
/// - std::string (encoded using UTF-8)
|
|
628
|
+
/// - std::u16string
|
|
629
|
+
template <typename T>
|
|
630
|
+
static String From(napi_env env, const T& value);
|
|
631
|
+
|
|
632
|
+
String(); ///< Creates a new _empty_ String instance.
|
|
633
|
+
String(napi_env env,
|
|
634
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
635
|
+
|
|
636
|
+
operator std::string()
|
|
637
|
+
const; ///< Converts a String value to a UTF-8 encoded C++ string.
|
|
638
|
+
operator std::u16string()
|
|
639
|
+
const; ///< Converts a String value to a UTF-16 encoded C++ string.
|
|
640
|
+
std::string Utf8Value()
|
|
641
|
+
const; ///< Converts a String value to a UTF-8 encoded C++ string.
|
|
642
|
+
std::u16string Utf16Value()
|
|
643
|
+
const; ///< Converts a String value to a UTF-16 encoded C++ string.
|
|
426
644
|
};
|
|
427
645
|
|
|
428
646
|
/// A JavaScript symbol value.
|
|
429
647
|
class Symbol : public Name {
|
|
430
648
|
public:
|
|
431
649
|
/// Creates a new Symbol value with an optional description.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
650
|
+
static Symbol New(
|
|
651
|
+
napi_env env, ///< Node-API environment
|
|
652
|
+
const char* description =
|
|
653
|
+
nullptr ///< Optional UTF-8 encoded null-terminated C string
|
|
654
|
+
/// describing the symbol
|
|
655
|
+
);
|
|
656
|
+
|
|
657
|
+
/// Creates a new Symbol value with a description.
|
|
658
|
+
static Symbol New(
|
|
659
|
+
napi_env env, ///< Node-API environment
|
|
660
|
+
const std::string&
|
|
661
|
+
description ///< UTF-8 encoded C++ string describing the symbol
|
|
662
|
+
);
|
|
663
|
+
|
|
664
|
+
/// Creates a new Symbol value with a description.
|
|
665
|
+
static Symbol New(napi_env env, ///< Node-API environment
|
|
666
|
+
String description ///< String value describing the symbol
|
|
667
|
+
);
|
|
668
|
+
|
|
669
|
+
/// Creates a new Symbol value with a description.
|
|
670
|
+
static Symbol New(
|
|
671
|
+
napi_env env, ///< Node-API environment
|
|
672
|
+
napi_value description ///< String value describing the symbol
|
|
673
|
+
);
|
|
674
|
+
|
|
675
|
+
/// Get a public Symbol (e.g. Symbol.iterator).
|
|
676
|
+
static MaybeOrValue<Symbol> WellKnown(napi_env, const std::string& name);
|
|
677
|
+
|
|
678
|
+
// Create a symbol in the global registry, UTF-8 Encoded cpp string
|
|
679
|
+
static MaybeOrValue<Symbol> For(napi_env env,
|
|
680
|
+
const std::string& description);
|
|
681
|
+
|
|
682
|
+
// Create a symbol in the global registry, C style string (null terminated)
|
|
683
|
+
static MaybeOrValue<Symbol> For(napi_env env, const char* description);
|
|
684
|
+
|
|
685
|
+
// Create a symbol in the global registry, String value describing the symbol
|
|
686
|
+
static MaybeOrValue<Symbol> For(napi_env env, String description);
|
|
687
|
+
|
|
688
|
+
// Create a symbol in the global registry, napi_value describing the symbol
|
|
689
|
+
static MaybeOrValue<Symbol> For(napi_env env, napi_value description);
|
|
690
|
+
|
|
691
|
+
Symbol(); ///< Creates a new _empty_ Symbol instance.
|
|
692
|
+
Symbol(napi_env env,
|
|
693
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
461
694
|
};
|
|
462
695
|
|
|
463
696
|
/// A JavaScript object value.
|
|
464
697
|
class Object : public Value {
|
|
465
698
|
public:
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
699
|
+
/// Enables property and element assignments using indexing syntax.
|
|
700
|
+
///
|
|
701
|
+
/// This is a convenient helper to get and set object properties. As
|
|
702
|
+
/// getting and setting object properties may throw with JavaScript
|
|
703
|
+
/// exceptions, it is notable that these operations may fail.
|
|
704
|
+
/// When NODE_ADDON_API_ENABLE_MAYBE is defined, the process will abort
|
|
705
|
+
/// on JavaScript exceptions.
|
|
706
|
+
///
|
|
707
|
+
/// Example:
|
|
708
|
+
///
|
|
709
|
+
/// Napi::Value propertyValue = object1['A'];
|
|
710
|
+
/// object2['A'] = propertyValue;
|
|
711
|
+
/// Napi::Value elementValue = array[0];
|
|
712
|
+
/// array[1] = elementValue;
|
|
713
|
+
template <typename Key>
|
|
714
|
+
class PropertyLValue {
|
|
476
715
|
public:
|
|
477
716
|
/// Converts an L-value to a value.
|
|
478
717
|
operator Value() const;
|
|
@@ -490,201 +729,249 @@ namespace Napi {
|
|
|
490
729
|
Key _key;
|
|
491
730
|
|
|
492
731
|
friend class Napi::Object;
|
|
493
|
-
|
|
732
|
+
};
|
|
494
733
|
|
|
495
734
|
/// Creates a new Object value.
|
|
496
|
-
static Object New(
|
|
497
|
-
napi_env env ///< N-API environment
|
|
735
|
+
static Object New(napi_env env ///< Node-API environment
|
|
498
736
|
);
|
|
499
737
|
|
|
500
738
|
Object(); ///< Creates a new _empty_ Object instance.
|
|
501
|
-
Object(napi_env env,
|
|
739
|
+
Object(napi_env env,
|
|
740
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
502
741
|
|
|
503
742
|
/// Gets or sets a named property.
|
|
504
|
-
PropertyLValue<std::string> operator
|
|
505
|
-
|
|
743
|
+
PropertyLValue<std::string> operator[](
|
|
744
|
+
const char* utf8name ///< UTF-8 encoded null-terminated property name
|
|
506
745
|
);
|
|
507
746
|
|
|
508
747
|
/// Gets or sets a named property.
|
|
509
|
-
PropertyLValue<std::string> operator
|
|
510
|
-
|
|
748
|
+
PropertyLValue<std::string> operator[](
|
|
749
|
+
const std::string& utf8name ///< UTF-8 encoded property name
|
|
511
750
|
);
|
|
512
751
|
|
|
513
752
|
/// Gets or sets an indexed property or array element.
|
|
514
|
-
PropertyLValue<uint32_t> operator
|
|
515
|
-
|
|
753
|
+
PropertyLValue<uint32_t> operator[](
|
|
754
|
+
uint32_t index /// Property / element index
|
|
516
755
|
);
|
|
517
756
|
|
|
757
|
+
/// Gets or sets an indexed property or array element.
|
|
758
|
+
PropertyLValue<Value> operator[](Value index /// Property / element index
|
|
759
|
+
) const;
|
|
760
|
+
|
|
518
761
|
/// Gets a named property.
|
|
519
|
-
Value operator
|
|
520
|
-
|
|
762
|
+
MaybeOrValue<Value> operator[](
|
|
763
|
+
const char* utf8name ///< UTF-8 encoded null-terminated property name
|
|
521
764
|
) const;
|
|
522
765
|
|
|
523
766
|
/// Gets a named property.
|
|
524
|
-
Value operator
|
|
525
|
-
|
|
767
|
+
MaybeOrValue<Value> operator[](
|
|
768
|
+
const std::string& utf8name ///< UTF-8 encoded property name
|
|
526
769
|
) const;
|
|
527
770
|
|
|
528
771
|
/// Gets an indexed property or array element.
|
|
529
|
-
Value operator
|
|
530
|
-
uint32_t index ///< Property / element index
|
|
772
|
+
MaybeOrValue<Value> operator[](uint32_t index ///< Property / element index
|
|
531
773
|
) const;
|
|
532
774
|
|
|
533
775
|
/// Checks whether a property is present.
|
|
534
|
-
bool Has(
|
|
535
|
-
napi_value key ///< Property key primitive
|
|
776
|
+
MaybeOrValue<bool> Has(napi_value key ///< Property key primitive
|
|
536
777
|
) const;
|
|
537
778
|
|
|
538
779
|
/// Checks whether a property is present.
|
|
539
|
-
bool Has(
|
|
540
|
-
Value key ///< Property key
|
|
780
|
+
MaybeOrValue<bool> Has(Value key ///< Property key
|
|
541
781
|
) const;
|
|
542
782
|
|
|
543
783
|
/// Checks whether a named property is present.
|
|
544
|
-
bool Has(
|
|
545
|
-
|
|
784
|
+
MaybeOrValue<bool> Has(
|
|
785
|
+
const char* utf8name ///< UTF-8 encoded null-terminated property name
|
|
546
786
|
) const;
|
|
547
787
|
|
|
548
788
|
/// Checks whether a named property is present.
|
|
549
|
-
bool Has(
|
|
550
|
-
|
|
789
|
+
MaybeOrValue<bool> Has(
|
|
790
|
+
const std::string& utf8name ///< UTF-8 encoded property name
|
|
551
791
|
) const;
|
|
552
792
|
|
|
553
793
|
/// Checks whether a own property is present.
|
|
554
|
-
bool HasOwnProperty(
|
|
555
|
-
|
|
794
|
+
MaybeOrValue<bool> HasOwnProperty(
|
|
795
|
+
napi_value key ///< Property key primitive
|
|
556
796
|
) const;
|
|
557
797
|
|
|
558
798
|
/// Checks whether a own property is present.
|
|
559
|
-
bool HasOwnProperty(
|
|
560
|
-
Value key ///< Property key
|
|
799
|
+
MaybeOrValue<bool> HasOwnProperty(Value key ///< Property key
|
|
561
800
|
) const;
|
|
562
801
|
|
|
563
802
|
/// Checks whether a own property is present.
|
|
564
|
-
bool HasOwnProperty(
|
|
565
|
-
|
|
803
|
+
MaybeOrValue<bool> HasOwnProperty(
|
|
804
|
+
const char* utf8name ///< UTF-8 encoded null-terminated property name
|
|
566
805
|
) const;
|
|
567
806
|
|
|
568
807
|
/// Checks whether a own property is present.
|
|
569
|
-
bool HasOwnProperty(
|
|
570
|
-
|
|
808
|
+
MaybeOrValue<bool> HasOwnProperty(
|
|
809
|
+
const std::string& utf8name ///< UTF-8 encoded property name
|
|
571
810
|
) const;
|
|
572
811
|
|
|
573
812
|
/// Gets a property.
|
|
574
|
-
Value Get(
|
|
575
|
-
napi_value key ///< Property key primitive
|
|
813
|
+
MaybeOrValue<Value> Get(napi_value key ///< Property key primitive
|
|
576
814
|
) const;
|
|
577
815
|
|
|
578
816
|
/// Gets a property.
|
|
579
|
-
Value Get(
|
|
580
|
-
Value key ///< Property key
|
|
817
|
+
MaybeOrValue<Value> Get(Value key ///< Property key
|
|
581
818
|
) const;
|
|
582
819
|
|
|
583
820
|
/// Gets a named property.
|
|
584
|
-
Value Get(
|
|
585
|
-
|
|
821
|
+
MaybeOrValue<Value> Get(
|
|
822
|
+
const char* utf8name ///< UTF-8 encoded null-terminated property name
|
|
586
823
|
) const;
|
|
587
824
|
|
|
588
825
|
/// Gets a named property.
|
|
589
|
-
Value Get(
|
|
590
|
-
|
|
826
|
+
MaybeOrValue<Value> Get(
|
|
827
|
+
const std::string& utf8name ///< UTF-8 encoded property name
|
|
591
828
|
) const;
|
|
592
829
|
|
|
593
830
|
/// Sets a property.
|
|
594
831
|
template <typename ValueType>
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
);
|
|
832
|
+
MaybeOrValue<bool> Set(napi_value key, ///< Property key primitive
|
|
833
|
+
const ValueType& value ///< Property value primitive
|
|
834
|
+
) const;
|
|
599
835
|
|
|
600
836
|
/// Sets a property.
|
|
601
837
|
template <typename ValueType>
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
);
|
|
838
|
+
MaybeOrValue<bool> Set(Value key, ///< Property key
|
|
839
|
+
const ValueType& value ///< Property value
|
|
840
|
+
) const;
|
|
606
841
|
|
|
607
842
|
/// Sets a named property.
|
|
608
843
|
template <typename ValueType>
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
);
|
|
844
|
+
MaybeOrValue<bool> Set(
|
|
845
|
+
const char* utf8name, ///< UTF-8 encoded null-terminated property name
|
|
846
|
+
const ValueType& value) const;
|
|
613
847
|
|
|
614
848
|
/// Sets a named property.
|
|
615
849
|
template <typename ValueType>
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
);
|
|
850
|
+
MaybeOrValue<bool> Set(
|
|
851
|
+
const std::string& utf8name, ///< UTF-8 encoded property name
|
|
852
|
+
const ValueType& value ///< Property value primitive
|
|
853
|
+
) const;
|
|
620
854
|
|
|
621
855
|
/// Delete property.
|
|
622
|
-
bool Delete(
|
|
623
|
-
|
|
624
|
-
);
|
|
856
|
+
MaybeOrValue<bool> Delete(napi_value key ///< Property key primitive
|
|
857
|
+
) const;
|
|
625
858
|
|
|
626
859
|
/// Delete property.
|
|
627
|
-
bool Delete(
|
|
628
|
-
|
|
629
|
-
);
|
|
860
|
+
MaybeOrValue<bool> Delete(Value key ///< Property key
|
|
861
|
+
) const;
|
|
630
862
|
|
|
631
863
|
/// Delete property.
|
|
632
|
-
bool Delete(
|
|
633
|
-
|
|
634
|
-
);
|
|
864
|
+
MaybeOrValue<bool> Delete(
|
|
865
|
+
const char* utf8name ///< UTF-8 encoded null-terminated property name
|
|
866
|
+
) const;
|
|
635
867
|
|
|
636
868
|
/// Delete property.
|
|
637
|
-
bool Delete(
|
|
638
|
-
|
|
639
|
-
);
|
|
869
|
+
MaybeOrValue<bool> Delete(
|
|
870
|
+
const std::string& utf8name ///< UTF-8 encoded property name
|
|
871
|
+
) const;
|
|
640
872
|
|
|
641
873
|
/// Checks whether an indexed property is present.
|
|
642
|
-
bool Has(
|
|
643
|
-
uint32_t index ///< Property / element index
|
|
874
|
+
MaybeOrValue<bool> Has(uint32_t index ///< Property / element index
|
|
644
875
|
) const;
|
|
645
876
|
|
|
646
877
|
/// Gets an indexed property or array element.
|
|
647
|
-
Value Get(
|
|
648
|
-
uint32_t index ///< Property / element index
|
|
878
|
+
MaybeOrValue<Value> Get(uint32_t index ///< Property / element index
|
|
649
879
|
) const;
|
|
650
880
|
|
|
651
881
|
/// Sets an indexed property or array element.
|
|
652
882
|
template <typename ValueType>
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
);
|
|
883
|
+
MaybeOrValue<bool> Set(uint32_t index, ///< Property / element index
|
|
884
|
+
const ValueType& value ///< Property value primitive
|
|
885
|
+
) const;
|
|
657
886
|
|
|
658
887
|
/// Deletes an indexed property or array element.
|
|
659
|
-
bool Delete(
|
|
660
|
-
|
|
661
|
-
);
|
|
888
|
+
MaybeOrValue<bool> Delete(uint32_t index ///< Property / element index
|
|
889
|
+
) const;
|
|
662
890
|
|
|
663
|
-
|
|
891
|
+
/// This operation can fail in case of Proxy.[[OwnPropertyKeys]] and
|
|
892
|
+
/// Proxy.[[GetOwnProperty]] calling into JavaScript. See:
|
|
893
|
+
/// -
|
|
894
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
|
|
895
|
+
/// -
|
|
896
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p
|
|
897
|
+
MaybeOrValue<Array> GetPropertyNames() const; ///< Get all property names
|
|
664
898
|
|
|
665
899
|
/// Defines a property on the object.
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
900
|
+
///
|
|
901
|
+
/// This operation can fail in case of Proxy.[[DefineOwnProperty]] calling
|
|
902
|
+
/// into JavaScript. See
|
|
903
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc
|
|
904
|
+
MaybeOrValue<bool> DefineProperty(
|
|
905
|
+
const PropertyDescriptor&
|
|
906
|
+
property ///< Descriptor for the property to be defined
|
|
907
|
+
) const;
|
|
669
908
|
|
|
670
909
|
/// Defines properties on the object.
|
|
671
|
-
|
|
672
|
-
|
|
910
|
+
///
|
|
911
|
+
/// This operation can fail in case of Proxy.[[DefineOwnProperty]] calling
|
|
912
|
+
/// into JavaScript. See
|
|
913
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc
|
|
914
|
+
MaybeOrValue<bool> DefineProperties(
|
|
915
|
+
const std::initializer_list<PropertyDescriptor>& properties
|
|
673
916
|
///< List of descriptors for the properties to be defined
|
|
674
|
-
);
|
|
917
|
+
) const;
|
|
675
918
|
|
|
676
919
|
/// Defines properties on the object.
|
|
677
|
-
|
|
678
|
-
|
|
920
|
+
///
|
|
921
|
+
/// This operation can fail in case of Proxy.[[DefineOwnProperty]] calling
|
|
922
|
+
/// into JavaScript. See
|
|
923
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc
|
|
924
|
+
MaybeOrValue<bool> DefineProperties(
|
|
925
|
+
const std::vector<PropertyDescriptor>& properties
|
|
679
926
|
///< Vector of descriptors for the properties to be defined
|
|
680
|
-
);
|
|
927
|
+
) const;
|
|
681
928
|
|
|
682
929
|
/// Checks if an object is an instance created by a constructor function.
|
|
683
930
|
///
|
|
684
931
|
/// This is equivalent to the JavaScript `instanceof` operator.
|
|
685
|
-
|
|
686
|
-
|
|
932
|
+
///
|
|
933
|
+
/// This operation can fail in case of Proxy.[[GetPrototypeOf]] calling into
|
|
934
|
+
/// JavaScript.
|
|
935
|
+
/// See
|
|
936
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof
|
|
937
|
+
MaybeOrValue<bool> InstanceOf(
|
|
938
|
+
const Function& constructor ///< Constructor function
|
|
687
939
|
) const;
|
|
940
|
+
|
|
941
|
+
template <typename Finalizer, typename T>
|
|
942
|
+
inline void AddFinalizer(Finalizer finalizeCallback, T* data) const;
|
|
943
|
+
|
|
944
|
+
template <typename Finalizer, typename T, typename Hint>
|
|
945
|
+
inline void AddFinalizer(Finalizer finalizeCallback,
|
|
946
|
+
T* data,
|
|
947
|
+
Hint* finalizeHint) const;
|
|
948
|
+
|
|
949
|
+
#ifdef NAPI_CPP_EXCEPTIONS
|
|
950
|
+
class const_iterator;
|
|
951
|
+
|
|
952
|
+
inline const_iterator begin() const;
|
|
953
|
+
|
|
954
|
+
inline const_iterator end() const;
|
|
955
|
+
|
|
956
|
+
class iterator;
|
|
957
|
+
|
|
958
|
+
inline iterator begin();
|
|
959
|
+
|
|
960
|
+
inline iterator end();
|
|
961
|
+
#endif // NAPI_CPP_EXCEPTIONS
|
|
962
|
+
|
|
963
|
+
#if NAPI_VERSION >= 8
|
|
964
|
+
/// This operation can fail in case of Proxy.[[GetPrototypeOf]] calling into
|
|
965
|
+
/// JavaScript.
|
|
966
|
+
/// See
|
|
967
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof
|
|
968
|
+
MaybeOrValue<bool> Freeze() const;
|
|
969
|
+
/// This operation can fail in case of Proxy.[[GetPrototypeOf]] calling into
|
|
970
|
+
/// JavaScript.
|
|
971
|
+
/// See
|
|
972
|
+
/// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof
|
|
973
|
+
MaybeOrValue<bool> Seal() const;
|
|
974
|
+
#endif // NAPI_VERSION >= 8
|
|
688
975
|
};
|
|
689
976
|
|
|
690
977
|
template <typename T>
|
|
@@ -721,57 +1008,119 @@ namespace Napi {
|
|
|
721
1008
|
uint32_t Length() const;
|
|
722
1009
|
};
|
|
723
1010
|
|
|
724
|
-
|
|
725
|
-
class
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
static ArrayBuffer New(
|
|
729
|
-
napi_env env, ///< N-API environment
|
|
730
|
-
size_t byteLength ///< Length of the buffer to be allocated, in bytes
|
|
731
|
-
);
|
|
1011
|
+
#ifdef NAPI_CPP_EXCEPTIONS
|
|
1012
|
+
class Object::const_iterator {
|
|
1013
|
+
private:
|
|
1014
|
+
enum class Type { BEGIN, END };
|
|
732
1015
|
|
|
733
|
-
|
|
734
|
-
static ArrayBuffer New(
|
|
735
|
-
napi_env env, ///< N-API environment
|
|
736
|
-
void* externalData, ///< Pointer to the external buffer to be used by the array
|
|
737
|
-
size_t byteLength ///< Length of the external buffer to be used by the array, in bytes
|
|
738
|
-
);
|
|
1016
|
+
inline const_iterator(const Object* object, const Type type);
|
|
739
1017
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
static ArrayBuffer New(
|
|
743
|
-
napi_env env, ///< N-API environment
|
|
744
|
-
void* externalData, ///< Pointer to the external buffer to be used by the array
|
|
745
|
-
size_t byteLength, ///< Length of the external buffer to be used by the array,
|
|
746
|
-
/// in bytes
|
|
747
|
-
Finalizer finalizeCallback ///< Function to be called when the array buffer is destroyed;
|
|
748
|
-
/// must implement `void operator()(Env env, void* externalData)`
|
|
749
|
-
);
|
|
1018
|
+
public:
|
|
1019
|
+
inline const_iterator& operator++();
|
|
750
1020
|
|
|
751
|
-
|
|
752
|
-
template <typename Finalizer, typename Hint>
|
|
753
|
-
static ArrayBuffer New(
|
|
754
|
-
napi_env env, ///< N-API environment
|
|
755
|
-
void* externalData, ///< Pointer to the external buffer to be used by the array
|
|
756
|
-
size_t byteLength, ///< Length of the external buffer to be used by the array,
|
|
757
|
-
/// in bytes
|
|
758
|
-
Finalizer finalizeCallback, ///< Function to be called when the array buffer is destroyed;
|
|
759
|
-
/// must implement `void operator()(Env env, void* externalData, Hint* hint)`
|
|
760
|
-
Hint* finalizeHint ///< Hint (second parameter) to be passed to the finalize callback
|
|
761
|
-
);
|
|
1021
|
+
inline bool operator==(const const_iterator& other) const;
|
|
762
1022
|
|
|
763
|
-
|
|
764
|
-
ArrayBuffer(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
|
|
1023
|
+
inline bool operator!=(const const_iterator& other) const;
|
|
765
1024
|
|
|
766
|
-
|
|
767
|
-
|
|
1025
|
+
inline const std::pair<Value, Object::PropertyLValue<Value>> operator*()
|
|
1026
|
+
const;
|
|
768
1027
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1028
|
+
private:
|
|
1029
|
+
const Napi::Object* _object;
|
|
1030
|
+
Array _keys;
|
|
1031
|
+
uint32_t _index;
|
|
772
1032
|
|
|
773
|
-
|
|
774
|
-
|
|
1033
|
+
friend class Object;
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
class Object::iterator {
|
|
1037
|
+
private:
|
|
1038
|
+
enum class Type { BEGIN, END };
|
|
1039
|
+
|
|
1040
|
+
inline iterator(Object* object, const Type type);
|
|
1041
|
+
|
|
1042
|
+
public:
|
|
1043
|
+
inline iterator& operator++();
|
|
1044
|
+
|
|
1045
|
+
inline bool operator==(const iterator& other) const;
|
|
1046
|
+
|
|
1047
|
+
inline bool operator!=(const iterator& other) const;
|
|
1048
|
+
|
|
1049
|
+
inline std::pair<Value, Object::PropertyLValue<Value>> operator*();
|
|
1050
|
+
|
|
1051
|
+
private:
|
|
1052
|
+
Napi::Object* _object;
|
|
1053
|
+
Array _keys;
|
|
1054
|
+
uint32_t _index;
|
|
1055
|
+
|
|
1056
|
+
friend class Object;
|
|
1057
|
+
};
|
|
1058
|
+
#endif // NAPI_CPP_EXCEPTIONS
|
|
1059
|
+
|
|
1060
|
+
/// A JavaScript array buffer value.
|
|
1061
|
+
class ArrayBuffer : public Object {
|
|
1062
|
+
public:
|
|
1063
|
+
/// Creates a new ArrayBuffer instance over a new automatically-allocated buffer.
|
|
1064
|
+
static ArrayBuffer New(
|
|
1065
|
+
napi_env env, ///< Node-API environment
|
|
1066
|
+
size_t byteLength ///< Length of the buffer to be allocated, in bytes
|
|
1067
|
+
);
|
|
1068
|
+
|
|
1069
|
+
/// Creates a new ArrayBuffer instance, using an external buffer with
|
|
1070
|
+
/// specified byte length.
|
|
1071
|
+
static ArrayBuffer New(
|
|
1072
|
+
napi_env env, ///< Node-API environment
|
|
1073
|
+
void* externalData, ///< Pointer to the external buffer to be used by
|
|
1074
|
+
///< the array
|
|
1075
|
+
size_t byteLength ///< Length of the external buffer to be used by the
|
|
1076
|
+
///< array, in bytes
|
|
1077
|
+
);
|
|
1078
|
+
|
|
1079
|
+
/// Creates a new ArrayBuffer instance, using an external buffer with
|
|
1080
|
+
/// specified byte length.
|
|
1081
|
+
template <typename Finalizer>
|
|
1082
|
+
static ArrayBuffer New(
|
|
1083
|
+
napi_env env, ///< Node-API environment
|
|
1084
|
+
void* externalData, ///< Pointer to the external buffer to be used by
|
|
1085
|
+
///< the array
|
|
1086
|
+
size_t byteLength, ///< Length of the external buffer to be used by the
|
|
1087
|
+
///< array,
|
|
1088
|
+
/// in bytes
|
|
1089
|
+
Finalizer finalizeCallback ///< Function to be called when the array
|
|
1090
|
+
///< buffer is destroyed;
|
|
1091
|
+
/// must implement `void operator()(Env env,
|
|
1092
|
+
/// void* externalData)`
|
|
1093
|
+
);
|
|
1094
|
+
|
|
1095
|
+
/// Creates a new ArrayBuffer instance, using an external buffer with
|
|
1096
|
+
/// specified byte length.
|
|
1097
|
+
template <typename Finalizer, typename Hint>
|
|
1098
|
+
static ArrayBuffer New(
|
|
1099
|
+
napi_env env, ///< Node-API environment
|
|
1100
|
+
void* externalData, ///< Pointer to the external buffer to be used by
|
|
1101
|
+
///< the array
|
|
1102
|
+
size_t byteLength, ///< Length of the external buffer to be used by the
|
|
1103
|
+
///< array,
|
|
1104
|
+
/// in bytes
|
|
1105
|
+
Finalizer finalizeCallback, ///< Function to be called when the array
|
|
1106
|
+
///< buffer is destroyed;
|
|
1107
|
+
/// must implement `void operator()(Env
|
|
1108
|
+
/// env, void* externalData, Hint* hint)`
|
|
1109
|
+
Hint* finalizeHint ///< Hint (second parameter) to be passed to the
|
|
1110
|
+
///< finalize callback
|
|
1111
|
+
);
|
|
1112
|
+
|
|
1113
|
+
ArrayBuffer(); ///< Creates a new _empty_ ArrayBuffer instance.
|
|
1114
|
+
ArrayBuffer(napi_env env,
|
|
1115
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
1116
|
+
|
|
1117
|
+
void* Data(); ///< Gets a pointer to the data buffer.
|
|
1118
|
+
size_t ByteLength(); ///< Gets the length of the array buffer in bytes.
|
|
1119
|
+
|
|
1120
|
+
#if NAPI_VERSION >= 7
|
|
1121
|
+
bool IsDetached() const;
|
|
1122
|
+
void Detach();
|
|
1123
|
+
#endif // NAPI_VERSION >= 7
|
|
775
1124
|
};
|
|
776
1125
|
|
|
777
1126
|
/// A JavaScript typed-array value with unknown array type.
|
|
@@ -786,7 +1135,8 @@ namespace Napi {
|
|
|
786
1135
|
class TypedArray : public Object {
|
|
787
1136
|
public:
|
|
788
1137
|
TypedArray(); ///< Creates a new _empty_ TypedArray instance.
|
|
789
|
-
TypedArray(napi_env env,
|
|
1138
|
+
TypedArray(napi_env env,
|
|
1139
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
790
1140
|
|
|
791
1141
|
napi_typedarray_type TypedArrayType() const; ///< Gets the type of this typed-array.
|
|
792
1142
|
Napi::ArrayBuffer ArrayBuffer() const; ///< Gets the backing array buffer.
|
|
@@ -819,12 +1169,10 @@ namespace Napi {
|
|
|
819
1169
|
: std::is_same<T, uint32_t>::value ? napi_uint32_array
|
|
820
1170
|
: std::is_same<T, float>::value ? napi_float32_array
|
|
821
1171
|
: std::is_same<T, double>::value ? napi_float64_array
|
|
822
|
-
|
|
823
|
-
// released in once it is no longer experimental
|
|
824
|
-
#if (NAPI_VERSION > 2147483646)
|
|
1172
|
+
#if NAPI_VERSION > 5
|
|
825
1173
|
: std::is_same<T, int64_t>::value ? napi_bigint64_array
|
|
826
1174
|
: std::is_same<T, uint64_t>::value ? napi_biguint64_array
|
|
827
|
-
#endif //
|
|
1175
|
+
#endif // NAPI_VERSION > 5
|
|
828
1176
|
: unknown_array_type;
|
|
829
1177
|
}
|
|
830
1178
|
/// !endcond
|
|
@@ -843,16 +1191,19 @@ namespace Napi {
|
|
|
843
1191
|
/// parameter T), except when creating a "clamped" array:
|
|
844
1192
|
///
|
|
845
1193
|
/// Uint8Array::New(env, length, napi_uint8_clamped_array)
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1194
|
+
static TypedArrayOf New(
|
|
1195
|
+
napi_env env, ///< Node-API environment
|
|
1196
|
+
size_t elementLength, ///< Length of the created array, as a number of
|
|
1197
|
+
///< elements
|
|
849
1198
|
#if defined(NAPI_HAS_CONSTEXPR)
|
|
850
|
-
|
|
1199
|
+
napi_typedarray_type type =
|
|
1200
|
+
TypedArray::TypedArrayTypeForPrimitiveType<T>()
|
|
851
1201
|
#else
|
|
852
|
-
|
|
1202
|
+
napi_typedarray_type type
|
|
853
1203
|
#endif
|
|
854
|
-
|
|
855
|
-
|
|
1204
|
+
///< Type of array, if different from the default array type for the
|
|
1205
|
+
///< template parameter T.
|
|
1206
|
+
);
|
|
856
1207
|
|
|
857
1208
|
/// Creates a new TypedArray instance over a provided array buffer.
|
|
858
1209
|
///
|
|
@@ -860,21 +1211,26 @@ namespace Napi {
|
|
|
860
1211
|
/// parameter T), except when creating a "clamped" array:
|
|
861
1212
|
///
|
|
862
1213
|
/// Uint8Array::New(env, length, buffer, 0, napi_uint8_clamped_array)
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1214
|
+
static TypedArrayOf New(
|
|
1215
|
+
napi_env env, ///< Node-API environment
|
|
1216
|
+
size_t elementLength, ///< Length of the created array, as a number of
|
|
1217
|
+
///< elements
|
|
1218
|
+
Napi::ArrayBuffer arrayBuffer, ///< Backing array buffer instance to use
|
|
1219
|
+
size_t bufferOffset, ///< Offset into the array buffer where the
|
|
1220
|
+
///< typed-array starts
|
|
868
1221
|
#if defined(NAPI_HAS_CONSTEXPR)
|
|
869
|
-
|
|
1222
|
+
napi_typedarray_type type =
|
|
1223
|
+
TypedArray::TypedArrayTypeForPrimitiveType<T>()
|
|
870
1224
|
#else
|
|
871
|
-
|
|
1225
|
+
napi_typedarray_type type
|
|
872
1226
|
#endif
|
|
873
|
-
|
|
874
|
-
|
|
1227
|
+
///< Type of array, if different from the default array type for the
|
|
1228
|
+
///< template parameter T.
|
|
1229
|
+
);
|
|
875
1230
|
|
|
876
1231
|
TypedArrayOf(); ///< Creates a new _empty_ TypedArrayOf instance.
|
|
877
|
-
TypedArrayOf(napi_env env,
|
|
1232
|
+
TypedArrayOf(napi_env env,
|
|
1233
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
878
1234
|
|
|
879
1235
|
T& operator [](size_t index); ///< Gets or sets an element in the array.
|
|
880
1236
|
const T& operator [](size_t index) const; ///< Gets an element in the array.
|
|
@@ -916,7 +1272,8 @@ namespace Napi {
|
|
|
916
1272
|
size_t byteLength);
|
|
917
1273
|
|
|
918
1274
|
DataView(); ///< Creates a new _empty_ DataView instance.
|
|
919
|
-
DataView(napi_env env,
|
|
1275
|
+
DataView(napi_env env,
|
|
1276
|
+
napi_value value); ///< Wraps a Node-API value primitive.
|
|
920
1277
|
|
|
921
1278
|
Napi::ArrayBuffer ArrayBuffer() const; ///< Gets the backing array buffer.
|
|
922
1279
|
size_t ByteOffset() const; ///< Gets the offset into the buffer where the array starts.
|
|
@@ -955,47 +1312,81 @@ namespace Napi {
|
|
|
955
1312
|
|
|
956
1313
|
class Function : public Object {
|
|
957
1314
|
public:
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1315
|
+
using VoidCallback = void (*)(const CallbackInfo& info);
|
|
1316
|
+
using Callback = Value (*)(const CallbackInfo& info);
|
|
1317
|
+
|
|
1318
|
+
template <VoidCallback cb>
|
|
1319
|
+
static Function New(napi_env env,
|
|
1320
|
+
const char* utf8name = nullptr,
|
|
1321
|
+
void* data = nullptr);
|
|
1322
|
+
|
|
1323
|
+
template <Callback cb>
|
|
1324
|
+
static Function New(napi_env env,
|
|
1325
|
+
const char* utf8name = nullptr,
|
|
1326
|
+
void* data = nullptr);
|
|
1327
|
+
|
|
1328
|
+
template <VoidCallback cb>
|
|
1329
|
+
static Function New(napi_env env,
|
|
1330
|
+
const std::string& utf8name,
|
|
1331
|
+
void* data = nullptr);
|
|
1332
|
+
|
|
1333
|
+
template <Callback cb>
|
|
1334
|
+
static Function New(napi_env env,
|
|
1335
|
+
const std::string& utf8name,
|
|
1336
|
+
void* data = nullptr);
|
|
1337
|
+
|
|
1338
|
+
/// Callable must implement operator() accepting a const CallbackInfo&
|
|
1339
|
+
/// and return either void or Value.
|
|
1340
|
+
template <typename Callable>
|
|
1341
|
+
static Function New(napi_env env,
|
|
1342
|
+
Callable cb,
|
|
1343
|
+
const char* utf8name = nullptr,
|
|
1344
|
+
void* data = nullptr);
|
|
1345
|
+
/// Callable must implement operator() accepting a const CallbackInfo&
|
|
1346
|
+
/// and return either void or Value.
|
|
1347
|
+
template <typename Callable>
|
|
1348
|
+
static Function New(napi_env env,
|
|
1349
|
+
Callable cb,
|
|
1350
|
+
const std::string& utf8name,
|
|
1351
|
+
void* data = nullptr);
|
|
1352
|
+
|
|
1353
|
+
Function();
|
|
1354
|
+
Function(napi_env env, napi_value value);
|
|
1355
|
+
|
|
1356
|
+
MaybeOrValue<Value> operator()(
|
|
1357
|
+
const std::initializer_list<napi_value>& args) const;
|
|
1358
|
+
|
|
1359
|
+
MaybeOrValue<Value> Call(
|
|
1360
|
+
const std::initializer_list<napi_value>& args) const;
|
|
1361
|
+
MaybeOrValue<Value> Call(const std::vector<napi_value>& args) const;
|
|
1362
|
+
MaybeOrValue<Value> Call(const std::vector<Value>& args) const;
|
|
1363
|
+
MaybeOrValue<Value> Call(size_t argc, const napi_value* args) const;
|
|
1364
|
+
MaybeOrValue<Value> Call(
|
|
1365
|
+
napi_value recv, const std::initializer_list<napi_value>& args) const;
|
|
1366
|
+
MaybeOrValue<Value> Call(napi_value recv,
|
|
1367
|
+
const std::vector<napi_value>& args) const;
|
|
1368
|
+
MaybeOrValue<Value> Call(napi_value recv,
|
|
1369
|
+
const std::vector<Value>& args) const;
|
|
1370
|
+
MaybeOrValue<Value> Call(napi_value recv,
|
|
1371
|
+
size_t argc,
|
|
1372
|
+
const napi_value* args) const;
|
|
1373
|
+
|
|
1374
|
+
MaybeOrValue<Value> MakeCallback(
|
|
1375
|
+
napi_value recv,
|
|
1376
|
+
const std::initializer_list<napi_value>& args,
|
|
1377
|
+
napi_async_context context = nullptr) const;
|
|
1378
|
+
MaybeOrValue<Value> MakeCallback(napi_value recv,
|
|
1379
|
+
const std::vector<napi_value>& args,
|
|
1380
|
+
napi_async_context context = nullptr) const;
|
|
1381
|
+
MaybeOrValue<Value> MakeCallback(napi_value recv,
|
|
1382
|
+
size_t argc,
|
|
1383
|
+
const napi_value* args,
|
|
1384
|
+
napi_async_context context = nullptr) const;
|
|
1385
|
+
|
|
1386
|
+
MaybeOrValue<Object> New(
|
|
1387
|
+
const std::initializer_list<napi_value>& args) const;
|
|
1388
|
+
MaybeOrValue<Object> New(const std::vector<napi_value>& args) const;
|
|
1389
|
+
MaybeOrValue<Object> New(size_t argc, const napi_value* args) const;
|
|
999
1390
|
};
|
|
1000
1391
|
|
|
1001
1392
|
class Promise : public Object {
|
|
@@ -1070,7 +1461,7 @@ namespace Napi {
|
|
|
1070
1461
|
// A reference can be moved but cannot be copied.
|
|
1071
1462
|
Reference(Reference<T>&& other);
|
|
1072
1463
|
Reference<T>& operator =(Reference<T>&& other);
|
|
1073
|
-
|
|
1464
|
+
NAPI_DISALLOW_ASSIGN(Reference<T>)
|
|
1074
1465
|
|
|
1075
1466
|
operator napi_ref() const;
|
|
1076
1467
|
bool operator ==(const Reference<T> &other) const;
|
|
@@ -1083,14 +1474,16 @@ namespace Napi {
|
|
|
1083
1474
|
// within a HandleScope so that the value handle gets cleaned up efficiently.
|
|
1084
1475
|
T Value() const;
|
|
1085
1476
|
|
|
1086
|
-
uint32_t Ref();
|
|
1087
|
-
uint32_t Unref();
|
|
1477
|
+
uint32_t Ref() const;
|
|
1478
|
+
uint32_t Unref() const;
|
|
1088
1479
|
void Reset();
|
|
1089
1480
|
void Reset(const T& value, uint32_t refcount = 0);
|
|
1090
1481
|
|
|
1091
|
-
// Call this on a reference that is declared as static data, to prevent its
|
|
1092
|
-
// from running at program shutdown time, which would attempt to
|
|
1093
|
-
// the environment is no longer valid.
|
|
1482
|
+
// Call this on a reference that is declared as static data, to prevent its
|
|
1483
|
+
// destructor from running at program shutdown time, which would attempt to
|
|
1484
|
+
// reset the reference when the environment is no longer valid. Avoid using
|
|
1485
|
+
// this if at all possible. If you do need to use static data, MAKE SURE to
|
|
1486
|
+
// warn your users that your addon is NOT threadsafe.
|
|
1094
1487
|
void SuppressDestruct();
|
|
1095
1488
|
|
|
1096
1489
|
protected:
|
|
@@ -1115,30 +1508,33 @@ namespace Napi {
|
|
|
1115
1508
|
ObjectReference& operator =(Reference<Object>&& other);
|
|
1116
1509
|
ObjectReference(ObjectReference&& other);
|
|
1117
1510
|
ObjectReference& operator =(ObjectReference&& other);
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
Napi::Value Get(const char* utf8name) const;
|
|
1121
|
-
Napi::Value Get(const std::string& utf8name) const;
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1511
|
+
NAPI_DISALLOW_ASSIGN(ObjectReference)
|
|
1512
|
+
|
|
1513
|
+
MaybeOrValue<Napi::Value> Get(const char* utf8name) const;
|
|
1514
|
+
MaybeOrValue<Napi::Value> Get(const std::string& utf8name) const;
|
|
1515
|
+
MaybeOrValue<bool> Set(const char* utf8name, napi_value value) const;
|
|
1516
|
+
MaybeOrValue<bool> Set(const char* utf8name, Napi::Value value) const;
|
|
1517
|
+
MaybeOrValue<bool> Set(const char* utf8name, const char* utf8value) const;
|
|
1518
|
+
MaybeOrValue<bool> Set(const char* utf8name, bool boolValue) const;
|
|
1519
|
+
MaybeOrValue<bool> Set(const char* utf8name, double numberValue) const;
|
|
1520
|
+
MaybeOrValue<bool> Set(const std::string& utf8name, napi_value value) const;
|
|
1521
|
+
MaybeOrValue<bool> Set(const std::string& utf8name,
|
|
1522
|
+
Napi::Value value) const;
|
|
1523
|
+
MaybeOrValue<bool> Set(const std::string& utf8name,
|
|
1524
|
+
std::string& utf8value) const;
|
|
1525
|
+
MaybeOrValue<bool> Set(const std::string& utf8name, bool boolValue) const;
|
|
1526
|
+
MaybeOrValue<bool> Set(const std::string& utf8name,
|
|
1527
|
+
double numberValue) const;
|
|
1528
|
+
|
|
1529
|
+
MaybeOrValue<Napi::Value> Get(uint32_t index) const;
|
|
1530
|
+
MaybeOrValue<bool> Set(uint32_t index, const napi_value value) const;
|
|
1531
|
+
MaybeOrValue<bool> Set(uint32_t index, const Napi::Value value) const;
|
|
1532
|
+
MaybeOrValue<bool> Set(uint32_t index, const char* utf8value) const;
|
|
1533
|
+
MaybeOrValue<bool> Set(uint32_t index, const std::string& utf8value) const;
|
|
1534
|
+
MaybeOrValue<bool> Set(uint32_t index, bool boolValue) const;
|
|
1535
|
+
MaybeOrValue<bool> Set(uint32_t index, double numberValue) const;
|
|
1536
|
+
|
|
1537
|
+
protected:
|
|
1142
1538
|
ObjectReference(const ObjectReference&);
|
|
1143
1539
|
};
|
|
1144
1540
|
|
|
@@ -1152,30 +1548,39 @@ namespace Napi {
|
|
|
1152
1548
|
FunctionReference& operator =(Reference<Function>&& other);
|
|
1153
1549
|
FunctionReference(FunctionReference&& other);
|
|
1154
1550
|
FunctionReference& operator =(FunctionReference&& other);
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
Napi::Value Call(
|
|
1161
|
-
|
|
1162
|
-
Napi::Value Call(
|
|
1163
|
-
Napi::Value Call(
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1551
|
+
NAPI_DISALLOW_ASSIGN_COPY(FunctionReference)
|
|
1552
|
+
|
|
1553
|
+
MaybeOrValue<Napi::Value> operator()(
|
|
1554
|
+
const std::initializer_list<napi_value>& args) const;
|
|
1555
|
+
|
|
1556
|
+
MaybeOrValue<Napi::Value> Call(
|
|
1557
|
+
const std::initializer_list<napi_value>& args) const;
|
|
1558
|
+
MaybeOrValue<Napi::Value> Call(const std::vector<napi_value>& args) const;
|
|
1559
|
+
MaybeOrValue<Napi::Value> Call(
|
|
1560
|
+
napi_value recv, const std::initializer_list<napi_value>& args) const;
|
|
1561
|
+
MaybeOrValue<Napi::Value> Call(napi_value recv,
|
|
1562
|
+
const std::vector<napi_value>& args) const;
|
|
1563
|
+
MaybeOrValue<Napi::Value> Call(napi_value recv,
|
|
1564
|
+
size_t argc,
|
|
1565
|
+
const napi_value* args) const;
|
|
1566
|
+
|
|
1567
|
+
MaybeOrValue<Napi::Value> MakeCallback(
|
|
1568
|
+
napi_value recv,
|
|
1569
|
+
const std::initializer_list<napi_value>& args,
|
|
1570
|
+
napi_async_context context = nullptr) const;
|
|
1571
|
+
MaybeOrValue<Napi::Value> MakeCallback(
|
|
1572
|
+
napi_value recv,
|
|
1573
|
+
const std::vector<napi_value>& args,
|
|
1574
|
+
napi_async_context context = nullptr) const;
|
|
1575
|
+
MaybeOrValue<Napi::Value> MakeCallback(
|
|
1576
|
+
napi_value recv,
|
|
1577
|
+
size_t argc,
|
|
1578
|
+
const napi_value* args,
|
|
1579
|
+
napi_async_context context = nullptr) const;
|
|
1580
|
+
|
|
1581
|
+
MaybeOrValue<Object> New(
|
|
1582
|
+
const std::initializer_list<napi_value>& args) const;
|
|
1583
|
+
MaybeOrValue<Object> New(const std::vector<napi_value>& args) const;
|
|
1179
1584
|
};
|
|
1180
1585
|
|
|
1181
1586
|
// Shortcuts to creating a new reference with inferred type and refcount = 0.
|
|
@@ -1188,43 +1593,48 @@ namespace Napi {
|
|
|
1188
1593
|
ObjectReference Persistent(Object value);
|
|
1189
1594
|
FunctionReference Persistent(Function value);
|
|
1190
1595
|
|
|
1191
|
-
/// A persistent reference to a JavaScript error object. Use of this class
|
|
1192
|
-
/// on whether C++ exceptions are enabled at compile time.
|
|
1596
|
+
/// A persistent reference to a JavaScript error object. Use of this class
|
|
1597
|
+
/// depends somewhat on whether C++ exceptions are enabled at compile time.
|
|
1193
1598
|
///
|
|
1194
1599
|
/// ### Handling Errors With C++ Exceptions
|
|
1195
1600
|
///
|
|
1196
|
-
/// If C++ exceptions are enabled, then the `Error` class extends
|
|
1197
|
-
/// integrated error-handling for C++ exceptions
|
|
1601
|
+
/// If C++ exceptions are enabled, then the `Error` class extends
|
|
1602
|
+
/// `std::exception` and enables integrated error-handling for C++ exceptions
|
|
1603
|
+
/// and JavaScript exceptions.
|
|
1198
1604
|
///
|
|
1199
|
-
/// If a
|
|
1200
|
-
/// argument), then the
|
|
1201
|
-
///
|
|
1202
|
-
///
|
|
1203
|
-
/// a
|
|
1605
|
+
/// If a Node-API call fails without executing any JavaScript code (for
|
|
1606
|
+
/// example due to an invalid argument), then the Node-API wrapper
|
|
1607
|
+
/// automatically converts and throws the error as a C++ exception of type
|
|
1608
|
+
/// `Napi::Error`. Or if a JavaScript function called by C++ code via Node-API
|
|
1609
|
+
/// throws a JavaScript exception, then the Node-API wrapper automatically
|
|
1610
|
+
/// converts and throws it as a C++ exception of type `Napi::Error`.
|
|
1204
1611
|
///
|
|
1205
|
-
/// If a C++ exception of type `Napi::Error` escapes from a
|
|
1206
|
-
/// wrapper automatically converts and throws it
|
|
1207
|
-
/// a
|
|
1612
|
+
/// If a C++ exception of type `Napi::Error` escapes from a Node-API C++
|
|
1613
|
+
/// callback, then the Node-API wrapper automatically converts and throws it
|
|
1614
|
+
/// as a JavaScript exception. Therefore, catching a C++ exception of type
|
|
1615
|
+
/// `Napi::Error` prevents a JavaScript exception from being thrown.
|
|
1208
1616
|
///
|
|
1209
1617
|
/// #### Example 1A - Throwing a C++ exception:
|
|
1210
1618
|
///
|
|
1211
1619
|
/// Napi::Env env = ...
|
|
1212
1620
|
/// throw Napi::Error::New(env, "Example exception");
|
|
1213
1621
|
///
|
|
1214
|
-
/// Following C++ statements will not be executed. The exception will bubble
|
|
1215
|
-
/// exception of type `Napi::Error`, until it is either caught
|
|
1216
|
-
///
|
|
1622
|
+
/// Following C++ statements will not be executed. The exception will bubble
|
|
1623
|
+
/// up as a C++ exception of type `Napi::Error`, until it is either caught
|
|
1624
|
+
/// while still in C++, or else automatically propataged as a JavaScript
|
|
1625
|
+
/// exception when the callback returns to JavaScript.
|
|
1217
1626
|
///
|
|
1218
|
-
/// #### Example 2A - Propagating a
|
|
1627
|
+
/// #### Example 2A - Propagating a Node-API C++ exception:
|
|
1219
1628
|
///
|
|
1220
1629
|
/// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
|
|
1221
1630
|
/// Napi::Value result = jsFunctionThatThrows({ arg1, arg2 });
|
|
1222
1631
|
///
|
|
1223
|
-
/// Following C++ statements will not be executed. The exception will bubble
|
|
1224
|
-
/// exception of type `Napi::Error`, until it is either caught
|
|
1225
|
-
///
|
|
1632
|
+
/// Following C++ statements will not be executed. The exception will bubble
|
|
1633
|
+
/// up as a C++ exception of type `Napi::Error`, until it is either caught
|
|
1634
|
+
/// while still in C++, or else automatically propagated as a JavaScript
|
|
1635
|
+
/// exception when the callback returns to JavaScript.
|
|
1226
1636
|
///
|
|
1227
|
-
/// #### Example 3A - Handling a
|
|
1637
|
+
/// #### Example 3A - Handling a Node-API C++ exception:
|
|
1228
1638
|
///
|
|
1229
1639
|
/// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
|
|
1230
1640
|
/// Napi::Value result;
|
|
@@ -1234,38 +1644,42 @@ namespace Napi {
|
|
|
1234
1644
|
/// cerr << "Caught JavaScript exception: " + e.what();
|
|
1235
1645
|
/// }
|
|
1236
1646
|
///
|
|
1237
|
-
/// Since the exception was caught here, it will not be propagated as a
|
|
1647
|
+
/// Since the exception was caught here, it will not be propagated as a
|
|
1648
|
+
/// JavaScript exception.
|
|
1238
1649
|
///
|
|
1239
1650
|
/// ### Handling Errors Without C++ Exceptions
|
|
1240
1651
|
///
|
|
1241
|
-
/// If C++ exceptions are disabled (by defining `NAPI_DISABLE_CPP_EXCEPTIONS`)
|
|
1242
|
-
/// does not extend `std::exception`, and APIs in the `Napi`
|
|
1243
|
-
/// exceptions when they fail. Instead, they raise
|
|
1244
|
-
/// return _empty_ `Value`s. Calling code
|
|
1245
|
-
///
|
|
1246
|
-
///
|
|
1247
|
-
///
|
|
1652
|
+
/// If C++ exceptions are disabled (by defining `NAPI_DISABLE_CPP_EXCEPTIONS`)
|
|
1653
|
+
/// then this class does not extend `std::exception`, and APIs in the `Napi`
|
|
1654
|
+
/// namespace do not throw C++ exceptions when they fail. Instead, they raise
|
|
1655
|
+
/// _pending_ JavaScript exceptions and return _empty_ `Value`s. Calling code
|
|
1656
|
+
/// should check `Value::IsEmpty()` before attempting to use a returned value,
|
|
1657
|
+
/// and may use methods on the `Env` class to check for, get, and clear a
|
|
1658
|
+
/// pending JavaScript exception. If the pending exception is not cleared, it
|
|
1659
|
+
/// will be thrown when the native callback returns to JavaScript.
|
|
1248
1660
|
///
|
|
1249
1661
|
/// #### Example 1B - Throwing a JS exception
|
|
1250
1662
|
///
|
|
1251
1663
|
/// Napi::Env env = ...
|
|
1252
|
-
/// Napi::Error::New(env, "Example
|
|
1253
|
-
/// return;
|
|
1664
|
+
/// Napi::Error::New(env, "Example
|
|
1665
|
+
/// exception").ThrowAsJavaScriptException(); return;
|
|
1254
1666
|
///
|
|
1255
|
-
/// After throwing a JS exception, the code should generally return
|
|
1256
|
-
/// callback, after performing any necessary
|
|
1667
|
+
/// After throwing a JS exception, the code should generally return
|
|
1668
|
+
/// immediately from the native callback, after performing any necessary
|
|
1669
|
+
/// cleanup.
|
|
1257
1670
|
///
|
|
1258
|
-
/// #### Example 2B - Propagating a
|
|
1671
|
+
/// #### Example 2B - Propagating a Node-API JS exception:
|
|
1259
1672
|
///
|
|
1260
1673
|
/// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
|
|
1261
1674
|
/// Napi::Value result = jsFunctionThatThrows({ arg1, arg2 });
|
|
1262
1675
|
/// if (result.IsEmpty()) return;
|
|
1263
1676
|
///
|
|
1264
|
-
/// An empty value result from a
|
|
1265
|
-
/// exception is pending. To let the exception propagate, the
|
|
1266
|
-
/// immediately from the native callback, after
|
|
1677
|
+
/// An empty value result from a Node-API call indicates an error occurred,
|
|
1678
|
+
/// and a JavaScript exception is pending. To let the exception propagate, the
|
|
1679
|
+
/// code should generally return immediately from the native callback, after
|
|
1680
|
+
/// performing any necessary cleanup.
|
|
1267
1681
|
///
|
|
1268
|
-
/// #### Example 3B - Handling a
|
|
1682
|
+
/// #### Example 3B - Handling a Node-API JS exception:
|
|
1269
1683
|
///
|
|
1270
1684
|
/// Napi::Function jsFunctionThatThrows = someObj.As<Napi::Function>();
|
|
1271
1685
|
/// Napi::Value result = jsFunctionThatThrows({ arg1, arg2 });
|
|
@@ -1274,8 +1688,8 @@ namespace Napi {
|
|
|
1274
1688
|
/// cerr << "Caught JavaScript exception: " + e.Message();
|
|
1275
1689
|
/// }
|
|
1276
1690
|
///
|
|
1277
|
-
/// Since the exception was cleared here, it will not be propagated as a
|
|
1278
|
-
/// after the native callback returns.
|
|
1691
|
+
/// Since the exception was cleared here, it will not be propagated as a
|
|
1692
|
+
/// JavaScript exception after the native callback returns.
|
|
1279
1693
|
class Error : public ObjectReference
|
|
1280
1694
|
#ifdef NAPI_CPP_EXCEPTIONS
|
|
1281
1695
|
, public std::exception
|
|
@@ -1295,28 +1709,34 @@ namespace Napi {
|
|
|
1295
1709
|
Error(Error&& other);
|
|
1296
1710
|
Error& operator =(Error&& other);
|
|
1297
1711
|
Error(const Error&);
|
|
1298
|
-
Error& operator =(Error&);
|
|
1712
|
+
Error& operator =(const Error&);
|
|
1299
1713
|
|
|
1300
1714
|
const std::string& Message() const NAPI_NOEXCEPT;
|
|
1301
1715
|
void ThrowAsJavaScriptException() const;
|
|
1302
1716
|
|
|
1717
|
+
Object Value() const;
|
|
1718
|
+
|
|
1303
1719
|
#ifdef NAPI_CPP_EXCEPTIONS
|
|
1304
1720
|
const char* what() const NAPI_NOEXCEPT override;
|
|
1305
1721
|
#endif // NAPI_CPP_EXCEPTIONS
|
|
1306
1722
|
|
|
1307
1723
|
protected:
|
|
1308
1724
|
/// !cond INTERNAL
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1725
|
+
using create_error_fn = napi_status (*)(napi_env envb,
|
|
1726
|
+
napi_value code,
|
|
1727
|
+
napi_value msg,
|
|
1728
|
+
napi_value* result);
|
|
1729
|
+
|
|
1730
|
+
template <typename TError>
|
|
1731
|
+
static TError New(napi_env env,
|
|
1732
|
+
const char* message,
|
|
1733
|
+
size_t length,
|
|
1734
|
+
create_error_fn create_error);
|
|
1735
|
+
/// !endcond
|
|
1317
1736
|
|
|
1318
1737
|
private:
|
|
1319
|
-
|
|
1738
|
+
static inline const char* ERROR_WRAP_VALUE() NAPI_NOEXCEPT;
|
|
1739
|
+
mutable std::string _message;
|
|
1320
1740
|
};
|
|
1321
1741
|
|
|
1322
1742
|
class TypeError : public Error {
|
|
@@ -1343,8 +1763,7 @@ namespace Napi {
|
|
|
1343
1763
|
~CallbackInfo();
|
|
1344
1764
|
|
|
1345
1765
|
// Disallow copying to prevent multiple free of _dynamicArgs
|
|
1346
|
-
|
|
1347
|
-
void operator=(CallbackInfo const &) = delete;
|
|
1766
|
+
NAPI_DISALLOW_ASSIGN_COPY(CallbackInfo)
|
|
1348
1767
|
|
|
1349
1768
|
Napi::Env Env() const;
|
|
1350
1769
|
Value NewTarget() const;
|
|
@@ -1369,6 +1788,9 @@ namespace Napi {
|
|
|
1369
1788
|
|
|
1370
1789
|
class PropertyDescriptor {
|
|
1371
1790
|
public:
|
|
1791
|
+
using GetterCallback = Napi::Value (*)(const Napi::CallbackInfo& info);
|
|
1792
|
+
using SetterCallback = void (*)(const Napi::CallbackInfo& info);
|
|
1793
|
+
|
|
1372
1794
|
#ifndef NODE_ADDON_API_DISABLE_DEPRECATED
|
|
1373
1795
|
template <typename Getter>
|
|
1374
1796
|
static PropertyDescriptor Accessor(const char* utf8name,
|
|
@@ -1436,6 +1858,36 @@ namespace Napi {
|
|
|
1436
1858
|
void* data = nullptr);
|
|
1437
1859
|
#endif // !NODE_ADDON_API_DISABLE_DEPRECATED
|
|
1438
1860
|
|
|
1861
|
+
template <GetterCallback Getter>
|
|
1862
|
+
static PropertyDescriptor Accessor(const char* utf8name,
|
|
1863
|
+
napi_property_attributes attributes = napi_default,
|
|
1864
|
+
void* data = nullptr);
|
|
1865
|
+
|
|
1866
|
+
template <GetterCallback Getter>
|
|
1867
|
+
static PropertyDescriptor Accessor(const std::string& utf8name,
|
|
1868
|
+
napi_property_attributes attributes = napi_default,
|
|
1869
|
+
void* data = nullptr);
|
|
1870
|
+
|
|
1871
|
+
template <GetterCallback Getter>
|
|
1872
|
+
static PropertyDescriptor Accessor(Name name,
|
|
1873
|
+
napi_property_attributes attributes = napi_default,
|
|
1874
|
+
void* data = nullptr);
|
|
1875
|
+
|
|
1876
|
+
template <GetterCallback Getter, SetterCallback Setter>
|
|
1877
|
+
static PropertyDescriptor Accessor(const char* utf8name,
|
|
1878
|
+
napi_property_attributes attributes = napi_default,
|
|
1879
|
+
void* data = nullptr);
|
|
1880
|
+
|
|
1881
|
+
template <GetterCallback Getter, SetterCallback Setter>
|
|
1882
|
+
static PropertyDescriptor Accessor(const std::string& utf8name,
|
|
1883
|
+
napi_property_attributes attributes = napi_default,
|
|
1884
|
+
void* data = nullptr);
|
|
1885
|
+
|
|
1886
|
+
template <GetterCallback Getter, SetterCallback Setter>
|
|
1887
|
+
static PropertyDescriptor Accessor(Name name,
|
|
1888
|
+
napi_property_attributes attributes = napi_default,
|
|
1889
|
+
void* data = nullptr);
|
|
1890
|
+
|
|
1439
1891
|
template <typename Getter>
|
|
1440
1892
|
static PropertyDescriptor Accessor(Napi::Env env,
|
|
1441
1893
|
Napi::Object object,
|
|
@@ -1541,6 +1993,120 @@ namespace Napi {
|
|
|
1541
1993
|
napi_property_descriptor _desc;
|
|
1542
1994
|
};
|
|
1543
1995
|
|
|
1996
|
+
template <typename T, typename TCallback>
|
|
1997
|
+
struct MethodCallbackData {
|
|
1998
|
+
TCallback callback;
|
|
1999
|
+
void* data;
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
template <typename T, typename TGetterCallback, typename TSetterCallback>
|
|
2003
|
+
struct AccessorCallbackData {
|
|
2004
|
+
TGetterCallback getterCallback;
|
|
2005
|
+
TSetterCallback setterCallback;
|
|
2006
|
+
void* data;
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
template <typename T>
|
|
2010
|
+
class InstanceWrap {
|
|
2011
|
+
public:
|
|
2012
|
+
using InstanceVoidMethodCallback = void (T::*)(const CallbackInfo& info);
|
|
2013
|
+
using InstanceMethodCallback = Napi::Value (T::*)(const CallbackInfo& info);
|
|
2014
|
+
using InstanceGetterCallback = Napi::Value (T::*)(const CallbackInfo& info);
|
|
2015
|
+
using InstanceSetterCallback = void (T::*)(const CallbackInfo& info,
|
|
2016
|
+
const Napi::Value& value);
|
|
2017
|
+
|
|
2018
|
+
using PropertyDescriptor = ClassPropertyDescriptor<T>;
|
|
2019
|
+
|
|
2020
|
+
static PropertyDescriptor InstanceMethod(const char* utf8name,
|
|
2021
|
+
InstanceVoidMethodCallback method,
|
|
2022
|
+
napi_property_attributes attributes = napi_default,
|
|
2023
|
+
void* data = nullptr);
|
|
2024
|
+
static PropertyDescriptor InstanceMethod(const char* utf8name,
|
|
2025
|
+
InstanceMethodCallback method,
|
|
2026
|
+
napi_property_attributes attributes = napi_default,
|
|
2027
|
+
void* data = nullptr);
|
|
2028
|
+
static PropertyDescriptor InstanceMethod(Symbol name,
|
|
2029
|
+
InstanceVoidMethodCallback method,
|
|
2030
|
+
napi_property_attributes attributes = napi_default,
|
|
2031
|
+
void* data = nullptr);
|
|
2032
|
+
static PropertyDescriptor InstanceMethod(Symbol name,
|
|
2033
|
+
InstanceMethodCallback method,
|
|
2034
|
+
napi_property_attributes attributes = napi_default,
|
|
2035
|
+
void* data = nullptr);
|
|
2036
|
+
template <InstanceVoidMethodCallback method>
|
|
2037
|
+
static PropertyDescriptor InstanceMethod(const char* utf8name,
|
|
2038
|
+
napi_property_attributes attributes = napi_default,
|
|
2039
|
+
void* data = nullptr);
|
|
2040
|
+
template <InstanceMethodCallback method>
|
|
2041
|
+
static PropertyDescriptor InstanceMethod(const char* utf8name,
|
|
2042
|
+
napi_property_attributes attributes = napi_default,
|
|
2043
|
+
void* data = nullptr);
|
|
2044
|
+
template <InstanceVoidMethodCallback method>
|
|
2045
|
+
static PropertyDescriptor InstanceMethod(Symbol name,
|
|
2046
|
+
napi_property_attributes attributes = napi_default,
|
|
2047
|
+
void* data = nullptr);
|
|
2048
|
+
template <InstanceMethodCallback method>
|
|
2049
|
+
static PropertyDescriptor InstanceMethod(Symbol name,
|
|
2050
|
+
napi_property_attributes attributes = napi_default,
|
|
2051
|
+
void* data = nullptr);
|
|
2052
|
+
static PropertyDescriptor InstanceAccessor(const char* utf8name,
|
|
2053
|
+
InstanceGetterCallback getter,
|
|
2054
|
+
InstanceSetterCallback setter,
|
|
2055
|
+
napi_property_attributes attributes = napi_default,
|
|
2056
|
+
void* data = nullptr);
|
|
2057
|
+
static PropertyDescriptor InstanceAccessor(Symbol name,
|
|
2058
|
+
InstanceGetterCallback getter,
|
|
2059
|
+
InstanceSetterCallback setter,
|
|
2060
|
+
napi_property_attributes attributes = napi_default,
|
|
2061
|
+
void* data = nullptr);
|
|
2062
|
+
template <InstanceGetterCallback getter, InstanceSetterCallback setter=nullptr>
|
|
2063
|
+
static PropertyDescriptor InstanceAccessor(const char* utf8name,
|
|
2064
|
+
napi_property_attributes attributes = napi_default,
|
|
2065
|
+
void* data = nullptr);
|
|
2066
|
+
template <InstanceGetterCallback getter, InstanceSetterCallback setter=nullptr>
|
|
2067
|
+
static PropertyDescriptor InstanceAccessor(Symbol name,
|
|
2068
|
+
napi_property_attributes attributes = napi_default,
|
|
2069
|
+
void* data = nullptr);
|
|
2070
|
+
static PropertyDescriptor InstanceValue(const char* utf8name,
|
|
2071
|
+
Napi::Value value,
|
|
2072
|
+
napi_property_attributes attributes = napi_default);
|
|
2073
|
+
static PropertyDescriptor InstanceValue(Symbol name,
|
|
2074
|
+
Napi::Value value,
|
|
2075
|
+
napi_property_attributes attributes = napi_default);
|
|
2076
|
+
|
|
2077
|
+
protected:
|
|
2078
|
+
static void AttachPropData(napi_env env, napi_value value, const napi_property_descriptor* prop);
|
|
2079
|
+
|
|
2080
|
+
private:
|
|
2081
|
+
using This = InstanceWrap<T>;
|
|
2082
|
+
|
|
2083
|
+
using InstanceVoidMethodCallbackData =
|
|
2084
|
+
MethodCallbackData<T, InstanceVoidMethodCallback>;
|
|
2085
|
+
using InstanceMethodCallbackData =
|
|
2086
|
+
MethodCallbackData<T, InstanceMethodCallback>;
|
|
2087
|
+
using InstanceAccessorCallbackData =
|
|
2088
|
+
AccessorCallbackData<T, InstanceGetterCallback, InstanceSetterCallback>;
|
|
2089
|
+
|
|
2090
|
+
static napi_value InstanceVoidMethodCallbackWrapper(napi_env env, napi_callback_info info);
|
|
2091
|
+
static napi_value InstanceMethodCallbackWrapper(napi_env env, napi_callback_info info);
|
|
2092
|
+
static napi_value InstanceGetterCallbackWrapper(napi_env env, napi_callback_info info);
|
|
2093
|
+
static napi_value InstanceSetterCallbackWrapper(napi_env env, napi_callback_info info);
|
|
2094
|
+
|
|
2095
|
+
template <InstanceSetterCallback method>
|
|
2096
|
+
static napi_value WrappedMethod(napi_env env,
|
|
2097
|
+
napi_callback_info info) NAPI_NOEXCEPT;
|
|
2098
|
+
|
|
2099
|
+
template <InstanceSetterCallback setter> struct SetterTag {};
|
|
2100
|
+
|
|
2101
|
+
template <InstanceSetterCallback setter>
|
|
2102
|
+
static napi_callback WrapSetter(SetterTag<setter>) NAPI_NOEXCEPT {
|
|
2103
|
+
return &This::WrappedMethod<setter>;
|
|
2104
|
+
}
|
|
2105
|
+
static napi_callback WrapSetter(SetterTag<nullptr>) NAPI_NOEXCEPT {
|
|
2106
|
+
return nullptr;
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
|
|
1544
2110
|
/// Base class to be extended by C++ classes exposed to JavaScript; each C++ class instance gets
|
|
1545
2111
|
/// "wrapped" by a JavaScript object that is managed by this class.
|
|
1546
2112
|
///
|
|
@@ -1555,8 +2121,8 @@ namespace Napi {
|
|
|
1555
2121
|
/// public:
|
|
1556
2122
|
/// static void Initialize(Napi::Env& env, Napi::Object& target) {
|
|
1557
2123
|
/// Napi::Function constructor = DefineClass(env, "Example", {
|
|
1558
|
-
/// InstanceAccessor
|
|
1559
|
-
/// InstanceMethod("doSomething"
|
|
2124
|
+
/// InstanceAccessor<&Example::GetSomething, &Example::SetSomething>("value"),
|
|
2125
|
+
/// InstanceMethod<&Example::DoSomething>("doSomething"),
|
|
1560
2126
|
/// });
|
|
1561
2127
|
/// target.Set("Example", constructor);
|
|
1562
2128
|
/// }
|
|
@@ -1567,23 +2133,21 @@ namespace Napi {
|
|
|
1567
2133
|
/// Napi::Value DoSomething(const Napi::CallbackInfo& info);
|
|
1568
2134
|
/// }
|
|
1569
2135
|
template <typename T>
|
|
1570
|
-
class ObjectWrap : public Reference<Object> {
|
|
2136
|
+
class ObjectWrap : public InstanceWrap<T>, public Reference<Object> {
|
|
1571
2137
|
public:
|
|
1572
2138
|
ObjectWrap(const CallbackInfo& callbackInfo);
|
|
2139
|
+
virtual ~ObjectWrap();
|
|
1573
2140
|
|
|
1574
2141
|
static T* Unwrap(Object wrapper);
|
|
1575
2142
|
|
|
1576
2143
|
// Methods exposed to JavaScript must conform to one of these callback signatures.
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
typedef Napi::Value (T::*InstanceMethodCallback)(const CallbackInfo& info);
|
|
1583
|
-
typedef Napi::Value (T::*InstanceGetterCallback)(const CallbackInfo& info);
|
|
1584
|
-
typedef void (T::*InstanceSetterCallback)(const CallbackInfo& info, const Napi::Value& value);
|
|
2144
|
+
using StaticVoidMethodCallback = void (*)(const CallbackInfo& info);
|
|
2145
|
+
using StaticMethodCallback = Napi::Value (*)(const CallbackInfo& info);
|
|
2146
|
+
using StaticGetterCallback = Napi::Value (*)(const CallbackInfo& info);
|
|
2147
|
+
using StaticSetterCallback = void (*)(const CallbackInfo& info,
|
|
2148
|
+
const Napi::Value& value);
|
|
1585
2149
|
|
|
1586
|
-
|
|
2150
|
+
using PropertyDescriptor = ClassPropertyDescriptor<T>;
|
|
1587
2151
|
|
|
1588
2152
|
static Function DefineClass(Napi::Env env,
|
|
1589
2153
|
const char* utf8name,
|
|
@@ -1609,6 +2173,22 @@ namespace Napi {
|
|
|
1609
2173
|
StaticMethodCallback method,
|
|
1610
2174
|
napi_property_attributes attributes = napi_default,
|
|
1611
2175
|
void* data = nullptr);
|
|
2176
|
+
template <StaticVoidMethodCallback method>
|
|
2177
|
+
static PropertyDescriptor StaticMethod(const char* utf8name,
|
|
2178
|
+
napi_property_attributes attributes = napi_default,
|
|
2179
|
+
void* data = nullptr);
|
|
2180
|
+
template <StaticVoidMethodCallback method>
|
|
2181
|
+
static PropertyDescriptor StaticMethod(Symbol name,
|
|
2182
|
+
napi_property_attributes attributes = napi_default,
|
|
2183
|
+
void* data = nullptr);
|
|
2184
|
+
template <StaticMethodCallback method>
|
|
2185
|
+
static PropertyDescriptor StaticMethod(const char* utf8name,
|
|
2186
|
+
napi_property_attributes attributes = napi_default,
|
|
2187
|
+
void* data = nullptr);
|
|
2188
|
+
template <StaticMethodCallback method>
|
|
2189
|
+
static PropertyDescriptor StaticMethod(Symbol name,
|
|
2190
|
+
napi_property_attributes attributes = napi_default,
|
|
2191
|
+
void* data = nullptr);
|
|
1612
2192
|
static PropertyDescriptor StaticAccessor(const char* utf8name,
|
|
1613
2193
|
StaticGetterCallback getter,
|
|
1614
2194
|
StaticSetterCallback setter,
|
|
@@ -1619,55 +2199,32 @@ namespace Napi {
|
|
|
1619
2199
|
StaticSetterCallback setter,
|
|
1620
2200
|
napi_property_attributes attributes = napi_default,
|
|
1621
2201
|
void* data = nullptr);
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
napi_property_attributes attributes = napi_default,
|
|
1625
|
-
void* data = nullptr);
|
|
1626
|
-
static PropertyDescriptor InstanceMethod(const char* utf8name,
|
|
1627
|
-
InstanceMethodCallback method,
|
|
1628
|
-
napi_property_attributes attributes = napi_default,
|
|
1629
|
-
void* data = nullptr);
|
|
1630
|
-
static PropertyDescriptor InstanceMethod(Symbol name,
|
|
1631
|
-
InstanceVoidMethodCallback method,
|
|
2202
|
+
template <StaticGetterCallback getter, StaticSetterCallback setter=nullptr>
|
|
2203
|
+
static PropertyDescriptor StaticAccessor(const char* utf8name,
|
|
1632
2204
|
napi_property_attributes attributes = napi_default,
|
|
1633
2205
|
void* data = nullptr);
|
|
1634
|
-
|
|
1635
|
-
|
|
2206
|
+
template <StaticGetterCallback getter, StaticSetterCallback setter=nullptr>
|
|
2207
|
+
static PropertyDescriptor StaticAccessor(Symbol name,
|
|
1636
2208
|
napi_property_attributes attributes = napi_default,
|
|
1637
2209
|
void* data = nullptr);
|
|
1638
|
-
static PropertyDescriptor InstanceAccessor(const char* utf8name,
|
|
1639
|
-
InstanceGetterCallback getter,
|
|
1640
|
-
InstanceSetterCallback setter,
|
|
1641
|
-
napi_property_attributes attributes = napi_default,
|
|
1642
|
-
void* data = nullptr);
|
|
1643
|
-
static PropertyDescriptor InstanceAccessor(Symbol name,
|
|
1644
|
-
InstanceGetterCallback getter,
|
|
1645
|
-
InstanceSetterCallback setter,
|
|
1646
|
-
napi_property_attributes attributes = napi_default,
|
|
1647
|
-
void* data = nullptr);
|
|
1648
2210
|
static PropertyDescriptor StaticValue(const char* utf8name,
|
|
1649
2211
|
Napi::Value value,
|
|
1650
2212
|
napi_property_attributes attributes = napi_default);
|
|
1651
2213
|
static PropertyDescriptor StaticValue(Symbol name,
|
|
1652
2214
|
Napi::Value value,
|
|
1653
2215
|
napi_property_attributes attributes = napi_default);
|
|
1654
|
-
static
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
static PropertyDescriptor InstanceValue(Symbol name,
|
|
1658
|
-
Napi::Value value,
|
|
1659
|
-
napi_property_attributes attributes = napi_default);
|
|
2216
|
+
static Napi::Value OnCalledAsFunction(
|
|
2217
|
+
const Napi::CallbackInfo& callbackInfo);
|
|
2218
|
+
virtual void Finalize(Napi::Env env);
|
|
1660
2219
|
|
|
1661
2220
|
private:
|
|
2221
|
+
using This = ObjectWrap<T>;
|
|
2222
|
+
|
|
1662
2223
|
static napi_value ConstructorCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1663
2224
|
static napi_value StaticVoidMethodCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1664
2225
|
static napi_value StaticMethodCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1665
2226
|
static napi_value StaticGetterCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1666
2227
|
static napi_value StaticSetterCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1667
|
-
static napi_value InstanceVoidMethodCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1668
|
-
static napi_value InstanceMethodCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1669
|
-
static napi_value InstanceGetterCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1670
|
-
static napi_value InstanceSetterCallbackWrapper(napi_env env, napi_callback_info info);
|
|
1671
2228
|
static void FinalizeCallback(napi_env env, void* data, void* hint);
|
|
1672
2229
|
static Function DefineClass(Napi::Env env,
|
|
1673
2230
|
const char* utf8name,
|
|
@@ -1675,26 +2232,31 @@ namespace Napi {
|
|
|
1675
2232
|
const napi_property_descriptor* props,
|
|
1676
2233
|
void* data = nullptr);
|
|
1677
2234
|
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
2235
|
+
using StaticVoidMethodCallbackData =
|
|
2236
|
+
MethodCallbackData<T, StaticVoidMethodCallback>;
|
|
2237
|
+
using StaticMethodCallbackData =
|
|
2238
|
+
MethodCallbackData<T, StaticMethodCallback>;
|
|
2239
|
+
|
|
2240
|
+
using StaticAccessorCallbackData =
|
|
2241
|
+
AccessorCallbackData<T, StaticGetterCallback, StaticSetterCallback>;
|
|
2242
|
+
|
|
2243
|
+
template <StaticSetterCallback method>
|
|
2244
|
+
static napi_value WrappedMethod(napi_env env,
|
|
2245
|
+
napi_callback_info info) NAPI_NOEXCEPT;
|
|
2246
|
+
|
|
2247
|
+
template <StaticSetterCallback setter> struct StaticSetterTag {};
|
|
2248
|
+
|
|
2249
|
+
template <StaticSetterCallback setter>
|
|
2250
|
+
static napi_callback WrapStaticSetter(StaticSetterTag<setter>)
|
|
2251
|
+
NAPI_NOEXCEPT {
|
|
2252
|
+
return &This::WrappedMethod<setter>;
|
|
2253
|
+
}
|
|
2254
|
+
static napi_callback WrapStaticSetter(StaticSetterTag<nullptr>)
|
|
2255
|
+
NAPI_NOEXCEPT {
|
|
2256
|
+
return nullptr;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
bool _construction_failed = true;
|
|
1698
2260
|
};
|
|
1699
2261
|
|
|
1700
2262
|
class HandleScope {
|
|
@@ -1703,6 +2265,9 @@ namespace Napi {
|
|
|
1703
2265
|
explicit HandleScope(Napi::Env env);
|
|
1704
2266
|
~HandleScope();
|
|
1705
2267
|
|
|
2268
|
+
// Disallow copying to prevent double close of napi_handle_scope
|
|
2269
|
+
NAPI_DISALLOW_ASSIGN_COPY(HandleScope)
|
|
2270
|
+
|
|
1706
2271
|
operator napi_handle_scope() const;
|
|
1707
2272
|
|
|
1708
2273
|
Napi::Env Env() const;
|
|
@@ -1718,6 +2283,9 @@ namespace Napi {
|
|
|
1718
2283
|
explicit EscapableHandleScope(Napi::Env env);
|
|
1719
2284
|
~EscapableHandleScope();
|
|
1720
2285
|
|
|
2286
|
+
// Disallow copying to prevent double close of napi_escapable_handle_scope
|
|
2287
|
+
NAPI_DISALLOW_ASSIGN_COPY(EscapableHandleScope)
|
|
2288
|
+
|
|
1721
2289
|
operator napi_escapable_handle_scope() const;
|
|
1722
2290
|
|
|
1723
2291
|
Napi::Env Env() const;
|
|
@@ -1735,6 +2303,9 @@ namespace Napi {
|
|
|
1735
2303
|
CallbackScope(napi_env env, napi_async_context context);
|
|
1736
2304
|
virtual ~CallbackScope();
|
|
1737
2305
|
|
|
2306
|
+
// Disallow copying to prevent double close of napi_callback_scope
|
|
2307
|
+
NAPI_DISALLOW_ASSIGN_COPY(CallbackScope)
|
|
2308
|
+
|
|
1738
2309
|
operator napi_callback_scope() const;
|
|
1739
2310
|
|
|
1740
2311
|
Napi::Env Env() const;
|
|
@@ -1753,11 +2324,12 @@ namespace Napi {
|
|
|
1753
2324
|
|
|
1754
2325
|
AsyncContext(AsyncContext&& other);
|
|
1755
2326
|
AsyncContext& operator =(AsyncContext&& other);
|
|
1756
|
-
|
|
1757
|
-
AsyncContext& operator =(AsyncContext&) = delete;
|
|
2327
|
+
NAPI_DISALLOW_ASSIGN_COPY(AsyncContext)
|
|
1758
2328
|
|
|
1759
2329
|
operator napi_async_context() const;
|
|
1760
2330
|
|
|
2331
|
+
Napi::Env Env() const;
|
|
2332
|
+
|
|
1761
2333
|
private:
|
|
1762
2334
|
napi_env _env;
|
|
1763
2335
|
napi_async_context _context;
|
|
@@ -1770,8 +2342,7 @@ namespace Napi {
|
|
|
1770
2342
|
// An async worker can be moved but cannot be copied.
|
|
1771
2343
|
AsyncWorker(AsyncWorker&& other);
|
|
1772
2344
|
AsyncWorker& operator =(AsyncWorker&& other);
|
|
1773
|
-
|
|
1774
|
-
AsyncWorker& operator =(AsyncWorker&) = delete;
|
|
2345
|
+
NAPI_DISALLOW_ASSIGN_COPY(AsyncWorker)
|
|
1775
2346
|
|
|
1776
2347
|
operator napi_async_work() const;
|
|
1777
2348
|
|
|
@@ -1784,6 +2355,10 @@ namespace Napi {
|
|
|
1784
2355
|
ObjectReference& Receiver();
|
|
1785
2356
|
FunctionReference& Callback();
|
|
1786
2357
|
|
|
2358
|
+
virtual void OnExecute(Napi::Env env);
|
|
2359
|
+
virtual void OnWorkComplete(Napi::Env env,
|
|
2360
|
+
napi_status status);
|
|
2361
|
+
|
|
1787
2362
|
protected:
|
|
1788
2363
|
explicit AsyncWorker(const Function& callback);
|
|
1789
2364
|
explicit AsyncWorker(const Function& callback,
|
|
@@ -1817,10 +2392,10 @@ namespace Napi {
|
|
|
1817
2392
|
void SetError(const std::string& error);
|
|
1818
2393
|
|
|
1819
2394
|
private:
|
|
1820
|
-
static void
|
|
1821
|
-
static void
|
|
1822
|
-
|
|
1823
|
-
|
|
2395
|
+
static inline void OnAsyncWorkExecute(napi_env env, void* asyncworker);
|
|
2396
|
+
static inline void OnAsyncWorkComplete(napi_env env,
|
|
2397
|
+
napi_status status,
|
|
2398
|
+
void* asyncworker);
|
|
1824
2399
|
|
|
1825
2400
|
napi_env _env;
|
|
1826
2401
|
napi_async_work _work;
|
|
@@ -1830,7 +2405,7 @@ namespace Napi {
|
|
|
1830
2405
|
bool _suppress_destruct;
|
|
1831
2406
|
};
|
|
1832
2407
|
|
|
1833
|
-
#if (NAPI_VERSION > 3)
|
|
2408
|
+
#if (NAPI_VERSION > 3 && !defined(__wasm32__))
|
|
1834
2409
|
class ThreadSafeFunction {
|
|
1835
2410
|
public:
|
|
1836
2411
|
// This API may only be called from the main thread.
|
|
@@ -1960,8 +2535,7 @@ namespace Napi {
|
|
|
1960
2535
|
ThreadSafeFunction();
|
|
1961
2536
|
ThreadSafeFunction(napi_threadsafe_function tsFunctionValue);
|
|
1962
2537
|
|
|
1963
|
-
|
|
1964
|
-
ThreadSafeFunction& operator=(ThreadSafeFunction&& other);
|
|
2538
|
+
operator napi_threadsafe_function() const;
|
|
1965
2539
|
|
|
1966
2540
|
// This API may be called from any thread.
|
|
1967
2541
|
napi_status BlockingCall() const;
|
|
@@ -1985,14 +2559,20 @@ namespace Napi {
|
|
|
1985
2559
|
template <typename DataType, typename Callback>
|
|
1986
2560
|
napi_status NonBlockingCall(DataType* data, Callback callback) const;
|
|
1987
2561
|
|
|
2562
|
+
// This API may only be called from the main thread.
|
|
2563
|
+
void Ref(napi_env env) const;
|
|
2564
|
+
|
|
2565
|
+
// This API may only be called from the main thread.
|
|
2566
|
+
void Unref(napi_env env) const;
|
|
2567
|
+
|
|
1988
2568
|
// This API may be called from any thread.
|
|
1989
2569
|
napi_status Acquire() const;
|
|
1990
2570
|
|
|
1991
2571
|
// This API may be called from any thread.
|
|
1992
|
-
napi_status Release();
|
|
2572
|
+
napi_status Release() const;
|
|
1993
2573
|
|
|
1994
2574
|
// This API may be called from any thread.
|
|
1995
|
-
napi_status Abort();
|
|
2575
|
+
napi_status Abort() const;
|
|
1996
2576
|
|
|
1997
2577
|
struct ConvertibleContext
|
|
1998
2578
|
{
|
|
@@ -2028,9 +2608,356 @@ namespace Napi {
|
|
|
2028
2608
|
void* context,
|
|
2029
2609
|
void* data);
|
|
2030
2610
|
|
|
2031
|
-
|
|
2611
|
+
napi_threadsafe_function _tsfn;
|
|
2032
2612
|
};
|
|
2033
|
-
|
|
2613
|
+
|
|
2614
|
+
// A TypedThreadSafeFunction by default has no context (nullptr) and can
|
|
2615
|
+
// accept any type (void) to its CallJs.
|
|
2616
|
+
template <typename ContextType = std::nullptr_t,
|
|
2617
|
+
typename DataType = void,
|
|
2618
|
+
void (*CallJs)(Napi::Env, Napi::Function, ContextType*, DataType*) =
|
|
2619
|
+
nullptr>
|
|
2620
|
+
class TypedThreadSafeFunction {
|
|
2621
|
+
public:
|
|
2622
|
+
// This API may only be called from the main thread.
|
|
2623
|
+
// Helper function that returns nullptr if running Node-API 5+, otherwise a
|
|
2624
|
+
// non-empty, no-op Function. This provides the ability to specify at
|
|
2625
|
+
// compile-time a callback parameter to `New` that safely does no action
|
|
2626
|
+
// when targeting _any_ Node-API version.
|
|
2627
|
+
#if NAPI_VERSION > 4
|
|
2628
|
+
static std::nullptr_t EmptyFunctionFactory(Napi::Env env);
|
|
2629
|
+
#else
|
|
2630
|
+
static Napi::Function EmptyFunctionFactory(Napi::Env env);
|
|
2631
|
+
#endif
|
|
2632
|
+
static Napi::Function FunctionOrEmpty(Napi::Env env,
|
|
2633
|
+
Napi::Function& callback);
|
|
2634
|
+
|
|
2635
|
+
#if NAPI_VERSION > 4
|
|
2636
|
+
// This API may only be called from the main thread.
|
|
2637
|
+
// Creates a new threadsafe function with:
|
|
2638
|
+
// Callback [missing] Resource [missing] Finalizer [missing]
|
|
2639
|
+
template <typename ResourceString>
|
|
2640
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2641
|
+
napi_env env,
|
|
2642
|
+
ResourceString resourceName,
|
|
2643
|
+
size_t maxQueueSize,
|
|
2644
|
+
size_t initialThreadCount,
|
|
2645
|
+
ContextType* context = nullptr);
|
|
2646
|
+
|
|
2647
|
+
// This API may only be called from the main thread.
|
|
2648
|
+
// Creates a new threadsafe function with:
|
|
2649
|
+
// Callback [missing] Resource [passed] Finalizer [missing]
|
|
2650
|
+
template <typename ResourceString>
|
|
2651
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2652
|
+
napi_env env,
|
|
2653
|
+
const Object& resource,
|
|
2654
|
+
ResourceString resourceName,
|
|
2655
|
+
size_t maxQueueSize,
|
|
2656
|
+
size_t initialThreadCount,
|
|
2657
|
+
ContextType* context = nullptr);
|
|
2658
|
+
|
|
2659
|
+
// This API may only be called from the main thread.
|
|
2660
|
+
// Creates a new threadsafe function with:
|
|
2661
|
+
// Callback [missing] Resource [missing] Finalizer [passed]
|
|
2662
|
+
template <typename ResourceString,
|
|
2663
|
+
typename Finalizer,
|
|
2664
|
+
typename FinalizerDataType = void>
|
|
2665
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2666
|
+
napi_env env,
|
|
2667
|
+
ResourceString resourceName,
|
|
2668
|
+
size_t maxQueueSize,
|
|
2669
|
+
size_t initialThreadCount,
|
|
2670
|
+
ContextType* context,
|
|
2671
|
+
Finalizer finalizeCallback,
|
|
2672
|
+
FinalizerDataType* data = nullptr);
|
|
2673
|
+
|
|
2674
|
+
// This API may only be called from the main thread.
|
|
2675
|
+
// Creates a new threadsafe function with:
|
|
2676
|
+
// Callback [missing] Resource [passed] Finalizer [passed]
|
|
2677
|
+
template <typename ResourceString,
|
|
2678
|
+
typename Finalizer,
|
|
2679
|
+
typename FinalizerDataType = void>
|
|
2680
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2681
|
+
napi_env env,
|
|
2682
|
+
const Object& resource,
|
|
2683
|
+
ResourceString resourceName,
|
|
2684
|
+
size_t maxQueueSize,
|
|
2685
|
+
size_t initialThreadCount,
|
|
2686
|
+
ContextType* context,
|
|
2687
|
+
Finalizer finalizeCallback,
|
|
2688
|
+
FinalizerDataType* data = nullptr);
|
|
2689
|
+
#endif
|
|
2690
|
+
|
|
2691
|
+
// This API may only be called from the main thread.
|
|
2692
|
+
// Creates a new threadsafe function with:
|
|
2693
|
+
// Callback [passed] Resource [missing] Finalizer [missing]
|
|
2694
|
+
template <typename ResourceString>
|
|
2695
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2696
|
+
napi_env env,
|
|
2697
|
+
const Function& callback,
|
|
2698
|
+
ResourceString resourceName,
|
|
2699
|
+
size_t maxQueueSize,
|
|
2700
|
+
size_t initialThreadCount,
|
|
2701
|
+
ContextType* context = nullptr);
|
|
2702
|
+
|
|
2703
|
+
// This API may only be called from the main thread.
|
|
2704
|
+
// Creates a new threadsafe function with:
|
|
2705
|
+
// Callback [passed] Resource [passed] Finalizer [missing]
|
|
2706
|
+
template <typename ResourceString>
|
|
2707
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2708
|
+
napi_env env,
|
|
2709
|
+
const Function& callback,
|
|
2710
|
+
const Object& resource,
|
|
2711
|
+
ResourceString resourceName,
|
|
2712
|
+
size_t maxQueueSize,
|
|
2713
|
+
size_t initialThreadCount,
|
|
2714
|
+
ContextType* context = nullptr);
|
|
2715
|
+
|
|
2716
|
+
// This API may only be called from the main thread.
|
|
2717
|
+
// Creates a new threadsafe function with:
|
|
2718
|
+
// Callback [passed] Resource [missing] Finalizer [passed]
|
|
2719
|
+
template <typename ResourceString,
|
|
2720
|
+
typename Finalizer,
|
|
2721
|
+
typename FinalizerDataType = void>
|
|
2722
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2723
|
+
napi_env env,
|
|
2724
|
+
const Function& callback,
|
|
2725
|
+
ResourceString resourceName,
|
|
2726
|
+
size_t maxQueueSize,
|
|
2727
|
+
size_t initialThreadCount,
|
|
2728
|
+
ContextType* context,
|
|
2729
|
+
Finalizer finalizeCallback,
|
|
2730
|
+
FinalizerDataType* data = nullptr);
|
|
2731
|
+
|
|
2732
|
+
// This API may only be called from the main thread.
|
|
2733
|
+
// Creates a new threadsafe function with:
|
|
2734
|
+
// Callback [passed] Resource [passed] Finalizer [passed]
|
|
2735
|
+
template <typename CallbackType,
|
|
2736
|
+
typename ResourceString,
|
|
2737
|
+
typename Finalizer,
|
|
2738
|
+
typename FinalizerDataType>
|
|
2739
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2740
|
+
napi_env env,
|
|
2741
|
+
CallbackType callback,
|
|
2742
|
+
const Object& resource,
|
|
2743
|
+
ResourceString resourceName,
|
|
2744
|
+
size_t maxQueueSize,
|
|
2745
|
+
size_t initialThreadCount,
|
|
2746
|
+
ContextType* context,
|
|
2747
|
+
Finalizer finalizeCallback,
|
|
2748
|
+
FinalizerDataType* data = nullptr);
|
|
2749
|
+
|
|
2750
|
+
TypedThreadSafeFunction();
|
|
2751
|
+
TypedThreadSafeFunction(napi_threadsafe_function tsFunctionValue);
|
|
2752
|
+
|
|
2753
|
+
operator napi_threadsafe_function() const;
|
|
2754
|
+
|
|
2755
|
+
// This API may be called from any thread.
|
|
2756
|
+
napi_status BlockingCall(DataType* data = nullptr) const;
|
|
2757
|
+
|
|
2758
|
+
// This API may be called from any thread.
|
|
2759
|
+
napi_status NonBlockingCall(DataType* data = nullptr) const;
|
|
2760
|
+
|
|
2761
|
+
// This API may only be called from the main thread.
|
|
2762
|
+
void Ref(napi_env env) const;
|
|
2763
|
+
|
|
2764
|
+
// This API may only be called from the main thread.
|
|
2765
|
+
void Unref(napi_env env) const;
|
|
2766
|
+
|
|
2767
|
+
// This API may be called from any thread.
|
|
2768
|
+
napi_status Acquire() const;
|
|
2769
|
+
|
|
2770
|
+
// This API may be called from any thread.
|
|
2771
|
+
napi_status Release() const;
|
|
2772
|
+
|
|
2773
|
+
// This API may be called from any thread.
|
|
2774
|
+
napi_status Abort() const;
|
|
2775
|
+
|
|
2776
|
+
// This API may be called from any thread.
|
|
2777
|
+
ContextType* GetContext() const;
|
|
2778
|
+
|
|
2779
|
+
private:
|
|
2780
|
+
template <typename ResourceString,
|
|
2781
|
+
typename Finalizer,
|
|
2782
|
+
typename FinalizerDataType>
|
|
2783
|
+
static TypedThreadSafeFunction<ContextType, DataType, CallJs> New(
|
|
2784
|
+
napi_env env,
|
|
2785
|
+
const Function& callback,
|
|
2786
|
+
const Object& resource,
|
|
2787
|
+
ResourceString resourceName,
|
|
2788
|
+
size_t maxQueueSize,
|
|
2789
|
+
size_t initialThreadCount,
|
|
2790
|
+
ContextType* context,
|
|
2791
|
+
Finalizer finalizeCallback,
|
|
2792
|
+
FinalizerDataType* data,
|
|
2793
|
+
napi_finalize wrapper);
|
|
2794
|
+
|
|
2795
|
+
static void CallJsInternal(napi_env env,
|
|
2796
|
+
napi_value jsCallback,
|
|
2797
|
+
void* context,
|
|
2798
|
+
void* data);
|
|
2799
|
+
|
|
2800
|
+
protected:
|
|
2801
|
+
napi_threadsafe_function _tsfn;
|
|
2802
|
+
};
|
|
2803
|
+
template <typename DataType>
|
|
2804
|
+
class AsyncProgressWorkerBase : public AsyncWorker {
|
|
2805
|
+
public:
|
|
2806
|
+
virtual void OnWorkProgress(DataType* data) = 0;
|
|
2807
|
+
class ThreadSafeData {
|
|
2808
|
+
public:
|
|
2809
|
+
ThreadSafeData(AsyncProgressWorkerBase* asyncprogressworker, DataType* data)
|
|
2810
|
+
: _asyncprogressworker(asyncprogressworker), _data(data) {}
|
|
2811
|
+
|
|
2812
|
+
AsyncProgressWorkerBase* asyncprogressworker() { return _asyncprogressworker; };
|
|
2813
|
+
DataType* data() { return _data; };
|
|
2814
|
+
|
|
2815
|
+
private:
|
|
2816
|
+
AsyncProgressWorkerBase* _asyncprogressworker;
|
|
2817
|
+
DataType* _data;
|
|
2818
|
+
};
|
|
2819
|
+
void OnWorkComplete(Napi::Env env, napi_status status) override;
|
|
2820
|
+
protected:
|
|
2821
|
+
explicit AsyncProgressWorkerBase(const Object& receiver,
|
|
2822
|
+
const Function& callback,
|
|
2823
|
+
const char* resource_name,
|
|
2824
|
+
const Object& resource,
|
|
2825
|
+
size_t queue_size = 1);
|
|
2826
|
+
virtual ~AsyncProgressWorkerBase();
|
|
2827
|
+
|
|
2828
|
+
// Optional callback of Napi::ThreadSafeFunction only available after NAPI_VERSION 4.
|
|
2829
|
+
// Refs: https://github.com/nodejs/node/pull/27791
|
|
2830
|
+
#if NAPI_VERSION > 4
|
|
2831
|
+
explicit AsyncProgressWorkerBase(Napi::Env env,
|
|
2832
|
+
const char* resource_name,
|
|
2833
|
+
const Object& resource,
|
|
2834
|
+
size_t queue_size = 1);
|
|
2835
|
+
#endif
|
|
2836
|
+
|
|
2837
|
+
static inline void OnAsyncWorkProgress(Napi::Env env,
|
|
2838
|
+
Napi::Function jsCallback,
|
|
2839
|
+
void* data);
|
|
2840
|
+
|
|
2841
|
+
napi_status NonBlockingCall(DataType* data);
|
|
2842
|
+
|
|
2843
|
+
private:
|
|
2844
|
+
ThreadSafeFunction _tsfn;
|
|
2845
|
+
bool _work_completed = false;
|
|
2846
|
+
napi_status _complete_status;
|
|
2847
|
+
static inline void OnThreadSafeFunctionFinalize(Napi::Env env, void* data, AsyncProgressWorkerBase* context);
|
|
2848
|
+
};
|
|
2849
|
+
|
|
2850
|
+
template<class T>
|
|
2851
|
+
class AsyncProgressWorker : public AsyncProgressWorkerBase<void> {
|
|
2852
|
+
public:
|
|
2853
|
+
virtual ~AsyncProgressWorker();
|
|
2854
|
+
|
|
2855
|
+
class ExecutionProgress {
|
|
2856
|
+
friend class AsyncProgressWorker;
|
|
2857
|
+
public:
|
|
2858
|
+
void Signal() const;
|
|
2859
|
+
void Send(const T* data, size_t count) const;
|
|
2860
|
+
private:
|
|
2861
|
+
explicit ExecutionProgress(AsyncProgressWorker* worker) : _worker(worker) {}
|
|
2862
|
+
AsyncProgressWorker* const _worker;
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
void OnWorkProgress(void*) override;
|
|
2866
|
+
|
|
2867
|
+
protected:
|
|
2868
|
+
explicit AsyncProgressWorker(const Function& callback);
|
|
2869
|
+
explicit AsyncProgressWorker(const Function& callback,
|
|
2870
|
+
const char* resource_name);
|
|
2871
|
+
explicit AsyncProgressWorker(const Function& callback,
|
|
2872
|
+
const char* resource_name,
|
|
2873
|
+
const Object& resource);
|
|
2874
|
+
explicit AsyncProgressWorker(const Object& receiver,
|
|
2875
|
+
const Function& callback);
|
|
2876
|
+
explicit AsyncProgressWorker(const Object& receiver,
|
|
2877
|
+
const Function& callback,
|
|
2878
|
+
const char* resource_name);
|
|
2879
|
+
explicit AsyncProgressWorker(const Object& receiver,
|
|
2880
|
+
const Function& callback,
|
|
2881
|
+
const char* resource_name,
|
|
2882
|
+
const Object& resource);
|
|
2883
|
+
|
|
2884
|
+
// Optional callback of Napi::ThreadSafeFunction only available after NAPI_VERSION 4.
|
|
2885
|
+
// Refs: https://github.com/nodejs/node/pull/27791
|
|
2886
|
+
#if NAPI_VERSION > 4
|
|
2887
|
+
explicit AsyncProgressWorker(Napi::Env env);
|
|
2888
|
+
explicit AsyncProgressWorker(Napi::Env env,
|
|
2889
|
+
const char* resource_name);
|
|
2890
|
+
explicit AsyncProgressWorker(Napi::Env env,
|
|
2891
|
+
const char* resource_name,
|
|
2892
|
+
const Object& resource);
|
|
2893
|
+
#endif
|
|
2894
|
+
virtual void Execute(const ExecutionProgress& progress) = 0;
|
|
2895
|
+
virtual void OnProgress(const T* data, size_t count) = 0;
|
|
2896
|
+
|
|
2897
|
+
private:
|
|
2898
|
+
void Execute() override;
|
|
2899
|
+
void Signal() const;
|
|
2900
|
+
void SendProgress_(const T* data, size_t count);
|
|
2901
|
+
|
|
2902
|
+
std::mutex _mutex;
|
|
2903
|
+
T* _asyncdata;
|
|
2904
|
+
size_t _asyncsize;
|
|
2905
|
+
};
|
|
2906
|
+
|
|
2907
|
+
template<class T>
|
|
2908
|
+
class AsyncProgressQueueWorker : public AsyncProgressWorkerBase<std::pair<T*, size_t>> {
|
|
2909
|
+
public:
|
|
2910
|
+
virtual ~AsyncProgressQueueWorker() {};
|
|
2911
|
+
|
|
2912
|
+
class ExecutionProgress {
|
|
2913
|
+
friend class AsyncProgressQueueWorker;
|
|
2914
|
+
public:
|
|
2915
|
+
void Signal() const;
|
|
2916
|
+
void Send(const T* data, size_t count) const;
|
|
2917
|
+
private:
|
|
2918
|
+
explicit ExecutionProgress(AsyncProgressQueueWorker* worker) : _worker(worker) {}
|
|
2919
|
+
AsyncProgressQueueWorker* const _worker;
|
|
2920
|
+
};
|
|
2921
|
+
|
|
2922
|
+
void OnWorkComplete(Napi::Env env, napi_status status) override;
|
|
2923
|
+
void OnWorkProgress(std::pair<T*, size_t>*) override;
|
|
2924
|
+
|
|
2925
|
+
protected:
|
|
2926
|
+
explicit AsyncProgressQueueWorker(const Function& callback);
|
|
2927
|
+
explicit AsyncProgressQueueWorker(const Function& callback,
|
|
2928
|
+
const char* resource_name);
|
|
2929
|
+
explicit AsyncProgressQueueWorker(const Function& callback,
|
|
2930
|
+
const char* resource_name,
|
|
2931
|
+
const Object& resource);
|
|
2932
|
+
explicit AsyncProgressQueueWorker(const Object& receiver,
|
|
2933
|
+
const Function& callback);
|
|
2934
|
+
explicit AsyncProgressQueueWorker(const Object& receiver,
|
|
2935
|
+
const Function& callback,
|
|
2936
|
+
const char* resource_name);
|
|
2937
|
+
explicit AsyncProgressQueueWorker(const Object& receiver,
|
|
2938
|
+
const Function& callback,
|
|
2939
|
+
const char* resource_name,
|
|
2940
|
+
const Object& resource);
|
|
2941
|
+
|
|
2942
|
+
// Optional callback of Napi::ThreadSafeFunction only available after NAPI_VERSION 4.
|
|
2943
|
+
// Refs: https://github.com/nodejs/node/pull/27791
|
|
2944
|
+
#if NAPI_VERSION > 4
|
|
2945
|
+
explicit AsyncProgressQueueWorker(Napi::Env env);
|
|
2946
|
+
explicit AsyncProgressQueueWorker(Napi::Env env,
|
|
2947
|
+
const char* resource_name);
|
|
2948
|
+
explicit AsyncProgressQueueWorker(Napi::Env env,
|
|
2949
|
+
const char* resource_name,
|
|
2950
|
+
const Object& resource);
|
|
2951
|
+
#endif
|
|
2952
|
+
virtual void Execute(const ExecutionProgress& progress) = 0;
|
|
2953
|
+
virtual void OnProgress(const T* data, size_t count) = 0;
|
|
2954
|
+
|
|
2955
|
+
private:
|
|
2956
|
+
void Execute() override;
|
|
2957
|
+
void Signal() const;
|
|
2958
|
+
void SendProgress_(const T* data, size_t count);
|
|
2959
|
+
};
|
|
2960
|
+
#endif // NAPI_VERSION > 3 && !defined(__wasm32__)
|
|
2034
2961
|
|
|
2035
2962
|
// Memory management.
|
|
2036
2963
|
class MemoryManagement {
|
|
@@ -2045,6 +2972,29 @@ namespace Napi {
|
|
|
2045
2972
|
static const napi_node_version* GetNodeVersion(Env env);
|
|
2046
2973
|
};
|
|
2047
2974
|
|
|
2975
|
+
#if NAPI_VERSION > 5
|
|
2976
|
+
template <typename T>
|
|
2977
|
+
class Addon : public InstanceWrap<T> {
|
|
2978
|
+
public:
|
|
2979
|
+
static inline Object Init(Env env, Object exports);
|
|
2980
|
+
static T* Unwrap(Object wrapper);
|
|
2981
|
+
|
|
2982
|
+
protected:
|
|
2983
|
+
using AddonProp = ClassPropertyDescriptor<T>;
|
|
2984
|
+
void DefineAddon(Object exports,
|
|
2985
|
+
const std::initializer_list<AddonProp>& props);
|
|
2986
|
+
Napi::Object DefineProperties(Object object,
|
|
2987
|
+
const std::initializer_list<AddonProp>& props);
|
|
2988
|
+
|
|
2989
|
+
private:
|
|
2990
|
+
Object entry_point_;
|
|
2991
|
+
};
|
|
2992
|
+
#endif // NAPI_VERSION > 5
|
|
2993
|
+
|
|
2994
|
+
#ifdef NAPI_CPP_CUSTOM_NAMESPACE
|
|
2995
|
+
} // namespace NAPI_CPP_CUSTOM_NAMESPACE
|
|
2996
|
+
#endif
|
|
2997
|
+
|
|
2048
2998
|
} // namespace Napi
|
|
2049
2999
|
|
|
2050
3000
|
// Inline implementations of all the above class methods are included here.
|