mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 07:10:19 +00:00
!11445 run_time独立编译
Merge pull request !11445 from jiangzhijun8/DuliBianYi_20241016
This commit is contained in:
commit
00e39c0db7
@ -56,6 +56,7 @@
|
||||
"dlp_permission_service",
|
||||
"dsoftbus",
|
||||
"eventhandler",
|
||||
"ets_frontend",
|
||||
"ets_runtime",
|
||||
"ets_utils",
|
||||
"faultloggerd",
|
||||
@ -83,8 +84,10 @@
|
||||
"memory_utils",
|
||||
"napi",
|
||||
"netmanager_base",
|
||||
"node",
|
||||
"os_account",
|
||||
"power_manager",
|
||||
"preferences",
|
||||
"qos_manager",
|
||||
"relational_store",
|
||||
"resource_management",
|
||||
|
@ -52,6 +52,7 @@ ohos_shared_library("ability_runtime") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
output_extension = "so"
|
||||
|
@ -43,7 +43,9 @@ ohos_shared_library("cj_ability_ffi") {
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:cj_bind_ffi",
|
||||
"napi:cj_bind_native",
|
||||
]
|
||||
|
@ -20,7 +20,10 @@ ohos_shared_library("ark_interop_helper_ffi") {
|
||||
sources = [ "ark_interop_helper.cpp" ]
|
||||
|
||||
external_deps = [
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
"napi:ark_interop",
|
||||
|
@ -40,9 +40,11 @@ ohos_shared_library("autostartupcallback") {
|
||||
external_deps = [
|
||||
"ability_base:session_info",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -41,10 +41,10 @@ ohos_shared_library("autostartupmanager") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:session_info",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -50,10 +50,13 @@ template("delegator") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -42,6 +42,7 @@ ohos_shared_library("appmanager_napi") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -49,6 +49,8 @@ ohos_shared_library("appmanager") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -46,6 +46,7 @@ ohos_shared_library("apprecovery_napi") {
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -52,6 +52,7 @@ ohos_shared_library("sendablecontextmanager_napi") {
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -46,6 +46,9 @@ ohos_shared_library("startupmanager_napi") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -37,7 +37,12 @@ ohos_shared_library("autofillmanager_napi") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:view_data",
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -34,6 +34,7 @@ ohos_shared_library("dialog_request_info") {
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -67,20 +67,17 @@ ohos_shared_library("featureability") {
|
||||
}
|
||||
|
||||
if (ability_runtime_relational) {
|
||||
include_dirs += [
|
||||
"${relational_store_napi_path}/common/include",
|
||||
"${relational_store_napi_path}/dataability/include",
|
||||
"${relational_store_napi_path}/rdb/include",
|
||||
]
|
||||
include_dirs += [ "data_ability/include" ]
|
||||
sources += [
|
||||
"${relational_store_napi_path}/common/src/js_df_manager.cpp",
|
||||
"${relational_store_napi_path}/common/src/js_utils.cpp",
|
||||
"${relational_store_napi_path}/dataability/src/napi_data_ability_predicates.cpp",
|
||||
"${relational_store_napi_path}/rdb/src/napi_rdb_js_utils.cpp",
|
||||
"${relational_store_napi_path}/rdb/src/napi_result_set.cpp",
|
||||
"data_ability/js_utils.cpp",
|
||||
"data_ability/napi_data_ability_predicates.cpp",
|
||||
"data_ability/napi_rdb_js_utils.cpp",
|
||||
"data_ability/napi_result_set.cpp",
|
||||
]
|
||||
external_deps += [
|
||||
"eventhandler:libeventhandler",
|
||||
"kv_store:distributeddata_mgr",
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
"relational_store:rdb_data_share_adapter",
|
||||
|
@ -0,0 +1,363 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
|
||||
#define DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
#define DECLARE_JS_PROPERTY(env, key, value) \
|
||||
napi_property_descriptor(DECLARE_NAPI_DEFAULT_PROPERTY((key), Convert2JSValue((env), (value))))
|
||||
|
||||
#define ASSERT(condition, message, retVal) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
LOG_ERROR("test (" #condition ") failed: " message); \
|
||||
return retVal; \
|
||||
} \
|
||||
} while (0)
|
||||
static constexpr int OK = 0;
|
||||
static constexpr int ERR = -1;
|
||||
static constexpr uint32_t ASYNC_RST_SIZE = 2;
|
||||
static constexpr uint32_t DEFAULT_VALUE_LENGTH = 1024;
|
||||
static constexpr uint32_t MAX_VALUE_LENGTH = 1024 * 1024 * 8; // the max length of all kand of out string value
|
||||
static constexpr uint32_t SYNC_RESULT_ELEMENT_NUM = 2;
|
||||
struct JsFeatureSpace {
|
||||
const char *spaceName;
|
||||
const char *nameBase64;
|
||||
bool isComponent;
|
||||
};
|
||||
|
||||
void SetHapVersion(int32_t hapversion);
|
||||
int32_t GetHapVersion();
|
||||
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, napi_value &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, bool &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, double &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, int64_t &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::string &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::vector<uint8_t> &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::vector<float> &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::monostate &value);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, int32_t> &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, bool> &output);
|
||||
|
||||
bool IsNull(napi_env env, napi_value value);
|
||||
|
||||
bool Equal(napi_env env, napi_ref ref, napi_value value);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, T &output);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, T &output);
|
||||
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, uint32_t &output);
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, int32_t &output);
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, int64_t &output);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::vector<T> &value);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, T> &value);
|
||||
|
||||
template<typename... Types>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::variant<Types...> &value);
|
||||
|
||||
using Descriptor = std::function<std::vector<napi_property_descriptor>()>;
|
||||
const std::optional<JsFeatureSpace> GetJsFeatureSpace(const std::string &name);
|
||||
/* napi_define_class wrapper */
|
||||
napi_value DefineClass(napi_env env, const std::string &spaceName, const std::string &className,
|
||||
const Descriptor &descriptor, napi_callback ctor);
|
||||
napi_value GetClass(napi_env env, const std::string &spaceName, const std::string &className);
|
||||
std::string Convert2String(napi_env env, napi_value jsStr);
|
||||
|
||||
int32_t Convert2JSValue(napi_env env, std::string value, napi_value &output);
|
||||
int32_t Convert2JSValue(napi_env env, bool value, napi_value &output);
|
||||
int32_t Convert2JSValue(napi_env env, double value, napi_value &output);
|
||||
|
||||
napi_value Convert2JSValue(napi_env env, const std::string &value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::vector<uint8_t> &value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::vector<float> &value);
|
||||
napi_value Convert2JSValue(napi_env env, int32_t value);
|
||||
napi_value Convert2JSValue(napi_env env, uint32_t value);
|
||||
napi_value Convert2JSValue(napi_env env, int64_t value);
|
||||
napi_value Convert2JSValue(napi_env env, double value);
|
||||
napi_value Convert2JSValue(napi_env env, bool value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::map<std::string, int> &value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::monostate &value);
|
||||
|
||||
template<typename T>
|
||||
napi_value Convert2JSValue(napi_env env, const T &value);
|
||||
|
||||
template<typename T>
|
||||
napi_value Convert2JSValue(napi_env env, const std::vector<T> &value);
|
||||
|
||||
template<typename K, typename V>
|
||||
napi_value Convert2JSValue(napi_env env, const std::map<K, V> &value);
|
||||
|
||||
template<typename T>
|
||||
napi_value Convert2JSValue(napi_env env, const std::tuple<int32_t, std::string, T> &value);
|
||||
|
||||
template<typename... Types>
|
||||
napi_value Convert2JSValue(napi_env env, const std::variant<Types...> &value);
|
||||
|
||||
template<typename T>
|
||||
std::string ToString(const T &key);
|
||||
|
||||
template<typename K>
|
||||
std::enable_if_t<!std::is_same_v<K, std::string>, std::string> ConvertMapKey(const K &key)
|
||||
{
|
||||
return ToString(key);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
std::enable_if_t<std::is_same_v<K, std::string>, const std::string &> ConvertMapKey(const K &key)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int32_t GetCPPValue(napi_env env, napi_value jsValue, T &value)
|
||||
{
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
template<typename T, typename First, typename... Types>
|
||||
int32_t GetCPPValue(napi_env env, napi_value jsValue, T &value)
|
||||
{
|
||||
First cValue;
|
||||
auto ret = Convert2Value(env, jsValue, cValue);
|
||||
if (ret == napi_ok) {
|
||||
value = cValue;
|
||||
return ret;
|
||||
}
|
||||
return GetCPPValue<T, Types...>(env, jsValue, value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
napi_value GetJSValue(napi_env env, const T &value)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T, typename First, typename... Types>
|
||||
napi_value GetJSValue(napi_env env, const T &value)
|
||||
{
|
||||
auto *val = std::get_if<First>(&value);
|
||||
if (val != nullptr) {
|
||||
return Convert2JSValue(env, *val);
|
||||
}
|
||||
return GetJSValue<T, Types...>(env, value);
|
||||
}
|
||||
|
||||
std::pair<napi_status, napi_value> GetInnerValue(napi_env env, napi_value in, const std::string &prop, bool optional);
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t>, int32_t> GetNamedProperty(
|
||||
napi_env env, napi_value in, const std::string &prop, T &value, bool optional = false)
|
||||
{
|
||||
auto [status, jsValue] = GetInnerValue(env, in, prop, optional);
|
||||
if (jsValue == nullptr) {
|
||||
return status;
|
||||
}
|
||||
return Convert2ValueExt(env, jsValue, value);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<!std::is_same_v<T, int32_t> && !std::is_same_v<T, uint32_t>, int32_t> GetNamedProperty(
|
||||
napi_env env, napi_value in, const std::string &prop, T &value, bool optional = false)
|
||||
{
|
||||
auto [status, jsValue] = GetInnerValue(env, in, prop, optional);
|
||||
if (jsValue == nullptr) {
|
||||
return status;
|
||||
}
|
||||
return Convert2Value(env, jsValue, value);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline int32_t SetNamedProperty(napi_env env, napi_value in, const std::string &prop, T value)
|
||||
{
|
||||
return napi_set_named_property(env, in, prop.c_str(), Convert2JSValue(env, value));
|
||||
};
|
||||
|
||||
napi_value ToJsObject(napi_env env, napi_value sendableValue);
|
||||
napi_value ToJsArray(napi_env env, napi_value sendableValue);
|
||||
napi_value ToJsTypedArray(napi_env env, napi_value sendableValue);
|
||||
napi_value Convert2JSValue(napi_env env, napi_value sendableValue);
|
||||
} // namespace JSUtils
|
||||
|
||||
template<typename T>
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::vector<T> &value)
|
||||
{
|
||||
bool isArray = false;
|
||||
napi_is_array(env, jsValue, &isArray);
|
||||
if (!isArray) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
uint32_t arrLen = 0;
|
||||
napi_get_array_length(env, jsValue, &arrLen);
|
||||
if (arrLen == 0) {
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < arrLen; ++i) {
|
||||
napi_value element;
|
||||
napi_get_element(env, jsValue, i, &element);
|
||||
T item;
|
||||
auto status = Convert2Value(env, element, item);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
value.push_back(std::move(item));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, T> &value)
|
||||
{
|
||||
napi_value jsMapList = nullptr;
|
||||
uint32_t jsCount = 0;
|
||||
napi_status status = napi_get_property_names(env, jsValue, &jsMapList);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_array_length(env, jsMapList, &jsCount);
|
||||
if (status != napi_ok || jsCount <= 0) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value jsKey = nullptr;
|
||||
napi_value jsVal = nullptr;
|
||||
for (uint32_t index = 0; index < jsCount; index++) {
|
||||
status = napi_get_element(env, jsMapList, index, &jsKey);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
std::string key;
|
||||
int ret = Convert2Value(env, jsKey, key);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_property(env, jsValue, jsKey, &jsVal);
|
||||
if (status != napi_ok || jsVal == nullptr) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
T val;
|
||||
ret = Convert2Value(env, jsVal, val);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
value.insert(std::pair<std::string, T>(key, val));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<typename K, typename V>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::map<K, V> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_status status = napi_create_object(env, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (const auto &[key, val] : value) {
|
||||
const std::string &name = ConvertMapKey(key);
|
||||
status = napi_set_named_property(env, jsValue, name.c_str(), Convert2JSValue(env, val));
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::tuple<int32_t, std::string, T> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_status status = napi_create_object(env, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_value code = Convert2JSValue(env, std::get<0>(value));
|
||||
napi_value description = Convert2JSValue(env, std::get<1>(value));
|
||||
napi_value val = Convert2JSValue(env, std::get<2>(value));
|
||||
if (description == nullptr || val == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_named_property(env, jsValue, "code", code);
|
||||
napi_set_named_property(env, jsValue, "description", description);
|
||||
napi_set_named_property(env, jsValue, "value", val);
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::variant<Types...> &value)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
if (type == napi_undefined) {
|
||||
return napi_generic_failure;
|
||||
}
|
||||
|
||||
return GetCPPValue<decltype(value), Types...>(env, jsValue, value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::vector<T> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_status status = napi_create_array_with_length(env, value.size(), &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < value.size(); ++i) {
|
||||
napi_set_element(env, jsValue, i, Convert2JSValue(env, value[i]));
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::variant<Types...> &value)
|
||||
{
|
||||
return GetJSValue<decltype(value), Types...>(env, value);
|
||||
}
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
||||
#endif // DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
|
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef PREFERENCES_JSKIT_NAPI_ASYNC_PROXY_H
|
||||
#define PREFERENCES_JSKIT_NAPI_ASYNC_PROXY_H
|
||||
#include <vector>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
constexpr int MAX_INPUT_COUNT = 10;
|
||||
constexpr int OK = 0;
|
||||
constexpr int ERR = -1;
|
||||
|
||||
// T inherits AysncContext
|
||||
template<class T> class NapiAsyncProxy {
|
||||
public:
|
||||
constexpr static int RESULT_COUNT = 2;
|
||||
using InputParser = void (*)(const napi_env &, const napi_value &, T *);
|
||||
using NapiAsyncExecute = int (*)(T *);
|
||||
using NapiAsyncComplete = int (*)(T *, napi_value &);
|
||||
|
||||
// AsyncContext base
|
||||
struct AysncContext {
|
||||
AysncContext()
|
||||
{
|
||||
}
|
||||
virtual ~AysncContext()
|
||||
{
|
||||
if (env == nullptr) {
|
||||
return;
|
||||
}
|
||||
napi_delete_async_work(env, work);
|
||||
napi_delete_reference(env, callbackRef);
|
||||
}
|
||||
napi_env env = nullptr;
|
||||
napi_callback_info info = nullptr;
|
||||
napi_async_work work = nullptr;
|
||||
napi_deferred deferred = nullptr;
|
||||
napi_ref callbackRef = nullptr;
|
||||
NapiAsyncExecute execFunc = nullptr;
|
||||
int execStatus = ERR;
|
||||
NapiAsyncComplete completeFunc = nullptr;
|
||||
void *boundObj = nullptr;
|
||||
};
|
||||
|
||||
public:
|
||||
void Init(napi_env env, napi_callback_info info)
|
||||
{
|
||||
asyncContext = new T();
|
||||
if (asyncContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
asyncContext->env = env;
|
||||
asyncContext->info = info;
|
||||
}
|
||||
|
||||
~NapiAsyncProxy()
|
||||
{
|
||||
if (asyncContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete asyncContext;
|
||||
asyncContext = nullptr;
|
||||
}
|
||||
|
||||
static void DefParserThis(const napi_env &env, const napi_value &self, T *context)
|
||||
{
|
||||
napi_unwrap(env, self, &context->boundObj);
|
||||
}
|
||||
|
||||
void ParseInputs(const std::vector<InputParser> &parsers, InputParser parserThis = DefParserThis)
|
||||
{
|
||||
if (asyncContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value thisObj = nullptr;
|
||||
size_t argc = parsers.size() + 1;
|
||||
napi_value args[MAX_INPUT_COUNT] = { 0 };
|
||||
napi_get_cb_info(asyncContext->env, asyncContext->info, &argc, args, &thisObj, nullptr);
|
||||
for (size_t i = 0; i < argc && argc <= MAX_INPUT_COUNT; i++) {
|
||||
if (i >= parsers.size()) {
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(asyncContext->env, args[i], &valueType);
|
||||
if (valueType == napi_function) {
|
||||
napi_create_reference(asyncContext->env, args[i], 1, &asyncContext->callbackRef);
|
||||
}
|
||||
break;
|
||||
}
|
||||
auto *parserFunction = parsers[i];
|
||||
if (parserFunction != nullptr) {
|
||||
parserFunction(asyncContext->env, args[i], this->asyncContext);
|
||||
}
|
||||
}
|
||||
parserThis(asyncContext->env, thisObj, asyncContext);
|
||||
}
|
||||
|
||||
napi_value DoAsyncWork(std::string resourceName, NapiAsyncExecute execFunc, NapiAsyncComplete completeFunc)
|
||||
{
|
||||
if (asyncContext == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value ret = nullptr;
|
||||
if (asyncContext->callbackRef == nullptr) {
|
||||
napi_create_promise(asyncContext->env, &asyncContext->deferred, &ret);
|
||||
} else {
|
||||
napi_get_undefined(asyncContext->env, &ret);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(asyncContext->env, resourceName.c_str(), NAPI_AUTO_LENGTH, &resource);
|
||||
asyncContext->execFunc = execFunc;
|
||||
asyncContext->completeFunc = completeFunc;
|
||||
NAPI_CALL_BASE(asyncContext->env, napi_create_async_work(asyncContext->env, nullptr, resource,
|
||||
[](napi_env env, void *data) {
|
||||
T *context = (T *)data;
|
||||
context->execStatus = context->execFunc(context);
|
||||
},
|
||||
[](napi_env env, napi_status status, void *data) {
|
||||
T *context = (T *)data;
|
||||
napi_value output = nullptr;
|
||||
int completeStatus = context->completeFunc(context, output);
|
||||
napi_value result[RESULT_COUNT] = { 0 };
|
||||
if (context->execStatus == OK && completeStatus == OK) {
|
||||
napi_get_undefined(env, &result[0]);
|
||||
result[1] = output;
|
||||
} else {
|
||||
napi_value message = nullptr;
|
||||
napi_create_string_utf8(env, "async call failed", NAPI_AUTO_LENGTH, &message);
|
||||
napi_create_error(env, nullptr, message, &result[0]);
|
||||
napi_get_undefined(env, &result[1]);
|
||||
}
|
||||
if (context->deferred) {
|
||||
// promise
|
||||
if (context->execStatus == OK && completeStatus == OK) {
|
||||
napi_resolve_deferred(env, context->deferred, result[1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, context->deferred, result[0]);
|
||||
}
|
||||
} else {
|
||||
// callback
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, context->callbackRef, &callback);
|
||||
napi_value callbackResult = nullptr;
|
||||
napi_call_function(env, nullptr, callback, RESULT_COUNT, result, &callbackResult);
|
||||
}
|
||||
delete context;
|
||||
},
|
||||
(void *)asyncContext, &asyncContext->work), ret);
|
||||
NAPI_CALL_BASE(asyncContext->env, napi_queue_async_work(asyncContext->env, asyncContext->work), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
T *asyncContext;
|
||||
};
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DATAABILITY_JSKIT_NAPI_DATA_ABILITY_PREDICATES_H
|
||||
#define DATAABILITY_JSKIT_NAPI_DATA_ABILITY_PREDICATES_H
|
||||
|
||||
#include <memory>
|
||||
#include "data_ability_predicates.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DataAbilityJsKit {
|
||||
class DataAbilityPredicatesProxy {
|
||||
public:
|
||||
static void Init(napi_env env, napi_value exports);
|
||||
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::DataAbilityPredicates> value);
|
||||
static std::shared_ptr<NativeRdb::DataAbilityPredicates> GetNativePredicates(
|
||||
const napi_env env, const napi_value arg);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
|
||||
|
||||
DataAbilityPredicatesProxy();
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> GetPredicates() const;
|
||||
|
||||
private:
|
||||
~DataAbilityPredicatesProxy();
|
||||
|
||||
static napi_value New(napi_env env, napi_callback_info info);
|
||||
static std::shared_ptr<NativeRdb::DataAbilityPredicates> GetNativePredicates(napi_env env,
|
||||
napi_callback_info info);
|
||||
static napi_value EqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value NotEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value EndWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value Or(napi_env env, napi_callback_info info);
|
||||
static napi_value And(napi_env env, napi_callback_info info);
|
||||
static napi_value Contains(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value EndsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNull(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNotNull(napi_env env, napi_callback_info info);
|
||||
static napi_value Like(napi_env env, napi_callback_info info);
|
||||
static napi_value Glob(napi_env env, napi_callback_info info);
|
||||
static napi_value Between(napi_env env, napi_callback_info info);
|
||||
static napi_value NotBetween(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThan(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThan(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByAsc(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByDesc(napi_env env, napi_callback_info info);
|
||||
static napi_value Distinct(napi_env env, napi_callback_info info);
|
||||
static napi_value Limit(napi_env env, napi_callback_info info);
|
||||
static napi_value Offset(napi_env env, napi_callback_info info);
|
||||
static napi_value GroupBy(napi_env env, napi_callback_info info);
|
||||
static napi_value IndexedBy(napi_env env, napi_callback_info info);
|
||||
static napi_value In(napi_env env, napi_callback_info info);
|
||||
static napi_value NotIn(napi_env env, napi_callback_info info);
|
||||
static napi_value Clear(napi_env env, napi_callback_info info);
|
||||
static napi_value IsRawSelection(napi_env env, napi_callback_info info);
|
||||
static napi_value GetWhereClause(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWhereClause(napi_env env, napi_callback_info info);
|
||||
static napi_value GetWhereArgs(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWhereArgs(napi_env env, napi_callback_info info);
|
||||
static napi_value GetOrder(napi_env env, napi_callback_info info);
|
||||
static napi_value SetOrder(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLimit(napi_env env, napi_callback_info info);
|
||||
static napi_value GetOffset(napi_env env, napi_callback_info info);
|
||||
static napi_value IsDistinct(napi_env env, napi_callback_info info);
|
||||
static napi_value GetGroup(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIndex(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNeedAnd(napi_env env, napi_callback_info info);
|
||||
static napi_value IsSorted(napi_env env, napi_callback_info info);
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates_;
|
||||
};
|
||||
} // namespace DataAbilityJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
EXTERN_C_START
|
||||
__attribute__((visibility("default")))
|
||||
napi_value NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_NewInstance(napi_env env,
|
||||
OHOS::NativeRdb::DataAbilityPredicates *predicates);
|
||||
|
||||
__attribute__((visibility("default"))) OHOS::NativeRdb::DataAbilityPredicates *
|
||||
NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_GetNativeObject(
|
||||
const napi_env env, const napi_value arg);
|
||||
EXTERN_C_END
|
||||
#endif // DATAABILITY_JSKIT_NAPI_DATA_ABILITY_PREDICATES_H
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef APPDATAMGR_NAPI_PREDICATES_UTILS_H
|
||||
#define APPDATAMGR_NAPI_PREDICATES_UTILS_H
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DataAbilityJsKit {
|
||||
napi_value InitPredicatesUtils(napi_env env, napi_value info);
|
||||
#define RDB_CHECK_RETURN_NULLPTR(assertion, message) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_ERROR("%{public}s", message); \
|
||||
return nullptr; \
|
||||
} \
|
||||
} while (0)
|
||||
} // namespace DataAbilityJsKit
|
||||
} // namespace OHOS
|
||||
#endif // APPDATAMGR_NAPI_PREDICATES_UTILS_H
|
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef RDB_JS_NAPI_ERROR_H
|
||||
#define RDB_JS_NAPI_ERROR_H
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
constexpr int MAX_INPUT_COUNT = 10;
|
||||
constexpr int OK = 0;
|
||||
constexpr int ERR = -1;
|
||||
constexpr int APIVERSION_V9 = 9;
|
||||
constexpr int APIVERSION_8 = 8;
|
||||
|
||||
constexpr int E_PARAM_ERROR = 401;
|
||||
constexpr int E_INNER_ERROR = 14800000;
|
||||
|
||||
constexpr int E_DB_INVALID = 14800010;
|
||||
constexpr int E_DB_CORRUPTED = 14800011;
|
||||
constexpr int E_RESULT_GET_ERROR = 14800013;
|
||||
constexpr int E_RESULT_GOTO_ERROR = 14800012;
|
||||
|
||||
#define RDB_NAPI_ASSERT_BASE_FROMV9(env, assertion, error, retVal, version) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
if ((error) == nullptr) { \
|
||||
LOG_ERROR("throw error: error message is empty,version= %{public}d", version); \
|
||||
napi_throw_error((env), nullptr, "error message is empty"); \
|
||||
return retVal; \
|
||||
} \
|
||||
if (((version) > (APIVERSION_8)) || (((error)->GetCode()) == (401))) { \
|
||||
LOG_ERROR("throw error: code = %{public}d , message = %{public}s, version= %{public}d", \
|
||||
(error)->GetCode(), (error)->GetMessage().c_str(), version); \
|
||||
napi_throw_error((env), std::to_string((error)->GetCode()).c_str(), (error)->GetMessage().c_str()); \
|
||||
return retVal; \
|
||||
} \
|
||||
LOG_ERROR("nothrow error: code = %{public}d , message = %{public}s, version= %{public}d", \
|
||||
(error)->GetCode(), (error)->GetMessage().c_str(), version); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RDB_REVT_NOTHING
|
||||
|
||||
#define RDB_NAPI_ASSERT_FROMV9(env, assertion, error, version) \
|
||||
RDB_NAPI_ASSERT_BASE_FROMV9(env, assertion, error, nullptr, version)
|
||||
|
||||
#define RDB_NAPI_ASSERT_RETURN_VOID_FROMV9(env, assertion, error, version) \
|
||||
RDB_NAPI_ASSERT_BASE_FROMV9(env, assertion, error, NAPI_RETVAL_NOTHING, version)
|
||||
|
||||
#define RDB_ASYNC_PARAM_CHECK_FUNCTION(theCall) \
|
||||
do { \
|
||||
int err = (theCall); \
|
||||
if (err != OK) { \
|
||||
return err; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RDB_CHECK_RETURN_NULLPTR(assertion, message) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_ERROR("%{public}s", message); \
|
||||
return nullptr; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RDB_CHECK_RETURN_VOID(assertion, message) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_ERROR("%{public}s", message); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_RETURN_CORE(assertion, theCall, revt) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
theCall; \
|
||||
return revt; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_RETURN_ERR(assertion) \
|
||||
CHECK_RETURN_CORE(assertion, RDB_REVT_NOTHING, ERR)
|
||||
|
||||
#define RDB_CHECK_RETURN_CALL_RESULT(assertion, theCall) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
(theCall); \
|
||||
return ERR; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class Error {
|
||||
public:
|
||||
virtual ~Error(){};
|
||||
virtual std::string GetMessage() = 0;
|
||||
virtual int GetCode() = 0;
|
||||
};
|
||||
|
||||
class InnerError : public Error {
|
||||
public:
|
||||
InnerError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "System error.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_INNER_ERROR;
|
||||
};
|
||||
};
|
||||
|
||||
class ParamTypeError : public Error {
|
||||
public:
|
||||
ParamTypeError(const std::string &name, const std::string &wantType) : name(name), wantType(wantType){};
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Parameter error. The type of '" + name + "' must be " + wantType;
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_PARAM_ERROR;
|
||||
};
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::string wantType;
|
||||
};
|
||||
|
||||
class ParamNumError : public Error {
|
||||
public:
|
||||
ParamNumError(const std::string &wantNum) : wantNum(wantNum){};
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Parameter error. Need " + wantNum + " parameters!";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_PARAM_ERROR;
|
||||
};
|
||||
|
||||
private:
|
||||
std::string wantNum;
|
||||
};
|
||||
|
||||
class DbInvalidError : public Error {
|
||||
public:
|
||||
DbInvalidError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Failed open database, invalid database name.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_DB_INVALID;
|
||||
};
|
||||
};
|
||||
|
||||
class DbCorruptedError : public Error {
|
||||
public:
|
||||
DbCorruptedError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Failed open database, database corrupted.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_DB_CORRUPTED;
|
||||
};
|
||||
};
|
||||
|
||||
class ResultGetError : public Error {
|
||||
public:
|
||||
ResultGetError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "The column value is null or the column type is incompatible.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_RESULT_GET_ERROR;
|
||||
};
|
||||
};
|
||||
|
||||
class ResultGotoError : public Error {
|
||||
public:
|
||||
ResultGotoError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "The result set is empty or the specified location is invalid.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_RESULT_GOTO_ERROR;
|
||||
};
|
||||
};
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RDB_JS_NAPI_ERROR_H
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RDB_JSKIT_NAPI_RDB_JS_UTILS_H
|
||||
#define RDB_JSKIT_NAPI_RDB_JS_UTILS_H
|
||||
#include "asset_value.h"
|
||||
#include "js_utils.h"
|
||||
#include "result_set.h"
|
||||
#include "value_object.h"
|
||||
namespace OHOS::AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
using Asset = OHOS::NativeRdb::AssetValue;
|
||||
using RowEntity = OHOS::NativeRdb::RowEntity;
|
||||
using ValueObject = OHOS::NativeRdb::ValueObject;
|
||||
using BigInt = OHOS::NativeRdb::BigInteger;
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value input, Asset &output);
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const Asset &value);
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const RowEntity &value);
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, ValueObject &valueObject);
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const BigInt &value);
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, BigInt &value);
|
||||
}; // namespace JSUtils
|
||||
} // namespace OHOS::AppDataMgrJsKit
|
||||
#endif // RDB_JSKIT_NAPI_RDB_JS_UTILS_H
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RDB_JSKIT_NAPI_RDB_PREDICATES_H
|
||||
#define RDB_JSKIT_NAPI_RDB_PREDICATES_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "napi_rdb_error.h"
|
||||
#include "rdb_predicates.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RdbJsKit {
|
||||
class RdbPredicatesProxy {
|
||||
public:
|
||||
static void Init(napi_env env, napi_value exports);
|
||||
static napi_value NewInstance(
|
||||
napi_env env, std::shared_ptr<NativeRdb::RdbPredicates> value, int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
|
||||
|
||||
explicit RdbPredicatesProxy(std::string &tableName);
|
||||
std::shared_ptr<NativeRdb::RdbPredicates> GetPredicates() const;
|
||||
int apiversion = AppDataMgrJsKit::APIVERSION_8;
|
||||
|
||||
private:
|
||||
~RdbPredicatesProxy();
|
||||
|
||||
static napi_value New(napi_env env, napi_callback_info info);
|
||||
static napi_value NewV9(napi_env env, napi_callback_info info);
|
||||
static napi_value InnerNew(napi_env env, napi_callback_info info, int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static std::shared_ptr<NativeRdb::RdbPredicates> GetNativePredicates(napi_env env, napi_callback_info info);
|
||||
|
||||
static RdbPredicatesProxy *ParseFieldArrayByName(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::vector<std::string> &fieldarray, const std::string fieldName, const std::string fieldType);
|
||||
static RdbPredicatesProxy *ParseFieldByName(
|
||||
napi_env env, napi_callback_info info, napi_value &thiz, std::string &field, const std::string fieldName);
|
||||
static RdbPredicatesProxy *ParseInt32FieldByName(
|
||||
napi_env env, napi_callback_info info, napi_value &thiz, int32_t &field, const std::string fieldName);
|
||||
static RdbPredicatesProxy *ParseFieldAndValueArray(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, std::vector<NativeRdb::ValueObject> &value, const std::string valueType);
|
||||
static RdbPredicatesProxy *ParseFieldAndValue(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, NativeRdb::ValueObject &value, const std::string valueType);
|
||||
static RdbPredicatesProxy *ParseFieldAndStringValue(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, std::string &value, const std::string valueType);
|
||||
static RdbPredicatesProxy *ParseFieldLowAndHigh(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, NativeRdb::ValueObject &low, NativeRdb::ValueObject &High);
|
||||
|
||||
static napi_value EqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value NotEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value EndWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value Or(napi_env env, napi_callback_info info);
|
||||
static napi_value And(napi_env env, napi_callback_info info);
|
||||
static napi_value Contains(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value EndsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNull(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNotNull(napi_env env, napi_callback_info info);
|
||||
static napi_value Like(napi_env env, napi_callback_info info);
|
||||
static napi_value Glob(napi_env env, napi_callback_info info);
|
||||
static napi_value Between(napi_env env, napi_callback_info info);
|
||||
static napi_value NotBetween(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThan(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThan(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByAsc(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByDesc(napi_env env, napi_callback_info info);
|
||||
static napi_value Distinct(napi_env env, napi_callback_info info);
|
||||
static napi_value Limit(napi_env env, napi_callback_info info);
|
||||
static napi_value Offset(napi_env env, napi_callback_info info);
|
||||
static napi_value GroupBy(napi_env env, napi_callback_info info);
|
||||
static napi_value IndexedBy(napi_env env, napi_callback_info info);
|
||||
static napi_value In(napi_env env, napi_callback_info info);
|
||||
static napi_value NotIn(napi_env env, napi_callback_info info);
|
||||
static napi_value Using(napi_env env, napi_callback_info info);
|
||||
static napi_value Clear(napi_env env, napi_callback_info info);
|
||||
static napi_value CrossJoin(napi_env env, napi_callback_info info);
|
||||
static napi_value LeftOuterJoin(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinCount(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinConditions(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinTableNames(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinTypes(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinCount(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinTypes(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinTableNames(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinConditions(napi_env env, napi_callback_info info);
|
||||
static napi_value InnerJoin(napi_env env, napi_callback_info info);
|
||||
static napi_value On(napi_env env, napi_callback_info info);
|
||||
static napi_value InDevices(napi_env env, napi_callback_info info);
|
||||
static napi_value InAllDevices(napi_env env, napi_callback_info info);
|
||||
|
||||
std::shared_ptr<NativeRdb::RdbPredicates> predicates_;
|
||||
};
|
||||
} // namespace RdbJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RDB_JSKIT_NAPI_RDB_PREDICATES_H
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef DISTRIBUTEDDATAMGR_NAPI_RDB_TRACE_H
|
||||
#define DISTRIBUTEDDATAMGR_NAPI_RDB_TRACE_H
|
||||
|
||||
#define DO_NOTHING
|
||||
|
||||
#ifdef RDB_TRACE_ON
|
||||
#include "hitrace.h"
|
||||
#define DISTRIBUTED_DATA_HITRACE(trace) HiTrace hitrace(trace)
|
||||
#else
|
||||
#define DISTRIBUTED_DATA_HITRACE(trace) DO_NOTHING
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef RDB_JSKIT_NAPI_RESULT_SET_H
|
||||
#define RDB_JSKIT_NAPI_RESULT_SET_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "js_proxy.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "napi_rdb_error.h"
|
||||
#include "result_set_bridge.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RdbJsKit {
|
||||
class ResultSetProxy final : public JSProxy::JSEntity<NativeRdb::ResultSet, DataShare::ResultSetBridge> {
|
||||
public:
|
||||
ResultSetProxy() = default;
|
||||
~ResultSetProxy();
|
||||
ResultSetProxy(std::shared_ptr<NativeRdb::ResultSet> resultSet);
|
||||
ResultSetProxy &operator=(std::shared_ptr<NativeRdb::ResultSet> resultSet);
|
||||
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet,
|
||||
int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::ResultSet> resultSet,
|
||||
int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static std::shared_ptr<NativeRdb::AbsSharedResultSet> GetNativeObject(const napi_env env, const napi_value arg);
|
||||
static napi_value GetConstructor(napi_env env, int version);
|
||||
std::shared_ptr<DataShare::ResultSetBridge> Create() override;
|
||||
int apiversion = AppDataMgrJsKit::APIVERSION_8;
|
||||
|
||||
private:
|
||||
static ResultSetProxy *GetInnerResultSet(napi_env env, napi_callback_info info, int &version);
|
||||
static ResultSetProxy *ParseInt32FieldByName(
|
||||
napi_env env, napi_callback_info info, int32_t &field, const std::string& fieldName);
|
||||
static ResultSetProxy *ParseFieldByName(napi_env env, napi_callback_info info, std::string &field);
|
||||
|
||||
static napi_value InnerInitialize(
|
||||
napi_env env, napi_callback_info info, int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static napi_value Initialize(napi_env env, napi_callback_info info);
|
||||
static napi_value InitializeV9(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAllColumnNames(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnCount(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLong(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnType(napi_env env, napi_callback_info info);
|
||||
static napi_value GoTo(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnIndex(napi_env env, napi_callback_info info);
|
||||
static napi_value GetInt(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnName(napi_env env, napi_callback_info info);
|
||||
static napi_value Close(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRowCount(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRowIndex(napi_env env, napi_callback_info info);
|
||||
static napi_value IsEnded(napi_env env, napi_callback_info info);
|
||||
static napi_value IsBegin(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToFirstRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToLastRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToNextRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToPreviousRow(napi_env env, napi_callback_info info);
|
||||
static napi_value IsAtFirstRow(napi_env env, napi_callback_info info);
|
||||
static napi_value IsAtLastRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetBlob(napi_env env, napi_callback_info info);
|
||||
static napi_value GetString(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDouble(napi_env env, napi_callback_info info);
|
||||
static napi_value IsColumnNull(napi_env env, napi_callback_info info);
|
||||
static napi_value IsClosed(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value GetSharedBlockName(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSharedBlockAshmemFd(napi_env env, napi_callback_info info);
|
||||
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> sharedResultSet_;
|
||||
|
||||
std::string sharedBlockName_;
|
||||
int32_t sharedBlockAshmemFd_ = -1;
|
||||
};
|
||||
} // namespace RdbJsKit
|
||||
} // namespace OHOS
|
||||
#endif // RDB_JSKIT_NAPI_RESULT_SET_H
|
716
frameworks/js/napi/featureAbility/data_ability/js_utils.cpp
Normal file
716
frameworks/js/napi/featureAbility/data_ability/js_utils.cpp
Normal file
@ -0,0 +1,716 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "JSUtils"
|
||||
|
||||
#include "js_utils.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "js_native_api_types.h"
|
||||
#include "logger.h"
|
||||
#include "securec.h"
|
||||
using namespace OHOS::Rdb;
|
||||
|
||||
#define CHECK_RETURN_RET(assertion, message, revt) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_WARN("assertion (" #assertion ") failed: " message); \
|
||||
return revt; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
static int32_t g_hapVersion = -1; // the current apiVersion of hap
|
||||
}
|
||||
|
||||
static constexpr JSUtils::JsFeatureSpace FEATURE_NAME_SPACES[] = {
|
||||
{ "ohos.data.cloudData", "ZGF0YS5jbG91ZERhdGE=", true },
|
||||
{ "ohos.data.dataAbility", "ZGF0YS5kYXRhQWJpbGl0eQ==", true },
|
||||
{ "ohos.data.dataShare", "ZGF0YS5kYXRhU2hhcmU=", false },
|
||||
{ "ohos.data.distributedDataObject", "ZGF0YS5kaXN0cmlidXRlZERhdGFPYmplY3Q=", false },
|
||||
{ "ohos.data.distributedKVStore", "ZGF0YS5kaXN0cmlidXRlZEtWU3RvcmU=", false },
|
||||
{ "ohos.data.rdb", "ZGF0YS5yZGI=", true },
|
||||
{ "ohos.data.relationalStore", "ZGF0YS5yZWxhdGlvbmFsU3RvcmU=", true },
|
||||
};
|
||||
|
||||
void JSUtils::SetHapVersion(int32_t hapversion)
|
||||
{
|
||||
g_hapVersion = hapversion;
|
||||
}
|
||||
|
||||
int32_t JSUtils::GetHapVersion()
|
||||
{
|
||||
return g_hapVersion;
|
||||
}
|
||||
|
||||
const std::optional<JSUtils::JsFeatureSpace> JSUtils::GetJsFeatureSpace(const std::string &name)
|
||||
{
|
||||
auto jsFeature = JsFeatureSpace{ name.data(), nullptr, false };
|
||||
auto iter = std::lower_bound(FEATURE_NAME_SPACES,
|
||||
FEATURE_NAME_SPACES + sizeof(FEATURE_NAME_SPACES) / sizeof(FEATURE_NAME_SPACES[0]), jsFeature,
|
||||
[](const JsFeatureSpace &JsFeatureSpace1, const JsFeatureSpace &JsFeatureSpace2) {
|
||||
return strcmp(JsFeatureSpace1.spaceName, JsFeatureSpace2.spaceName) < 0;
|
||||
});
|
||||
if (iter < FEATURE_NAME_SPACES + sizeof(FEATURE_NAME_SPACES) / sizeof(FEATURE_NAME_SPACES[0]) &&
|
||||
strcmp(iter->spaceName, name.data()) == 0) {
|
||||
return *iter;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::pair<napi_status, napi_value> JSUtils::GetInnerValue(
|
||||
napi_env env, napi_value in, const std::string &prop, bool optional)
|
||||
{
|
||||
bool hasProp = false;
|
||||
napi_status status = napi_has_named_property(env, in, prop.c_str(), &hasProp);
|
||||
if (status != napi_ok) {
|
||||
return std::make_pair(napi_generic_failure, nullptr);
|
||||
}
|
||||
if (!hasProp) {
|
||||
status = optional ? napi_ok : napi_generic_failure;
|
||||
return std::make_pair(status, nullptr);
|
||||
}
|
||||
napi_value inner = nullptr;
|
||||
status = napi_get_named_property(env, in, prop.c_str(), &inner);
|
||||
if (status != napi_ok || inner == nullptr) {
|
||||
return std::make_pair(napi_generic_failure, nullptr);
|
||||
}
|
||||
if (optional && JSUtils::IsNull(env, inner)) {
|
||||
return std::make_pair(napi_ok, nullptr);
|
||||
}
|
||||
return std::make_pair(napi_ok, inner);
|
||||
}
|
||||
|
||||
std::string JSUtils::Convert2String(napi_env env, napi_value jsStr)
|
||||
{
|
||||
std::string value = ""; // TD: need to check everywhere in use whether empty is work well.
|
||||
JSUtils::Convert2Value(env, jsStr, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2ValueExt(napi_env env, napi_value jsValue, uint32_t &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
status = napi_get_value_uint32(env, jsValue, &output);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_uint32 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2ValueExt(napi_env env, napi_value jsValue, int32_t &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
status = napi_get_value_int32(env, jsValue, &output);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_int32 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, napi_value &output)
|
||||
{
|
||||
output = jsValue;
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, bool &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_boolean) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
bool bValue = false;
|
||||
status = napi_get_value_bool(env, jsValue, &bValue);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("napi_get_value_bool failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
output = bValue;
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2ValueExt(napi_env env, napi_value jsValue, int64_t &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
status = napi_get_value_int64(env, jsValue, &output);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_int64 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, double &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
double number = 0.0;
|
||||
status = napi_get_value_double(env, jsValue, &number);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_double failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
output = number;
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, int64_t &output)
|
||||
{
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::vector<float> &output)
|
||||
{
|
||||
bool isTypedArray = false;
|
||||
napi_is_typedarray(env, jsValue, &isTypedArray);
|
||||
if (!isTypedArray) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
napi_typedarray_type type;
|
||||
napi_value input_buffer = nullptr;
|
||||
size_t byte_offset = 0;
|
||||
size_t length = 0;
|
||||
void *tmp = nullptr;
|
||||
auto status = napi_get_typedarray_info(env, jsValue, &type, &length, &tmp, &input_buffer, &byte_offset);
|
||||
if (status != napi_ok || type != napi_float32_array) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
output = (tmp != nullptr
|
||||
? std::vector<float>(static_cast<float *>(tmp), static_cast<float *>(tmp) + length / sizeof(float))
|
||||
: std::vector<float>());
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::string &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_string) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
size_t buffSize = 0;
|
||||
napi_get_value_string_utf8(env, jsValue, nullptr, 0, &buffSize);
|
||||
|
||||
// cut down with 0 if more than MAX_VALUE_LENGTH
|
||||
if (buffSize >= JSUtils::MAX_VALUE_LENGTH - 1) {
|
||||
buffSize = JSUtils::MAX_VALUE_LENGTH - 1;
|
||||
}
|
||||
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(buffSize + 1);
|
||||
if (!buffer) {
|
||||
LOG_ERROR("buffer data is nullptr.");
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_value_string_utf8(env, jsValue, buffer.get(), buffSize + 1, &buffSize);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("napi_get_value_string_utf8 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
output = std::string(buffer.get());
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::vector<uint8_t> &output)
|
||||
{
|
||||
bool isTypedArray = false;
|
||||
napi_is_typedarray(env, jsValue, &isTypedArray);
|
||||
if (!isTypedArray) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
napi_typedarray_type type;
|
||||
napi_value input_buffer = nullptr;
|
||||
size_t byte_offset = 0;
|
||||
size_t length = 0;
|
||||
void *tmp = nullptr;
|
||||
auto status = napi_get_typedarray_info(env, jsValue, &type, &length, &tmp, &input_buffer, &byte_offset);
|
||||
if (status != napi_ok || type != napi_uint8_array) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
output = (tmp != nullptr ? std::vector<uint8_t>(static_cast<uint8_t *>(tmp), static_cast<uint8_t *>(tmp) + length)
|
||||
: std::vector<uint8_t>());
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::monostate &value)
|
||||
{
|
||||
napi_value tempValue = nullptr;
|
||||
napi_get_null(env, &tempValue);
|
||||
bool equal = false;
|
||||
napi_strict_equals(env, jsValue, tempValue, &equal);
|
||||
if (equal) {
|
||||
value = std::monostate();
|
||||
return napi_ok;
|
||||
}
|
||||
LOG_DEBUG("jsValue is not null.");
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, int32_t> &output)
|
||||
{
|
||||
LOG_DEBUG("napi_value -> std::map<std::string, int32_t> ");
|
||||
output.clear();
|
||||
napi_value jsMapList = nullptr;
|
||||
uint32_t jsCount = 0;
|
||||
napi_status status = napi_get_property_names(env, jsValue, &jsMapList);
|
||||
CHECK_RETURN_RET(status == napi_ok, "get_property_names failed", napi_invalid_arg);
|
||||
status = napi_get_array_length(env, jsMapList, &jsCount);
|
||||
LOG_DEBUG("jsCOUNT: %{public}d", jsCount);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsCount > 0, "get_map failed", napi_invalid_arg);
|
||||
napi_value jsKey = nullptr;
|
||||
napi_value jsVal = nullptr;
|
||||
for (uint32_t index = 0; index < jsCount; index++) {
|
||||
status = napi_get_element(env, jsMapList, index, &jsKey);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsKey != nullptr, "no element", napi_invalid_arg);
|
||||
std::string key;
|
||||
int ret = Convert2Value(env, jsKey, key);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert key failed", ret);
|
||||
status = napi_get_property(env, jsValue, jsKey, &jsVal);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsVal != nullptr, "no element", napi_invalid_arg);
|
||||
int32_t val;
|
||||
ret = Convert2ValueExt(env, jsVal, val);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert val failed", ret);
|
||||
output.insert(std::pair<std::string, int32_t>(key, val));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, bool> &output)
|
||||
{
|
||||
LOG_DEBUG("napi_value -> std::map<std::string, bool> ");
|
||||
output.clear();
|
||||
napi_value jsMapList = nullptr;
|
||||
uint32_t jsCount = 0;
|
||||
napi_status status = napi_get_property_names(env, jsValue, &jsMapList);
|
||||
CHECK_RETURN_RET(status == napi_ok, "get_property_names failed", napi_invalid_arg);
|
||||
status = napi_get_array_length(env, jsMapList, &jsCount);
|
||||
LOG_DEBUG("jsCount: %{public}d", jsCount);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsCount > 0, "get_map failed", napi_invalid_arg);
|
||||
napi_value jsKey = nullptr;
|
||||
napi_value jsVal = nullptr;
|
||||
for (uint32_t index = 0; index < jsCount; index++) {
|
||||
status = napi_get_element(env, jsMapList, index, &jsKey);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsKey != nullptr, "no element", napi_invalid_arg);
|
||||
std::string key;
|
||||
int ret = Convert2Value(env, jsKey, key);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert key failed", ret);
|
||||
status = napi_get_property(env, jsValue, jsKey, &jsVal);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsVal != nullptr, "no element", napi_invalid_arg);
|
||||
bool val;
|
||||
ret = Convert2Value(env, jsVal, val);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert val failed", ret);
|
||||
output.insert(std::pair<std::string, bool>(key, val));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::string &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
if (napi_create_string_utf8(env, value.c_str(), value.size(), &jsValue) != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::vector<uint8_t> &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
void *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
napi_status status = napi_create_arraybuffer(env, value.size(), &native, &buffer);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < value.size(); i++) {
|
||||
*(static_cast<uint8_t *>(native) + i) = value[i];
|
||||
}
|
||||
status = napi_create_typedarray(env, napi_uint8_array, value.size(), buffer, 0, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, int32_t value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_int32(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, uint32_t value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_uint32(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, int64_t value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_int64(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, double value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_double(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, bool value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_get_boolean(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::vector<float> &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
float *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
napi_status status = napi_create_arraybuffer(env, value.size() * sizeof(float), (void **)&native, &buffer);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
if (native == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < value.size(); i++) {
|
||||
*(native + i) = value[i];
|
||||
}
|
||||
status = napi_create_typedarray(env, napi_float32_array, value.size(), buffer, 0, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::map<std::string, int> &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_array_with_length(env, value.size(), &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (const auto &[device, result] : value) {
|
||||
napi_value jsElement = nullptr;
|
||||
status = napi_create_array_with_length(env, SYNC_RESULT_ELEMENT_NUM, &jsElement);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_element(env, jsElement, 0, Convert2JSValue(env, device));
|
||||
napi_set_element(env, jsElement, 1, Convert2JSValue(env, result));
|
||||
napi_set_element(env, jsValue, index++, jsElement);
|
||||
}
|
||||
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2JSValue(napi_env env, std::string value, napi_value &output)
|
||||
{
|
||||
std::string tempStr = std::string(value);
|
||||
if (napi_create_string_utf8(env, tempStr.c_str(), tempStr.size(), &output) != napi_ok) {
|
||||
LOG_ERROR("Convert2JSValue create JS string failed.");
|
||||
return ERR;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2JSValue(napi_env env, bool value, napi_value &output)
|
||||
{
|
||||
if (napi_get_boolean(env, value, &output) != napi_ok) {
|
||||
LOG_ERROR("Convert2JSValue create JS bool failed.");
|
||||
return ERR;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2JSValue(napi_env env, double value, napi_value &output)
|
||||
{
|
||||
if (napi_create_double(env, value, &output) != napi_ok) {
|
||||
LOG_ERROR("Convert2JSValue create JS double failed.");
|
||||
return ERR;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::monostate &value)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
napi_get_null(env, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JSUtils::IsNull(napi_env env, napi_value value)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, value, &type);
|
||||
return status == napi_ok && (type == napi_undefined || type == napi_null);
|
||||
}
|
||||
|
||||
napi_value JSUtils::DefineClass(napi_env env, const std::string &spaceName, const std::string &className,
|
||||
const Descriptor &descriptor, napi_callback ctor)
|
||||
{
|
||||
auto featureSpace = GetJsFeatureSpace(spaceName);
|
||||
if (!featureSpace.has_value() || !featureSpace->isComponent) {
|
||||
return nullptr;
|
||||
}
|
||||
auto constructor = GetClass(env, spaceName, className);
|
||||
if (constructor != nullptr) {
|
||||
return constructor;
|
||||
}
|
||||
auto rootPropName = std::string(featureSpace->nameBase64);
|
||||
napi_value root = nullptr;
|
||||
bool hasRoot = false;
|
||||
napi_value global = nullptr;
|
||||
napi_get_global(env, &global);
|
||||
napi_has_named_property(env, global, rootPropName.c_str(), &hasRoot);
|
||||
if (hasRoot) {
|
||||
napi_get_named_property(env, global, rootPropName.c_str(), &root);
|
||||
} else {
|
||||
napi_create_object(env, &root);
|
||||
napi_set_named_property(env, global, rootPropName.c_str(), root);
|
||||
}
|
||||
|
||||
std::string propName = "constructor_of_" + className;
|
||||
bool hasProp = false;
|
||||
napi_has_named_property(env, root, propName.c_str(), &hasProp);
|
||||
if (hasProp) {
|
||||
napi_get_named_property(env, root, propName.c_str(), &constructor);
|
||||
if (constructor != nullptr) {
|
||||
LOG_DEBUG("got %{public}s from %{public}s", propName.c_str(), featureSpace->spaceName);
|
||||
return constructor;
|
||||
}
|
||||
hasProp = false; // no constructor.
|
||||
}
|
||||
auto properties = descriptor();
|
||||
NAPI_CALL(env, napi_define_class(env, className.c_str(), className.size(), ctor, nullptr, properties.size(),
|
||||
properties.data(), &constructor));
|
||||
NAPI_ASSERT(env, constructor != nullptr, "napi_define_class failed!");
|
||||
|
||||
if (!hasProp) {
|
||||
napi_set_named_property(env, root, propName.c_str(), constructor);
|
||||
LOG_DEBUG("save %{public}s to %{public}s", propName.c_str(), featureSpace->spaceName);
|
||||
}
|
||||
return constructor;
|
||||
}
|
||||
|
||||
napi_value JSUtils::GetClass(napi_env env, const std::string &spaceName, const std::string &className)
|
||||
{
|
||||
auto featureSpace = GetJsFeatureSpace(spaceName);
|
||||
if (!featureSpace.has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto rootPropName = std::string(featureSpace->nameBase64);
|
||||
napi_value root = nullptr;
|
||||
napi_value global = nullptr;
|
||||
napi_get_global(env, &global);
|
||||
bool hasRoot;
|
||||
napi_has_named_property(env, global, rootPropName.c_str(), &hasRoot);
|
||||
if (!hasRoot) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_get_named_property(env, global, rootPropName.c_str(), &root);
|
||||
std::string propName = "constructor_of_" + className;
|
||||
napi_value constructor = nullptr;
|
||||
bool hasProp = false;
|
||||
napi_has_named_property(env, root, propName.c_str(), &hasProp);
|
||||
if (!hasProp) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_get_named_property(env, root, propName.c_str(), &constructor);
|
||||
if (constructor != nullptr) {
|
||||
LOG_DEBUG("got %{public}s from %{public}s", propName.c_str(), featureSpace->spaceName);
|
||||
return constructor;
|
||||
}
|
||||
hasProp = false; // no constructor.
|
||||
return constructor;
|
||||
}
|
||||
|
||||
bool JSUtils::Equal(napi_env env, napi_ref ref, napi_value value)
|
||||
{
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, ref, &callback);
|
||||
|
||||
bool isEquals = false;
|
||||
napi_strict_equals(env, value, callback, &isEquals);
|
||||
return isEquals;
|
||||
}
|
||||
|
||||
napi_value JSUtils::ToJsObject(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
LOG_DEBUG("sendableObject -> jsObject");
|
||||
napi_value keys = nullptr;
|
||||
napi_status status = napi_get_all_property_names(env, sendableValue, napi_key_own_only,
|
||||
static_cast<napi_key_filter>(napi_key_enumerable | napi_key_skip_symbols), napi_key_numbers_to_strings, &keys);
|
||||
ASSERT(status == napi_ok, "napi_get_all_property_names failed", nullptr);
|
||||
uint32_t length = 0;
|
||||
status = napi_get_array_length(env, keys, &length);
|
||||
ASSERT(status == napi_ok, "napi_get_array_length failed", nullptr);
|
||||
std::vector<napi_property_descriptor> descriptors;
|
||||
// keysHold guarantees that the string address is valid before create the sendable object.
|
||||
std::vector<std::string> keysHold(length, "");
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
napi_value key = nullptr;
|
||||
status = napi_get_element(env, keys, i, &key);
|
||||
ASSERT(status == napi_ok, "napi_get_element failed", nullptr);
|
||||
JSUtils::Convert2Value(env, key, keysHold[i]);
|
||||
napi_value value = nullptr;
|
||||
status = napi_get_named_property(env, sendableValue, keysHold[i].c_str(), &value);
|
||||
ASSERT(status == napi_ok, "napi_get_named_property failed", nullptr);
|
||||
descriptors.emplace_back(DECLARE_JS_PROPERTY(env, keysHold[i].c_str(), value));
|
||||
}
|
||||
napi_value jsObject = nullptr;
|
||||
status = napi_create_object_with_properties(env, &jsObject, descriptors.size(), descriptors.data());
|
||||
ASSERT(status == napi_ok, "napi_create_object_with_properties failed", nullptr);
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
napi_value JSUtils::ToJsArray(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
LOG_DEBUG("sendableArray -> jsArray");
|
||||
uint32_t arrLen = 0;
|
||||
napi_status status = napi_get_array_length(env, sendableValue, &arrLen);
|
||||
ASSERT(status == napi_ok, "napi_get_array_length failed", nullptr);
|
||||
napi_value jsArray = nullptr;
|
||||
status = napi_create_array_with_length(env, arrLen, &jsArray);
|
||||
ASSERT(status == napi_ok, "napi_create_array_with_length failed", nullptr);
|
||||
for (size_t i = 0; i < arrLen; ++i) {
|
||||
napi_value element;
|
||||
status = napi_get_element(env, sendableValue, i, &element);
|
||||
ASSERT(status == napi_ok, "napi_get_element failed", nullptr);
|
||||
status = napi_set_element(env, jsArray, i, Convert2JSValue(env, element));
|
||||
ASSERT(status == napi_ok, "napi_set_element failed", nullptr);
|
||||
}
|
||||
return jsArray;
|
||||
}
|
||||
|
||||
napi_value JSUtils::ToJsTypedArray(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
LOG_DEBUG("sendableTypedArray -> jsTypedArray");
|
||||
napi_typedarray_type type;
|
||||
size_t length = 0;
|
||||
void *tmp = nullptr;
|
||||
napi_status status = napi_get_typedarray_info(env, sendableValue, &type, &length, &tmp, nullptr, nullptr);
|
||||
ASSERT(status == napi_ok, "napi_get_typedarray_info failed", nullptr);
|
||||
|
||||
if (type != napi_uint8_array && type != napi_float32_array) {
|
||||
LOG_ERROR("type is invalid %{public}d", type);
|
||||
return nullptr;
|
||||
}
|
||||
napi_value jsTypedArray = nullptr;
|
||||
void *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
status = napi_create_arraybuffer(env, length, (void **)&native, &buffer);
|
||||
ASSERT(status == napi_ok, "napi_create_arraybuffer failed", nullptr);
|
||||
if (length > 0) {
|
||||
errno_t result = memcpy_s(native, length, tmp, length);
|
||||
if (result != EOK) {
|
||||
LOG_ERROR("memcpy_s failed, result is %{public}d", result);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto size = (type == napi_uint8_array) ? length : length / sizeof(float);
|
||||
status = napi_create_typedarray(env, type, size, buffer, 0, &jsTypedArray);
|
||||
ASSERT(status == napi_ok, "napi_create_typedarray failed", nullptr);
|
||||
return jsTypedArray;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, sendableValue, &type);
|
||||
ASSERT(status == napi_ok, "napi_typeof failed", nullptr);
|
||||
if (type != napi_object) {
|
||||
return sendableValue;
|
||||
}
|
||||
bool result = false;
|
||||
status = napi_is_sendable(env, sendableValue, &result);
|
||||
ASSERT(status == napi_ok, "napi_is_sendable failed", nullptr);
|
||||
if (!result) {
|
||||
return sendableValue;
|
||||
}
|
||||
|
||||
status = napi_is_array(env, sendableValue, &result);
|
||||
ASSERT(status == napi_ok, "napi_is_array failed", nullptr);
|
||||
if (result) {
|
||||
return ToJsArray(env, sendableValue);
|
||||
}
|
||||
status = napi_is_typedarray(env, sendableValue, &result);
|
||||
ASSERT(status == napi_ok, "napi_is_typedarray failed", nullptr);
|
||||
if (result) {
|
||||
return ToJsTypedArray(env, sendableValue);
|
||||
}
|
||||
return ToJsObject(env, sendableValue);
|
||||
}
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
@ -0,0 +1,815 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "DataAbilityPredicatesProxy"
|
||||
#include "napi_data_ability_predicates.h"
|
||||
|
||||
#include "js_utils.h"
|
||||
#include "logger.h"
|
||||
#include "napi_async_proxy.h"
|
||||
#include "napi_predicates_utils.h"
|
||||
|
||||
using namespace OHOS::Rdb;
|
||||
using namespace OHOS::NativeRdb;
|
||||
using namespace OHOS::AppDataMgrJsKit;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DataAbilityJsKit {
|
||||
static __thread napi_ref constructor_ = nullptr;
|
||||
|
||||
void DataAbilityPredicatesProxy::Init(napi_env env, napi_value exports)
|
||||
{
|
||||
LOG_INFO("Init DataAbilityPredicatesProxy");
|
||||
napi_property_descriptor descriptors[] = {
|
||||
DECLARE_NAPI_FUNCTION("equalTo", EqualTo),
|
||||
DECLARE_NAPI_FUNCTION("notEqualTo", NotEqualTo),
|
||||
DECLARE_NAPI_FUNCTION("beginWrap", BeginWrap),
|
||||
DECLARE_NAPI_FUNCTION("endWrap", EndWrap),
|
||||
DECLARE_NAPI_FUNCTION("or", Or),
|
||||
DECLARE_NAPI_FUNCTION("and", And),
|
||||
DECLARE_NAPI_FUNCTION("contains", Contains),
|
||||
DECLARE_NAPI_FUNCTION("beginsWith", BeginsWith),
|
||||
DECLARE_NAPI_FUNCTION("endsWith", EndsWith),
|
||||
DECLARE_NAPI_FUNCTION("isNull", IsNull),
|
||||
DECLARE_NAPI_FUNCTION("isNotNull", IsNotNull),
|
||||
DECLARE_NAPI_FUNCTION("like", Like),
|
||||
DECLARE_NAPI_FUNCTION("glob", Glob),
|
||||
DECLARE_NAPI_FUNCTION("between", Between),
|
||||
DECLARE_NAPI_FUNCTION("notBetween", NotBetween),
|
||||
DECLARE_NAPI_FUNCTION("greaterThan", GreaterThan),
|
||||
DECLARE_NAPI_FUNCTION("lessThan", LessThan),
|
||||
DECLARE_NAPI_FUNCTION("greaterThanOrEqualTo", GreaterThanOrEqualTo),
|
||||
DECLARE_NAPI_FUNCTION("lessThanOrEqualTo", LessThanOrEqualTo),
|
||||
DECLARE_NAPI_FUNCTION("orderByAsc", OrderByAsc),
|
||||
DECLARE_NAPI_FUNCTION("orderByDesc", OrderByDesc),
|
||||
DECLARE_NAPI_FUNCTION("distinct", Distinct),
|
||||
DECLARE_NAPI_FUNCTION("limitAs", Limit),
|
||||
DECLARE_NAPI_FUNCTION("offsetAs", Offset),
|
||||
DECLARE_NAPI_FUNCTION("groupBy", GroupBy),
|
||||
DECLARE_NAPI_FUNCTION("indexedBy", IndexedBy),
|
||||
DECLARE_NAPI_FUNCTION("in", In),
|
||||
DECLARE_NAPI_FUNCTION("notIn", NotIn),
|
||||
DECLARE_NAPI_FUNCTION("clear", Clear),
|
||||
DECLARE_NAPI_FUNCTION("isRawSelection", IsRawSelection),
|
||||
DECLARE_NAPI_GETTER_SETTER("whereClause", GetWhereClause, SetWhereClause),
|
||||
DECLARE_NAPI_GETTER_SETTER("whereArgs", GetWhereArgs, SetWhereArgs),
|
||||
DECLARE_NAPI_GETTER_SETTER("order", GetOrder, SetOrder),
|
||||
DECLARE_NAPI_GETTER("limit", GetLimit),
|
||||
DECLARE_NAPI_GETTER("offset", GetOffset),
|
||||
DECLARE_NAPI_GETTER("isDistinct", IsDistinct),
|
||||
DECLARE_NAPI_GETTER("group", GetGroup),
|
||||
DECLARE_NAPI_GETTER("index", GetIndex),
|
||||
DECLARE_NAPI_GETTER("isNeedAnd", IsNeedAnd),
|
||||
DECLARE_NAPI_GETTER("isSorted", IsSorted),
|
||||
};
|
||||
|
||||
napi_value cons = nullptr;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_define_class(env, "DataAbilityPredicates", NAPI_AUTO_LENGTH, New, nullptr,
|
||||
sizeof(descriptors) / sizeof(napi_property_descriptor), descriptors, &cons));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_reference(env, cons, 1, &constructor_));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, exports, "DataAbilityPredicates", cons));
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::New(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value new_target = nullptr;
|
||||
NAPI_CALL(env, napi_get_new_target(env, info, &new_target));
|
||||
bool is_constructor = (new_target != nullptr);
|
||||
|
||||
napi_value thiz = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr));
|
||||
|
||||
if (is_constructor) {
|
||||
auto *proxy = new (std::nothrow) DataAbilityPredicatesProxy();
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy::New new failed, proxy is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_status status = napi_wrap(env, thiz, proxy, DataAbilityPredicatesProxy::Destructor, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy::New napi_wrap failed! napi_status:%{public}d!", status);
|
||||
delete proxy;
|
||||
return nullptr;
|
||||
}
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value cons = nullptr;
|
||||
NAPI_CALL(env, napi_get_reference_value(env, constructor_, &cons));
|
||||
|
||||
napi_value output = nullptr;
|
||||
NAPI_CALL(env, napi_new_instance(env, cons, 0, nullptr, &output));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NewInstance(
|
||||
napi_env env, std::shared_ptr<NativeRdb::DataAbilityPredicates> value)
|
||||
{
|
||||
napi_value cons = nullptr;
|
||||
napi_status status = napi_get_reference_value(env, constructor_, &cons);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy get constructor failed! napi_status:%{public}d!", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value instance = nullptr;
|
||||
status = napi_new_instance(env, cons, 0, nullptr, &instance);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy napi_new_instance failed! napi_status:%{public}d!", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DataAbilityPredicatesProxy *proxy = nullptr;
|
||||
status = napi_unwrap(env, instance, reinterpret_cast<void **>(&proxy));
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy native instance is nullptr! napi_status:%{public}d!", status);
|
||||
return instance;
|
||||
}
|
||||
proxy->predicates_ = std::move(value);
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::GetNativePredicates(
|
||||
const napi_env env, const napi_value arg)
|
||||
{
|
||||
if (arg == nullptr) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy arg is null.");
|
||||
return nullptr;
|
||||
}
|
||||
DataAbilityPredicatesProxy *proxy = nullptr;
|
||||
napi_unwrap(env, arg, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy proxy is null.");
|
||||
return nullptr;
|
||||
}
|
||||
return proxy->predicates_;
|
||||
}
|
||||
|
||||
void DataAbilityPredicatesProxy::Destructor(napi_env env, void *nativeObject, void *)
|
||||
{
|
||||
DataAbilityPredicatesProxy *proxy = static_cast<DataAbilityPredicatesProxy *>(nativeObject);
|
||||
delete proxy;
|
||||
}
|
||||
|
||||
DataAbilityPredicatesProxy::~DataAbilityPredicatesProxy()
|
||||
{
|
||||
}
|
||||
|
||||
DataAbilityPredicatesProxy::DataAbilityPredicatesProxy() : predicates_(new DataAbilityPredicates())
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::GetNativePredicates(
|
||||
napi_env env, napi_callback_info info)
|
||||
{
|
||||
DataAbilityPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return predicatesProxy->predicates_;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::EqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::EqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->EqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NotEqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::NotEqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->NotEqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::BeginWrap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->BeginWrap();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::EndWrap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->EndWrap();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Or(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Or();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::And(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->And();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Contains(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Contains Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Contains(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::BeginsWith(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::BeginsWith Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->BeginsWith(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::EndsWith(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::EndsWith Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->EndsWith(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsNull(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::IsNull Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->IsNull(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsNotNull(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::IsNotNull Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->IsNotNull(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Like(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Like Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Like(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Glob(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Glob Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Glob(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Between(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 3;
|
||||
// 3 represents the number of parameters
|
||||
napi_value args[3] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Between Invalid argvs!");
|
||||
std::string field;
|
||||
// args[0] represents the first parameter
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject low;
|
||||
// args[1] represents the second parameter
|
||||
JSUtils::Convert2Value(env, args[1], low);
|
||||
ValueObject high;
|
||||
// args[2] represents the third parameter
|
||||
JSUtils::Convert2Value(env, args[2], high);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Between(field, low, high);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NotBetween(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 3;
|
||||
// 3 represents the number of parameters
|
||||
napi_value args[3] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::NotBetween Invalid argvs!");
|
||||
std::string field;
|
||||
// args[0] represents the first parameter
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject low;
|
||||
// args[1] represents the second parameter
|
||||
JSUtils::Convert2Value(env, args[1], low);
|
||||
ValueObject high;
|
||||
// args[2] represents the third parameter
|
||||
JSUtils::Convert2Value(env, args[2], high);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->NotBetween(field, low, high);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GreaterThan(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::GreaterThan Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->GreaterThan(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::LessThan(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::LessThan Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->LessThan(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GreaterThanOrEqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::GreaterThanOrEqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->GreaterThanOrEqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::LessThanOrEqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::LessThanOrEqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->LessThanOrEqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::OrderByAsc(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::OrderByAsc Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->OrderByAsc(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::OrderByDesc(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::OrderByDesc Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->OrderByDesc(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Distinct(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Distinct();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Limit(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Limit Invalid argvs!");
|
||||
|
||||
int32_t limit = 0;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2ValueExt(env, args[0], limit) == napi_ok, "the limit is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Limit(limit);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Offset(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Offset Invalid argvs!");
|
||||
|
||||
int32_t offset = 0;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2ValueExt(env, args[0], offset) == napi_ok, "the offset is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Offset(offset);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GroupBy(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::GroupBy Invalid argvs!");
|
||||
|
||||
std::vector<std::string> fields = {};
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], fields) == napi_ok, "the fields is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->GroupBy(fields);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IndexedBy(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::IndexedBy Invalid argvs!");
|
||||
|
||||
std::string indexName;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], indexName) == napi_ok, "the indexName is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->IndexedBy(indexName);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::In(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::In Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
std::vector<ValueObject> values;
|
||||
NAPI_ASSERT(env, JSUtils::Convert2Value(env, args[1], values) == napi_ok, "Invalid values!");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->In(field, values);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NotIn(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::NotIn Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
std::vector<ValueObject> values;
|
||||
NAPI_ASSERT(env, JSUtils::Convert2Value(env, args[1], values) == napi_ok, "Invalid values");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->NotIn(field, values);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Clear(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Clear();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsRawSelection(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
bool out = nativePredicates->IsRawSelection();
|
||||
return JSUtils::Convert2JSValue(env, out);
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::GetPredicates() const
|
||||
{
|
||||
return this->predicates_;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetWhereClause(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetWhereClause();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::SetWhereClause(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::SetWhereClause Invalid argvs!");
|
||||
|
||||
std::string whereClause;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], whereClause) == napi_ok, "whereClause is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->SetWhereClause(whereClause);
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetWhereArgs(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetWhereArgs();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::SetWhereArgs(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::SetWhereArgs Invalid argvs!");
|
||||
|
||||
std::vector<std::string> whereArgs;
|
||||
NAPI_ASSERT(env, JSUtils::Convert2Value(env, args[0], whereArgs) == napi_ok, "Invalid whereArgs!");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->SetWhereArgs(whereArgs);
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetOrder(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetOrder();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::SetOrder(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::SetOrder Invalid argvs!");
|
||||
|
||||
std::string order;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], order) != napi_ok, "the order is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->SetOrder(order);
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetLimit(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->GetLimit());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetOffset(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->GetOffset());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsDistinct(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->IsDistinct());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetGroup(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetGroup();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetIndex();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsNeedAnd(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->IsNeedAnd());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsSorted(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->IsSorted());
|
||||
}
|
||||
} // namespace DataAbilityJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
EXTERN_C_START
|
||||
__attribute__((visibility("default")))
|
||||
napi_value NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_NewInstance(
|
||||
napi_env env, OHOS::NativeRdb::DataAbilityPredicates *predicates)
|
||||
{
|
||||
return OHOS::DataAbilityJsKit::DataAbilityPredicatesProxy::NewInstance(
|
||||
env, std::shared_ptr<OHOS::NativeRdb::DataAbilityPredicates>(predicates));
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) OHOS::NativeRdb::DataAbilityPredicates *
|
||||
NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_GetNativeObject(const napi_env env, const napi_value arg)
|
||||
{
|
||||
auto predicates = OHOS::DataAbilityJsKit::DataAbilityPredicatesProxy::GetNativePredicates(env, arg);
|
||||
return predicates.get();
|
||||
}
|
||||
EXTERN_C_END
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "NapiRdbJsUtils"
|
||||
#include "napi_rdb_js_utils.h"
|
||||
|
||||
#include "logger.h"
|
||||
#include "result_set.h"
|
||||
|
||||
namespace OHOS::AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
using namespace OHOS::Rdb;
|
||||
using namespace NativeRdb;
|
||||
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, Asset &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_object) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "version", output.version), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "name", output.name), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "uri", output.uri), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "createTime", output.createTime), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "modifyTime", output.modifyTime), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "size", output.size), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "hash", output.hash), napi_invalid_arg);
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const Asset &value)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
NAPI_CALL_BASE(env, napi_create_object(env, &object), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "version", value.version), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "name", value.name), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "uri", value.uri), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "createTime", value.createTime), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "modifyTime", value.modifyTime), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "size", value.size), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "hash", value.hash), object);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const RowEntity &rowEntity)
|
||||
{
|
||||
napi_value ret = nullptr;
|
||||
NAPI_CALL(env, napi_create_object(env, &ret));
|
||||
auto &values = rowEntity.Get();
|
||||
for (auto const &[key, object] : values) {
|
||||
napi_value value = JSUtils::Convert2JSValue(env, object.value);
|
||||
NAPI_CALL(env, napi_set_named_property(env, ret, key.c_str(), value));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, ValueObject &valueObject)
|
||||
{
|
||||
auto status = Convert2Value(env, jsValue, valueObject.value);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const BigInt& value)
|
||||
{
|
||||
napi_value val = nullptr;
|
||||
napi_status status = napi_create_bigint_words(env, value.Sign(), value.Size(), value.TrueForm(), &val);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, BigInt& value)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_bigint) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
int sign = 0;
|
||||
size_t count = 0;
|
||||
status = napi_get_value_bigint_words(env, jsValue, nullptr, &count, nullptr);
|
||||
if (status != napi_ok) {
|
||||
return napi_bigint_expected;
|
||||
}
|
||||
std::vector<uint64_t> words(count, 0);
|
||||
status = napi_get_value_bigint_words(env, jsValue, &sign, &count, words.data());
|
||||
if (status != napi_ok) {
|
||||
return napi_bigint_expected;
|
||||
}
|
||||
value = BigInteger(sign, std::move(words));
|
||||
return napi_ok;
|
||||
}
|
||||
}; // namespace JSUtils
|
||||
} // namespace OHOS::AppDataMgrJsKit
|
@ -0,0 +1,640 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "ResultSetProxy"
|
||||
#include "napi_result_set.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "js_utils.h"
|
||||
#include "logger.h"
|
||||
#include "napi_rdb_error.h"
|
||||
#include "napi_rdb_trace.h"
|
||||
#include "rdb_errno.h"
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "rdb_result_set_bridge.h"
|
||||
#include "shared_block.h"
|
||||
#include "string_ex.h"
|
||||
#endif
|
||||
|
||||
using namespace OHOS::Rdb;
|
||||
using namespace OHOS::NativeRdb;
|
||||
using namespace OHOS::AppDataMgrJsKit;
|
||||
|
||||
namespace OHOS {
|
||||
namespace RdbJsKit {
|
||||
static napi_ref __thread ctorRef_ = nullptr;
|
||||
static napi_ref __thread ctorRefV9_ = nullptr;
|
||||
static const int E_OK = 0;
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
napi_value ResultSetProxy::NewInstance(napi_env env, std::shared_ptr<AbsSharedResultSet> resultSet, int version)
|
||||
{
|
||||
auto instance = NewInstance(env, std::static_pointer_cast<NativeRdb::ResultSet>(resultSet), version);
|
||||
ResultSetProxy *proxy = nullptr;
|
||||
auto status = napi_unwrap(env, instance, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("NewInstance native instance is nullptr! code:%{public}d!", status);
|
||||
return instance;
|
||||
}
|
||||
|
||||
if (resultSet != nullptr && resultSet->GetBlock() != nullptr) {
|
||||
proxy->sharedBlockName_ = resultSet->GetBlock()->Name();
|
||||
proxy->sharedBlockAshmemFd_ = resultSet->GetBlock()->GetFd();
|
||||
}
|
||||
proxy->sharedResultSet_ = resultSet;
|
||||
return instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value ResultSetProxy::NewInstance(napi_env env, std::shared_ptr<NativeRdb::ResultSet> resultSet, int version)
|
||||
{
|
||||
napi_value cons = GetConstructor(env, version);
|
||||
if (cons == nullptr) {
|
||||
LOG_ERROR("NewInstance GetConstructor is nullptr!");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value instance = nullptr;
|
||||
napi_status status = napi_new_instance(env, cons, 0, nullptr, &instance);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("NewInstance napi_new_instance failed! code:%{public}d!", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ResultSetProxy *proxy = nullptr;
|
||||
status = napi_unwrap(env, instance, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("NewInstance native instance is nullptr! code:%{public}d!", status);
|
||||
return instance;
|
||||
}
|
||||
*proxy = std::move(resultSet);
|
||||
return instance;
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> ResultSetProxy::GetNativeObject(
|
||||
napi_env const env, napi_value const arg)
|
||||
{
|
||||
if (arg == nullptr) {
|
||||
LOG_ERROR("ResultSetProxy GetNativeObject arg is null.");
|
||||
return nullptr;
|
||||
}
|
||||
ResultSetProxy *proxy = nullptr;
|
||||
napi_unwrap(env, arg, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr || proxy->sharedResultSet_ == nullptr) {
|
||||
LOG_ERROR("ResultSetProxy GetNativeObject proxy or sharedResultSet_ is null.");
|
||||
return nullptr;
|
||||
}
|
||||
return proxy->sharedResultSet_;
|
||||
}
|
||||
|
||||
std::shared_ptr<DataShare::ResultSetBridge> ResultSetProxy::Create()
|
||||
{
|
||||
auto instance = GetInstance();
|
||||
if (instance == nullptr) {
|
||||
LOG_ERROR("resultSet_ is null.");
|
||||
return nullptr;
|
||||
}
|
||||
SetInstance(nullptr);
|
||||
return std::make_shared<RdbDataShareAdapter::RdbResultSetBridge>(instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value ResultSetProxy::GetConstructor(napi_env env, int version)
|
||||
{
|
||||
napi_value cons = nullptr;
|
||||
if (version > APIVERSION_8 && ctorRefV9_ != nullptr) {
|
||||
NAPI_CALL(env, napi_get_reference_value(env, ctorRefV9_, &cons));
|
||||
return cons;
|
||||
}
|
||||
if (version == APIVERSION_8 && ctorRef_ != nullptr) {
|
||||
NAPI_CALL(env, napi_get_reference_value(env, ctorRef_, &cons));
|
||||
return cons;
|
||||
}
|
||||
|
||||
napi_property_descriptor clzDes[] = {
|
||||
DECLARE_NAPI_FUNCTION("goToRow", GoToRow),
|
||||
DECLARE_NAPI_FUNCTION("getLong", GetLong),
|
||||
DECLARE_NAPI_FUNCTION("getColumnType", GetColumnType),
|
||||
DECLARE_NAPI_FUNCTION("goTo", GoTo),
|
||||
DECLARE_NAPI_FUNCTION("getColumnIndex", GetColumnIndex),
|
||||
DECLARE_NAPI_FUNCTION("getInt", GetInt),
|
||||
DECLARE_NAPI_FUNCTION("getColumnName", GetColumnName),
|
||||
DECLARE_NAPI_FUNCTION("close", Close),
|
||||
DECLARE_NAPI_FUNCTION("goToFirstRow", GoToFirstRow),
|
||||
DECLARE_NAPI_FUNCTION("goToLastRow", GoToLastRow),
|
||||
DECLARE_NAPI_FUNCTION("goToNextRow", GoToNextRow),
|
||||
DECLARE_NAPI_FUNCTION("goToPreviousRow", GoToPreviousRow),
|
||||
DECLARE_NAPI_FUNCTION("getBlob", GetBlob),
|
||||
DECLARE_NAPI_FUNCTION("getString", GetString),
|
||||
DECLARE_NAPI_FUNCTION("getDouble", GetDouble),
|
||||
DECLARE_NAPI_FUNCTION("isColumnNull", IsColumnNull),
|
||||
|
||||
DECLARE_NAPI_GETTER("columnNames", GetAllColumnNames),
|
||||
DECLARE_NAPI_GETTER("columnCount", GetColumnCount),
|
||||
DECLARE_NAPI_GETTER("isEnded", IsEnded),
|
||||
DECLARE_NAPI_GETTER("isStarted", IsBegin),
|
||||
DECLARE_NAPI_GETTER("isClosed", IsClosed),
|
||||
DECLARE_NAPI_GETTER("rowCount", GetRowCount),
|
||||
DECLARE_NAPI_GETTER("rowIndex", GetRowIndex),
|
||||
DECLARE_NAPI_GETTER("isAtFirstRow", IsAtFirstRow),
|
||||
DECLARE_NAPI_GETTER("isAtLastRow", IsAtLastRow),
|
||||
};
|
||||
|
||||
if (version > APIVERSION_8) {
|
||||
NAPI_CALL(env, napi_define_class(env, "ResultSetV9", NAPI_AUTO_LENGTH, InitializeV9, nullptr,
|
||||
sizeof(clzDes) / sizeof(napi_property_descriptor), clzDes, &cons));
|
||||
NAPI_CALL(env, napi_create_reference(env, cons, 1, &ctorRefV9_));
|
||||
return cons;
|
||||
}
|
||||
|
||||
NAPI_CALL(env, napi_define_class(env, "ResultSet", NAPI_AUTO_LENGTH, Initialize, nullptr,
|
||||
sizeof(clzDes) / sizeof(napi_property_descriptor), clzDes, &cons));
|
||||
NAPI_CALL(env, napi_create_reference(env, cons, 1, &ctorRef_));
|
||||
return cons;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::InnerInitialize(napi_env env, napi_callback_info info, int version)
|
||||
{
|
||||
napi_value self = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &self, nullptr));
|
||||
auto *proxy = new (std::nothrow) ResultSetProxy();
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("ResultSetProxy::InnerInitialize new failed, proxy is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
proxy->apiversion = version;
|
||||
auto finalize = [](napi_env env, void *data, void *hint) {
|
||||
ResultSetProxy *proxy = reinterpret_cast<ResultSetProxy *>(data);
|
||||
delete proxy;
|
||||
};
|
||||
napi_status status = napi_wrap(env, self, proxy, finalize, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("ResultSetProxy napi_wrap failed! code:%{public}d!, version:%{public}d.", status, version);
|
||||
finalize(env, proxy, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::Initialize(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return InnerInitialize(env, info, APIVERSION_8);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::InitializeV9(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return InnerInitialize(env, info, APIVERSION_V9);
|
||||
}
|
||||
|
||||
ResultSetProxy::~ResultSetProxy()
|
||||
{
|
||||
LOG_DEBUG("ResultSetProxy destructor!");
|
||||
}
|
||||
|
||||
ResultSetProxy::ResultSetProxy(std::shared_ptr<ResultSet> resultSet)
|
||||
{
|
||||
if (GetInstance() == resultSet) {
|
||||
return;
|
||||
}
|
||||
SetInstance(std::move(resultSet));
|
||||
}
|
||||
|
||||
ResultSetProxy &ResultSetProxy::operator=(std::shared_ptr<ResultSet> resultSet)
|
||||
{
|
||||
if (GetInstance() == resultSet) {
|
||||
return *this;
|
||||
}
|
||||
SetInstance(std::move(resultSet));
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResultSetProxy *ResultSetProxy::GetInnerResultSet(napi_env env, napi_callback_info info, int &version)
|
||||
{
|
||||
ResultSetProxy *resultSetProxy = nullptr;
|
||||
napi_value self = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &self, nullptr);
|
||||
napi_unwrap(env, self, reinterpret_cast<void **>(&resultSetProxy));
|
||||
RDB_NAPI_ASSERT_FROMV9(env, resultSetProxy && resultSetProxy->GetInstance(), std::make_shared<ResultGotoError>(),
|
||||
resultSetProxy->apiversion);
|
||||
|
||||
version = resultSetProxy->apiversion;
|
||||
return resultSetProxy;
|
||||
}
|
||||
|
||||
ResultSetProxy *ResultSetProxy::ParseInt32FieldByName(
|
||||
napi_env env, napi_callback_info info, int32_t &field, const std::string& name)
|
||||
{
|
||||
DISTRIBUTED_DATA_HITRACE(std::string(__FUNCTION__));
|
||||
napi_value self = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &self, nullptr);
|
||||
ResultSetProxy *resultSetProxy = nullptr;
|
||||
napi_unwrap(env, self, reinterpret_cast<void **>(&resultSetProxy));
|
||||
RDB_NAPI_ASSERT_FROMV9(env, resultSetProxy && resultSetProxy->GetInstance(),
|
||||
std::make_shared<ParamTypeError>("resultSet", "not null"), resultSetProxy->apiversion);
|
||||
RDB_NAPI_ASSERT_FROMV9(
|
||||
env, argc == 1, std::make_shared<ParamNumError>("1"), resultSetProxy->apiversion);
|
||||
|
||||
napi_status status = napi_get_value_int32(env, args[0], &field);
|
||||
RDB_NAPI_ASSERT_FROMV9(
|
||||
env, status == napi_ok, std::make_shared<ParamTypeError>(name, "a number."), resultSetProxy->apiversion);
|
||||
return resultSetProxy;
|
||||
}
|
||||
|
||||
ResultSetProxy *ResultSetProxy::ParseFieldByName(napi_env env, napi_callback_info info, std::string &field)
|
||||
{
|
||||
napi_value self = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &self, nullptr);
|
||||
ResultSetProxy *resultSetProxy = nullptr;
|
||||
napi_unwrap(env, self, reinterpret_cast<void **>(&resultSetProxy));
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
RDB_NAPI_ASSERT_FROMV9(
|
||||
env, argc == 1, std::make_shared<ParamNumError>("1"), resultSetProxy->apiversion);
|
||||
|
||||
field = JSUtils::Convert2String(env, args[0]);
|
||||
return resultSetProxy;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetAllColumnNames(napi_env env, napi_callback_info info)
|
||||
{
|
||||
std::vector<std::string> colNames;
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetAllColumnNames(colNames);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetAllColumnNames failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, colNames);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t position;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, position, "position");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToRow(position);
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnCount(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t count = 0;
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnCount(count);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnCount failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, count);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetLong(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
int64_t result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetLong(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnType(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
ColumnType columnType;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnType(columnIndex, columnType);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnType failed code:%{public}d, version:%{public}d.", errCode, resultSetProxy->apiversion);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, int32_t(columnType));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t offset;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, offset, "offset");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoTo(offset);
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
std::string input;
|
||||
int32_t result = -1;
|
||||
auto resultSetProxy = ParseFieldByName(env, info, input);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnIndex(input, result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnIndex failed code:%{public}d, version:%{public}d.", errCode, resultSetProxy->apiversion);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetInt(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
int32_t result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetInt(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnName(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
std::string result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnName(columnIndex, result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnName failed code:%{public}d, version:%{public}d.", errCode, resultSetProxy->apiversion);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::Close(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->Close();
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGotoError>(), version);
|
||||
napi_value result = nullptr;
|
||||
napi_get_null(env, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetRowCount(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
ResultSetProxy *resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int32_t result;
|
||||
int errCode = resultSetProxy->GetInstance()->GetRowCount(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetRowCount failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetRowIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int32_t result;
|
||||
int errCode = resultSetProxy->GetInstance()->GetRowIndex(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetRowIndex failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsEnded(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsEnded(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsEnded failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
result = true;
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsBegin(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsStarted(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsBegin failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToFirstRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToFirstRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToLastRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToLastRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToNextRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToNextRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToPreviousRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToPreviousRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsAtFirstRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsAtFirstRow(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsAtFirstRow failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsAtLastRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsAtLastRow(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsAtLastRow failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetBlob(napi_env env, napi_callback_info info)
|
||||
{
|
||||
DISTRIBUTED_DATA_HITRACE(std::string(__FUNCTION__));
|
||||
int32_t columnIndex;
|
||||
std::vector<uint8_t> result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetBlob(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetString(napi_env env, napi_callback_info info)
|
||||
{
|
||||
DISTRIBUTED_DATA_HITRACE(std::string(__FUNCTION__));
|
||||
int32_t columnIndex;
|
||||
std::string result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetString(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetDouble(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
double result = 0.0;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetDouble(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsColumnNull(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
bool result = false;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->IsColumnNull(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
napi_value output = nullptr;
|
||||
napi_get_boolean(env, result, &output);
|
||||
return output;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsClosed(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int result = resultSetProxy->GetInstance()->IsClosed();
|
||||
napi_value output = nullptr;
|
||||
napi_get_boolean(env, result, &output);
|
||||
return output;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetSharedBlockName(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr));
|
||||
|
||||
ResultSetProxy *proxy;
|
||||
NAPI_CALL(env, napi_unwrap(env, thiz, reinterpret_cast<void **>(&proxy)));
|
||||
RDB_CHECK_RETURN_NULLPTR(proxy != nullptr,
|
||||
"ResultSetProxy::GetSharedBlockName proxy is nullptr");
|
||||
|
||||
return JSUtils::Convert2JSValue(env, proxy->sharedBlockName_);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetSharedBlockAshmemFd(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr));
|
||||
|
||||
ResultSetProxy *proxy;
|
||||
NAPI_CALL(env, napi_unwrap(env, thiz, reinterpret_cast<void **>(&proxy)));
|
||||
RDB_CHECK_RETURN_NULLPTR(proxy != nullptr,
|
||||
"ResultSetProxy::GetSharedBlockAshmemFd proxy is nullptr");
|
||||
|
||||
return JSUtils::Convert2JSValue(env, proxy->sharedBlockAshmemFd_);
|
||||
}
|
||||
} // namespace RdbJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
|
||||
__attribute__((visibility("default"))) napi_value NewCInstance(napi_env env,
|
||||
napi_value arg) asm("NAPI_OHOS_Data_RdbJsKit_ResultSetProxy_NewInstance");
|
||||
napi_value NewCInstance(napi_env env, std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> resultSet)
|
||||
{
|
||||
return OHOS::RdbJsKit::ResultSetProxy::NewInstance(env, resultSet);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> GetCObject(napi_env env,
|
||||
napi_value arg) asm("NAPI_OHOS_Data_RdbJsKit_ResultSetProxy_GetNativeObject");
|
||||
std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> GetCObject(napi_env env, napi_value arg)
|
||||
{
|
||||
return OHOS::RdbJsKit::ResultSetProxy::GetNativeObject(env, arg);
|
||||
}
|
||||
#endif
|
@ -34,8 +34,10 @@ ohos_shared_library("featureability_napi") {
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -50,12 +50,14 @@ ohos_shared_library("napi_ability_common") {
|
||||
"ability_base:want",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
|
@ -56,6 +56,7 @@ ohos_shared_library("napi_common") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
@ -78,6 +79,7 @@ ohos_shared_library("napi_common") {
|
||||
]
|
||||
public_external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"graphic_2d:EGL",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ ohos_shared_library("insightintentdriver_napi") {
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
cflags_cc = []
|
||||
|
@ -34,9 +34,10 @@ ohos_shared_library("childprocessmanager_napi") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:session_info",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -45,8 +45,10 @@ ohos_shared_library("dialogrequest_napi") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
cflags_cc = []
|
||||
if (os_dlp_part_enabled) {
|
||||
cflags_cc += [ "-DWITH_DLP" ]
|
||||
|
@ -37,7 +37,6 @@ ohos_shared_library("dialogsession_napi") {
|
||||
}
|
||||
external_deps = [
|
||||
"ability_base:extractortool",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
@ -47,10 +46,10 @@ ohos_shared_library("dialogsession_napi") {
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"jsoncpp:jsoncpp",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
cflags_cc = []
|
||||
|
@ -41,8 +41,10 @@ ohos_shared_library("missionmanager") {
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -40,8 +40,10 @@ ohos_shared_library("missionmanager_napi") {
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
@ -100,11 +102,14 @@ ohos_shared_library("distributedmissionmanager") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
|
@ -58,23 +58,21 @@ ohos_shared_library("particleability") {
|
||||
"jsoncpp:jsoncpp",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
]
|
||||
|
||||
if (ability_runtime_relational) {
|
||||
include_dirs += [
|
||||
"${relational_store_napi_path}/common/include",
|
||||
"${relational_store_napi_path}/dataability/include",
|
||||
"${relational_store_napi_path}/rdb/include",
|
||||
]
|
||||
include_dirs += [ "../featureAbility/data_ability/include" ]
|
||||
sources += [
|
||||
"${relational_store_napi_path}/common/src/js_df_manager.cpp",
|
||||
"${relational_store_napi_path}/common/src/js_utils.cpp",
|
||||
"${relational_store_napi_path}/dataability/src/napi_data_ability_predicates.cpp",
|
||||
"${relational_store_napi_path}/rdb/src/napi_rdb_js_utils.cpp",
|
||||
"${relational_store_napi_path}/rdb/src/napi_result_set.cpp",
|
||||
"../featureAbility/data_ability/js_utils.cpp",
|
||||
"../featureAbility/data_ability/napi_data_ability_predicates.cpp",
|
||||
"../featureAbility/data_ability/napi_rdb_js_utils.cpp",
|
||||
"../featureAbility/data_ability/napi_result_set.cpp",
|
||||
]
|
||||
external_deps += [
|
||||
"eventhandler:libeventhandler",
|
||||
"kv_store:distributeddata_mgr",
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
"relational_store:rdb_data_share_adapter",
|
||||
|
@ -38,6 +38,7 @@ ohos_shared_library("quickfixmanager_napi") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -38,6 +38,7 @@ ohos_shared_library("uripermissionmanager_napi") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
|
@ -44,10 +44,12 @@ ohos_shared_library("wantagent") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
]
|
||||
|
||||
cflags_cc = []
|
||||
|
@ -49,6 +49,7 @@ ohos_shared_library("wantagent_napi") {
|
||||
"ipc:ipc_core",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
]
|
||||
|
||||
relative_install_dir = "module/app/ability"
|
||||
|
@ -84,6 +84,7 @@ ohos_shared_library("ability_context_native") {
|
||||
"access_token:libtoken_callback_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:libdfx_dumpcatcher",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
|
@ -166,6 +166,7 @@ ohos_shared_library("abilitykit_utils") {
|
||||
|
||||
public_external_deps = [
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"icu:shared_icuuc",
|
||||
"jsoncpp:jsoncpp",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
@ -173,11 +174,9 @@ ohos_shared_library("abilitykit_utils") {
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"icu:shared_icuuc",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
public_external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
@ -350,8 +349,10 @@ ohos_shared_library("abilitykit_native") {
|
||||
"ipc:rpc",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:windowstage_kit",
|
||||
]
|
||||
if (!(host_os == "linux" && host_cpu == "arm64")) {
|
||||
external_deps += [ "relational_store:native_rdb" ]
|
||||
@ -416,13 +417,9 @@ ohos_shared_library("abilitykit_native") {
|
||||
"input:libmmi-client",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwsutils",
|
||||
"window_manager:windowstage_kit",
|
||||
]
|
||||
|
||||
public_external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
public_external_deps += [ "window_manager:libdm" ]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
@ -494,6 +491,7 @@ ohos_shared_library("extensionkit_native") {
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
@ -509,7 +507,6 @@ ohos_shared_library("extensionkit_native") {
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "ability_base:session_info" ]
|
||||
public_external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
@ -556,6 +553,7 @@ ohos_shared_library("insight_intent_executor") {
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
subsystem_name = "ability"
|
||||
@ -641,6 +639,7 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
@ -651,6 +650,8 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
cflags_cc = []
|
||||
@ -682,12 +683,10 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"icu:shared_icuuc",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwsutils",
|
||||
"window_manager:windowstage_kit",
|
||||
]
|
||||
public_external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
@ -734,6 +733,7 @@ ohos_shared_library("ability_thread") {
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
@ -824,7 +824,10 @@ ohos_shared_library("form_extension_module") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"window_manager:libwm",
|
||||
@ -833,7 +836,6 @@ ohos_shared_library("form_extension_module") {
|
||||
if (ability_runtime_graphics) {
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_provider_client",
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -1083,6 +1085,8 @@ ohos_shared_library("ui_service_extension_module") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"form_fwk:fmskit_native",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
@ -1093,21 +1097,17 @@ ohos_shared_library("ui_service_extension_module") {
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ace_engine:ace_uicontent",
|
||||
"form_fwk:form_manager",
|
||||
"image_framework:image",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwsutils",
|
||||
"window_manager:scene_session",
|
||||
"window_manager:session_manager_lite",
|
||||
"window_manager:window_native_kit",
|
||||
"window_manager:windowstage_kit",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_native",
|
||||
"form_fwk:fmskit_provider_client",
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwmutil",
|
||||
"window_manager:window_native_kit",
|
||||
@ -1161,18 +1161,11 @@ ohos_shared_library("continuation_ipc") {
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"resource_management:global_resmgr",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
public_external_deps = [
|
||||
"accessibility:accessibility_common",
|
||||
"libuv:uv",
|
||||
]
|
||||
public_external_deps = []
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
public_external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
public_external_deps += []
|
||||
}
|
||||
|
||||
defines = []
|
||||
@ -1204,6 +1197,7 @@ ohos_shared_library("data_ability_helper") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"data_share:datashare_common",
|
||||
@ -1222,7 +1216,6 @@ ohos_shared_library("data_ability_helper") {
|
||||
if (ability_runtime_graphics) {
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_provider_client",
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -1251,7 +1244,10 @@ ohos_shared_library("service_extension_module") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
@ -1263,7 +1259,6 @@ ohos_shared_library("service_extension_module") {
|
||||
]
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_provider_client",
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -1463,13 +1458,17 @@ ohos_shared_library("ui_extension_module") {
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "form_fwk:form_manager" ]
|
||||
external_deps += []
|
||||
}
|
||||
|
||||
relative_install_dir = "extensionability/"
|
||||
@ -1596,16 +1595,18 @@ ohos_shared_library("share_extension_module") {
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
external_deps += [ "window_manager:libwm" ]
|
||||
}
|
||||
|
||||
relative_install_dir = "extensionability/"
|
||||
@ -1657,16 +1658,18 @@ ohos_shared_library("action_extension_module") {
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
external_deps += [ "window_manager:libwm" ]
|
||||
}
|
||||
|
||||
relative_install_dir = "extensionability/"
|
||||
@ -1818,8 +1821,13 @@ ohos_shared_library("embedded_ui_extension_module") {
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
@ -1909,13 +1917,18 @@ ohos_shared_library("auto_fill_extension_module") {
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "form_fwk:form_manager" ]
|
||||
external_deps += []
|
||||
}
|
||||
|
||||
relative_install_dir = "extensionability/"
|
||||
@ -2013,8 +2026,13 @@ ohos_shared_library("photo_editor_extension_module") {
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "module_checker_delegate.h"
|
||||
#include "utils/log.h"
|
||||
#include <string>
|
||||
|
||||
bool AppModuleChecker::CheckModuleLoadable(const char *moduleName,
|
||||
std::unique_ptr<ApiAllowListChecker> &apiAllowListChecker)
|
||||
|
@ -186,6 +186,10 @@ ohos_shared_library("appkit_native") {
|
||||
"faultloggerd:libdfx_procinfo",
|
||||
"faultloggerd:libfaultloggerd",
|
||||
"ffrt:libffrt",
|
||||
"graphic_2d:2d_graphics",
|
||||
"graphic_2d:EGL",
|
||||
"graphic_2d:libcomposer",
|
||||
"graphic_2d:librender_service_base",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
@ -193,8 +197,11 @@ ohos_shared_library("appkit_native") {
|
||||
"i18n:preferred_language",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"ipc:ipc_single",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"preferences:native_preferences",
|
||||
"resource_management:global_resmgr",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
@ -314,6 +321,7 @@ ohos_shared_library("app_context") {
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
@ -385,6 +393,7 @@ ohos_shared_library("app_context_utils") {
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
@ -455,9 +464,11 @@ ohos_shared_library("appkit_delegator") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
@ -546,7 +557,6 @@ ohos_shared_library("application_context_manager") {
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -62,7 +62,7 @@
|
||||
#include "locale_config.h"
|
||||
#include "ace_forward_compatibility.h"
|
||||
#include "form_constants.h"
|
||||
#include "include/private/EGL/cache.h"
|
||||
#include "cache.h"
|
||||
#ifdef SUPPORT_APP_PREFERRED_LANGUAGE
|
||||
#include "preferred_language.h"
|
||||
#endif
|
||||
|
@ -41,11 +41,11 @@ ohos_shared_library("insightintentcontext") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -143,9 +143,12 @@ ohos_shared_library("ability_manager") {
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"jsoncpp:jsoncpp",
|
||||
"relational_store:native_dataability",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
if (host_cpu != "arm64") {
|
||||
external_deps += [ "relational_store:native_rdb" ]
|
||||
}
|
||||
@ -273,6 +276,9 @@ ohos_shared_library("ability_manager_c") {
|
||||
external_deps = [
|
||||
"ability_base:session_info",
|
||||
"c_utils:utils",
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
|
@ -154,7 +154,6 @@ ohos_shared_library("app_manager") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"image_framework:image_native",
|
||||
"relational_store:native_rdb",
|
||||
"skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
|
@ -46,6 +46,7 @@ ohos_shared_library("auto_fill_manager") {
|
||||
"ability_base:base",
|
||||
"ability_base:view_data",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
|
@ -44,8 +44,10 @@ ohos_shared_library("ability_deps_wrapper") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/config/components/idl_tool/idl.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
import("//foundation/ability/idl_tool/idl_config.gni")
|
||||
|
||||
idl_interface_sources = [
|
||||
"${target_gen_dir}/quick_fix_manager_proxy.cpp",
|
||||
|
@ -105,6 +105,7 @@ ohos_shared_library("runtime") {
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"ets_utils:console",
|
||||
"ets_utils:timer",
|
||||
"ets_utils:worker",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"hilog:libhilog",
|
||||
|
@ -42,8 +42,10 @@ ohos_shared_library("js_environment") {
|
||||
public_configs = [ ":public_js_environment_config" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"ets_utils:console",
|
||||
"ets_utils:worker",
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:libunwinder",
|
||||
"ffrt:libffrt",
|
||||
|
@ -64,6 +64,7 @@ ohos_shared_library("libsrms") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_single",
|
||||
"os_account:os_account_innerkits",
|
||||
"safwk:system_ability_fwk",
|
||||
|
@ -159,8 +159,8 @@ ohos_shared_library("abilityms") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"config_policy:configpolicy_util",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"graphic_2d:color_manager",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
@ -423,6 +423,7 @@ ohos_shared_library("mission_list") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"config_policy:configpolicy_util",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"graphic_2d:color_manager",
|
||||
"hicollie:libhicollie",
|
||||
|
@ -122,6 +122,7 @@ ohos_shared_library("libappms") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
|
@ -91,6 +91,7 @@ ohos_shared_library("event_report") {
|
||||
sources = [ "src/event_report.cpp" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
@ -136,6 +137,7 @@ ohos_shared_library("app_util") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"config_policy:configpolicy_util",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
@ -170,7 +172,9 @@ ohos_shared_library("res_sched_util") {
|
||||
|
||||
external_deps = [
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
|
@ -253,6 +253,7 @@ ohos_source_set("abilityms_test_source") {
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"jsoncpp:jsoncpp",
|
||||
"kv_store:distributeddata_inner",
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -101,6 +101,7 @@ ohos_executable("aa") {
|
||||
"ability_base:base",
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"c_utils:utils",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -52,6 +52,7 @@ ohos_shared_library("startup_util") {
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user