(headerText)
| 49 | } |
| 50 | |
| 51 | function parseGcbEnum(headerText) { |
| 52 | const start = headerText.indexOf("typedef enum zr_gcb_class_t"); |
| 53 | if (start < 0) throw new Error("missing zr_gcb_class_t enum"); |
| 54 | const brace = headerText.indexOf("{", start); |
| 55 | const end = headerText.indexOf("}", brace); |
| 56 | if (brace < 0 || end < 0) throw new Error("malformed zr_gcb_class_t enum"); |
| 57 | |
| 58 | const body = headerText.slice(brace + 1, end); |
| 59 | const names = body |
| 60 | .split(",") |
| 61 | .map((s) => s.trim()) |
| 62 | .filter(Boolean) |
| 63 | .map((s) => s.replace(/\s*=.*$/, "").trim()) |
| 64 | .filter((s) => s.startsWith("ZR_GCB_")); |
| 65 | |
| 66 | const map = new Map(); |
| 67 | for (let i = 0; i < names.length; i++) map.set(names[i], i); |
| 68 | if (!map.has("ZR_GCB_OTHER")) throw new Error("expected ZR_GCB_OTHER in enum"); |
| 69 | return map; |
| 70 | } |
| 71 | |
| 72 | function parseIncGcbRanges(incText, gcbEnum) { |
| 73 | const block = extractBlock(incText, "static const zr_unicode_range8_t kGcbRanges[]"); |
no test coverage detected