From b43c75310ac6b8b181bd402d6e8411c084493f94 Mon Sep 17 00:00:00 2001 From: lifansheng Date: Fri, 24 Sep 2021 22:24:59 +0800 Subject: [PATCH] Signed-off-by: lifansheng On branch OpenHarmony-3.0-LTS Your branch is up to date with 'origin/OpenHarmony-3.0-LTS'. Changes to be committed: modified: lrubuffer/native_module_lrubuffer.cpp modified: scope/native_module_scope.cpp modified: util/BUILD.gn modified: util/js_rational.cpp modified: util/js_textdecoder.cpp modified: util/native_module_util.cpp --- lrubuffer/native_module_lrubuffer.cpp | 3 +-- scope/native_module_scope.cpp | 3 +-- util/BUILD.gn | 34 --------------------------- util/js_rational.cpp | 7 ++++-- util/js_textdecoder.cpp | 4 ++-- util/native_module_util.cpp | 15 +----------- 6 files changed, 10 insertions(+), 56 deletions(-) diff --git a/lrubuffer/native_module_lrubuffer.cpp b/lrubuffer/native_module_lrubuffer.cpp index eee051c..cbd5a66 100755 --- a/lrubuffer/native_module_lrubuffer.cpp +++ b/lrubuffer/native_module_lrubuffer.cpp @@ -22,8 +22,7 @@ static napi_value LruBufferInit(napi_env env, napi_value exports) const char *lruBufferClassName = "lrubuffer"; napi_value lruBufferClass = nullptr; NAPI_CALL(env, napi_define_class(env, lruBufferClassName, strlen(lruBufferClassName), nullptr, - nullptr, 0, nullptr, - &lruBufferClass)); + nullptr, 0, nullptr, &lruBufferClass)); static napi_property_descriptor desc[] = { DECLARE_NAPI_PROPERTY("lrubuffer", lruBufferClass), }; diff --git a/scope/native_module_scope.cpp b/scope/native_module_scope.cpp index c3eff3e..3dd9411 100755 --- a/scope/native_module_scope.cpp +++ b/scope/native_module_scope.cpp @@ -22,8 +22,7 @@ static napi_value ScopeInit(napi_env env, napi_value exports) const char *ClassName = "scope"; napi_value scopeClass = nullptr; NAPI_CALL(env, napi_define_class(env, ClassName, strlen(ClassName), nullptr, - nullptr, 0, nullptr, - &scopeClass)); + nullptr, 0, nullptr, &scopeClass)); static napi_property_descriptor desc[] = { DECLARE_NAPI_PROPERTY("scope", scopeClass) }; diff --git a/util/BUILD.gn b/util/BUILD.gn index cc2856c..ea5e47e 100755 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -11,33 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//ark/ts2abc/ts2panda/ts2abc_config.gni") import("//build/ohos.gni") import("//build/ohos/ace/ace.gni") -import("//foundation/ace/ace_engine/ace_config.gni") - -# compile .js to .abc. -action("gen_util_abc") { - visibility = [ ":*" ] - script = "//ark/ts2abc/ts2panda/scripts/generate_js_bytecode.py" - - args = [ - "--src-js", - rebase_path("//base/compileruntime/js_util_module/util/util_js.js"), - "--dst-file", - rebase_path(target_out_dir + "/util.abc"), - "--node", - rebase_path("${node_path}"), - "--frontend-tool-path", - rebase_path("${ts2abc_build_path}"), - "--node-modules", - rebase_path("${node_modules}"), - ] - deps = [ "//ark/ts2abc/ts2panda:ark_ts2abc_build" ] - - inputs = [ "//base/compileruntime/js_util_module/util/util_js.js" ] - outputs = [ target_out_dir + "/util.abc" ] -} base_output_path = get_label_info(":util_js", "target_out_dir") util_js_obj_path = base_output_path + "/util.o" @@ -47,14 +22,6 @@ gen_js_obj("util_js") { output = util_js_obj_path } -abc_output_path = get_label_info(":util_abc", "target_out_dir") -util_abc_obj_path = abc_output_path + "/util_abc.o" -gen_js_obj("util_abc") { - input = "$target_out_dir/util.abc" - output = util_abc_obj_path - dep = ":gen_util_abc" -} - ohos_shared_library("util") { include_dirs = [ "//foundation/ace/napi", @@ -74,7 +41,6 @@ ohos_shared_library("util") { ] deps = [ - ":util_abc", ":util_js", "//base/compileruntime/js_util_module/util/:util_js", "//foundation/ace/napi/:ace_napi", diff --git a/util/js_rational.cpp b/util/js_rational.cpp index 567c26f..5449740 100755 --- a/util/js_rational.cpp +++ b/util/js_rational.cpp @@ -20,11 +20,14 @@ #include "utils/log.h" #include "securec.h" namespace OHOS::Util { - RationalNumber::RationalNumber(napi_env env, int num, int den) + RationalNumber::RationalNumber(napi_env env, int molecule, int denominator) { env_ = env; napi_value result = nullptr; - den < 0 ? num *= -1, den *= -1 : 0; + int num = molecule; + int den = denominator; + num = den < 0 ? num * (-1) : num; + den = den < 0 ? den * (-1) : den; if (den == 0) { if (num > 0) { mnum = 1; diff --git a/util/js_textdecoder.cpp b/util/js_textdecoder.cpp index 4d3c9c6..8f38672 100755 --- a/util/js_textdecoder.cpp +++ b/util/js_textdecoder.cpp @@ -73,8 +73,8 @@ namespace OHOS::Util { NAPI_CALL(env_, napi_get_typedarray_info(env_, src, &type, &length, &data1, &arrayBuffer, &byteOffset)); const char *source = static_cast(data1); UErrorCode codeFlag = U_ZERO_ERROR; - size_t limit = GetMinByteSize() *length; - size_t len = limit *sizeof(UChar); + size_t limit = GetMinByteSize() * length; + size_t len = limit * sizeof(UChar); UChar *arr = nullptr; if (limit > 0) { arr = new UChar[limit + 1]; diff --git a/util/native_module_util.cpp b/util/native_module_util.cpp index ed8e51a..dea60e7 100755 --- a/util/native_module_util.cpp +++ b/util/native_module_util.cpp @@ -27,8 +27,6 @@ extern const char _binary_util_js_js_start[]; extern const char _binary_util_js_js_end[]; -extern const char _binary_util_abc_start[]; -extern const char _binary_util_abc_end[]; namespace OHOS::Util { static std::string temp = "cdfijoOs"; napi_value RationalNumberClass = nullptr; @@ -834,15 +832,4 @@ namespace OHOS::Util { *buflen = _binary_util_js_js_end - _binary_util_js_js_start; } } - // util JS register - extern "C" - __attribute__((visibility("default"))) void NAPI_util_GetABCCode(const char** buf, int* buflen) - { - if (buf != nullptr) { - *buf = _binary_util_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_util_abc_end - _binary_util_abc_start; - } - } -} +} \ No newline at end of file -- Gitee