( baseName: string, externalLabels: (string | null)[], explicitObjcName?: string | null )
| 74 | * Initializer rules are handled by `objcSelectorForSwiftInit`. |
| 75 | */ |
| 76 | export function objcSelectorForSwiftMethod( |
| 77 | baseName: string, |
| 78 | externalLabels: (string | null)[], |
| 79 | explicitObjcName?: string | null |
| 80 | ): string | null { |
| 81 | if (!baseName) return null; |
| 82 | if (explicitObjcName) return explicitObjcName; |
| 83 | |
| 84 | if (externalLabels.length === 0) { |
| 85 | return baseName; |
| 86 | } |
| 87 | |
| 88 | const [first, ...rest] = externalLabels; |
| 89 | // Single param: "_" → "base:" ; "label" → "baseWithLabel:" |
| 90 | // Multi-param mirrors the same first-keyword formation, then appends each |
| 91 | // subsequent label as its own keyword. A `null` later label is invalid |
| 92 | // ObjC (no way to express unlabeled middle params) — keep as `:` to be safe. |
| 93 | const firstKeyword = |
| 94 | first === null || first === undefined || first === '_' || first === '' |
| 95 | ? `${baseName}:` |
| 96 | : `${baseName}With${capFirst(first)}:`; |
| 97 | |
| 98 | const restKeywords = rest.map((l) => `${l ?? ''}:`).join(''); |
| 99 | return firstKeyword + restKeywords; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Compute the bridged ObjC selector for a Swift `init(...)` declaration. |
no test coverage detected