From 9f9455f7edb362a20b1007c2feeaf86ff38a1726 Mon Sep 17 00:00:00 2001 From: Igor Loginov Date: Mon, 16 Jun 2025 08:26:54 +0300 Subject: [PATCH] Add invalidate|remove|add file cache bridges --- ui2abc/libarkts/native/src/bridges.cc | 25 ++++++++++++++++--- ui2abc/libarkts/src/Es2pandaNativeModule.ts | 9 +++++++ .../libarkts/src/arkts-api/peers/Context.ts | 12 +++++++++ .../src/arkts-api/utilities/public.ts | 13 ++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/ui2abc/libarkts/native/src/bridges.cc b/ui2abc/libarkts/native/src/bridges.cc index a4c887e11..e3594d4e0 100644 --- a/ui2abc/libarkts/native/src/bridges.cc +++ b/ui2abc/libarkts/native/src/bridges.cc @@ -388,12 +388,30 @@ KNativePointer impl_CreateGlobalContext(KNativePointer configPtr, KStringArray e } KOALA_INTEROP_4(CreateGlobalContext, KNativePointer, KNativePointer, KStringArray, KUInt, KBoolean) -void impl_DestroyGlobalContext(KNativePointer contextPtr) { - auto context = reinterpret_cast(contextPtr); - GetImpl()->DestroyGlobalContext(context); +void impl_DestroyGlobalContext(KNativePointer globalContextPtr) { + auto globalContext = reinterpret_cast(globalContextPtr); + GetImpl()->DestroyGlobalContext(globalContext); } KOALA_INTEROP_V1(DestroyGlobalContext, KNativePointer) +void impl_InvalidateFileCache(KNativePointer globalContextPtr, KStringPtr& fileName) { + auto globalContext = reinterpret_cast(globalContextPtr); + GetImpl()->InvalidateFileCache(globalContext, getStringCopy(fileName)); +} +KOALA_INTEROP_V2(InvalidateFileCache, KNativePointer, KStringPtr) + +void impl_RemoveFileCache(KNativePointer globalContextPtr, KStringPtr& fileName) { + auto globalContext = reinterpret_cast(globalContextPtr); + GetImpl()->RemoveFileCache(globalContext, getStringCopy(fileName)); +} +KOALA_INTEROP_V2(RemoveFileCache, KNativePointer, KStringPtr) + +void impl_AddFileCache(KNativePointer globalContextPtr, KStringPtr& fileName) { + auto globalContext = reinterpret_cast(globalContextPtr); + GetImpl()->AddFileCache(globalContext, getStringCopy(fileName)); +} +KOALA_INTEROP_V2(AddFileCache, KNativePointer, KStringPtr) + // From koala-wrapper // TODO check if some code should be generated @@ -556,3 +574,4 @@ KInt impl_GenerateStaticDeclarationsFromContext(KNativePointer contextPtr, KStri return GetImpl()->GenerateStaticDeclarationsFromContext(context, outputPath.data()); } KOALA_INTEROP_2(GenerateStaticDeclarationsFromContext, KInt, KNativePointer, KStringPtr) + diff --git a/ui2abc/libarkts/src/Es2pandaNativeModule.ts b/ui2abc/libarkts/src/Es2pandaNativeModule.ts index db7cffb80..861ee831c 100644 --- a/ui2abc/libarkts/src/Es2pandaNativeModule.ts +++ b/ui2abc/libarkts/src/Es2pandaNativeModule.ts @@ -81,6 +81,15 @@ export class Es2pandaNativeModule { _DestroyGlobalContext(context: KNativePointer): void { throw new Error("Not implemented"); } + _InvalidateFileCache(globalContext: KNativePointer, fileName: String): void { + throw new Error("Not implemented"); + } + _RemoveFileCache(globalContext: KNativePointer, fileName: String): void { + throw new Error("Not implemented"); + } + _AddFileCache(globalContext: KNativePointer, fileName: String): void { + throw new Error("Not implemented"); + } _DestroyContext(context: KPtr): void { throw new Error("Not implemented") } diff --git a/ui2abc/libarkts/src/arkts-api/peers/Context.ts b/ui2abc/libarkts/src/arkts-api/peers/Context.ts index 349884d6e..965a52fbe 100644 --- a/ui2abc/libarkts/src/arkts-api/peers/Context.ts +++ b/ui2abc/libarkts/src/arkts-api/peers/Context.ts @@ -109,4 +109,16 @@ export class GlobalContext extends ArktsObject { this.peer = nullptr } } + + invalidateFileCache(fileName: string) { + global.es2panda._InvalidateFileCache(this.peer, fileName) + } + + removeFileCache(fileName: string) { + global.es2panda._RemoveFileCache(this.peer, fileName) + } + + addFileCache(fileName: string) { + global.es2panda._AddFileCache(this.peer, fileName) + } } diff --git a/ui2abc/libarkts/src/arkts-api/utilities/public.ts b/ui2abc/libarkts/src/arkts-api/utilities/public.ts index dfca57230..abd4c8a81 100644 --- a/ui2abc/libarkts/src/arkts-api/utilities/public.ts +++ b/ui2abc/libarkts/src/arkts-api/utilities/public.ts @@ -112,6 +112,19 @@ export function rebindSubtree(node: AstNode): void { checkErrors() } +export function recheckContext(context: KNativePointer): void { + global.es2panda._AstNodeRecheck( + context, + global.es2panda._ProgramAst( + context, + global.es2panda._ContextProgram( + context + ) + ) + ) + checkErrors() +} + export function getDecl(node: AstNode): AstNode | undefined { if (isMemberExpression(node)) { return getDecl(node.property!) -- Gitee