Class: Protobuf::Visitor::CreateDescriptorVisitor
- Inherits:
-
Base
- Object
- Base
- Protobuf::Visitor::CreateDescriptorVisitor
show all
- Defined in:
- lib/protobuf/compiler/visitors.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#silent
Instance Method Summary
collapse
Methods inherited from Base
#create_file_with_backup, #log_writing
Constructor Details
Returns a new instance of CreateDescriptorVisitor.
193
194
195
196
|
# File 'lib/protobuf/compiler/visitors.rb', line 193
def initialize(filename=nil)
@context = []
@filename = filename
end
|
Instance Attribute Details
#file_descriptor ⇒ Object
Returns the value of attribute file_descriptor.
190
191
192
|
# File 'lib/protobuf/compiler/visitors.rb', line 190
def file_descriptor
@file_descriptor
end
|
#filename ⇒ Object
Returns the value of attribute filename.
191
192
193
|
# File 'lib/protobuf/compiler/visitors.rb', line 191
def filename
@filename
end
|
Instance Method Details
#add_option(name, value) ⇒ Object
#current_descriptor ⇒ Object
209
210
211
|
# File 'lib/protobuf/compiler/visitors.rb', line 209
def current_descriptor
@context.last
end
|
#descriptor=(descriptor) ⇒ Object
Also known as:
message_descriptor=
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/protobuf/compiler/visitors.rb', line 242
def descriptor=(descriptor)
case current_descriptor
when Google::Protobuf::FileDescriptorProto
current_descriptor.message_type << descriptor
when Google::Protobuf::DescriptorProto
current_descriptor.nested_type << descriptor
else
raise ArgumentError.new('Invalid context')
end
end
|
#enum_descriptor=(descriptor) ⇒ Object
254
255
256
|
# File 'lib/protobuf/compiler/visitors.rb', line 254
def enum_descriptor=(descriptor)
current_descriptor.enum_type << descriptor
end
|
#enum_value_descriptor=(descriptor) ⇒ Object
258
259
260
|
# File 'lib/protobuf/compiler/visitors.rb', line 258
def enum_value_descriptor=(descriptor)
current_descriptor.value << descriptor
end
|
#extension_range_descriptor=(descriptor) ⇒ Object
283
284
285
|
# File 'lib/protobuf/compiler/visitors.rb', line 283
def extension_range_descriptor=(descriptor)
current_descriptor.extension_range << descriptor
end
|
#field_descriptor=(descriptor) ⇒ Object
270
271
272
273
274
275
276
277
278
279
280
281
|
# File 'lib/protobuf/compiler/visitors.rb', line 270
def field_descriptor=(descriptor)
case current_descriptor
when Google::Protobuf::FileDescriptorProto
current_descriptor.extension << descriptor
when Google::Protobuf::DescriptorProto
current_descriptor.field << descriptor
else
raise ArgumentError.new('Invalid context')
end
end
|
#in_context(descriptor, &block) ⇒ Object
203
204
205
206
207
|
# File 'lib/protobuf/compiler/visitors.rb', line 203
def in_context(descriptor, &block)
@context.push descriptor
block.call
@context.pop
end
|
#method_descriptor=(descriptor) ⇒ Object
266
267
268
|
# File 'lib/protobuf/compiler/visitors.rb', line 266
def method_descriptor=(descriptor)
current_descriptor.method << descriptor
end
|
#service_descriptor=(descriptor) ⇒ Object
262
263
264
|
# File 'lib/protobuf/compiler/visitors.rb', line 262
def service_descriptor=(descriptor)
current_descriptor.service << descriptor
end
|
#visit(node) ⇒ Object
198
199
200
201
|
# File 'lib/protobuf/compiler/visitors.rb', line 198
def visit(node)
node.accept_descriptor_visitor self
self
end
|