diff --git a/koala-wrapper/native/src/bridges.cc b/koala-wrapper/native/src/bridges.cc index 440bb5ba44bbf6a3650255987243ab0a6a630099..2fa2bd6d4ac38df2fe5871cebb47658fa4d65fad 100644 --- a/koala-wrapper/native/src/bridges.cc +++ b/koala-wrapper/native/src/bridges.cc @@ -316,6 +316,29 @@ static KNativePointer impl_ExternalSourcePrograms(KNativePointer instance) } KOALA_INTEROP_1(ExternalSourcePrograms, KNativePointer, KNativePointer); +KNativePointer impl_CreateContextGenerateAbcForExternalSourceFiles( + KNativePointer configPtr, KInt fileNamesCount, KStringArray fileNames) +{ + auto config = reinterpret_cast(configPtr); + const std::size_t headerLen = 4; + const char **argv = + new const char *[static_cast(fileNamesCount)]; + std::size_t position = headerLen; + std::size_t strLen; + for (std::size_t i = 0; i < static_cast(fileNamesCount); ++i) { + strLen = unpackUInt(fileNames + position); + position += headerLen; + argv[i] = strdup( + std::string(reinterpret_cast(fileNames + position), + strLen) + .c_str()); + position += strLen; + } + return GetImpl()->CreateContextGenerateAbcForExternalSourceFiles( + config, fileNamesCount, argv); +} +KOALA_INTEROP_3(CreateContextGenerateAbcForExternalSourceFiles, KNativePointer, KNativePointer, KInt, KStringArray) + KBoolean impl_IsClassProperty(KNativePointer nodePtr) { auto node = reinterpret_cast(nodePtr); diff --git a/koala-wrapper/src/Es2pandaNativeModule.ts b/koala-wrapper/src/Es2pandaNativeModule.ts index 83a90fea2e5988d44f46bd413e381d7504e33271..52cec79e50d2d7d4d1ecbafd955614640dd1d829 100644 --- a/koala-wrapper/src/Es2pandaNativeModule.ts +++ b/koala-wrapper/src/Es2pandaNativeModule.ts @@ -105,6 +105,10 @@ export class Es2pandaNativeModule { _CreateContextFromString(config: KPtr, source: String, filename: String): KPtr { throw new Error('Not implemented'); } + _CreateContextGenerateAbcForExternalSourceFiles(config: KPtr, fileCount: KInt, filenames: + string[]): KPtr { + throw new Error('Not implemented'); + } _CreateContextFromFile(config: KPtr, filename: String): KPtr { throw new Error('Not implemented'); } diff --git a/koala-wrapper/src/arkts-api/peers/Context.ts b/koala-wrapper/src/arkts-api/peers/Context.ts index b4bf7a203faa00c7eb776d1dfc428ff0d54a923d..d091e7fd37fa67f936fc99ed255872dea0fb17e2 100644 --- a/koala-wrapper/src/arkts-api/peers/Context.ts +++ b/koala-wrapper/src/arkts-api/peers/Context.ts @@ -16,8 +16,8 @@ import { ArktsObject } from './ArktsObject'; import { global } from '../static/global'; import { throwError, filterSource } from '../../utils'; -import { passString } from '../utilities/private'; -import { KBoolean, KNativePointer } from '@koalaui/interop'; +import { passString, passStringArray } from '../utilities/private'; +import { KBoolean, KInt, KNativePointer } from '@koalaui/interop'; import { AstNode } from './AstNode'; import { Program } from './Program'; export class Context extends ArktsObject { @@ -45,6 +45,17 @@ export class Context extends ArktsObject { ); } + static createContextGenerateAbcForExternalSourceFiles( + filenames: string[]): Context { + if (!global.configIsInitialized()) { + throwError(`Config not initialized`); + } + return new Context( + global.es2panda._CreateContextGenerateAbcForExternalSourceFiles(global.config, filenames.length, passStringArray(filenames)) + ); + } + + static destroyAndRecreate(ast: AstNode): Context { console.log('[TS WRAPPER] DESTROY AND RECREATE'); const source = filterSource(ast.dumpSrc()); diff --git a/koala-wrapper/src/arkts-api/utilities/public.ts b/koala-wrapper/src/arkts-api/utilities/public.ts index 927073e744f86fd0100c70be073322ef0a6bdd4e..030b584e792844663236a9f3db1fd73f6083af49 100644 --- a/koala-wrapper/src/arkts-api/utilities/public.ts +++ b/koala-wrapper/src/arkts-api/utilities/public.ts @@ -15,7 +15,7 @@ import { global } from '../static/global'; import { isNumber, throwError, getEnumName } from '../../utils'; -import { KNativePointer, KInt, nullptr, withStringResult } from '@koalaui/interop'; +import { KNativePointer, KInt, nullptr, withStringResult, KStringArrayPtr } from '@koalaui/interop' import { passNode, passString, passStringArray, unpackNodeArray, unpackNonNullableNode } from './private'; import { isFunctionDeclaration, isMemberExpression, isMethodDefinition, isNumberLiteral } from '../factory/nodeTests'; import { @@ -42,6 +42,7 @@ import { Program } from '../peers/Program'; import { clearNodeCache, nodeByType } from '../class-by-peer'; import { SourcePosition } from '../peers/SourcePosition'; import { MemberExpression } from '../to-be-generated/MemberExpression'; +import { KNativePointerArray } from 'src/generated/Es2pandaNativeModule'; export function proceedToState(state: Es2pandaContextState, context: KNativePointer, forceDtsEmit = false): void { console.log('[TS WRAPPER] PROCEED TO STATE: ', getEnumName(Es2pandaContextState, state));