From d0227066056a54774538c6ea247eeb1dd4dd7dff Mon Sep 17 00:00:00 2001 From: gxz Date: Fri, 21 Jun 2024 17:41:29 +0800 Subject: [PATCH] chore: terra adapt overrideNodeParser --- scripts/terra/impl.ts | 45 +++++++++++++++++++++--------------------- scripts/terra/index.ts | 23 +++++++++++---------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/scripts/terra/impl.ts b/scripts/terra/impl.ts index ce7a1e2f..4b05e2be 100644 --- a/scripts/terra/impl.ts +++ b/scripts/terra/impl.ts @@ -11,6 +11,9 @@ import { ParseResult, TerraContext } from '@agoraio-extensions/terra-core'; import { IrisApiIdParserUserData, + OverrideNodeParserUserData, + getIrisApiIdValue, + getOverrideNodeParserUserData, renderWithConfiguration, } from '@agoraio-extensions/terra_shared_configs'; @@ -38,20 +41,22 @@ type TerraNodeUserData = IrisApiIdParserUserData & { prefix_name: string; }; -type VariableUserData = IrisApiIdParserUserData & { - name: string; -}; +type VariableUserData = IrisApiIdParserUserData & + OverrideNodeParserUserData & { + name: string; + }; -type ClazzMethodUserData = IrisApiIdParserUserData & { - output: string; - input: string; - input_map: Variable[]; - input_map_fixed: Variable[]; - output_map: Variable[]; - hasParameters: boolean; - bindingFunctionName: string; - returnParam: string; -}; +type ClazzMethodUserData = IrisApiIdParserUserData & + OverrideNodeParserUserData & { + output: string; + input: string; + input_map: Variable[]; + input_map_fixed: Variable[]; + output_map: Variable[]; + hasParameters: boolean; + bindingFunctionName: string; + returnParam: string; + }; export function impl(parseResult: ParseResult) { let preParseResult = deepClone(parseResult, ['parent', 'outVariable']); @@ -93,16 +98,10 @@ export function impl(parseResult: ParseResult) { returnParam: '', ...method.user_data, }; - if (!clazzMethodUserData.IrisApiIdParser) { - clazzMethodUserData.IrisApiIdParser = { - key: `${method.parent_name.replace(new RegExp('^I(.*)'), '$1')}_${ - method.name - }`, - value: `${method.parent_name.replace( - new RegExp('^I(.*)'), - '$1' - )}_${method.name}`, - }; + let overrideNode = getOverrideNodeParserUserData(method); + if (overrideNode && overrideNode.redirectIrisApiId) { + clazzMethodUserData.IrisApiIdParser.value = + overrideNode.redirectIrisApiId; } method.return_type.name = convertToCamelCase(method.return_type.name); method.asMemberFunction().parameters.map((param) => { diff --git a/scripts/terra/index.ts b/scripts/terra/index.ts index ef991049..24e91569 100644 --- a/scripts/terra/index.ts +++ b/scripts/terra/index.ts @@ -9,6 +9,7 @@ import { import { IrisApiIdParserUserData, + OverrideNodeParserUserData, renderWithConfiguration, } from '@agoraio-extensions/terra_shared_configs'; @@ -18,17 +19,19 @@ type CXXFileUserData = { fileName: string; }; -type TerraNodeUserData = IrisApiIdParserUserData & { - isStruct: boolean; - isEnumz: boolean; - isClazz: boolean; - isCallback: boolean; -}; +type TerraNodeUserData = IrisApiIdParserUserData & + OverrideNodeParserUserData & { + isStruct: boolean; + isEnumz: boolean; + isClazz: boolean; + isCallback: boolean; + }; -type ClazzMethodUserData = IrisApiIdParserUserData & { - output: string; - input: string; -}; +type ClazzMethodUserData = IrisApiIdParserUserData & + OverrideNodeParserUserData & { + output: string; + input: string; + }; export default function ( terraContext: TerraContext,