Skip to content

Commit

Permalink
Revert "refactor: get iris_api_id by read custom header comments"
Browse files Browse the repository at this point in the history
This reverts commit 09c00c7.
  • Loading branch information
guoxianzhe committed Jan 22, 2024
1 parent 09c00c7 commit c5fb5cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 73 deletions.
6 changes: 2 additions & 4 deletions headers/rtc_4.3.0/custom_headers/CustomIAgoraRtcEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ class IRtcEngine {
virtual int addVideoWatermark(const char *watermarkUrl,
const WatermarkOptions &options) = 0;

/**
* @iris_api_id: RtcEngine_joinChannelWithUserAccount_4685af9
* @source: virtual int joinChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount, const ChannelMediaOptions& options) = 0;
*/
// virtual int joinChannelWithUserAccount(const char* token, const char* channelId,
// const char* userAccount, const ChannelMediaOptions& options) = 0;
virtual int
joinChannelWithUserAccount(const char *token, const char *channelId,
const char *userAccount,
Expand Down
42 changes: 5 additions & 37 deletions src/parsers/add_node_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ import {
} from '@agoraio-extensions/cxx-parser';
import { ParseResult, TerraContext } from '@agoraio-extensions/terra-core';

import { irisApiId } from '../utils';
import {
CommentAction,
CommentConfig,
CommentConfigKey,
generateNodes,
getConfigsFromComments,
} from '../utils/parser_utils';

import { IrisApiIdParserUserData } from './iris_api_id_parser';
import { generateNodes } from '../utils/parser_utils';

export type AddNodeParserArgs = CXXParserConfigs & {
customHeaderFileNamePrefix?: string;
Expand Down Expand Up @@ -72,40 +63,17 @@ export const AddNodeParser = (
}

(customNode as Clazz).methods.forEach((customMethod) => {
let configs: CommentConfig[] = getConfigsFromComments(customMethod);
let foundMethodIndex = -1;
let irisApiIdValue = '';
for (let config of configs) {
switch (config.key) {
case CommentConfigKey.SOURCE:
// find method which has same name and signature
foundMethodIndex = foundClass.methods.findIndex(
(it) => it.name === customMethod.name
);
break;
case CommentConfigKey.IRIS_API_ID:
// find method which has same name and signature
irisApiIdValue = config.value;
break;
}
}
if (customMethod.name === 'joinChannelWithUserAccount') {
debugger;
}
// find method which has same name
const foundMethodIndex = foundClass.methods.findIndex(
(it) => it.name === customMethod.name
);
if (foundMethodIndex == -1) {
// add method if not found
foundClass.methods.push(customMethod);
return;
}

// mark method as custom
// iris use nativeSDK origin cpp api signature, so we need call applyIrisApiId to add iris api id by foundClass.methods[foundMethodIndex]
customMethod.user_data ??= {};
(customMethod.user_data as IrisApiIdParserUserData).IrisApiIdParser = {
key: '',
value: irisApiIdValue,
};

customMethod.user_data = {
...customMethod.user_data,
AddNodeParser: foundClass.methods[foundMethodIndex],
Expand Down
33 changes: 1 addition & 32 deletions src/utils/parser_utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
CXXParser,
CXXParserConfigs,
CXXTerraNode,
} from '@agoraio-extensions/cxx-parser';
import { CXXParser, CXXParserConfigs } from '@agoraio-extensions/cxx-parser';
import {
ParseResult,
TerraContext,
Expand Down Expand Up @@ -39,30 +35,3 @@ export function getConfigs(args: BaseParserArgs, terraContext: TerraContext) {
}
return configs;
}

export enum CommentConfigKey {
SOURCE = 'source',
ACTION = 'action',
IRIS_API_ID = 'iris_api_id',
}

export enum CommentAction {
ADD = 'add',
REPLACE = 'replace',
REMOVE = 'remove',
}

export type CommentConfig = { key: CommentConfigKey; value: string };

export const getConfigsFromComments = (node: CXXTerraNode) => {
const regex = /@(\w+):(.+?)(?=@|$)/gs;
const matches = [...node.comment.matchAll(regex)];
const configs: CommentConfig[] = matches.map((match) => {
return {
key: match[1] as CommentConfigKey,
value: match[2].trim(),
};
});
node.comment = '';
return configs;
};

0 comments on commit c5fb5cd

Please sign in to comment.