From 1f56d66af7b595b9e4b8d1ac3dc46482016e4e1c Mon Sep 17 00:00:00 2001 From: LeechyLiang Date: Sun, 6 Apr 2025 21:51:20 +0800 Subject: [PATCH] Modify signature rawString2Builder Signed-off-by: LeechyLiang Change-Id: Icb291d95177f7972716e1287f558c6ee930dadb9 --- framework/js/ani/BUILD.gn | 1 + framework/js/ani/src/system_date_time_ani.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/js/ani/BUILD.gn b/framework/js/ani/BUILD.gn index ba2c5ce4..a9335f0b 100644 --- a/framework/js/ani/BUILD.gn +++ b/framework/js/ani/BUILD.gn @@ -26,6 +26,7 @@ ohos_shared_library("systemdatetime_ani") { "hilog:libhilog", "init:libbegetutil", "runtime_core:ani", + "runtime_core:ani_helpers", "samgr:samgr_proxy", ] diff --git a/framework/js/ani/src/system_date_time_ani.cpp b/framework/js/ani/src/system_date_time_ani.cpp index ac178cd6..c72a92ac 100644 --- a/framework/js/ani/src/system_date_time_ani.cpp +++ b/framework/js/ani/src/system_date_time_ani.cpp @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -50,6 +51,7 @@ static ani_double GetTime([[maybe_unused]] ani_env *env, ani_object booleanObjec return GetRealTime(false); } ani_boolean isNano; + // Pls replace manually if (ANI_OK !=env->Object_CallMethodByName_Boolean(booleanObject, "unboxed", nullptr, &isNano)) { TIME_HILOGE(TIME_MODULE_JS_ANI, "Object_CallMethodByName_Boolean Fail"); } @@ -78,14 +80,17 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) static const char *namespaceName = "L@ohos/systemDateTime/systemDateTime;"; ani_namespace ns; + // Pls replace manually if (ANI_OK != env->FindNamespace(namespaceName, &ns)) { TIME_HILOGE(TIME_MODULE_JS_ANI, "Not found '%{public}s'", namespaceName); return ANI_ERROR; } + arkts::ani_signature::SignatureBuilder GetTimeZoneSigBuilder; + GetTimeZoneSigBuilder.SetReturnClass("std.core.String"); + auto GetTimeZoneSignature = GetTimeZoneSigBuilder.BuildSignatureDescriptor(); std::array methods = { - ani_native_function {"getTime", nullptr, reinterpret_cast(GetTime)}, - ani_native_function {"getTimezoneSync", ":Lstd/core/String;", reinterpret_cast(GetTimeZone)}, + ani_native_function{ "getTimezoneSync", GetTimeZoneSignature.c_str(), reinterpret_cast(GetTimeZone) }, }; if (ANI_OK != env->Namespace_BindNativeFunctions(ns, methods.data(), methods.size())) { -- Gitee