Skip to content

Commit 8c64b50

Browse files
committed
Rename proto_package_to_prefix_mappings_path to package_to_prefix_mappings_path.
1 parent 6a77c9b commit 8c64b50

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

objectivec/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ This options allow you to provide a custom prefix for all the symbols generated
133133
from a proto file (classes (from message), enums, the Root for extension
134134
support).
135135

136-
If not set, the generation options `prefix_to_proto_package_mappings_path` and
136+
If not set, the generation options `package_to_prefix_mappings_path` and
137137
`use_package_as_prefix` (documented below) controls what is used instead. Since
138138
Objective C uses a global namespace for all of its classes, there can be collisions.
139139
`use_package_as_prefix=yes` should avoid collisions since proto package are used to
@@ -182,8 +182,8 @@ supported keys are:
182182
having to add the runtime directory to the header search path since the
183183
generate `#import` will be more complete.
184184

185-
* `prefix_to_proto_package_mappings_path`: The `value` used for
186-
this key is a path to a file containing a list of prefixes and proto packages.
185+
* `package_to_prefix_mappings_path`: The `value` used for this key is a
186+
path to a file containing a list of proto packages and prefixes.
187187
The generator will use this to locate which ObjC class prefix to use when
188188
generating sources _unless_ the `objc_class_prefix` file option is set.
189189
This option can be useful if multiple apps consume a common set of

src/google/protobuf/compiler/objectivec/objectivec_generator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ bool ObjectiveCGenerator::GenerateAll(
190190
// header search path since the generate #import will be more complete.
191191
generation_options.runtime_import_prefix =
192192
StripSuffixString(options[i].second, "/");
193-
} else if (options[i].first == "prefix_to_proto_package_mappings_path") {
193+
} else if (options[i].first == "package_to_prefix_mappings_path") {
194194
// Path to use for when loading the objc class prefix mappings to use.
195195
// The `objc_class_prefix` file option is always honored first if one is present.
196196
// This option also has precedent over the use_package_as_prefix option.
@@ -204,7 +204,7 @@ bool ObjectiveCGenerator::GenerateAll(
204204
// entry can be made as "no_package:PATH=prefix", where PATH is the
205205
// path for the .proto file.
206206
//
207-
SetPrefixToProtoPackageMappingsPath(options[i].second);
207+
SetPackageToPrefixMappingsPath(options[i].second);
208208
} else if (options[i].first == "use_package_as_prefix") {
209209
// Controls how the symbols should be prefixed to avoid symbols
210210
// collisions. The objc_class_prefix file option is always honored, this

src/google/protobuf/compiler/objectivec/objectivec_helpers.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ class PrefixModeStorage {
112112
public:
113113
PrefixModeStorage();
114114

115-
const std::string prefix_to_proto_package_mappings_path() const { return prefix_to_proto_package_mappings_path_; }
116-
void set_prefix_to_proto_package_mappings_path(const std::string& path) {
117-
prefix_to_proto_package_mappings_path_ = path;
118-
prefix_to_proto_package_map_.clear();
115+
const std::string package_to_prefix_mappings_path() const { return package_to_prefix_mappings_path_; }
116+
void set_package_to_prefix_mappings_path(const std::string& path) {
117+
package_to_prefix_mappings_path_ = path;
118+
package_to_prefix_map_.clear();
119119
}
120120

121121
std::string prefix_from_proto_package_mappings(const FileDescriptor* file);
@@ -137,8 +137,8 @@ class PrefixModeStorage {
137137

138138
private:
139139
bool use_package_name_;
140-
std::map<std::string, std::string> prefix_to_proto_package_map_;
141-
std::string prefix_to_proto_package_mappings_path_;
140+
std::map<std::string, std::string> package_to_prefix_map_;
141+
std::string package_to_prefix_mappings_path_;
142142
std::string exception_path_;
143143
std::string forced_prefix_;
144144
std::unordered_set<std::string> exceptions_;
@@ -168,20 +168,20 @@ std::string PrefixModeStorage::prefix_from_proto_package_mappings(const FileDesc
168168
return "";
169169
}
170170

171-
if (prefix_to_proto_package_map_.empty() && !prefix_to_proto_package_mappings_path_.empty()) {
171+
if (package_to_prefix_map_.empty() && !package_to_prefix_mappings_path_.empty()) {
172172
std::string error_str;
173173
// Re use the same collector as we use for expected_prefixes_path since the file
174174
// format is the same.
175-
PackageToPrefixesCollector collector("Package to prefixes", &prefix_to_proto_package_map_);
176-
if (!ParseSimpleFile(prefix_to_proto_package_mappings_path_, &collector, &error_str)) {
175+
PackageToPrefixesCollector collector("Package to prefixes", &package_to_prefix_map_);
176+
if (!ParseSimpleFile(package_to_prefix_mappings_path_, &collector, &error_str)) {
177177
if (error_str.empty()) {
178178
error_str = std::string("protoc:0: warning: Failed to parse")
179179
+ std::string(" prefix to proto package mappings file: ")
180-
+ prefix_to_proto_package_mappings_path_;
180+
+ package_to_prefix_mappings_path_;
181181
}
182182
std::cerr << error_str << std::endl;
183183
std::cerr.flush();
184-
prefix_to_proto_package_map_.clear();
184+
package_to_prefix_map_.clear();
185185
}
186186
}
187187

@@ -192,9 +192,9 @@ std::string PrefixModeStorage::prefix_from_proto_package_mappings(const FileDesc
192192
const std::string lookup_key = package.empty() ? no_package_prefix + file->name() : package;
193193

194194
std::map<std::string, std::string>::const_iterator prefix_lookup =
195-
prefix_to_proto_package_map_.find(lookup_key);
195+
package_to_prefix_map_.find(lookup_key);
196196

197-
if (prefix_lookup != prefix_to_proto_package_map_.end()) {
197+
if (prefix_lookup != package_to_prefix_map_.end()) {
198198
return prefix_lookup->second;
199199
}
200200

@@ -230,12 +230,12 @@ PrefixModeStorage g_prefix_mode;
230230

231231
} // namespace
232232

233-
std::string GetPrefixToProtoPackageMappingsPath() {
234-
return g_prefix_mode.prefix_to_proto_package_mappings_path();
233+
std::string GetPackageToPrefixMappingsPath() {
234+
return g_prefix_mode.package_to_prefix_mappings_path();
235235
}
236236

237-
void SetPrefixToProtoPackageMappingsPath(const std::string& file_path) {
238-
g_prefix_mode.set_prefix_to_proto_package_mappings_path(file_path);
237+
void SetPackageToPrefixMappingsPath(const std::string& file_path) {
238+
g_prefix_mode.set_package_to_prefix_mappings_path(file_path);
239239
}
240240

241241
bool UseProtoPackageAsDefaultPrefix() {

src/google/protobuf/compiler/objectivec/objectivec_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ namespace compiler {
4848
namespace objectivec {
4949

5050
// Get/Set the path to a file to load for objc class prefix lookups.
51-
std::string PROTOC_EXPORT GetPrefixToProtoPackageMappingsPath();
52-
void PROTOC_EXPORT SetPrefixToProtoPackageMappingsPath(
51+
std::string PROTOC_EXPORT GetPackageToPrefixMappingsPath();
52+
void PROTOC_EXPORT SetPackageToPrefixMappingsPath(
5353
const std::string& file_path);
5454
// Get/Set if the proto package should be used to make the default prefix for
5555
// symbols. This will then impact most of the type naming apis below. It is done

0 commit comments

Comments
 (0)