diff --git a/interfaces/kits/js/napi/inputmethod/src/js_input_method_controller.cpp b/interfaces/kits/js/napi/inputmethod/src/js_input_method_controller.cpp index 74aea75..7e0c606 100644 --- a/interfaces/kits/js/napi/inputmethod/src/js_input_method_controller.cpp +++ b/interfaces/kits/js/napi/inputmethod/src/js_input_method_controller.cpp @@ -21,6 +21,7 @@ #include "string_ex.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; constexpr size_t ARGC_ZERO = 0; void JsInputMethodController::Finalizer(NativeEngine* engine, void* data, void* hint) @@ -31,7 +32,7 @@ namespace MiscServices { NativeValue* JsInputMethodController::StopInput(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodController* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodController* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnStopInput(*engine, *info) : nullptr; } @@ -45,7 +46,7 @@ namespace MiscServices { InputMethodController::GetInstance()->HideCurrentInput(); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, true); + NativeValue* result = CreateJsValue(engine, true); return result; } diff --git a/interfaces/kits/js/napi/inputmethod/src/js_input_method_registry.cpp b/interfaces/kits/js/napi/inputmethod/src/js_input_method_registry.cpp index 9cbe6a4..3c5911f 100644 --- a/interfaces/kits/js/napi/inputmethod/src/js_input_method_registry.cpp +++ b/interfaces/kits/js/napi/inputmethod/src/js_input_method_registry.cpp @@ -24,6 +24,7 @@ namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; namespace { constexpr size_t ARGC_ZERO = 0; constexpr int32_t MAX_TYPE_NUM = 128; @@ -46,14 +47,14 @@ namespace MiscServices { static NativeValue* GetInputMethodSetting(NativeEngine* engine, NativeCallbackInfo* info) { IMSA_HILOGI("JsInputMethodRegistry::GetInputMethodSetting is called"); - JsInputMethodRegistry* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodRegistry* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetInputMethodSetting(*engine, *info) : nullptr; } static NativeValue* GetInputMethodController(NativeEngine* engine, NativeCallbackInfo* info) { IMSA_HILOGI("JsInputMethodRegistry::GetInputMethodController is called"); - JsInputMethodRegistry* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodRegistry* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetInputMethodController(*engine, *info) : nullptr; } @@ -90,7 +91,7 @@ namespace MiscServices { return nullptr; } - NativeObject* object = AbilityRuntime::ConvertNativeValueTo(exportObj); + NativeObject* object = ConvertNativeValueTo(exportObj); if (object == nullptr) { IMSA_HILOGI("object null"); return nullptr; @@ -99,12 +100,10 @@ namespace MiscServices { std::unique_ptr jsInputMethodRegistry = std::make_unique(engine); object->SetNativePointer(jsInputMethodRegistry.release(), JsInputMethodRegistry::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(*engine, *object, "getInputMethodSetting", - JsInputMethodRegistry::GetInputMethodSetting); - AbilityRuntime::BindNativeFunction(*engine, *object, "getInputMethodController", - JsInputMethodRegistry::GetInputMethodController); + BindNativeFunction(*engine, *object, "getInputMethodSetting", JsInputMethodRegistry::GetInputMethodSetting); + BindNativeFunction(*engine, *object, "getInputMethodController", JsInputMethodRegistry::GetInputMethodController); - object->SetProperty("MAX_TYPE_NUM", AbilityRuntime::CreateJsValue(*engine, static_cast(MAX_TYPE_NUM))); + object->SetProperty("MAX_TYPE_NUM", CreateJsValue(*engine, static_cast(MAX_TYPE_NUM))); return engine->CreateUndefined(); } diff --git a/interfaces/kits/js/napi/inputmethod/src/js_input_method_setting.cpp b/interfaces/kits/js/napi/inputmethod/src/js_input_method_setting.cpp index 5b50644..f89bc61 100644 --- a/interfaces/kits/js/napi/inputmethod/src/js_input_method_setting.cpp +++ b/interfaces/kits/js/napi/inputmethod/src/js_input_method_setting.cpp @@ -21,6 +21,7 @@ #include "string_ex.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; constexpr size_t ARGC_ZERO = 0; void JsInputMethodSetting::Finalizer(NativeEngine* engine, void* data, void* hint) @@ -31,13 +32,13 @@ namespace MiscServices { NativeValue* JsInputMethodSetting::DisplayOptionalInputMethod(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodSetting* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodSetting* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnDisplayOptionalInputMethod(*engine, *info) : nullptr; } NativeValue* JsInputMethodSetting::ListInputMethod(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodSetting* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodSetting* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnListInputMethod(*engine, *info) : nullptr; } @@ -68,16 +69,16 @@ namespace MiscServices { return engine.CreateUndefined(); } NativeValue* arrayValue = engine.CreateArray(properties.size()); - NativeArray* array = AbilityRuntime::ConvertNativeValueTo(arrayValue); + NativeArray* array = ConvertNativeValueTo(arrayValue); uint32_t index = 0; for (const auto &info : properties) { NativeValue* objValue = engine.CreateObject(); - NativeObject* object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject* object = ConvertNativeValueTo(objValue); IMSA_HILOGI("JsInputMethodSetting::ListInputMethod %{public}s/%{public}s", Str16ToStr8(info->mPackageName).c_str(), Str16ToStr8(info->mAbilityName).c_str()); - object->SetProperty("packageName", AbilityRuntime::CreateJsValue(engine, Str16ToStr8(info->mPackageName))); - object->SetProperty("methodId", AbilityRuntime::CreateJsValue(engine, Str16ToStr8(info->mAbilityName))); + object->SetProperty("packageName", CreateJsValue(engine, Str16ToStr8(info->mPackageName))); + object->SetProperty("methodId", CreateJsValue(engine, Str16ToStr8(info->mAbilityName))); array->SetElement(index++, objValue); } diff --git a/interfaces/kits/js/napi/inputmethod/src/js_input_method_utils.cpp b/interfaces/kits/js/napi/inputmethod/src/js_input_method_utils.cpp index 4a8be83..231afaf 100644 --- a/interfaces/kits/js/napi/inputmethod/src/js_input_method_utils.cpp +++ b/interfaces/kits/js/napi/inputmethod/src/js_input_method_utils.cpp @@ -22,11 +22,12 @@ #include "js_input_method_controller.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; NativeValue* CreateInputMethodSetting(NativeEngine& engine) { IMSA_HILOGI("JsInputMethodUtils::CreateInputMethodSetting is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("JsInputMethodUtils::CreateInputMethodSetting Failed to get object"); return nullptr; @@ -35,9 +36,8 @@ namespace OHOS { std::unique_ptr jsInputMethodSetting = std::make_unique(); object->SetNativePointer(jsInputMethodSetting.release(), JsInputMethodSetting::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(engine, *object, "displayOptionalInputMethod", - JsInputMethodSetting::DisplayOptionalInputMethod); - AbilityRuntime::BindNativeFunction(engine, *object, "listInputMethod", JsInputMethodSetting::ListInputMethod); + BindNativeFunction(engine, *object, "displayOptionalInputMethod", JsInputMethodSetting::DisplayOptionalInputMethod); + BindNativeFunction(engine, *object, "listInputMethod", JsInputMethodSetting::ListInputMethod); return objValue; } @@ -45,7 +45,7 @@ namespace OHOS { { IMSA_HILOGI("JsInputMethodUtils::CreateInputMethodController is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("JsInputMethodUtils::CreateInputMethodController Failed to get object"); return nullptr; @@ -54,7 +54,7 @@ namespace OHOS { std::unique_ptr jsInputMethodController = std::make_unique(); object->SetNativePointer(jsInputMethodController.release(), JsInputMethodController::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(engine, *object, "stopInput", JsInputMethodController::StopInput); + BindNativeFunction(engine, *object, "stopInput", JsInputMethodController::StopInput); return objValue; } } diff --git a/interfaces/kits/js/napi/inputmethodengine/include/js_editor_attribute.h b/interfaces/kits/js/napi/inputmethodengine/include/js_editor_attribute.h index 1c00366..308cb34 100644 --- a/interfaces/kits/js/napi/inputmethodengine/include/js_editor_attribute.h +++ b/interfaces/kits/js/napi/inputmethodengine/include/js_editor_attribute.h @@ -25,11 +25,7 @@ namespace OHOS { JsEditorAttribute() = default; ~JsEditorAttribute() = default; static void Finalizer(NativeEngine* engine, void* data, void* hint); -// static NativeValue* GetEnterKeyType(NativeEngine* engine, NativeCallbackInfo* info); -// static NativeValue* GetInputPattern(NativeEngine* engine, NativeCallbackInfo* info); private: -// NativeValue* OnGetEnterKeyType(NativeEngine& engine, NativeCallbackInfo& info); -// NativeValue* OnGetInputPattern(NativeEngine& engine, NativeCallbackInfo& info); }; } } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp index b1536c1..b833d92 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_editor_attribute.cpp @@ -29,47 +29,5 @@ namespace MiscServices { IMSA_HILOGI("JsEditorAttribute::Finalizer is called"); std::unique_ptr(static_cast(data)); } - -// NativeValue* JsEditorAttribute::GetEnterKeyType(NativeEngine* engine, NativeCallbackInfo* info) -// { -// JsEditorAttribute* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); -// return (me != nullptr) ? me->OnGetEnterKeyType(*engine, *info) : nullptr; -// } -// -// NativeValue* JsEditorAttribute::GetInputPattern(NativeEngine* engine, NativeCallbackInfo* info) -// { -// JsEditorAttribute* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); -// return (me != nullptr) ? me->OnGetInputPattern(*engine, *info) : nullptr; -// } - -// NativeValue* JsEditorAttribute::OnGetEnterKeyType(NativeEngine& engine, NativeCallbackInfo& info) -// { -// IMSA_HILOGI("JsEditorAttribute::OnGetEnterKeyType is called!"); -// if (info.argc != ARGC_ZERO) { -// IMSA_HILOGI("JsEditorAttribute::OnGetEnterKeyType has params!"); -// return engine.CreateUndefined(); -// } -// -// int32_t ret = InputMethodAbility::GetInstance()->GetEnterKeyType(); -// -// NativeValue* result = AbilityRuntime::CreateJsValue(engine, ret); -// -// return result; -// } -// -// NativeValue* JsEditorAttribute::OnGetInputPattern(NativeEngine& engine, NativeCallbackInfo& info) -// { -// IMSA_HILOGI("JsEditorAttribute::OnGetInputPattern is called!"); -// if (info.argc != ARGC_ZERO) { -// IMSA_HILOGI("JsEditorAttribute::OnGetInputPattern has params!"); -// return engine.CreateUndefined(); -// } -// -// int32_t ret = InputMethodAbility::GetInstance()->GetInputPattern(); -// -// NativeValue* result = AbilityRuntime::CreateJsValue(engine, ret); -// -// return result; -// } } } \ No newline at end of file diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine.cpp index 6d3fb5d..ca145af 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine.cpp @@ -24,6 +24,7 @@ #include "global.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; constexpr size_t ARGC_TWO = 2; JsInputMethodEngine::JsInputMethodEngine(NativeEngine* engine) { @@ -40,13 +41,13 @@ namespace MiscServices { NativeValue* JsInputMethodEngine::RegisterCallback(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodEngine* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodEngine* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnRegisterCallback(*engine, *info) : nullptr; } NativeValue* JsInputMethodEngine::UnRegisterCallback(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodEngine* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodEngine* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnUnRegisterCallback(*engine, *info) : nullptr; } @@ -59,7 +60,7 @@ namespace MiscServices { } std::string cbType; - if (!AbilityRuntime::ConvertFromJsValue(engine, info.argv[0], cbType)) { + if (!ConvertFromJsValue(engine, info.argv[0], cbType)) { IMSA_HILOGI("JsInputMethodEngine::OnRegisterCallback Failed to convert parameter to callbackType"); return engine.CreateUndefined(); } @@ -78,7 +79,7 @@ namespace MiscServices { } std::string cbType; - if (!AbilityRuntime::ConvertFromJsValue(engine, info.argv[0], cbType)) { + if (!ConvertFromJsValue(engine, info.argv[0], cbType)) { IMSA_HILOGI("JsInputMethodEngine::OnUnRegisterCallback Failed to convert parameter to callbackType"); return engine.CreateUndefined(); } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_listener.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_listener.cpp index 3eaadd9..429a08a 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_listener.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_listener.cpp @@ -19,6 +19,7 @@ namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; void JsInputMethodEngineListener::RegisterListenerWithType(NativeEngine& engine, std::string type, NativeValue* value) { @@ -120,7 +121,7 @@ namespace MiscServices { for (auto iter = jsCbMap_[methodName].begin(); iter != jsCbMap_[methodName].end(); iter++) { NativeValue* nativeValue = engine_->CallFunction(engine_->CreateUndefined(), (*iter)->Get(), argv, argc); bool ret = false; - if (AbilityRuntime::ConvertFromJsValue(*engine_, nativeValue, ret) && ret) { + if (ConvertFromJsValue(*engine_, nativeValue, ret) && ret) { result = true; } } @@ -133,7 +134,7 @@ namespace MiscServices { IMSA_HILOGI("JsInputMethodEngineListener::OnKeyboardStatus"); NativeValue* nativeValue = engine_->CreateObject(); - NativeObject* object = AbilityRuntime::ConvertNativeValueTo(nativeValue); + NativeObject* object = ConvertNativeValueTo(nativeValue); if (object == nullptr) { IMSA_HILOGI("Failed to convert rect to jsObject"); return; @@ -145,34 +146,19 @@ namespace MiscServices { } else { methodName = "keyboardHide"; } - CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + CallJsMethod(methodName, argv, ArraySize(argv)); } void JsInputMethodEngineListener::OnInputStart() { std::lock_guard lock(mMutex); IMSA_HILOGI("JsInputMethodEngineListener::OnInputStart"); -// NativeValue *nativeValuekb = engine_->CreateObject(); -// NativeObject *objectkb = AbilityRuntime::ConvertNativeValueTo(nativeValuekb); -// if (objectkb == nullptr) { -// IMSA_HILOGI("JsInputMethodEngineListener::OnInputStart Failed to get object"); -// return; -// } NativeValue *nativeValuekb = CreateKeyboardController(*engine_); -// objectkb->SetProperty("kbController", CreateKeyboardController(*engine_)); - -// NativeValue *nativeValuetx = engine_->CreateObject(); -// NativeObject *objecttx = AbilityRuntime::ConvertNativeValueTo(nativeValuetx); -// if (objecttx == nullptr) { -// IMSA_HILOGI("JsInputMethodEngineListener::OnInputStart Failed to get object"); -// return; -// } -// objecttx->SetProperty("textInputClient", CreateTextInputClient(*engine_)); NativeValue *nativeValuetx = CreateTextInputClient(*engine_); NativeValue* argv[] = {nativeValuekb, nativeValuetx}; std::string methodName = "inputStart"; - CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + CallJsMethod(methodName, argv, ArraySize(argv)); } void JsInputMethodEngineListener::OnInputStop(std::string imeId) @@ -181,16 +167,16 @@ namespace MiscServices { IMSA_HILOGI("JsInputMethodEngineListener::OnInputStop"); NativeValue* nativeValue = engine_->CreateObject(); - NativeObject* object = AbilityRuntime::ConvertNativeValueTo(nativeValue); + NativeObject* object = ConvertNativeValueTo(nativeValue); if (object == nullptr) { IMSA_HILOGI("Failed to convert rect to jsObject"); return; } - object->SetProperty("imeId", AbilityRuntime::CreateJsValue(*engine_, imeId)); + object->SetProperty("imeId", CreateJsValue(*engine_, imeId)); NativeValue* argv[] = {nativeValue}; std::string methodName = "inputStop"; - CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + CallJsMethod(methodName, argv, ArraySize(argv)); } } } \ No newline at end of file diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_registry.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_registry.cpp index 09ab344..e76fbd7 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_registry.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_registry.cpp @@ -25,6 +25,7 @@ namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; namespace { constexpr size_t ARGC_ZERO = 0; constexpr size_t ARGC_ONE = 1; @@ -46,19 +47,19 @@ namespace MiscServices { static NativeValue* GetInputMethodEngine(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodEngineRegistry* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodEngineRegistry* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetInputMethodEngine(*engine, *info) : nullptr; } static NativeValue* GetKeyboardDelegate(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodEngineRegistry* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodEngineRegistry* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetKeyboardDelegate(*engine, *info) : nullptr; } static NativeValue* MoveCursor(NativeEngine* engine, NativeCallbackInfo* info) { - JsInputMethodEngineRegistry* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsInputMethodEngineRegistry* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnMoveCursor(*engine, *info) : nullptr; } private: @@ -96,14 +97,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; int32_t number; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, number)) { + if (!ConvertFromJsValue(engine, nativeString, number)) { IMSA_HILOGI("JsInputMethodEngineRegistry::OnMoveCursor Failed to convert parameter to string"); return engine.CreateUndefined(); } InputMethodAbility::GetInstance()->MoveCursor(number); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, true); + NativeValue* result = CreateJsValue(engine, true); return result; } @@ -118,7 +119,7 @@ namespace MiscServices { return nullptr; } - NativeObject* object = AbilityRuntime::ConvertNativeValueTo(exportObj); + NativeObject* object = ConvertNativeValueTo(exportObj); if (object == nullptr) { IMSA_HILOGI("object null"); return nullptr; @@ -127,50 +128,46 @@ namespace MiscServices { std::unique_ptr jsInputMethodEngineRegistry = std::make_unique(engine); object->SetNativePointer(jsInputMethodEngineRegistry.release(), JsInputMethodEngineRegistry::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(*engine, *object, "getInputMethodEngine", JsInputMethodEngineRegistry::GetInputMethodEngine); - AbilityRuntime::BindNativeFunction(*engine, *object, "createKeyboardDelegate", JsInputMethodEngineRegistry::GetKeyboardDelegate); + BindNativeFunction(*engine, *object, "getInputMethodEngine", JsInputMethodEngineRegistry::GetInputMethodEngine); + BindNativeFunction(*engine, *object, "createKeyboardDelegate", JsInputMethodEngineRegistry::GetKeyboardDelegate); - object->SetProperty("ENTER_KEY_TYPE_UNSPECIFIED", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::UNSPECIFIED))); - object->SetProperty("ENTER_KEY_TYPE_GO", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::GO))); - object->SetProperty("ENTER_KEY_TYPE_SEARCH", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::SEARCH))); - object->SetProperty("ENTER_KEY_TYPE_SEND", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::SEND))); - object->SetProperty("ENTER_KEY_TYPE_NEXT", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::NEXT))); - object->SetProperty("ENTER_KEY_TYPE_DONE", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::DONE))); - object->SetProperty("ENTER_KEY_TYPE_PREVIOUS", AbilityRuntime::CreateJsValue(*engine, static_cast(EnterKeyType::PREVIOUS))); + object->SetProperty("ENTER_KEY_TYPE_UNSPECIFIED", CreateJsValue(*engine, static_cast(EnterKeyType::UNSPECIFIED))); + object->SetProperty("ENTER_KEY_TYPE_GO", CreateJsValue(*engine, static_cast(EnterKeyType::GO))); + object->SetProperty("ENTER_KEY_TYPE_SEARCH", CreateJsValue(*engine, static_cast(EnterKeyType::SEARCH))); + object->SetProperty("ENTER_KEY_TYPE_SEND", CreateJsValue(*engine, static_cast(EnterKeyType::SEND))); + object->SetProperty("ENTER_KEY_TYPE_NEXT", CreateJsValue(*engine, static_cast(EnterKeyType::NEXT))); + object->SetProperty("ENTER_KEY_TYPE_DONE", CreateJsValue(*engine, static_cast(EnterKeyType::DONE))); + object->SetProperty("ENTER_KEY_TYPE_PREVIOUS", CreateJsValue(*engine, static_cast(EnterKeyType::PREVIOUS))); - object->SetProperty("PATTERN_NULL", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::NONE))); - object->SetProperty("PATTERN_TEXT", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::TEXT))); - object->SetProperty("PATTERN_NUMBER", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::NUMBER))); - object->SetProperty("PATTERN_PHONE", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::PHONE))); - object->SetProperty("PATTERN_DATETIME", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::DATETIME))); - object->SetProperty("PATTERN_EMAIL", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::EMAIL_ADDRESS))); - object->SetProperty("PATTERN_URI", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::URL))); - object->SetProperty("PATTERN_PASSWORD", AbilityRuntime::CreateJsValue(*engine, static_cast(TextInputType::VISIBLE_PASSWORD))); + object->SetProperty("PATTERN_NULL", CreateJsValue(*engine, static_cast(TextInputType::NONE))); + object->SetProperty("PATTERN_TEXT", CreateJsValue(*engine, static_cast(TextInputType::TEXT))); + object->SetProperty("PATTERN_NUMBER", CreateJsValue(*engine, static_cast(TextInputType::NUMBER))); + object->SetProperty("PATTERN_PHONE", CreateJsValue(*engine, static_cast(TextInputType::PHONE))); + object->SetProperty("PATTERN_DATETIME", CreateJsValue(*engine, static_cast(TextInputType::DATETIME))); + object->SetProperty("PATTERN_EMAIL", CreateJsValue(*engine, static_cast(TextInputType::EMAIL_ADDRESS))); + object->SetProperty("PATTERN_URI", CreateJsValue(*engine, static_cast(TextInputType::URL))); + object->SetProperty("PATTERN_PASSWORD", CreateJsValue(*engine, static_cast(TextInputType::VISIBLE_PASSWORD))); + object->SetProperty("FLAG_SELECTING", CreateJsValue(*engine, static_cast(2))); + object->SetProperty("FLAG_SINGLE_LINE", CreateJsValue(*engine, static_cast(1))); - object->SetProperty("FLAG_SELECTING", AbilityRuntime::CreateJsValue(*engine, static_cast(2))); - object->SetProperty("FLAG_SINGLE_LINE", AbilityRuntime::CreateJsValue(*engine, static_cast(1))); + object->SetProperty("DISPLAY_MODE_PART", CreateJsValue(*engine, static_cast(0))); + object->SetProperty("DISPLAY_MODE_FULL", CreateJsValue(*engine, static_cast(1))); - object->SetProperty("DISPLAY_MODE_PART", AbilityRuntime::CreateJsValue(*engine, static_cast(0))); - object->SetProperty("DISPLAY_MODE_FULL", AbilityRuntime::CreateJsValue(*engine, static_cast(1))); + object->SetProperty("OPTION_ASCII", CreateJsValue(*engine, static_cast(20))); + object->SetProperty("OPTION_NONE", CreateJsValue(*engine, static_cast(0))); + object->SetProperty("OPTION_AUTO_CAP_CHARACTERS", CreateJsValue(*engine, static_cast(2))); + object->SetProperty("OPTION_AUTO_CAP_SENTENCES", CreateJsValue(*engine, static_cast(8))); + object->SetProperty("OPTION_AUTO_WORDS", CreateJsValue(*engine, static_cast(4))); + object->SetProperty("OPTION_MULTI_LINE", CreateJsValue(*engine, static_cast(1))); + object->SetProperty("OPTION_NO_FULLSCREEN", CreateJsValue(*engine, static_cast(10))); - object->SetProperty("OPTION_ASCII", AbilityRuntime::CreateJsValue(*engine, static_cast(20))); - object->SetProperty("OPTION_NONE", AbilityRuntime::CreateJsValue(*engine, static_cast(0))); - object->SetProperty("OPTION_AUTO_CAP_CHARACTERS", AbilityRuntime::CreateJsValue(*engine, static_cast(2))); - object->SetProperty("OPTION_AUTO_CAP_SENTENCES", AbilityRuntime::CreateJsValue(*engine, static_cast(8))); - object->SetProperty("OPTION_AUTO_WORDS", AbilityRuntime::CreateJsValue(*engine, static_cast(4))); - object->SetProperty("OPTION_MULTI_LINE", AbilityRuntime::CreateJsValue(*engine, static_cast(1))); - object->SetProperty("OPTION_NO_FULLSCREEN", AbilityRuntime::CreateJsValue(*engine, static_cast(10))); + BindNativeFunction(*engine, *object, "MoveCursor", JsInputMethodEngineRegistry::MoveCursor); - - - AbilityRuntime::BindNativeFunction(*engine, *object, "MoveCursor", JsInputMethodEngineRegistry::MoveCursor); - - object->SetProperty("FUNCTION_KEY_CONFIRM", AbilityRuntime::CreateJsValue(*engine, static_cast(1))); - object->SetProperty("CURSOR_UP", AbilityRuntime::CreateJsValue(*engine, static_cast(1))); - object->SetProperty("CURSOR_DOWN", AbilityRuntime::CreateJsValue(*engine, static_cast(2))); - object->SetProperty("CURSOR_LEFT", AbilityRuntime::CreateJsValue(*engine, static_cast(3))); - object->SetProperty("CURSOR_RIGHT", AbilityRuntime::CreateJsValue(*engine, static_cast(4))); + object->SetProperty("CURSOR_UP", CreateJsValue(*engine, static_cast(1))); + object->SetProperty("CURSOR_DOWN", CreateJsValue(*engine, static_cast(2))); + object->SetProperty("CURSOR_LEFT", CreateJsValue(*engine, static_cast(3))); + object->SetProperty("CURSOR_RIGHT", CreateJsValue(*engine, static_cast(4))); return engine->CreateUndefined(); } } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_utils.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_utils.cpp index ab3e342..8a1462b 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_utils.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_input_method_engine_utils.cpp @@ -26,11 +26,12 @@ #include "js_editor_attribute.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; NativeValue* CreateInputMethodEngine(NativeEngine &engine) { IMSA_HILOGI("JsInputMethodEngineUtils::CreateInputMethodEngine is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("JsInputMethodEngineUtils::CreateInputMethodEngine Failed to get object"); return nullptr; @@ -39,8 +40,8 @@ namespace OHOS { std::unique_ptr jsInputMethodEngine = std::make_unique(&engine); object->SetNativePointer(jsInputMethodEngine.release(), JsInputMethodEngine::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(engine, *object, "on", JsInputMethodEngine::RegisterCallback); - AbilityRuntime::BindNativeFunction(engine, *object, "off", JsInputMethodEngine::UnRegisterCallback); + BindNativeFunction(engine, *object, "on", JsInputMethodEngine::RegisterCallback); + BindNativeFunction(engine, *object, "off", JsInputMethodEngine::UnRegisterCallback); return objValue; } @@ -48,7 +49,7 @@ namespace OHOS { { IMSA_HILOGI("JsInputMethodEngineUtils::CreateKeyboardController is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("CreateKeyboardController Failed to get object"); return nullptr; @@ -57,7 +58,7 @@ namespace OHOS { std::unique_ptr jsKeyboardController = std::make_unique(); object->SetNativePointer(jsKeyboardController.release(), JsKeyboardController::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(engine, *object, "hideKeyboard", JsKeyboardController::HideKeyboardSelf); + BindNativeFunction(engine, *object, "hideKeyboard", JsKeyboardController::HideKeyboardSelf); return objValue; } @@ -66,7 +67,7 @@ namespace OHOS { { IMSA_HILOGI("JsInputMethodEngineUtils::CreateTextInputClient is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("CreateTextInputClient Failed to get object"); return nullptr; @@ -75,13 +76,13 @@ namespace OHOS { std::unique_ptr jsTextInputClient = std::make_unique(); object->SetNativePointer(jsTextInputClient.release(), JsTextInputClient::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(engine, *object, "insertText", JsTextInputClient::InsertText); - AbilityRuntime::BindNativeFunction(engine, *object, "deleteForward", JsTextInputClient::DeleteForward); - AbilityRuntime::BindNativeFunction(engine, *object, "deleteBackward", JsTextInputClient::DeleteBackward); - AbilityRuntime::BindNativeFunction(engine, *object, "sendKeyFunction", JsTextInputClient::SendFunctionKey); - AbilityRuntime::BindNativeFunction(engine, *object, "getForward", JsTextInputClient::GetForward); - AbilityRuntime::BindNativeFunction(engine, *object, "getBackward", JsTextInputClient::GetBackward); - AbilityRuntime::BindNativeFunction(engine, *object, "getEditorAttribute", JsTextInputClient::GetEditorAttribute); + BindNativeFunction(engine, *object, "insertText", JsTextInputClient::InsertText); + BindNativeFunction(engine, *object, "deleteForward", JsTextInputClient::DeleteForward); + BindNativeFunction(engine, *object, "deleteBackward", JsTextInputClient::DeleteBackward); + BindNativeFunction(engine, *object, "sendKeyFunction", JsTextInputClient::SendFunctionKey); + BindNativeFunction(engine, *object, "getForward", JsTextInputClient::GetForward); + BindNativeFunction(engine, *object, "getBackward", JsTextInputClient::GetBackward); + BindNativeFunction(engine, *object, "getEditorAttribute", JsTextInputClient::GetEditorAttribute); return objValue; } @@ -89,7 +90,7 @@ namespace OHOS { { IMSA_HILOGI("JsInputMethodEngineUtils::CreateKeyboardDelegate is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("CreateKeyboardDelegate Failed to get object"); return nullptr; @@ -98,8 +99,8 @@ namespace OHOS { std::unique_ptr jsKeyboardDelegate = std::make_unique(&engine); object->SetNativePointer(jsKeyboardDelegate.release(), JsKeyboardDelegate::Finalizer, nullptr); - AbilityRuntime::BindNativeFunction(engine, *object, "on", JsKeyboardDelegate::RegisterCallback); - AbilityRuntime::BindNativeFunction(engine, *object, "off", JsKeyboardDelegate::UnRegisterCallback); + BindNativeFunction(engine, *object, "on", JsKeyboardDelegate::RegisterCallback); + BindNativeFunction(engine, *object, "off", JsKeyboardDelegate::UnRegisterCallback); return objValue; } @@ -107,7 +108,7 @@ namespace OHOS { { IMSA_HILOGI("JsInputMethodEngineUtils::CreateEditorAttribute is called"); NativeValue *objValue = engine.CreateObject(); - NativeObject *object = AbilityRuntime::ConvertNativeValueTo(objValue); + NativeObject *object = ConvertNativeValueTo(objValue); if (object == nullptr) { IMSA_HILOGI("CreateEditorAttribute Failed to get object"); return nullptr; @@ -116,8 +117,8 @@ namespace OHOS { std::unique_ptr jsEditorAttribute = std::make_unique(); object->SetNativePointer(jsEditorAttribute.release(), JsEditorAttribute::Finalizer, nullptr); - object->SetProperty("enterKeyType", AbilityRuntime::CreateJsValue(engine, InputMethodAbility::GetInstance()->GetEnterKeyType())); - object->SetProperty("inputPattern", AbilityRuntime::CreateJsValue(engine, InputMethodAbility::GetInstance()->GetInputPattern())); + object->SetProperty("enterKeyType", CreateJsValue(engine, InputMethodAbility::GetInstance()->GetEnterKeyType())); + object->SetProperty("inputPattern", CreateJsValue(engine, InputMethodAbility::GetInstance()->GetInputPattern())); return objValue; } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_controller.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_controller.cpp index 2dfc9b4..afee607 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_controller.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_controller.cpp @@ -22,6 +22,7 @@ #include "input_method_ability.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; constexpr size_t ARGC_ZERO = 0; void JsKeyboardController::Finalizer(NativeEngine* engine, void* data, void* hint) { @@ -31,7 +32,7 @@ namespace MiscServices { NativeValue* JsKeyboardController::HideKeyboardSelf(NativeEngine* engine, NativeCallbackInfo* info) { - JsKeyboardController* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsKeyboardController* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnHideKeyboardSelf(*engine, *info) : nullptr; } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate.cpp index 71d64a2..1111ae5 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate.cpp @@ -24,6 +24,7 @@ #include "global.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; constexpr size_t ARGC_TWO = 2; JsKeyboardDelegate::JsKeyboardDelegate(NativeEngine* engine) { @@ -50,13 +51,13 @@ namespace MiscServices { NativeValue* JsKeyboardDelegate::RegisterCallback(NativeEngine* engine, NativeCallbackInfo* info) { - JsKeyboardDelegate* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsKeyboardDelegate* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnRegisterCallback(*engine, *info) : nullptr; } NativeValue* JsKeyboardDelegate::UnRegisterCallback(NativeEngine* engine, NativeCallbackInfo* info) { - JsKeyboardDelegate* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsKeyboardDelegate* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnUnRegisterCallback(*engine, *info) : nullptr; } @@ -69,7 +70,7 @@ namespace MiscServices { } std::string cbType; - if (!AbilityRuntime::ConvertFromJsValue(engine, info.argv[0], cbType)) { + if (!ConvertFromJsValue(engine, info.argv[0], cbType)) { IMSA_HILOGI("JsKeyboardDelegate::OnRegisterCallback Failed to convert parameter to callbackType"); return engine.CreateUndefined(); } @@ -88,7 +89,7 @@ namespace MiscServices { } std::string cbType; - if (!AbilityRuntime::ConvertFromJsValue(engine, info.argv[0], cbType)) { + if (!ConvertFromJsValue(engine, info.argv[0], cbType)) { IMSA_HILOGI("JsKeyboardDelegate::OnUnRegisterCallback Failed to convert parameter to callbackType"); return engine.CreateUndefined(); } diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate_listener.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate_listener.cpp index d1b57c2..b5118fd 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate_listener.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_keyboard_delegate_listener.cpp @@ -19,8 +19,8 @@ namespace OHOS { namespace MiscServices { - void JsKeyboardDelegateListener::RegisterListenerWithType(NativeEngine& engine, - std::string type, NativeValue* value) + using namespace AbilityRuntime; + void JsKeyboardDelegateListener::RegisterListenerWithType(NativeEngine& engine, std::string type, NativeValue* value) { // should do type check if (IfCallbackRegistered(type, value)) { @@ -120,7 +120,7 @@ namespace MiscServices { for (auto iter = jsCbMap_[methodName].begin(); iter != jsCbMap_[methodName].end(); iter++) { NativeValue* nativeValue = engine_->CallFunction(engine_->CreateUndefined(), (*iter)->Get(), argv, argc); bool ret = false; - if (AbilityRuntime::ConvertFromJsValue(*engine_, nativeValue, ret) && ret) { + if (ConvertFromJsValue(*engine_, nativeValue, ret) && ret) { result = true; } } @@ -133,7 +133,7 @@ namespace MiscServices { IMSA_HILOGI("JsKeyboardDelegateListener::OnKeyEvent"); NativeValue* nativeValue = engine_->CreateObject(); - NativeObject* object = AbilityRuntime::ConvertNativeValueTo(nativeValue); + NativeObject* object = ConvertNativeValueTo(nativeValue); if (object == nullptr) { IMSA_HILOGI("Failed to convert rect to jsObject"); return false; @@ -145,9 +145,9 @@ namespace MiscServices { } else { methodName = "keyUp"; } - object->SetProperty("keyCode", AbilityRuntime::CreateJsValue(*engine_, static_cast(keyCode))); - object->SetProperty("keyAction", AbilityRuntime::CreateJsValue(*engine_, static_cast(keyStatus))); - return CallJsMethodReturnBool(methodName, argv, AbilityRuntime::ArraySize(argv)); + object->SetProperty("keyCode", CreateJsValue(*engine_, static_cast(keyCode))); + object->SetProperty("keyAction", CreateJsValue(*engine_, static_cast(keyStatus))); + return CallJsMethodReturnBool(methodName, argv, ArraySize(argv)); } void JsKeyboardDelegateListener::OnCursorUpdate(int32_t positionX, int32_t positionY, int height) @@ -156,32 +156,31 @@ namespace MiscServices { IMSA_HILOGI("JsKeyboardDelegateListener::OnCursorUpdate"); auto task = [this, positionX, positionY, height] () { - NativeValue* nativeXValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(positionX)); - NativeValue* nativeYValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(positionY)); - NativeValue* nativeHValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(height)); + NativeValue* nativeXValue = CreateJsValue(*engine_, static_cast(positionX)); + NativeValue* nativeYValue = CreateJsValue(*engine_, static_cast(positionY)); + NativeValue* nativeHValue = CreateJsValue(*engine_, static_cast(height)); NativeValue* argv[] = {nativeXValue, nativeYValue, nativeHValue}; std::string methodName = "cursorContextChange"; - CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + CallJsMethod(methodName, argv, ArraySize(argv)); }; mainHandler_->PostTask(task); } - void JsKeyboardDelegateListener::OnSelectionChange(int32_t oldBegin, int32_t oldEnd, - int32_t newBegin, int32_t newEnd) + void JsKeyboardDelegateListener::OnSelectionChange(int32_t oldBegin, int32_t oldEnd, int32_t newBegin, int32_t newEnd) { std::lock_guard lock(mMutex); IMSA_HILOGI("JsKeyboardDelegateListener::OnSelectionChange"); auto task = [this, oldBegin, oldEnd, newBegin, newEnd] () { - NativeValue* nativeOBValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(oldBegin)); - NativeValue* nativeOEValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(oldEnd)); - NativeValue* nativeNBHValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(newBegin)); - NativeValue* nativeNEValue = AbilityRuntime::CreateJsValue(*engine_, static_cast(newEnd)); + NativeValue* nativeOBValue = CreateJsValue(*engine_, static_cast(oldBegin)); + NativeValue* nativeOEValue = CreateJsValue(*engine_, static_cast(oldEnd)); + NativeValue* nativeNBHValue = CreateJsValue(*engine_, static_cast(newBegin)); + NativeValue* nativeNEValue = CreateJsValue(*engine_, static_cast(newEnd)); NativeValue* argv[] = {nativeOBValue, nativeOEValue, nativeNBHValue, nativeNEValue}; std::string methodName = "selectionChange"; - CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + CallJsMethod(methodName, argv, ArraySize(argv)); }; mainHandler_->PostTask(task); @@ -192,11 +191,11 @@ namespace MiscServices { std::lock_guard lock(mMutex); IMSA_HILOGI("JsKeyboardDelegateListener::OnTextChange"); auto task = [this, text] () { - NativeValue* nativeValue = AbilityRuntime::CreateJsValue(*engine_, text); + NativeValue* nativeValue = CreateJsValue(*engine_, text); NativeValue* argv[] = {nativeValue}; std::string methodName = "textChange"; - CallJsMethod(methodName, argv, AbilityRuntime::ArraySize(argv)); + CallJsMethod(methodName, argv, ArraySize(argv)); }; mainHandler_->PostTask(task); diff --git a/interfaces/kits/js/napi/inputmethodengine/src/js_text_input_client.cpp b/interfaces/kits/js/napi/inputmethodengine/src/js_text_input_client.cpp index 9a65e4e..e13ab70 100644 --- a/interfaces/kits/js/napi/inputmethodengine/src/js_text_input_client.cpp +++ b/interfaces/kits/js/napi/inputmethodengine/src/js_text_input_client.cpp @@ -23,6 +23,7 @@ #include "js_input_method_engine_utils.h" namespace OHOS { namespace MiscServices { + using namespace AbilityRuntime; constexpr size_t ARGC_ZERO = 0; constexpr size_t ARGC_ONE = 1; @@ -34,43 +35,43 @@ namespace MiscServices { NativeValue* JsTextInputClient::InsertText(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnInsertText(*engine, *info) : nullptr; } NativeValue* JsTextInputClient::DeleteForward(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnDeleteForward(*engine, *info) : nullptr; } NativeValue* JsTextInputClient::DeleteBackward(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnDeleteBackward(*engine, *info) : nullptr; } NativeValue* JsTextInputClient::SendFunctionKey(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnSendFunctionKey(*engine, *info) : nullptr; } NativeValue* JsTextInputClient::GetForward(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetForward(*engine, *info) : nullptr; } NativeValue* JsTextInputClient::GetBackward(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetBackward(*engine, *info) : nullptr; } NativeValue* JsTextInputClient::GetEditorAttribute(NativeEngine* engine, NativeCallbackInfo* info) { - JsTextInputClient* me = AbilityRuntime::CheckParamsAndGetThis(engine, info); + JsTextInputClient* me = CheckParamsAndGetThis(engine, info); return (me != nullptr) ? me->OnGetEditorAttribute(*engine, *info) : nullptr; } @@ -86,14 +87,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; std::string textString; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, textString)) { + if (!ConvertFromJsValue(engine, nativeString, textString)) { IMSA_HILOGI("JsTextInputClient::OnInsertText Failed to convert parameter to string"); return engine.CreateUndefined(); } bool ret = InputMethodAbility::GetInstance()->InsertText(textString); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, ret); + NativeValue* result = CreateJsValue(engine, ret); return result; } @@ -110,14 +111,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; int32_t number; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, number)) { + if (!ConvertFromJsValue(engine, nativeString, number)) { IMSA_HILOGI("JsTextInputClient::OnDeleteForward Failed to convert parameter to string"); return engine.CreateUndefined(); } InputMethodAbility::GetInstance()->DeleteForward(number); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, true); + NativeValue* result = CreateJsValue(engine, true); return result; } @@ -134,14 +135,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; int32_t number; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, number)) { + if (!ConvertFromJsValue(engine, nativeString, number)) { IMSA_HILOGI("JsTextInputClient::OnDeleteBackward Failed to convert parameter to string"); return engine.CreateUndefined(); } InputMethodAbility::GetInstance()->DeleteBackward(number); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, true); + NativeValue* result = CreateJsValue(engine, true); return result; } @@ -158,14 +159,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; int32_t number; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, number)) { + if (!ConvertFromJsValue(engine, nativeString, number)) { IMSA_HILOGI("JsTextInputClient::OnSendFunctionKey Failed to convert parameter to string"); return engine.CreateUndefined(); } InputMethodAbility::GetInstance()->SendFunctionKey(number); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, true); + NativeValue* result = CreateJsValue(engine, true); return result; } @@ -182,14 +183,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; int32_t number; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, number)) { + if (!ConvertFromJsValue(engine, nativeString, number)) { IMSA_HILOGI("JsTextInputClient::OnGetForward Failed to convert parameter to string"); return engine.CreateUndefined(); } std::string ret = Str16ToStr8(InputMethodAbility::GetInstance()->GetTextBeforeCursor(number)); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, ret); + NativeValue* result = CreateJsValue(engine, ret); return result; } @@ -206,14 +207,14 @@ namespace MiscServices { nativeString = info.argv[ARGC_ZERO]; int32_t number; - if (!AbilityRuntime::ConvertFromJsValue(engine, nativeString, number)) { + if (!ConvertFromJsValue(engine, nativeString, number)) { IMSA_HILOGI("JsTextInputClient::OnGetBackward Failed to convert parameter to string"); return engine.CreateUndefined(); } std::string ret = Str16ToStr8(InputMethodAbility::GetInstance()->GetTextAfterCursor(number)); - NativeValue* result = AbilityRuntime::CreateJsValue(engine, ret); + NativeValue* result = CreateJsValue(engine, ret); return result; }