Skip to content

Commit

Permalink
feat: Add iris_utils.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Dec 12, 2023
1 parent 7bb4fc4 commit 23b9815
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/utils/iris_utils.ts
Original file line number Diff line number Diff line change
@@ -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}`;
}

0 comments on commit 23b9815

Please sign in to comment.