MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / blankCppExportMacros

Function blankCppExportMacros

src/extraction/languages/c-cpp.ts:699–720  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

697const CPP_CLASS_HEAD_MACROS_RE =
698 /\b(?:class|struct)\s+((?:[A-Z][A-Z0-9_]+(?:\s*\((?:[^()]|\([^()]*\))*\))?\s+)+)(?!final\b)[A-Za-z_]\w*(?:\s*::\s*[A-Za-z_]\w*)*/g;
699export function blankCppExportMacros(source: string): string {
700 if (source.indexOf('class') === -1 && source.indexOf('struct') === -1) return source;
701 if (!/\b(?:class|struct)\s+[A-Z][A-Z0-9_]/.test(source)) return source;
702 const code = maskCppCode(source);
703 const spans: Array<[number, number]> = [];
704 const re = new RegExp(CPP_CLASS_HEAD_MACROS_RE.source, 'g');
705 let m: RegExpExecArray | null;
706 while ((m = re.exec(code)) !== null) {
707 let i = skipCppSpace(code, m.index + m[0].length);
708 if (code[i] === '<') {
709 i = skipCppAngleArgs(code, i);
710 if (i < 0) continue;
711 i = skipCppSpace(code, i);
712 }
713 if (/^final\b/.test(code.slice(i, i + 6))) i = skipCppSpace(code, i + 5);
714 if (code[i] !== '{' && !(code[i] === ':' && code[i + 1] !== ':')) continue;
715 const run = m[1] as string;
716 const start = m.index + m[0].indexOf(run);
717 pushCppRunTokens(spans, run, start);
718 }
719 return blankCppSpans(source, spans, code);
720}
721
722// Comments and string/char literals (raw strings are masked beforehand by
723// maskCppRawStrings). The char-literal boundary leaves digit separators alone.

Callers 4

checkFunction · 0.90
extraction.test.tsFile · 0.90
preParseCppSourceFunction · 0.85

Calls 6

maskCppCodeFunction · 0.85
skipCppSpaceFunction · 0.85
skipCppAngleArgsFunction · 0.85
pushCppRunTokensFunction · 0.85
blankCppSpansFunction · 0.85
execMethod · 0.65

Tested by 1

checkFunction · 0.72