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); | 66 vars["comments"] = BuildCommentsString(location, true); |
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()); |
70 printer->Print(vars, | 73 printer->Print(vars, |
71 "$comments$" | 74 "$comments$" |
72 "+ (GPBExtensionDescriptor *)$method_name$;\n"); | 75 "+ (GPBExtensionDescriptor *)$method_name$$deprecated_attribute
$;\n"); |
73 } | 76 } |
74 | 77 |
75 void ExtensionGenerator::GenerateStaticVariablesInitialization( | 78 void ExtensionGenerator::GenerateStaticVariablesInitialization( |
76 io::Printer* printer) { | 79 io::Printer* printer) { |
77 map<string, string> vars; | 80 map<string, string> vars; |
78 vars["root_class_and_method_name"] = root_class_and_method_name_; | 81 vars["root_class_and_method_name"] = root_class_and_method_name_; |
79 vars["extended_type"] = ClassName(descriptor_->containing_type()); | 82 vars["extended_type"] = ClassName(descriptor_->containing_type()); |
80 vars["number"] = SimpleItoa(descriptor_->number()); | 83 vars["number"] = SimpleItoa(descriptor_->number()); |
81 | 84 |
82 std::vector<string> options; | 85 std::vector<string> options; |
83 if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated"); | 86 if (descriptor_->is_repeated()) options.push_back("GPBExtensionRepeated"); |
84 if (descriptor_->is_packed()) options.push_back("GPBExtensionPacked"); | 87 if (descriptor_->is_packed()) options.push_back("GPBExtensionPacked"); |
85 if (descriptor_->containing_type()->options().message_set_wire_format()) | 88 if (descriptor_->containing_type()->options().message_set_wire_format()) |
86 options.push_back("GPBExtensionSetWireFormat"); | 89 options.push_back("GPBExtensionSetWireFormat"); |
87 | 90 |
88 vars["options"] = BuildFlagsString(options); | 91 vars["options"] = BuildFlagsString(FLAGTYPE_EXTENSION, options); |
89 | 92 |
90 ObjectiveCType objc_type = GetObjectiveCType(descriptor_); | 93 ObjectiveCType objc_type = GetObjectiveCType(descriptor_); |
91 string singular_type; | 94 string singular_type; |
92 if (objc_type == OBJECTIVECTYPE_MESSAGE) { | 95 if (objc_type == OBJECTIVECTYPE_MESSAGE) { |
93 vars["type"] = string("GPBStringifySymbol(") + | 96 vars["type"] = string("GPBStringifySymbol(") + |
94 ClassName(descriptor_->message_type()) + ")"; | 97 ClassName(descriptor_->message_type()) + ")"; |
95 } else { | 98 } else { |
96 vars["type"] = "NULL"; | 99 vars["type"] = "NULL"; |
97 } | 100 } |
98 | 101 |
(...skipping 28 matching lines...) Expand all Loading... |
127 | 130 |
128 void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) { | 131 void ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) { |
129 printer->Print( | 132 printer->Print( |
130 "[registry addExtension:$root_class_and_method_name$];\n", | 133 "[registry addExtension:$root_class_and_method_name$];\n", |
131 "root_class_and_method_name", root_class_and_method_name_); | 134 "root_class_and_method_name", root_class_and_method_name_); |
132 } | 135 } |
133 } // namespace objectivec | 136 } // namespace objectivec |
134 } // namespace compiler | 137 } // namespace compiler |
135 } // namespace protobuf | 138 } // namespace protobuf |
136 } // namespace google | 139 } // namespace google |
OLD | NEW |