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.
192
193
194
195
|
# File 'lib/protobuf/compiler/visitors.rb', line 192
def initialize(filename=nil)
@context = []
@filename = filename
end
|
Instance Attribute Details
#file_descriptor ⇒ Object
Returns the value of attribute file_descriptor.
189
190
191
|
# File 'lib/protobuf/compiler/visitors.rb', line 189
def file_descriptor
@file_descriptor
end
|
#filename ⇒ Object
Returns the value of attribute filename.
190
191
192
|
# File 'lib/protobuf/compiler/visitors.rb', line 190
def filename
@filename
end
|
Instance Method Details
#add_option(name, value) ⇒ Object
#current_descriptor ⇒ Object
208
209
210
|
# File 'lib/protobuf/compiler/visitors.rb', line 208
def current_descriptor
@context.last
end
|
#descriptor=(descriptor) ⇒ Object
Also known as:
message_descriptor=
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/protobuf/compiler/visitors.rb', line 241
def descriptor=(descriptor)
case current_descriptor
when Google::Protobuf::FileDescriptorProto then
current_descriptor.message_type << descriptor
when Google::Protobuf::DescriptorProto then
current_descriptor.nested_type << descriptor
else
raise ArgumentError, 'Invalid context'
end
end
|
#enum_descriptor=(descriptor) ⇒ Object
253
254
255
|
# File 'lib/protobuf/compiler/visitors.rb', line 253
def enum_descriptor=(descriptor)
current_descriptor.enum_type << descriptor
end
|
#enum_value_descriptor=(descriptor) ⇒ Object
257
258
259
|
# File 'lib/protobuf/compiler/visitors.rb', line 257
def enum_value_descriptor=(descriptor)
current_descriptor.value << descriptor
end
|
#extension_range_descriptor=(descriptor) ⇒ Object
282
283
284
|
# File 'lib/protobuf/compiler/visitors.rb', line 282
def extension_range_descriptor=(descriptor)
current_descriptor.extension_range << descriptor
end
|
#field_descriptor=(descriptor) ⇒ Object
269
270
271
272
273
274
275
276
277
278
279
280
|
# File 'lib/protobuf/compiler/visitors.rb', line 269
def field_descriptor=(descriptor)
case current_descriptor
when Google::Protobuf::FileDescriptorProto then
current_descriptor.extension << descriptor
when Google::Protobuf::DescriptorProto then
current_descriptor.field << descriptor
else
raise ArgumentError, 'Invalid context'
end
end
|
#in_context(descriptor, &block) ⇒ Object
202
203
204
205
206
|
# File 'lib/protobuf/compiler/visitors.rb', line 202
def in_context(descriptor, &block)
@context.push descriptor
block.call
@context.pop
end
|
#method_descriptor=(descriptor) ⇒ Object
265
266
267
|
# File 'lib/protobuf/compiler/visitors.rb', line 265
def method_descriptor=(descriptor)
current_descriptor.method << descriptor
end
|
#service_descriptor=(descriptor) ⇒ Object
261
262
263
|
# File 'lib/protobuf/compiler/visitors.rb', line 261
def service_descriptor=(descriptor)
current_descriptor.service << descriptor
end
|
#visit(node) ⇒ Object
197
198
199
200
|
# File 'lib/protobuf/compiler/visitors.rb', line 197
def visit(node)
node.accept_descriptor_visitor(self)
self
end
|