Skip to content

Add J2ObjC companion and KNP compatibility alias for ExtensionRegistryLite to match Kotlin/Native protobuf codegen in Objective-C and Swift. - #2944

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1029062286
Open

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1029062286

Conversation

@copybara-service

Copy link
Copy Markdown

Add J2ObjC companion and KNP compatibility alias for ExtensionRegistryLite to match Kotlin/Native protobuf codegen in Objective-C and Swift.

Objective-C and Swift code migrating from J2ObjC protos to Kotlin/Native protos cannot call ExtensionRegistryLite.getGeneratedRegistry() through a single API because J2ObjC did not expose KNPComGoogleProtobufExtensionRegistryLite, its companion/shared properties, or a transitive include from GeneratedMessage.h.

  • Declare ComGoogleProtobufExtensionRegistryLiteCompanionProtocol (getGeneratedRegistry), companion and shared class properties on ComGoogleProtobufExtensionRegistryLite, and @compatibility_alias for KNPComGoogleProtobufExtensionRegistryLite and KNPComGoogleProtobufExtensionRegistryLiteCompanion.
  • Return ComGoogleProtobufExtensionRegistryLite_getEmptyRegistry() instead of nil in GeneratedExtensionRegistryLoader.m when zero extensions are linked so +getGeneratedRegistry is nonnull, matching Java and Kotlin/Native.
  • Include com/google/protobuf/ExtensionRegistryLite.h from GeneratedMessage.h so KNPComGoogleProtobufExtensionRegistryLite is available from generated proto headers.
  • Add Objective-C and Swift round-trip extension parse tests using KNPComGoogleProtobufExtensionRegistryLite.companion.getGeneratedRegistry.

…ryLite` to match Kotlin/Native protobuf codegen in Objective-C and Swift.

Objective-C and Swift code migrating from J2ObjC protos to Kotlin/Native protos cannot call `ExtensionRegistryLite.getGeneratedRegistry()` through a single API because J2ObjC did not expose `KNPComGoogleProtobufExtensionRegistryLite`, its `companion`/`shared` properties, or a transitive include from `GeneratedMessage.h`.

- Declare `ComGoogleProtobufExtensionRegistryLiteCompanionProtocol` (`getGeneratedRegistry`), `companion` and `shared` class properties on `ComGoogleProtobufExtensionRegistryLite`, and `@compatibility_alias` for `KNPComGoogleProtobufExtensionRegistryLite` and `KNPComGoogleProtobufExtensionRegistryLiteCompanion`.
- Return `ComGoogleProtobufExtensionRegistryLite_getEmptyRegistry()` instead of `nil` in `GeneratedExtensionRegistryLoader.m` when zero extensions are linked so `+getGeneratedRegistry` is nonnull, matching Java and Kotlin/Native.
- Include `com/google/protobuf/ExtensionRegistryLite.h` from `GeneratedMessage.h` so `KNPComGoogleProtobufExtensionRegistryLite` is available from generated proto headers.
- Add Objective-C and Swift round-trip extension parse tests using `KNPComGoogleProtobufExtensionRegistryLite.companion.getGeneratedRegistry`.

PiperOrigin-RevId: 1029062286

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant