Skip to content

Add prefix_to_proto_package_mappings_path ObjC option.#9498

Merged
thomasvl merged 1 commit intoprotocolbuffers:masterfrom
dnkoutso:objc_class_prefix_mappings
Feb 23, 2022
Merged

Add prefix_to_proto_package_mappings_path ObjC option.#9498
thomasvl merged 1 commit intoprotocolbuffers:masterfrom
dnkoutso:objc_class_prefix_mappings

Conversation

@dnkoutso
Copy link
Copy Markdown
Contributor

@dnkoutso dnkoutso commented Feb 12, 2022

Hey @thomasvl in the previous PR we introduced the default_objc_class_prefix objc_opt.

However, upon using it it had a major flaw. We have protos that we generate this prefix for for namespacing and it is not always the same. Upon using this, we realized that objc class prefix passed was also used when generating code for dependencies which was causing compilation issues. In other words, it was applied globally. This might be OK if anyone decides to use the same prefix for all protos so maybe we can keep that option as well?

I figured anyone can generate a map with the same prefix across all proto files if they desire to do so.

This is basically a different solution to #9469

Comment thread src/google/protobuf/compiler/objectivec/objectivec_generator.cc Outdated
@dnkoutso dnkoutso force-pushed the objc_class_prefix_mappings branch from 0b1f8c6 to 41e2a26 Compare February 12, 2022 04:02
Comment thread src/google/protobuf/compiler/objectivec/objectivec_helpers.h
@thomasvl
Copy link
Copy Markdown
Contributor

FYI I won't be able to really look until about the 22nd. Taking some time off.

@dnkoutso
Copy link
Copy Markdown
Contributor Author

no worries, thank you so much for your time @thomasvl !

Comment thread src/google/protobuf/compiler/objectivec/objectivec_helpers.cc Outdated
Comment thread src/google/protobuf/compiler/objectivec/objectivec_generator.cc
@dnkoutso dnkoutso force-pushed the objc_class_prefix_mappings branch 2 times, most recently from 492f35b to 7f993c2 Compare February 22, 2022 18:23
@dnkoutso dnkoutso force-pushed the objc_class_prefix_mappings branch 2 times, most recently from 6c19c25 to 72b485a Compare February 23, 2022 18:26
Comment thread src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@dnkoutso dnkoutso force-pushed the objc_class_prefix_mappings branch from 72b485a to 697c45c Compare February 23, 2022 18:27
@dnkoutso dnkoutso force-pushed the objc_class_prefix_mappings branch from 697c45c to 7f747ff Compare February 23, 2022 18:29
}

std::string PrefixModeStorage::prefix_from_proto_package_mappings(const FileDescriptor* file) {
if (!file) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually do need the file here as we perform some logic below to figure out the package to use.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I had commented not about the passing of file, but the passing of it by reference so it can't be nullptr.

@dnkoutso
Copy link
Copy Markdown
Contributor Author

@thomasvl I updated all logic! Let me know if there is anything else for me to change or address!

@dnkoutso dnkoutso changed the title Use a objc class prefix mappings path generator option instead. Add prefix_to_proto_package_mappings_path ObjC option. Feb 23, 2022
@thomasvl thomasvl merged commit a112c4a into protocolbuffers:master Feb 23, 2022
@dnkoutso dnkoutso deleted the objc_class_prefix_mappings branch February 23, 2022 19:36
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.

4 participants