OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 ExtensionGenerator::~ExtensionGenerator() {} | 59 ExtensionGenerator::~ExtensionGenerator() {} |
60 | 60 |
61 void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { | 61 void ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) { |
62 map<string, string> vars; | 62 map<string, string> vars; |
63 vars["method_name"] = method_name_; | 63 vars["method_name"] = method_name_; |
64 SourceLocation location; | 64 SourceLocation location; |
65 if (descriptor_->GetSourceLocation(&location)) { | 65 if (descriptor_->GetSourceLocation(&location)) { |
66 vars["comments"] = BuildCommentsString(location, true); | 66 vars["comments"] = BuildCommentsString(location); |
67 } else { | 67 } else { |
68 vars["comments"] = ""; | 68 vars["comments"] = ""; |
69 } | 69 } |
70 // Unlike normal message fields, check if the file for the extension was | |
71 // deprecated. | |
72 vars["deprecated_attribute"] = GetOptionalDeprecatedAttribute(descriptor_, des
criptor_->file()); | |
73 printer->Print(vars, | 70 printer->Print(vars, |
74 "$comments$" | 71 "$comments$" |
75 "+ (GPBExtensionDescriptor *)$method_name$$deprecated_attribute
$;\n"); | 72 "+ (GPBExtensionDescriptor *)$method_name$;\n"); |
76 } | 73 } |
77 | 74 |
78 void ExtensionGenerator::GenerateStaticVariablesInitialization( | 75 void ExtensionGenerator::GenerateStaticVariablesInitialization( |
79 io::Printer* printer) { | 76 io::Printer* printer) { |
80 map<string, string> vars; | 77 map<string, string> vars; |
81 vars["root_class_and_method_name"] = root_class_and_method_name_; | 78 vars["root_class_and_method_name"] = root_class_and_method_name_; |
82 vars["extended_type"] = ClassName(descriptor_->containing_type()); | 79 vars["extended_type"] = ClassName(descriptor_->containing_type()); |
83 vars["number"] = SimpleItoa(descriptor_->number()); | 80 vars["number"] = SimpleItoa(descriptor_->number()); |
84 | 81 |
85 std::vector<string> options; | 82 std::vector<string> options; |
86 if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated"); | 83 if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated"); |
87 if (descriptor_->is_packed()) options.push_back("GPBExtensionPacked"); | 84 if (descriptor_->is_packed()) options.push_back("GPBExtensionPacked"); |
88 if (descriptor_->containing_type()->options().message_set_wire_format()) | 85 if (descriptor_->containing_type()->options().message_set_wire_format()) |
89 options.push_back("GPBExtensionSetWireFormat"); | 86 options.push_back("GPBExtensionSetWireFormat"); |
90 | 87 |
91 vars["options"] = BuildFlagsString(FLAGTYPE_EXTENSION, options); | 88 vars["options"] = BuildFlagsString(options); |
92 | 89 |
93 ObjectiveCType objc_type = GetObjectiveCType(descriptor_); | 90 ObjectiveCType objc_type = GetObjectiveCType(descriptor_); |
94 string singular_type; | 91 string singular_type; |
95 if (objc_type == OBJECTIVECTYPE_MESSAGE) { | 92 if (objc_type == OBJECTIVECTYPE_MESSAGE) { |
96 vars["type"] = string("GPBStringifySymbol(") + | 93 vars["type"] = string("GPBStringifySymbol(") + |
97 ClassName(descriptor_->message_type()) + ")"; | 94 ClassName(descriptor_->message_type()) + ")"; |
98 } else { | 95 } else { |
99 vars["type"] = "NULL"; | 96 vars["type"] = "NULL"; |
100 } | 97 } |
101 | 98 |
(...skipping 28 matching lines...) Expand all Loading... |
130 | 127 |
131 void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) { | 128 void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) { |
132 printer->Print( | 129 printer->Print( |
133 "[registry addExtension:$root_class_and_method_name$];\n", | 130 "[registry addExtension:$root_class_and_method_name$];\n", |
134 "root_class_and_method_name", root_class_and_method_name_); | 131 "root_class_and_method_name", root_class_and_method_name_); |
135 } | 132 } |
136 } // namespace objectivec | 133 } // namespace objectivec |
137 } // namespace compiler | 134 } // namespace compiler |
138 } // namespace protobuf | 135 } // namespace protobuf |
139 } // namespace google | 136 } // namespace google |
OLD | NEW |