(source: string)
| 640 | */ |
| 641 | const CPP_INLINE_ANNOTATION_RE = /\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(/g; |
| 642 | export function blankCppInlineAnnotationMacros(source: string): string { |
| 643 | if (!/\b(?:UMETA|UPARAM|UE_DEPRECATED)/.test(source)) return source; |
| 644 | const chars = source.split(''); |
| 645 | const re = new RegExp(CPP_INLINE_ANNOTATION_RE.source, 'g'); |
| 646 | let m: RegExpExecArray | null; |
| 647 | while ((m = re.exec(source)) !== null) { |
| 648 | let i = m.index + m[0].length - 1; // index of the opening '(' |
| 649 | let depth = 0; |
| 650 | let end = -1; |
| 651 | for (; i < source.length; i++) { |
| 652 | const c = source[i]; |
| 653 | if (c === '"' || c === "'") { |
| 654 | const quote = c; |
| 655 | i++; |
| 656 | while (i < source.length && source[i] !== quote) { |
| 657 | if (source[i] === '\\') i++; |
| 658 | i++; |
| 659 | } |
| 660 | continue; |
| 661 | } |
| 662 | if (c === '(') depth++; |
| 663 | else if (c === ')') { |
| 664 | depth--; |
| 665 | if (depth === 0) { end = i + 1; break; } |
| 666 | } |
| 667 | } |
| 668 | if (end < 0) continue; |
| 669 | for (let k = m.index; k < end; k++) { |
| 670 | if (chars[k] !== '\n' && chars[k] !== '\r') chars[k] = ' '; |
| 671 | } |
| 672 | re.lastIndex = end; |
| 673 | } |
| 674 | return chars.join(''); |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * Blank CUDA-specific constructs before parsing `.cu`/`.cuh` files (parsed with |
no test coverage detected