cla-bot · GitHub

@vincentborko @claude

Follow-up to skiptools#262. That change escaped the Swift `@_cdecl` function name
derived from a source file name via `cdeclEscaped`, but `cdeclEscaped` is
a JNI-symbol escaper, not a Swift-identifier escaper — the two have
different rules, so reusing it leaves two cases wrong:
- `.` is preserved by `cdeclEscaped` (it is a separator callers handle),
  but a `.` is invalid in a Swift identifier. A file such as
  `Model.generated.swift` still produces an uncompilable declaration:
      func Model.generatedKt_Swift_i(...)   // '.' is not valid
- `_` is valid in a Swift identifier but `cdeclEscaped` mangles it to
  `_1`, so `Model_Extensions.swift` needlessly yields
  `Model_1ExtensionsKt_Swift_i` on the Swift side.
Add a dedicated `swiftIdentifierEscaped` that leaves ASCII alphanumerics
and `_` untouched and hex-escapes everything else, and apply it to the
Swift function name only; the JNI symbol keeps `cdeclEscaped`. The `+`
case from skiptools#262 is unchanged (both escapers map `+` to `_0002b`). Also
corrects the `cdeclEscaped` doc comment, which claimed `.` -> `_` while
the code preserves `.`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Read the original on github.com ↗