| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 variables_["enum_name"] = OneofEnumName(descriptor_); | 46 variables_["enum_name"] = OneofEnumName(descriptor_); |
| 47 variables_["name"] = OneofName(descriptor_); | 47 variables_["name"] = OneofName(descriptor_); |
| 48 variables_["capitalized_name"] = OneofNameCapitalized(descriptor_); | 48 variables_["capitalized_name"] = OneofNameCapitalized(descriptor_); |
| 49 variables_["raw_index"] = SimpleItoa(descriptor_->index()); | 49 variables_["raw_index"] = SimpleItoa(descriptor_->index()); |
| 50 const Descriptor* msg_descriptor = descriptor_->containing_type(); | 50 const Descriptor* msg_descriptor = descriptor_->containing_type(); |
| 51 variables_["owning_message_class"] = ClassName(msg_descriptor); | 51 variables_["owning_message_class"] = ClassName(msg_descriptor); |
| 52 | 52 |
| 53 string comments; | 53 string comments; |
| 54 SourceLocation location; | 54 SourceLocation location; |
| 55 if (descriptor_->GetSourceLocation(&location)) { | 55 if (descriptor_->GetSourceLocation(&location)) { |
| 56 comments = BuildCommentsString(location); | 56 comments = BuildCommentsString(location, true); |
| 57 } else { | 57 } else { |
| 58 comments = ""; | 58 comments = ""; |
| 59 } | 59 } |
| 60 variables_["comments"] = comments; | 60 variables_["comments"] = comments; |
| 61 } | 61 } |
| 62 | 62 |
| 63 OneofGenerator::~OneofGenerator() {} | 63 OneofGenerator::~OneofGenerator() {} |
| 64 | 64 |
| 65 void OneofGenerator::SetOneofIndexBase(int index_base) { | 65 void OneofGenerator::SetOneofIndexBase(int index_base) { |
| 66 int index = descriptor_->index() + index_base; | 66 int index = descriptor_->index() + index_base; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 97 printer->Print( | 97 printer->Print( |
| 98 variables_, | 98 variables_, |
| 99 "$comments$" | 99 "$comments$" |
| 100 "@property(nonatomic, readonly) $enum_name$ $name$OneOfCase;\n" | 100 "@property(nonatomic, readonly) $enum_name$ $name$OneOfCase;\n" |
| 101 "\n"); | 101 "\n"); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) { | 104 void OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) { |
| 105 printer->Print( | 105 printer->Print( |
| 106 variables_, | 106 variables_, |
| 107 "/// Clears whatever value was set for the oneof '$name$'.\n" | 107 "/**\n" |
| 108 " * Clears whatever value was set for the oneof '$name$'.\n" |
| 109 " **/\n" |
| 108 "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_mess
age_class$ *message);\n"); | 110 "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_mess
age_class$ *message);\n"); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) { | 113 void OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) { |
| 112 printer->Print( | 114 printer->Print( |
| 113 variables_, | 115 variables_, |
| 114 "@dynamic $name$OneOfCase;\n"); | 116 "@dynamic $name$OneOfCase;\n"); |
| 115 } | 117 } |
| 116 | 118 |
| 117 void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) { | 119 void OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) { |
| 118 printer->Print( | 120 printer->Print( |
| 119 variables_, | 121 variables_, |
| 120 "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_mess
age_class$ *message) {\n" | 122 "void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_mess
age_class$ *message) {\n" |
| 121 " GPBDescriptor *descriptor = [message descriptor];\n" | 123 " GPBDescriptor *descriptor = [message descriptor];\n" |
| 122 " GPBOneofDescriptor *oneof = descriptor->oneofs_[$raw_index$];\n" | 124 " GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:$raw_index
$];\n" |
| 123 " GPBMaybeClearOneof(message, oneof, $index$, 0);\n" | 125 " GPBMaybeClearOneof(message, oneof, $index$, 0);\n" |
| 124 "}\n"); | 126 "}\n"); |
| 125 } | 127 } |
| 126 | 128 |
| 127 string OneofGenerator::DescriptorName(void) const { | 129 string OneofGenerator::DescriptorName(void) const { |
| 128 return variables_.find("name")->second; | 130 return variables_.find("name")->second; |
| 129 } | 131 } |
| 130 | 132 |
| 131 string OneofGenerator::HasIndexAsString(void) const { | 133 string OneofGenerator::HasIndexAsString(void) const { |
| 132 return variables_.find("index")->second; | 134 return variables_.find("index")->second; |
| 133 } | 135 } |
| 134 | 136 |
| 135 } // namespace objectivec | 137 } // namespace objectivec |
| 136 } // namespace compiler | 138 } // namespace compiler |
| 137 } // namespace protobuf | 139 } // namespace protobuf |
| 138 } // namespace google | 140 } // namespace google |
| OLD | NEW |