Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefix_to_proto_package_mappings_path ObjC option. #9498

Merged

Conversation

dnkoutso
Copy link
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

@thomasvl
Copy link
Contributor

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

@dnkoutso
Copy link
Contributor Author

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

@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
@@ -140,6 +161,44 @@ PrefixModeStorage::PrefixModeStorage() {
}
}

std::string PrefixModeStorage::prefix_from_proto_package_mappings(const FileDescriptor* file) {
if (!file) {
Copy link
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
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
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.

None yet

4 participants