-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
5,894 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ cmake-build-debug/ | |
|
||
*.har | ||
package/include | ||
*.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,192 +1,53 @@ | ||
#include "napi.h" | ||
#include "napi/native_api.h" | ||
|
||
using namespace Napi; | ||
static napi_value Add(napi_env env, napi_callback_info info) | ||
{ | ||
size_t argc = 2; | ||
napi_value args[2] = {nullptr}; | ||
|
||
napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); | ||
|
||
#if (NAPI_VERSION > 5) | ||
Object InitAddon(Env env); | ||
Object InitAddonData(Env env); | ||
#endif | ||
Object InitArrayBuffer(Env env); | ||
Object InitAsyncContext(Env env); | ||
#if (NAPI_VERSION > 3) | ||
Object InitAsyncProgressQueueWorker(Env env); | ||
Object InitAsyncProgressWorker(Env env); | ||
#endif | ||
Object InitAsyncWorker(Env env); | ||
Object InitPersistentAsyncWorker(Env env); | ||
Object InitBasicTypesArray(Env env); | ||
Object InitBasicTypesBoolean(Env env); | ||
Object InitBasicTypesNumber(Env env); | ||
Object InitBasicTypesValue(Env env); | ||
#if (NAPI_VERSION > 5) | ||
Object InitBigInt(Env env); | ||
#endif | ||
Object InitBuffer(Env env); | ||
Object InitBufferNoExternal(Env env); | ||
#if (NAPI_VERSION > 2) | ||
Object InitCallbackScope(Env env); | ||
#endif | ||
#if (NAPI_VERSION > 4) | ||
Object InitDate(Env env); | ||
#endif | ||
Object InitCallbackInfo(Env env); | ||
Object InitDataView(Env env); | ||
Object InitDataViewReadWrite(Env env); | ||
Object InitEnvCleanup(Env env); | ||
Object InitErrorHandlingPrim(Env env); | ||
Object InitError(Env env); | ||
Object InitExternal(Env env); | ||
Object InitFunction(Env env); | ||
Object InitFunctionReference(Env env); | ||
Object InitHandleScope(Env env); | ||
Object InitMovableCallbacks(Env env); | ||
//Object InitMemoryManagement(Env env); | ||
Object InitName(Env env); | ||
Object InitObject(Env env); | ||
#ifndef NODE_ADDON_API_DISABLE_DEPRECATED | ||
Object InitObjectDeprecated(Env env); | ||
#endif // !NODE_ADDON_API_DISABLE_DEPRECATED | ||
Object InitPromise(Env env); | ||
//Object InitRunScript(Env env); | ||
#if (NAPI_VERSION > 3) | ||
Object InitThreadSafeFunctionCtx(Env env); | ||
Object InitThreadSafeFunctionException(Env env); | ||
Object InitThreadSafeFunctionExistingTsfn(Env env); | ||
Object InitThreadSafeFunctionPtr(Env env); | ||
Object InitThreadSafeFunctionSum(Env env); | ||
Object InitThreadSafeFunctionUnref(Env env); | ||
Object InitThreadSafeFunction(Env env); | ||
Object InitTypedThreadSafeFunctionCtx(Env env); | ||
Object InitTypedThreadSafeFunctionException(Env env); | ||
Object InitTypedThreadSafeFunctionExistingTsfn(Env env); | ||
Object InitTypedThreadSafeFunctionPtr(Env env); | ||
Object InitTypedThreadSafeFunctionSum(Env env); | ||
Object InitTypedThreadSafeFunctionUnref(Env env); | ||
Object InitTypedThreadSafeFunction(Env env); | ||
#endif | ||
//Object InitSymbol(Env env); | ||
Object InitTypedArray(Env env); | ||
//Object InitGlobalObject(Env env); | ||
Object InitObjectWrap(Env env); | ||
Object InitObjectWrapConstructorException(Env env); | ||
Object InitObjectWrapFunction(Env env); | ||
Object InitObjectWrapRemoveWrap(Env env); | ||
Object InitObjectWrapMultipleInheritance(Env env); | ||
Object InitObjectReference(Env env); | ||
Object InitReference(Env env); | ||
Object InitVersionManagement(Env env); | ||
Object InitThunkingManual(Env env); | ||
#if (NAPI_VERSION > 7) | ||
Object InitObjectFreezeSeal(Env env); | ||
Object InitTypeTaggable(Env env); | ||
#endif | ||
#if (NAPI_VERSION > 8) | ||
Object InitEnvMiscellaneous(Env env); | ||
#endif | ||
#if defined(NODE_ADDON_API_ENABLE_MAYBE) | ||
Object InitMaybeCheck(Env env); | ||
#endif | ||
napi_valuetype valuetype0; | ||
napi_typeof(env, args[0], &valuetype0); | ||
|
||
Object EntryInit(Env env, Object exports) { | ||
#if (NAPI_VERSION > 5) | ||
exports.Set("addon", InitAddon(env)); | ||
exports.Set("addon_data", InitAddonData(env)); | ||
#endif | ||
exports.Set("arraybuffer", InitArrayBuffer(env)); | ||
exports.Set("asynccontext", InitAsyncContext(env)); | ||
#if (NAPI_VERSION > 3) | ||
exports.Set("asyncprogressqueueworker", InitAsyncProgressQueueWorker(env)); | ||
exports.Set("asyncprogressworker", InitAsyncProgressWorker(env)); | ||
#endif | ||
// exports.Set("globalObject", InitGlobalObject(env)); | ||
exports.Set("asyncworker", InitAsyncWorker(env)); | ||
exports.Set("persistentasyncworker", InitPersistentAsyncWorker(env)); | ||
exports.Set("basic_types_array", InitBasicTypesArray(env)); | ||
exports.Set("basic_types_boolean", InitBasicTypesBoolean(env)); | ||
exports.Set("basic_types_number", InitBasicTypesNumber(env)); | ||
exports.Set("basic_types_value", InitBasicTypesValue(env)); | ||
#if (NAPI_VERSION > 5) | ||
exports.Set("bigint", InitBigInt(env)); | ||
#endif | ||
#if (NAPI_VERSION > 4) | ||
exports.Set("date", InitDate(env)); | ||
#endif | ||
exports.Set("buffer", InitBuffer(env)); | ||
exports.Set("bufferNoExternal", InitBufferNoExternal(env)); | ||
#if (NAPI_VERSION > 2) | ||
exports.Set("callbackscope", InitCallbackScope(env)); | ||
#endif | ||
exports.Set("callbackInfo", InitCallbackInfo(env)); | ||
exports.Set("dataview", InitDataView(env)); | ||
exports.Set("dataview_read_write", InitDataView(env)); | ||
exports.Set("dataview_read_write", InitDataViewReadWrite(env)); | ||
#if (NAPI_VERSION > 2) | ||
exports.Set("env_cleanup", InitEnvCleanup(env)); | ||
#endif | ||
exports.Set("error", InitError(env)); | ||
exports.Set("errorHandlingPrim", InitErrorHandlingPrim(env)); | ||
exports.Set("external", InitExternal(env)); | ||
exports.Set("function", InitFunction(env)); | ||
exports.Set("functionreference", InitFunctionReference(env)); | ||
exports.Set("name", InitName(env)); | ||
exports.Set("handlescope", InitHandleScope(env)); | ||
exports.Set("movable_callbacks", InitMovableCallbacks(env)); | ||
// exports.Set("memory_management", InitMemoryManagement(env)); | ||
exports.Set("object", InitObject(env)); | ||
#ifndef NODE_ADDON_API_DISABLE_DEPRECATED | ||
exports.Set("object_deprecated", InitObjectDeprecated(env)); | ||
#endif // !NODE_ADDON_API_DISABLE_DEPRECATED | ||
exports.Set("promise", InitPromise(env)); | ||
// exports.Set("symbol", InitSymbol(env)); | ||
#if (NAPI_VERSION > 3) | ||
exports.Set("threadsafe_function_ctx", InitThreadSafeFunctionCtx(env)); | ||
exports.Set("threadsafe_function_exception", | ||
InitThreadSafeFunctionException(env)); | ||
exports.Set("threadsafe_function_existing_tsfn", | ||
InitThreadSafeFunctionExistingTsfn(env)); | ||
exports.Set("threadsafe_function_ptr", InitThreadSafeFunctionPtr(env)); | ||
exports.Set("threadsafe_function_sum", InitThreadSafeFunctionSum(env)); | ||
exports.Set("threadsafe_function_unref", InitThreadSafeFunctionUnref(env)); | ||
exports.Set("threadsafe_function", InitThreadSafeFunction(env)); | ||
exports.Set("typed_threadsafe_function_ctx", | ||
InitTypedThreadSafeFunctionCtx(env)); | ||
exports.Set("typed_threadsafe_function_exception", | ||
InitTypedThreadSafeFunctionException(env)); | ||
exports.Set("typed_threadsafe_function_existing_tsfn", | ||
InitTypedThreadSafeFunctionExistingTsfn(env)); | ||
exports.Set("typed_threadsafe_function_ptr", | ||
InitTypedThreadSafeFunctionPtr(env)); | ||
exports.Set("typed_threadsafe_function_sum", | ||
InitTypedThreadSafeFunctionSum(env)); | ||
exports.Set("typed_threadsafe_function_unref", | ||
InitTypedThreadSafeFunctionUnref(env)); | ||
exports.Set("typed_threadsafe_function", InitTypedThreadSafeFunction(env)); | ||
#endif | ||
exports.Set("typedarray", InitTypedArray(env)); | ||
exports.Set("objectwrap", InitObjectWrap(env)); | ||
exports.Set("objectwrapConstructorException", | ||
InitObjectWrapConstructorException(env)); | ||
exports.Set("objectwrap_function", InitObjectWrapFunction(env)); | ||
exports.Set("objectwrap_removewrap", InitObjectWrapRemoveWrap(env)); | ||
exports.Set("objectwrap_multiple_inheritance", | ||
InitObjectWrapMultipleInheritance(env)); | ||
exports.Set("objectreference", InitObjectReference(env)); | ||
exports.Set("reference", InitReference(env)); | ||
exports.Set("version_management", InitVersionManagement(env)); | ||
exports.Set("thunking_manual", InitThunkingManual(env)); | ||
#if (NAPI_VERSION > 7) | ||
exports.Set("object_freeze_seal", InitObjectFreezeSeal(env)); | ||
exports.Set("type_taggable", InitTypeTaggable(env)); | ||
#endif | ||
#if (NAPI_VERSION > 8) | ||
exports.Set("env_misc", InitEnvMiscellaneous(env)); | ||
#endif | ||
napi_valuetype valuetype1; | ||
napi_typeof(env, args[1], &valuetype1); | ||
|
||
#if defined(NODE_ADDON_API_ENABLE_MAYBE) | ||
exports.Set("maybe_check", InitMaybeCheck(env)); | ||
#endif | ||
double value0; | ||
napi_get_value_double(env, args[0], &value0); | ||
|
||
double value1; | ||
napi_get_value_double(env, args[1], &value1); | ||
|
||
napi_value sum; | ||
napi_create_double(env, value0 + value1, &sum); | ||
|
||
return sum; | ||
|
||
} | ||
|
||
EXTERN_C_START | ||
static napi_value Init(napi_env env, napi_value exports) | ||
{ | ||
napi_property_descriptor desc[] = { | ||
{ "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } | ||
}; | ||
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); | ||
return exports; | ||
} | ||
EXTERN_C_END | ||
|
||
NODE_API_MODULE(entry, EntryInit) | ||
static napi_module demoModule = { | ||
.nm_version = 1, | ||
.nm_flags = 0, | ||
.nm_filename = nullptr, | ||
.nm_register_func = Init, | ||
.nm_modname = "entry", | ||
.nm_priv = ((void*)0), | ||
.reserved = { 0 }, | ||
}; | ||
|
||
extern "C" __attribute__((constructor)) void RegisterEntryModule(void) | ||
{ | ||
napi_module_register(&demoModule); | ||
} |
16 changes: 0 additions & 16 deletions
16
ohos_addon_example/entry/src/main/cpp/types/libentry/Index.d.ts
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
ohos_addon_example/entry/src/main/cpp/types/libexample/Index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {} |
2 changes: 1 addition & 1 deletion
2
.../main/cpp/types/libentry/oh-package.json5 → ...ain/cpp/types/libexample/oh-package.json5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ohos_addon_example/entry/src/ohosTest/ets/test/Ability.test.ets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...osTest/ets/test/BasicTypes/Array.test.ets → ...hosTest/ets/test/BasicTypes/Array.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...Test/ets/test/BasicTypes/Boolean.test.ets → ...sTest/ets/test/BasicTypes/Boolean.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.