From 23b981563db0155a30ddc540473033c155ced164 Mon Sep 17 00:00:00 2001 From: littleGnAl Date: Tue, 12 Dec 2023 18:42:05 +0800 Subject: [PATCH] feat: Add iris_utils.ts --- src/utils/iris_utils.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/utils/iris_utils.ts diff --git a/src/utils/iris_utils.ts b/src/utils/iris_utils.ts new file mode 100644 index 0000000..061bbce --- /dev/null +++ b/src/utils/iris_utils.ts @@ -0,0 +1,31 @@ +import { + Clazz, + MemberFunction, + SimpleTypeKind, +} from '@agoraio-extensions/cxx-parser'; + +export function irisApiType(clazz: Clazz, mf: MemberFunction): string { + const ptrEscape = 'ptr'; + const refEscape = 'ref'; + const whitespaceEscape = '_'; + const seperator = '__'; + + let ps = mf.parameters + .map((param) => { + let out = param.type.name.replaceAll('::', whitespaceEscape); + + if (param.type.is_const) { + out = `const${whitespaceEscape}${out}`; + } + if (param.type.kind === SimpleTypeKind.pointer_t) { + out += `${whitespaceEscape}${ptrEscape}`; + } else if (param.type.kind === SimpleTypeKind.reference_t) { + out += `${whitespaceEscape}${refEscape}`; + } + + return out; + }) + .join(seperator); + + return `${clazz.name.trimNamespace()}${seperator}${mf.name}${seperator}${ps}`; +}