Skip to content

Commit

Permalink
chore: terra adapt overrideNodeParser
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxianzhe committed Jun 21, 2024
1 parent 17f4942 commit d022706
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
45 changes: 22 additions & 23 deletions scripts/terra/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { ParseResult, TerraContext } from '@agoraio-extensions/terra-core';

import {
IrisApiIdParserUserData,
OverrideNodeParserUserData,
getIrisApiIdValue,
getOverrideNodeParserUserData,
renderWithConfiguration,
} from '@agoraio-extensions/terra_shared_configs';

Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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) => {
Expand Down
23 changes: 13 additions & 10 deletions scripts/terra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {

import {
IrisApiIdParserUserData,
OverrideNodeParserUserData,
renderWithConfiguration,
} from '@agoraio-extensions/terra_shared_configs';

Expand All @@ -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,
Expand Down

0 comments on commit d022706

Please sign in to comment.