protobuf 2.7.5-java → 2.7.6-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,7 @@ bool RubyGenerator::Generate(const FileDescriptor* file,
18
18
 
19
19
  filename = CreateRubyFileName(file_->name());
20
20
  ns_vector.clear();
21
+ extended_messages.clear();
21
22
  SplitStringUsing(file_->package(), ".", &ns_vector);
22
23
 
23
24
  // Get a ZeroCopyOutputStream object of the data.
@@ -41,9 +42,10 @@ bool RubyGenerator::Generate(const FileDescriptor* file,
41
42
  PrintMessagesForFileDescriptor(file_, false);
42
43
  PrintNewLine();
43
44
 
44
- PrintEnumsForFileDescriptor(file_, true);
45
45
  PrintMessagesForFileDescriptor(file_, true);
46
46
 
47
+ PrintDanglingExtendedMessages();
48
+
47
49
  PrintServices();
48
50
 
49
51
  PrintEnclosingNamespaceModuleEnds();
@@ -88,6 +90,9 @@ void RubyGenerator::PrintEnclosingNamespaceModuleEnds() const {
88
90
  ///////////////////////////////////////////////// [ messages ] ////////////////
89
91
  //
90
92
 
93
+ // Print a comment and then iteratively PrintMessage for each message
94
+ // type defined by in this FileDescriptor scope.
95
+ //
91
96
  void RubyGenerator::PrintMessagesForFileDescriptor(const FileDescriptor* descriptor, bool print_fields) const {
92
97
  if (descriptor->message_type_count() > 0) {
93
98
  if (print_fields) {
@@ -95,6 +100,7 @@ void RubyGenerator::PrintMessagesForFileDescriptor(const FileDescriptor* descrip
95
100
  }
96
101
  else {
97
102
  PrintComment("Message Classes", true);
103
+ StoreExtensionFields(descriptor);
98
104
  }
99
105
 
100
106
  for (int i = 0; i < descriptor->message_type_count(); i++) {
@@ -103,76 +109,102 @@ void RubyGenerator::PrintMessagesForFileDescriptor(const FileDescriptor* descrip
103
109
  }
104
110
  }
105
111
 
112
+ // Iterates the nested types of a message descriptor and calls PrintMessage for each.
113
+ //
106
114
  void RubyGenerator::PrintMessagesForDescriptor(const Descriptor* descriptor, bool print_fields) const {
107
115
  for (int i = 0; i < descriptor->nested_type_count(); i++) {
108
116
  PrintMessage(descriptor->nested_type(i), print_fields);
109
117
  }
110
118
  }
111
- //
119
+
112
120
  // Print out the given descriptor message as a Ruby class.
121
+ //
113
122
  void RubyGenerator::PrintMessage(const Descriptor* descriptor, bool print_fields) const {
114
123
  map<string,string> data;
115
124
  data["class_name"] = descriptor->name();
116
125
 
117
- if (print_fields && (descriptor->field_count() > 0 || descriptor->extension_count() > 0)) {
118
- printer_->Print(data, "class $class_name$");
119
- PrintNewLine();
120
- printer_->Indent();
126
+ switch (print_fields) {
127
+ case false:
121
128
 
122
- if (descriptor->enum_type_count() > 0) {
123
- PrintEnumsForDescriptor(descriptor, true);
124
- }
129
+ if (DescriptorHasNestedTypes(descriptor)) {
130
+ printer_->Print(data, "class $class_name$ < ::Protobuf::Message");
131
+ PrintNewLine();
132
+ printer_->Indent();
125
133
 
126
- if (descriptor->nested_type_count() > 0) {
127
- PrintMessagesForDescriptor(descriptor, true);
128
- }
134
+ if (descriptor->enum_type_count() > 0) {
135
+ PrintEnumsForDescriptor(descriptor, true);
136
+ }
129
137
 
130
- PrintExtensionRangesForDescriptor(descriptor);
138
+ if (descriptor->nested_type_count() > 0) {
139
+ PrintMessagesForDescriptor(descriptor, false);
140
+ }
131
141
 
132
- // Print Fields
133
- if (descriptor->field_count() > 0) {
134
- for (int i = 0; i < descriptor->field_count(); i++) {
135
- PrintMessageField(descriptor->field(i));
142
+ printer_->Outdent();
143
+ printer_->Print(data, "end");
136
144
  }
137
- }
138
-
139
- // Print Extension Fields
140
- if (descriptor->extension_count() > 0) {
141
- for (int i = 0; i < descriptor->extension_count(); i++) {
142
- PrintMessageField(descriptor->extension(i));
145
+ else {
146
+ printer_->Print(data, "class $class_name$ < ::Protobuf::Message; end");
143
147
  }
144
- }
145
148
 
146
- printer_->Outdent();
147
- printer_->Print(data, "end");
148
- PrintNewLine();
149
- }
150
- else if (DescriptorHasNestedTypes(descriptor)) {
151
- printer_->Print(data, "class $class_name$ < ::Protobuf::Message");
152
- PrintNewLine();
153
- printer_->Indent();
149
+ PrintNewLine();
150
+ StoreExtensionFields(descriptor);
154
151
 
155
- if (descriptor->enum_type_count() > 0) {
156
- PrintEnumsForDescriptor(descriptor, false);
157
- }
152
+ break;
158
153
 
159
- if (descriptor->nested_type_count() > 0) {
160
- PrintMessagesForDescriptor(descriptor, false);
161
- }
154
+ case true:
162
155
 
163
- printer_->Outdent();
164
- printer_->Print(data, "end");
165
- PrintNewLine();
166
- }
167
- else {
168
- printer_->Print(data, "class $class_name$ < ::Protobuf::Message; end");
169
- }
156
+ if (descriptor->field_count() > 0 || DescriptorHasExtensions(descriptor)) {
157
+ printer_->Print(data, "class $class_name$");
158
+ PrintNewLine();
159
+ printer_->Indent();
170
160
 
171
- PrintNewLine();
161
+ if (descriptor->nested_type_count() > 0) {
162
+ PrintMessagesForDescriptor(descriptor, true);
163
+ }
164
+
165
+ // Print Fields
166
+ if (descriptor->field_count() > 0) {
167
+ for (int i = 0; i < descriptor->field_count(); i++) {
168
+ PrintMessageField(descriptor->field(i));
169
+ }
170
+ }
171
+
172
+ PrintExtensionRangesForDescriptor(descriptor);
173
+
174
+ // Print Extension Fields
175
+ if (DescriptorHasExtensions(descriptor)) {
176
+ PrintMessageExtensionFields(descriptor->full_name());
177
+ }
178
+
179
+ printer_->Outdent();
180
+ printer_->Print(data, "end");
181
+ PrintNewLine();
182
+ PrintNewLine();
183
+ }
184
+ else if (descriptor->nested_type_count() > 0) {
185
+ printer_->Print(data, "class $class_name$");
186
+ PrintNewLine();
187
+ printer_->Indent();
188
+
189
+ if (descriptor->nested_type_count() > 0) {
190
+ PrintMessagesForDescriptor(descriptor, true);
191
+ }
192
+
193
+ printer_->Outdent();
194
+ printer_->Print(data, "end");
195
+ PrintNewLine();
196
+ PrintNewLine();
197
+ }
198
+
199
+ break;
200
+ }
172
201
  }
173
202
 
174
203
  void RubyGenerator::PrintExtensionRangesForDescriptor(const Descriptor* descriptor) const {
175
204
  if (descriptor->extension_range_count() > 0) {
205
+ PrintNewLine();
206
+ PrintComment("Extension Fields", false);
207
+
176
208
  for (int i = 0; i < descriptor->extension_range_count(); i++) {
177
209
  const Descriptor::ExtensionRange* range = descriptor->extension_range(i);
178
210
  map<string,string> data;
@@ -281,6 +313,20 @@ void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
281
313
  PrintNewLine();
282
314
  }
283
315
 
316
+ // Print out each extension field previously mapped to the full name of
317
+ // the descriptor message.
318
+ //
319
+ // After printign the fields, erase the fields from the map so that we know
320
+ // which fields are dangling and to print wrapped in a re-opened class block.
321
+ //
322
+ void RubyGenerator::PrintMessageExtensionFields(const string full_name) const {
323
+ vector<const FieldDescriptor*> message_extensions = extended_messages[full_name];
324
+ vector<const FieldDescriptor*>::iterator it;
325
+ for (it = message_extensions.begin(); it != message_extensions.end(); ++it) {
326
+ PrintMessageField(*it);
327
+ }
328
+ extended_messages.erase(full_name);
329
+ }
284
330
 
285
331
  //
286
332
  ///////////////////////////////////////////////// [ enums ] ///////////////////
@@ -288,7 +334,7 @@ void RubyGenerator::PrintMessageField(const FieldDescriptor* descriptor) const {
288
334
 
289
335
  void RubyGenerator::PrintEnumsForDescriptor(const Descriptor* descriptor, bool print_values) const {
290
336
  for (int i = 0; i < descriptor->enum_type_count(); i++) {
291
- PrintEnum(descriptor->enum_type(i), print_values);
337
+ PrintEnum(descriptor->enum_type(i));
292
338
  }
293
339
  }
294
340
 
@@ -302,33 +348,28 @@ void RubyGenerator::PrintEnumsForFileDescriptor(const FileDescriptor* descriptor
302
348
  }
303
349
 
304
350
  for (int i = 0; i < descriptor->enum_type_count(); i++) {
305
- PrintEnum(descriptor->enum_type(i), print_values);
351
+ PrintEnum(descriptor->enum_type(i));
306
352
  }
307
353
  }
308
354
  }
309
355
 
310
356
  // Print the given enum descriptor as a Ruby class.
311
- void RubyGenerator::PrintEnum(const EnumDescriptor* descriptor, bool print_values) const {
357
+ void RubyGenerator::PrintEnum(const EnumDescriptor* descriptor) const {
312
358
  map<string,string> data;
313
359
  data["class_name"] = descriptor->name();
314
360
 
315
- if (print_values) {
316
- printer_->Print(data, "class $class_name$");
317
- printer_->Indent();
318
- PrintNewLine();
319
-
320
- for (int i = 0; i < descriptor->value_count(); i++) {
321
- PrintEnumValue(descriptor->value(i));
322
- }
361
+ printer_->Print(data, "class $class_name$ < ::Protobuf::Enum");
362
+ printer_->Indent();
363
+ PrintNewLine();
323
364
 
324
- printer_->Outdent();
325
- printer_->Print(data, "end");
326
- PrintNewLine();
327
- }
328
- else {
329
- printer_->Print(data, "class $class_name$ < ::Protobuf::Enum; end");
365
+ for (int i = 0; i < descriptor->value_count(); i++) {
366
+ PrintEnumValue(descriptor->value(i));
330
367
  }
331
368
 
369
+ printer_->Outdent();
370
+ printer_->Print(data, "end");
371
+ PrintNewLine();
372
+
332
373
  PrintNewLine();
333
374
  }
334
375
 
@@ -387,6 +428,42 @@ void RubyGenerator::PrintServiceMethod(const MethodDescriptor* descriptor) const
387
428
  ///////////////////////////////////////////////// [ general ] ////////////////
388
429
  //
389
430
 
431
+ void RubyGenerator::PrintDanglingExtendedMessages() const {
432
+ if (extended_messages.size() > 0) {
433
+ PrintComment("Extended Messages", true);
434
+
435
+ tr1::unordered_map<string, vector<const FieldDescriptor*> >::iterator it;
436
+ for (it = extended_messages.begin(); it != extended_messages.end(); ++it ) {
437
+ map<string,string> data;
438
+ data["class_name"] = Constantize(it->first);
439
+
440
+ printer_->Print(data, "class $class_name$");
441
+ printer_->Indent();
442
+ PrintNewLine();
443
+
444
+ PrintMessageExtensionFields(it->first);
445
+
446
+ printer_->Outdent();
447
+ printer_->Print(data, "end");
448
+ PrintNewLine();
449
+ PrintNewLine();
450
+ }
451
+ }
452
+ }
453
+
454
+ // Explicitly check for the key with `count` so that we don't create
455
+ // empty vectors for classes simply using bracket access.
456
+ //
457
+ bool RubyGenerator::DescriptorHasExtensions(const Descriptor* descriptor) const {
458
+ const string full_name = descriptor->full_name();
459
+ if (extended_messages.count(full_name) > 0) {
460
+ return (extended_messages[full_name].size());
461
+ }
462
+ else {
463
+ return 0;
464
+ }
465
+ }
466
+
390
467
  // Print a header or one-line comment (as indicated by the as_header bool).
391
468
  void RubyGenerator::PrintComment(string comment, bool as_header) const {
392
469
  char format[] = "# $comment$\n";
@@ -444,6 +521,25 @@ void RubyGenerator::PrintNewLine() const {
444
521
  printer_->Print("\n");
445
522
  }
446
523
 
524
+ // We need to store any extension fields defined in the scope of this
525
+ // descriptor message by the field's containing type.
526
+ void RubyGenerator::StoreExtensionFields(const FileDescriptor* descriptor) const {
527
+ for (int i = 0; i < descriptor->extension_count(); i++) {
528
+ const FieldDescriptor* extension_field = descriptor->extension(i);
529
+ const Descriptor* containing = extension_field->containing_type();
530
+ extended_messages[containing->full_name()].push_back(extension_field);
531
+ }
532
+ }
533
+
534
+ // Same as above, only accept the Descriptor type instead of FileDescriptor.
535
+ void RubyGenerator::StoreExtensionFields(const Descriptor* descriptor) const {
536
+ for (int i = 0; i < descriptor->extension_count(); i++) {
537
+ const FieldDescriptor* extension_field = descriptor->extension(i);
538
+ const Descriptor* containing = extension_field->containing_type();
539
+ extended_messages[containing->full_name()].push_back(extension_field);
540
+ }
541
+ }
542
+
447
543
  } // namespace ruby
448
544
  } // namespace compiler
449
545
  } // namespace protobuf
@@ -5,6 +5,7 @@
5
5
  #include <iostream>
6
6
  #include <sstream>
7
7
  #include <vector>
8
+ #include <tr1/unordered_map>
8
9
 
9
10
  #include <google/protobuf/compiler/command_line_interface.h>
10
11
  #include <google/protobuf/compiler/code_generator.h>
@@ -31,28 +32,32 @@ class LIBPROTOC_EXPORT RubyGenerator : public CodeGenerator {
31
32
  GeneratorContext* context,
32
33
  string* error) const;
33
34
 
34
-
35
35
  private:
36
36
  mutable GeneratorContext* context_;
37
37
  mutable io::Printer* printer_;
38
38
  mutable const FileDescriptor* file_;
39
39
  mutable string filename;
40
40
  mutable vector<string> ns_vector;
41
+ mutable tr1::unordered_map<string, vector<const FieldDescriptor*> > extended_messages;
41
42
 
42
43
  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RubyGenerator);
43
44
 
45
+ bool DescriptorHasExtensions(const Descriptor* descriptor) const;
46
+ void PrintDanglingExtendedMessages() const;
47
+ void PrintExtensionRangesForDescriptor(const Descriptor* descriptor) const;
48
+
44
49
  void PrintEnclosingNamespaceModules() const;
45
50
  void PrintEnclosingNamespaceModuleEnds() const;
46
51
 
47
52
  void PrintMessagesForDescriptor(const Descriptor* descriptor, bool print_fields) const;
48
53
  void PrintMessagesForFileDescriptor(const FileDescriptor* descriptor, bool print_fields) const;
49
54
  void PrintMessage(const Descriptor* descriptor, bool print_fields) const;
50
- void PrintExtensionRangesForDescriptor(const Descriptor* descriptor) const;
51
55
  void PrintMessageField(const FieldDescriptor* descriptor) const;
56
+ void PrintMessageExtensionFields(const string full_name) const;
52
57
 
53
58
  void PrintEnumsForDescriptor(const Descriptor* descriptor, bool print_values) const;
54
59
  void PrintEnumsForFileDescriptor(const FileDescriptor* descriptor, bool print_values) const;
55
- void PrintEnum(const EnumDescriptor* descriptor, bool print_values) const;
60
+ void PrintEnum(const EnumDescriptor* descriptor) const;
56
61
  void PrintEnumValue(const EnumValueDescriptor* descriptor) const;
57
62
 
58
63
  void PrintServices() const;
@@ -67,6 +72,9 @@ class LIBPROTOC_EXPORT RubyGenerator : public CodeGenerator {
67
72
  void PrintRequire(string lib_name) const;
68
73
  void PrintNewLine() const;
69
74
 
75
+ void StoreExtensionFields(const FileDescriptor* descriptor) const;
76
+ void StoreExtensionFields(const Descriptor* descriptor) const;
77
+
70
78
  // Take the proto file name, strip ".proto"
71
79
  // from the end and add ".pb.rb"
72
80
  static string CreateRubyFileName(const string proto_filename) {
@@ -68,11 +68,8 @@ module Protobuf
68
68
  end
69
69
 
70
70
  def self.get_ext_field_by_name(name)
71
- # Check if the name has been used before, if not then set it to the sym value
72
- extension_fields[extension_field_name_to_tag[name.to_sym]]
73
- rescue TypeError, NoMethodError => e
74
- name = 'nil' if name.nil?
75
- raise FieldNotDefinedError.new("Field '#{name}' is not defined on message '#{self.name}'")
71
+ tag = extension_field_name_to_tag[name.to_sym]
72
+ extension_fields[tag] unless tag.nil?
76
73
  end
77
74
 
78
75
  def self.get_ext_field_by_tag(tag)
@@ -81,11 +78,8 @@ module Protobuf
81
78
 
82
79
  # Find a field object by +name+.
83
80
  def self.get_field_by_name(name)
84
- # Check if the name has been used before, if not then set it to the sym value
85
- fields[field_name_to_tag[name.to_sym]]
86
- rescue TypeError, NoMethodError => e
87
- name = 'nil' if name.nil?
88
- raise FieldNotDefinedError.new("Field '#{name}' is not defined on message '#{self.name}'")
81
+ tag = field_name_to_tag[name.to_sym]
82
+ fields[tag] unless tag.nil?
89
83
  end
90
84
 
91
85
  # Find a field object by +tag+ number.
@@ -93,6 +87,7 @@ module Protobuf
93
87
  fields[tag]
94
88
  rescue TypeError => e
95
89
  tag = tag.nil? ? 'nil' : tag.to_s
90
+ raise
96
91
  raise FieldNotDefinedError.new("Tag '#{tag}' does not reference a message field for '#{self.name}'")
97
92
  end
98
93
 
@@ -284,16 +279,12 @@ module Protobuf
284
279
  def [](name)
285
280
  if field = get_field_by_name(name) || get_ext_field_by_name(name)
286
281
  __send__(field.name)
287
- else
288
- raise NoMethodError, "No such field: #{name.inspect}"
289
282
  end
290
283
  end
291
284
 
292
285
  def []=(name, value)
293
286
  if field = get_field_by_name(name) || get_ext_field_by_name(name)
294
287
  __send__(field.setter_method_name, value)
295
- else
296
- raise NoMethodError, "No such field: #{name.inspect}"
297
288
  end
298
289
  end
299
290
 
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.7.5'
2
+ VERSION = '2.7.6'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
@@ -7,6 +7,7 @@ Bundler.setup :default, :development, :test
7
7
  require 'pry'
8
8
 
9
9
  $: << ::File.expand_path('..', File.dirname(__FILE__))
10
+ $: << ::File.expand_path('../spec/support', File.dirname(__FILE__))
10
11
  #$: << ::File.expand_path('../lib', File.dirname(__FILE__))
11
12
 
12
13
  require 'protobuf'
@@ -3,25 +3,26 @@
3
3
  #
4
4
  require 'protobuf/message'
5
5
 
6
+ ##
7
+ # Imports
8
+ #
9
+ require 'test/resource.pb'
10
+
6
11
  module Test
7
12
  ##
8
13
  # Enum Classes
9
14
  #
10
- class EnumTestType < ::Protobuf::Enum; end
15
+ class EnumTestType < ::Protobuf::Enum
16
+ define :ONE, 1
17
+ define :TWO, 2
18
+ end
19
+
11
20
 
12
21
  ##
13
22
  # Message Classes
14
23
  #
15
24
  class EnumTestMessage < ::Protobuf::Message; end
16
25
 
17
- ##
18
- # Enum Values
19
- #
20
- class EnumTestType
21
- define :ONE, 1
22
- define :TWO, 2
23
- end
24
-
25
26
  ##
26
27
  # Message Fields
27
28
  #
@@ -31,4 +32,11 @@ module Test
31
32
  repeated ::Test::EnumTestType, :repeated_enums, 3
32
33
  end
33
34
 
35
+ ##
36
+ # Extended Messages
37
+ #
38
+ class ::Test::Resource
39
+ optional ::Protobuf::Field::Int32Field, :ext_other_file_defined_field, 200, :extension => true
40
+ end
41
+
34
42
  end
@@ -1,4 +1,5 @@
1
1
  package test;
2
+ import 'test/resource.proto';
2
3
 
3
4
  enum EnumTestType {
4
5
  ONE = 1;
@@ -10,3 +11,7 @@ message EnumTestMessage {
10
11
  optional EnumTestType default_enum = 2 [default=ONE];
11
12
  repeated EnumTestType repeated_enums = 3;
12
13
  }
14
+
15
+ extend test.Resource {
16
+ optional int32 ext_other_file_defined_field = 200;
17
+ }
@@ -8,23 +8,31 @@ module Test
8
8
  ##
9
9
  # Enum Classes
10
10
  #
11
- class StatusType < ::Protobuf::Enum; end
11
+ class StatusType < ::Protobuf::Enum
12
+ define :PENDING, 0
13
+ define :ENABLED, 1
14
+ define :DISABLED, 2
15
+ define :DELETED, 3
16
+ end
17
+
12
18
 
13
19
  ##
14
20
  # Message Classes
15
21
  #
16
22
  class ResourceFindRequest < ::Protobuf::Message; end
17
23
  class Resource < ::Protobuf::Message; end
18
- class Nested < ::Protobuf::Message; end
19
-
20
- ##
21
- # Enum Values
22
- #
23
- class StatusType
24
- define :PENDING, 0
25
- define :ENABLED, 1
26
- define :DISABLED, 2
27
- define :DELETED, 3
24
+ class Searchable < ::Protobuf::Message
25
+ class SearchType < ::Protobuf::Enum
26
+ define :FLAT, 1
27
+ define :NESTED, 2
28
+ end
29
+
30
+ end
31
+ class MessageParent < ::Protobuf::Message
32
+ class MessageChild < ::Protobuf::Message; end
33
+ end
34
+ class Nested < ::Protobuf::Message
35
+ class NestedLevelOne < ::Protobuf::Message; end
28
36
  end
29
37
 
30
38
  ##
@@ -40,13 +48,41 @@ module Test
40
48
  optional ::Protobuf::Field::Int64Field, :date_created, 2
41
49
  optional ::Test::StatusType, :status, 3
42
50
  repeated ::Test::StatusType, :repeated_enum, 4
51
+
52
+ # Extension Fields
53
+ extensions 100...536870912
54
+ optional ::Protobuf::Field::BoolField, :ext_is_searchable, 100, :extension => true
55
+ optional ::Protobuf::Field::BoolField, :ext_is_hidden, 101, :extension => true
56
+ optional ::Test::Searchable::SearchType, :ext_search_type, 102, :default => ::Test::Searchable::SearchType::FLAT, :extension => true
57
+ optional ::Protobuf::Field::BoolField, :ext_nested_in_level_one, 105, :extension => true
58
+ end
59
+
60
+ class MessageParent
61
+ class MessageChild
62
+ optional ::Protobuf::Field::StringField, :child1, 1
63
+ end
64
+
43
65
  end
44
66
 
45
67
  class Nested
68
+ class NestedLevelOne
69
+ optional ::Protobuf::Field::BoolField, :level_one, 1, :default => true
70
+
71
+ # Extension Fields
72
+ extensions 100...102
73
+ optional ::Protobuf::Field::BoolField, :ext_nested_level_one_outer, 101, :extension => true
74
+ optional ::Protobuf::Field::BoolField, :ext_nested_level_one, 100, :extension => true
75
+ end
76
+
46
77
  optional ::Protobuf::Field::StringField, :name, 1
47
78
  optional ::Test::Resource, :resource, 2
48
79
  repeated ::Test::Resource, :multiple_resources, 3
49
80
  optional ::Test::StatusType, :status, 4
81
+
82
+ # Extension Fields
83
+ extensions 100...111
84
+ optional ::Protobuf::Field::StringField, :foo, 100, :extension => true
85
+ optional ::Protobuf::Field::Int64Field, :bar, 101, :extension => true
50
86
  end
51
87
 
52
88
  ##
@@ -13,17 +13,62 @@ message ResourceFindRequest {
13
13
  }
14
14
 
15
15
  message Resource {
16
+ extensions 100 to max;
17
+
16
18
  required string name = 1;
17
19
  optional int64 date_created = 2;
18
20
  optional StatusType status = 3;
19
21
  repeated StatusType repeated_enum = 4;
20
22
  }
21
23
 
24
+ message Searchable {
25
+ enum SearchType {
26
+ FLAT = 1;
27
+ NESTED = 2;
28
+ }
29
+
30
+ extend test.Resource {
31
+ optional bool ext_is_searchable = 100;
32
+ optional bool ext_is_hidden = 101;
33
+ optional Searchable.SearchType ext_search_type = 102 [default=FLAT];
34
+ }
35
+ }
36
+
37
+ message MessageParent {
38
+ message MessageChild {
39
+ optional string child1 = 1;
40
+ }
41
+ }
42
+
22
43
  message Nested {
44
+ extensions 100 to 110;
45
+
23
46
  optional string name = 1;
24
47
  optional Resource resource = 2;
25
48
  repeated Resource multiple_resources = 3;
26
49
  optional StatusType status = 4;
50
+
51
+ message NestedLevelOne {
52
+ extensions 100 to 101;
53
+ optional bool level_one = 1 [default=true];
54
+
55
+ extend Resource {
56
+ optional bool ext_nested_in_level_one = 105;
57
+ }
58
+ }
59
+
60
+ extend NestedLevelOne {
61
+ optional bool ext_nested_level_one = 100;
62
+ }
63
+ }
64
+
65
+ extend Nested {
66
+ optional string foo = 100;
67
+ optional int64 bar = 101;
68
+ }
69
+
70
+ extend Nested.NestedLevelOne {
71
+ optional bool ext_nested_level_one_outer = 101;
27
72
  }
28
73
 
29
74
  service ResourceService {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.7.5
5
+ version: 2.7.6
6
6
  platform: java
7
7
  authors:
8
8
  - BJ Neilsen
@@ -10,240 +10,149 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-13 00:00:00.000000000 Z
13
+ date: 2013-03-17 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- version_requirements: !ruby/object:Gem::Requirement
17
+ version_requirements: &5666 !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: !binary |-
22
- MA==
23
- none: false
24
- requirement: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: !binary |-
29
- MA==
21
+ version: '0'
30
22
  none: false
23
+ requirement: *5666
31
24
  prerelease: false
32
25
  type: :runtime
33
26
  - !ruby/object:Gem::Dependency
34
27
  name: ffi
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: !binary |-
40
- MA==
41
- none: false
42
- requirement: !ruby/object:Gem::Requirement
28
+ version_requirements: &5684 !ruby/object:Gem::Requirement
43
29
  requirements:
44
- - - ">="
30
+ - - ! '>='
45
31
  - !ruby/object:Gem::Version
46
- version: !binary |-
47
- MA==
32
+ version: '0'
48
33
  none: false
34
+ requirement: *5684
49
35
  prerelease: false
50
36
  type: :runtime
51
37
  - !ruby/object:Gem::Dependency
52
38
  name: multi_json
53
- version_requirements: !ruby/object:Gem::Requirement
39
+ version_requirements: &5700 !ruby/object:Gem::Requirement
54
40
  requirements:
55
- - - ">="
41
+ - - ! '>='
56
42
  - !ruby/object:Gem::Version
57
- version: !binary |-
58
- MA==
59
- none: false
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: !binary |-
65
- MA==
43
+ version: '0'
66
44
  none: false
45
+ requirement: *5700
67
46
  prerelease: false
68
47
  type: :runtime
69
48
  - !ruby/object:Gem::Dependency
70
49
  name: thor
71
- version_requirements: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: !binary |-
76
- MA==
77
- none: false
78
- requirement: !ruby/object:Gem::Requirement
50
+ version_requirements: &5716 !ruby/object:Gem::Requirement
79
51
  requirements:
80
- - - ">="
52
+ - - ! '>='
81
53
  - !ruby/object:Gem::Version
82
- version: !binary |-
83
- MA==
54
+ version: '0'
84
55
  none: false
56
+ requirement: *5716
85
57
  prerelease: false
86
58
  type: :runtime
87
59
  - !ruby/object:Gem::Dependency
88
60
  name: eventmachine
89
- version_requirements: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: !binary |-
94
- MA==
95
- none: false
96
- requirement: !ruby/object:Gem::Requirement
61
+ version_requirements: &5732 !ruby/object:Gem::Requirement
97
62
  requirements:
98
- - - ">="
63
+ - - ! '>='
99
64
  - !ruby/object:Gem::Version
100
- version: !binary |-
101
- MA==
65
+ version: '0'
102
66
  none: false
67
+ requirement: *5732
103
68
  prerelease: false
104
69
  type: :development
105
70
  - !ruby/object:Gem::Dependency
106
71
  name: ffi-rzmq
107
- version_requirements: !ruby/object:Gem::Requirement
72
+ version_requirements: &5750 !ruby/object:Gem::Requirement
108
73
  requirements:
109
- - - ">="
74
+ - - ! '>='
110
75
  - !ruby/object:Gem::Version
111
- version: !binary |-
112
- MA==
113
- none: false
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: !binary |-
119
- MA==
76
+ version: '0'
120
77
  none: false
78
+ requirement: *5750
121
79
  prerelease: false
122
80
  type: :development
123
81
  - !ruby/object:Gem::Dependency
124
82
  name: pry
125
- version_requirements: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: !binary |-
130
- MA==
131
- none: false
132
- requirement: !ruby/object:Gem::Requirement
83
+ version_requirements: &5766 !ruby/object:Gem::Requirement
133
84
  requirements:
134
- - - ">="
85
+ - - ! '>='
135
86
  - !ruby/object:Gem::Version
136
- version: !binary |-
137
- MA==
87
+ version: '0'
138
88
  none: false
89
+ requirement: *5766
139
90
  prerelease: false
140
91
  type: :development
141
92
  - !ruby/object:Gem::Dependency
142
93
  name: pry-nav
143
- version_requirements: !ruby/object:Gem::Requirement
94
+ version_requirements: &5782 !ruby/object:Gem::Requirement
144
95
  requirements:
145
- - - ">="
96
+ - - ! '>='
146
97
  - !ruby/object:Gem::Version
147
- version: !binary |-
148
- MA==
149
- none: false
150
- requirement: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: !binary |-
155
- MA==
98
+ version: '0'
156
99
  none: false
100
+ requirement: *5782
157
101
  prerelease: false
158
102
  type: :development
159
103
  - !ruby/object:Gem::Dependency
160
104
  name: rake
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: !binary |-
166
- MA==
167
- none: false
168
- requirement: !ruby/object:Gem::Requirement
105
+ version_requirements: &5798 !ruby/object:Gem::Requirement
169
106
  requirements:
170
- - - ">="
107
+ - - ! '>='
171
108
  - !ruby/object:Gem::Version
172
- version: !binary |-
173
- MA==
109
+ version: '0'
174
110
  none: false
111
+ requirement: *5798
175
112
  prerelease: false
176
113
  type: :development
177
114
  - !ruby/object:Gem::Dependency
178
115
  name: rake-compiler
179
- version_requirements: !ruby/object:Gem::Requirement
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- version: !binary |-
184
- MA==
185
- none: false
186
- requirement: !ruby/object:Gem::Requirement
116
+ version_requirements: &5814 !ruby/object:Gem::Requirement
187
117
  requirements:
188
- - - ">="
118
+ - - ! '>='
189
119
  - !ruby/object:Gem::Version
190
- version: !binary |-
191
- MA==
120
+ version: '0'
192
121
  none: false
122
+ requirement: *5814
193
123
  prerelease: false
194
124
  type: :development
195
125
  - !ruby/object:Gem::Dependency
196
126
  name: rspec
197
- version_requirements: !ruby/object:Gem::Requirement
127
+ version_requirements: &5830 !ruby/object:Gem::Requirement
198
128
  requirements:
199
- - - ">="
129
+ - - ! '>='
200
130
  - !ruby/object:Gem::Version
201
- version: !binary |-
202
- MA==
203
- none: false
204
- requirement: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: !binary |-
209
- MA==
131
+ version: '0'
210
132
  none: false
133
+ requirement: *5830
211
134
  prerelease: false
212
135
  type: :development
213
136
  - !ruby/object:Gem::Dependency
214
137
  name: simplecov
215
- version_requirements: !ruby/object:Gem::Requirement
216
- requirements:
217
- - - ">="
218
- - !ruby/object:Gem::Version
219
- version: !binary |-
220
- MA==
221
- none: false
222
- requirement: !ruby/object:Gem::Requirement
138
+ version_requirements: &5846 !ruby/object:Gem::Requirement
223
139
  requirements:
224
- - - ">="
140
+ - - ! '>='
225
141
  - !ruby/object:Gem::Version
226
- version: !binary |-
227
- MA==
142
+ version: '0'
228
143
  none: false
144
+ requirement: *5846
229
145
  prerelease: false
230
146
  type: :development
231
147
  - !ruby/object:Gem::Dependency
232
148
  name: yard
233
- version_requirements: !ruby/object:Gem::Requirement
149
+ version_requirements: &5862 !ruby/object:Gem::Requirement
234
150
  requirements:
235
- - - ">="
151
+ - - ! '>='
236
152
  - !ruby/object:Gem::Version
237
- version: !binary |-
238
- MA==
239
- none: false
240
- requirement: !ruby/object:Gem::Requirement
241
- requirements:
242
- - - ">="
243
- - !ruby/object:Gem::Version
244
- version: !binary |-
245
- MA==
153
+ version: '0'
246
154
  none: false
155
+ requirement: *5862
247
156
  prerelease: false
248
157
  type: :development
249
158
  description: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for Ruby.
@@ -256,9 +165,9 @@ executables:
256
165
  extensions: []
257
166
  extra_rdoc_files: []
258
167
  files:
259
- - ".gitignore"
260
- - ".travis.yml"
261
- - ".yardopts"
168
+ - .gitignore
169
+ - .travis.yml
170
+ - .yardopts
262
171
  - Gemfile
263
172
  - README.md
264
173
  - Rakefile
@@ -517,29 +426,109 @@ require_paths:
517
426
  - lib
518
427
  required_ruby_version: !ruby/object:Gem::Requirement
519
428
  requirements:
520
- - - ">="
429
+ - - ! '>='
521
430
  - !ruby/object:Gem::Version
522
431
  segments:
523
432
  - 0
524
433
  hash: 2
525
- version: !binary |-
526
- MA==
434
+ version: '0'
527
435
  none: false
528
436
  required_rubygems_version: !ruby/object:Gem::Requirement
529
437
  requirements:
530
- - - ">="
438
+ - - ! '>='
531
439
  - !ruby/object:Gem::Version
532
440
  segments:
533
441
  - 0
534
442
  hash: 2
535
- version: !binary |-
536
- MA==
443
+ version: '0'
537
444
  none: false
538
445
  requirements: []
539
446
  rubyforge_project:
540
- rubygems_version: 1.8.24
447
+ rubygems_version: 1.8.15
541
448
  signing_key:
542
449
  specification_version: 3
543
450
  summary: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for Ruby.
544
- test_files: []
451
+ test_files:
452
+ - spec/benchmark/tasks.rb
453
+ - spec/functional/embedded_service_spec.rb
454
+ - spec/functional/evented_server_spec.rb
455
+ - spec/functional/socket_server_spec.rb
456
+ - spec/functional/zmq_server_spec.rb
457
+ - spec/lib/protobuf/cli_spec.rb
458
+ - spec/lib/protobuf/enum_spec.rb
459
+ - spec/lib/protobuf/enum_value_spec.rb
460
+ - spec/lib/protobuf/field/int32_field_spec.rb
461
+ - spec/lib/protobuf/logger_spec.rb
462
+ - spec/lib/protobuf/message_spec.rb
463
+ - spec/lib/protobuf/rpc/client_spec.rb
464
+ - spec/lib/protobuf/rpc/connector_spec.rb
465
+ - spec/lib/protobuf/rpc/connectors/base_spec.rb
466
+ - spec/lib/protobuf/rpc/connectors/common_spec.rb
467
+ - spec/lib/protobuf/rpc/connectors/socket_spec.rb
468
+ - spec/lib/protobuf/rpc/connectors/zmq_spec.rb
469
+ - spec/lib/protobuf/rpc/servers/evented_server_spec.rb
470
+ - spec/lib/protobuf/rpc/servers/socket_server_spec.rb
471
+ - spec/lib/protobuf/rpc/servers/zmq/broker_spec.rb
472
+ - spec/lib/protobuf/rpc/servers/zmq/server_spec.rb
473
+ - spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
474
+ - spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb
475
+ - spec/lib/protobuf/rpc/service_dispatcher_spec.rb
476
+ - spec/lib/protobuf/rpc/service_filters_spec.rb
477
+ - spec/lib/protobuf/rpc/service_spec.rb
478
+ - spec/lib/protobuf_spec.rb
479
+ - spec/spec_helper.rb
480
+ - spec/support/all.rb
481
+ - spec/support/packed_field.rb
482
+ - spec/support/server.rb
483
+ - spec/support/test/enum.pb.rb
484
+ - spec/support/test/enum.proto
485
+ - spec/support/test/resource.pb.rb
486
+ - spec/support/test/resource.proto
487
+ - spec/support/test/resource_service.rb
488
+ - spec/support/test_app_file.rb
489
+ - spec/support/tolerance_matcher.rb
490
+ - test/data/data.bin
491
+ - test/data/data_source.py
492
+ - test/data/types.bin
493
+ - test/data/types_source.py
494
+ - test/data/unk.png
495
+ - test/proto/addressbook.pb.rb
496
+ - test/proto/addressbook.proto
497
+ - test/proto/addressbook_base.pb.rb
498
+ - test/proto/addressbook_base.proto
499
+ - test/proto/addressbook_ext.pb.rb
500
+ - test/proto/addressbook_ext.proto
501
+ - test/proto/collision.pb.rb
502
+ - test/proto/collision.proto
503
+ - test/proto/ext_collision.pb.rb
504
+ - test/proto/ext_collision.proto
505
+ - test/proto/ext_range.pb.rb
506
+ - test/proto/ext_range.proto
507
+ - test/proto/float_default.proto
508
+ - test/proto/lowercase.pb.rb
509
+ - test/proto/lowercase.proto
510
+ - test/proto/merge.pb.rb
511
+ - test/proto/merge.proto
512
+ - test/proto/nested.pb.rb
513
+ - test/proto/nested.proto
514
+ - test/proto/optional_field.pb.rb
515
+ - test/proto/optional_field.proto
516
+ - test/proto/packed.pb.rb
517
+ - test/proto/packed.proto
518
+ - test/proto/rpc.proto
519
+ - test/proto/types.pb.rb
520
+ - test/proto/types.proto
521
+ - test/test_addressbook.rb
522
+ - test/test_enum_value.rb
523
+ - test/test_extension.rb
524
+ - test/test_lowercase.rb
525
+ - test/test_message.rb
526
+ - test/test_optional_field.rb
527
+ - test/test_packed_field.rb
528
+ - test/test_parse.rb
529
+ - test/test_repeated_types.rb
530
+ - test/test_serialize.rb
531
+ - test/test_standard_message.rb
532
+ - test/test_types.rb
545
533
  has_rdoc:
534
+ ...