| 697 | const 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; |
| 699 | export 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. |