Commit aa0c52b6 authored by qq_38816927's avatar qq_38816927

arkts

parent dfd89616
...@@ -7,4 +7,7 @@ actual fun pirntSingleHiLog() { ...@@ -7,4 +7,7 @@ actual fun pirntSingleHiLog() {
} }
actual fun pirntRandomHiLog() { actual fun pirntRandomHiLog() {
}
actual fun testArkTsToKotin() {
} }
\ No newline at end of file
...@@ -7,4 +7,7 @@ expect fun pirntSingleHiLog(); ...@@ -7,4 +7,7 @@ expect fun pirntSingleHiLog();
//打印随机日志 //打印随机日志
expect fun pirntRandomHiLog(); expect fun pirntRandomHiLog();
\ No newline at end of file
expect fun testArkTsToKotin();
\ No newline at end of file
...@@ -9,3 +9,6 @@ actual fun pirntSingleHiLog() { ...@@ -9,3 +9,6 @@ actual fun pirntSingleHiLog() {
actual fun pirntRandomHiLog() { actual fun pirntRandomHiLog() {
} }
actual fun testArkTsToKotin() {
}
\ No newline at end of file
package com.dong.demo013 package com.dong.demo013
import kotlinx.cinterop.ExperimentalForeignApi
import platform.ohos.OH_LOG_Print import platform.ohos.OH_LOG_Print
import kotlin.experimental.ExperimentalNativeApi
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class) @OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@CName("hiLogPrintMsg") @CName("hiLogPrintMsg")
...@@ -47,3 +49,9 @@ actual fun pirntAllLevelHiLog(){ ...@@ -47,3 +49,9 @@ actual fun pirntAllLevelHiLog(){
actual fun pirntRandomHiLog(){ actual fun pirntRandomHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮"); hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
} }
@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
@CName("testArkTsToKotin")
actual fun testArkTsToKotin() {
print("测试ArkTs至Kotlin单向跳转")
}
\ No newline at end of file
package com.dong.demo013 package com.dong.demo013
import kotlinx.cinterop.ExperimentalForeignApi
import platform.ohos.OH_LOG_Print import platform.ohos.OH_LOG_Print
import kotlin.experimental.ExperimentalNativeApi
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class) @OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@CName("hiLogPrintMsg") @CName("hiLogPrintMsg")
...@@ -46,3 +48,9 @@ actual fun pirntAllLevelHiLog(){ ...@@ -46,3 +48,9 @@ actual fun pirntAllLevelHiLog(){
actual fun pirntRandomHiLog(){ actual fun pirntRandomHiLog(){
hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮"); hiLogPrintMsg(0u, 6u, 4660u, "TestTag", "持续日志打印-高亮");
} }
@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
@CName("testArkTsToKotin")
actual fun testArkTsToKotin() {
print("测试ArkTs至Kotlin单向跳转")
}
\ No newline at end of file
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
"dependencies": { "dependencies": {
"libentry.so": "file:./src/main/cpp/types/libentry", "libentry.so": "file:./src/main/cpp/types/libentry",
// 添加 compose.har 依赖 // 添加 compose.har 依赖
"compose": "file:./libs/compose.har", "compose": "file:./libs/compose.har"
} }
} }
\ No newline at end of file
...@@ -205,6 +205,7 @@ extern void setPixelRatio(libkn_KDouble ratio); ...@@ -205,6 +205,7 @@ extern void setPixelRatio(libkn_KDouble ratio);
extern void androidx_compose_ui_arkui_init(void* env, void* exports); extern void androidx_compose_ui_arkui_init(void* env, void* exports);
extern void* MainArkUIViewController(void* env); extern void* MainArkUIViewController(void* env);
extern libkn_KInt hiLogPrintMsg(libkn_KUInt type, libkn_KUInt level, libkn_KUInt domain, const char* tag, const char* message); extern libkn_KInt hiLogPrintMsg(libkn_KUInt type, libkn_KUInt level, libkn_KUInt domain, const char* tag, const char* message);
extern void testArkTsToKotin();
extern libkn_KInt kn_get_render_backend_id(); extern libkn_KInt kn_get_render_backend_id();
typedef struct { typedef struct {
...@@ -786,6 +787,7 @@ typedef struct { ...@@ -786,6 +787,7 @@ typedef struct {
void (*pirntAllLevelHiLog)(); void (*pirntAllLevelHiLog)();
void (*pirntRandomHiLog)(); void (*pirntRandomHiLog)();
void (*pirntSingleHiLog)(); void (*pirntSingleHiLog)();
void (*testArkTsToKotin_)();
} demo013; } demo013;
} dong; } dong;
} com; } com;
......
...@@ -84,6 +84,14 @@ static napi_value nativeRegisterNodeStatusModifyConstructor(napi_env env, napi_c ...@@ -84,6 +84,14 @@ static napi_value nativeRegisterNodeStatusModifyConstructor(napi_env env, napi_c
return nullptr; return nullptr;
} }
static napi_value nativeTestArkTsToKotin(napi_env env, napi_callback_info info) {
testArkTsToKotin();
napi_value undefined;
napi_get_undefined(env, &undefined);
return undefined;
}
EXTERN_C_START EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports) { static napi_value Init(napi_env env, napi_value exports) {
androidx_compose_ui_arkui_init(env, exports); androidx_compose_ui_arkui_init(env, exports);
...@@ -95,6 +103,7 @@ static napi_value Init(napi_env env, napi_value exports) { ...@@ -95,6 +103,7 @@ static napi_value Init(napi_env env, napi_value exports) {
{"nativeRegisterNodeConstructor", nullptr, nativeRegisterNodeConstructor, nullptr, nullptr, nullptr, napi_default, nullptr}, {"nativeRegisterNodeConstructor", nullptr, nativeRegisterNodeConstructor, nullptr, nullptr, nullptr, napi_default, nullptr},
{"nativeRegisterNodeStatusModifyConstructor", nullptr, nativeRegisterNodeStatusModifyConstructor, nullptr, nullptr, nullptr, napi_default, nullptr }, {"nativeRegisterNodeStatusModifyConstructor", nullptr, nativeRegisterNodeStatusModifyConstructor, nullptr, nullptr, nullptr, napi_default, nullptr },
{"nativeSetPixelRatio", nullptr, nativeSetPixelRatio, nullptr, nullptr, nullptr, napi_default, nullptr}, {"nativeSetPixelRatio", nullptr, nativeSetPixelRatio, nullptr, nullptr, nullptr, napi_default, nullptr},
{"testArkTsToKotin", nullptr, nativeTestArkTsToKotin, nullptr, nullptr, nullptr, napi_default, nullptr},
}; };
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
return exports; return exports;
......
import { ArkUIViewController } from "compose/src/main/cpp/types/libcompose_arkui_utils"; import { ArkUIViewController,testArkTsToKotin} from "compose/src/main/cpp/types/libcompose_arkui_utils";
export const MainArkUIViewController: () => ArkUIViewController export const MainArkUIViewController: () => ArkUIViewController
export const testArkTsToKotin:()=>void
...@@ -10,9 +10,9 @@ struct Index { ...@@ -10,9 +10,9 @@ struct Index {
private controller: ArkUIViewController | undefined = undefined; private controller: ArkUIViewController | undefined = undefined;
@State errorMessage: string = 'Native module not ready'; @State errorMessage: string = 'Native module not ready';
ab
aboutToAppear() { aboutToAppear() {
//ArkTs生命周期断点处 //ArkTs生命周期断点处
if (nativeApi === undefined) { if (nativeApi === undefined) {
hilog.error(DOMAIN, 'Compose', 'nativeApi is undefined, cannot create controller'); hilog.error(DOMAIN, 'Compose', 'nativeApi is undefined, cannot create controller');
...@@ -20,6 +20,15 @@ struct Index { ...@@ -20,6 +20,15 @@ struct Index {
return; return;
} }
hilog.info(DOMAIN, 'Compose', 'nativeApi is ready');
nativeApi.testArkTsToKotin();
try { try {
this.controller = nativeApi.MainArkUIViewController(); this.controller = nativeApi.MainArkUIViewController();
const state = this.controller ? 'created' : 'not_created'; const state = this.controller ? 'created' : 'not_created';
...@@ -33,6 +42,14 @@ struct Index { ...@@ -33,6 +42,14 @@ struct Index {
} }
} }
// 模拟耗时操作
private loadData() {
for (let i = 0; i < 10000; i++) {
// 模拟数据处理
let temp = i * i;
}
}
build() { build() {
Column() { Column() {
if (this.controller) { if (this.controller) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment