(source: string)
| 1576 | */ |
| 1577 | const CPP_INLINE_ANNOTATION_RE = /\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(/g; |
| 1578 | export function blankCppInlineAnnotationMacros(source: string): string { |
| 1579 | if (!/\b(?:UMETA|UPARAM|UE_DEPRECATED)/.test(source)) return source; |
| 1580 | const rawStrings = maskCppRawStrings(source); |
| 1581 | source = rawStrings.source; |
| 1582 | let chars: string[] | null = null; |
| 1583 | const re = new RegExp(CPP_INLINE_ANNOTATION_RE.source, 'g'); |
| 1584 | let m: RegExpExecArray | null; |
| 1585 | while ((m = re.exec(source)) !== null) { |
| 1586 | let i = m.index + m[0].length - 1; // index of the opening '(' |
| 1587 | let depth = 0; |
| 1588 | let end = -1; |
| 1589 | for (; i < source.length; i++) { |
| 1590 | const c = source[i]; |
| 1591 | if (c === '"' || c === "'") { |
| 1592 | const quote = c; |
| 1593 | i++; |
| 1594 | while (i < source.length && source[i] !== quote) { |
| 1595 | if (source[i] === '\\') i++; |
| 1596 | i++; |
| 1597 | } |
| 1598 | continue; |
| 1599 | } |
| 1600 | if (c === '(') depth++; |
| 1601 | else if (c === ')') { |
| 1602 | depth--; |
| 1603 | if (depth === 0) { end = i + 1; break; } |
| 1604 | } |
| 1605 | } |
| 1606 | if (end < 0) continue; |
| 1607 | chars ??= source.split(''); |
| 1608 | for (let k = m.index; k < end; k++) { |
| 1609 | if (chars[k] !== '\n' && chars[k] !== '\r') chars[k] = ' '; |
| 1610 | } |
| 1611 | re.lastIndex = end; |
| 1612 | } |
| 1613 | return rawStrings.restore(chars ? chars.join('') : source); |
| 1614 | } |
| 1615 | |
| 1616 | /** |
| 1617 | * Blank CUDA-specific constructs before parsing `.cu`/`.cuh` files (parsed with |
no test coverage detected