Class: Protobuf::Node::ProtoNode

Inherits:
Base
  • Object
show all
Defined in:
lib/protobuf/compiler/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#define_in_the_file

Constructor Details

#initialize(children) ⇒ ProtoNode

Returns a new instance of ProtoNode.



24
25
26
# File 'lib/protobuf/compiler/nodes.rb', line 24

def initialize(children)
  @children = children || []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



22
23
24
# File 'lib/protobuf/compiler/nodes.rb', line 22

def children
  @children
end

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/protobuf/compiler/nodes.rb', line 45

def accept_descriptor_visitor(visitor)
  descriptor = Google::Protobuf::FileDescriptorProto.new(:name => visitor.filename)
  visitor.file_descriptor = descriptor
  visitor.in_context(descriptor) do
    @children.each {|child| child.accept_descriptor_visitor(visitor) }
  end
end

#accept_message_visitor(visitor) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/protobuf/compiler/nodes.rb', line 28

def accept_message_visitor(visitor)
  visitor.write('### Generated by rprotoc. DO NOT EDIT!')
  visitor.write("### <proto file: #{visitor.proto_file}>") if visitor.attach_proto?
  visitor.write(visitor.commented_proto_contents) if visitor.attach_proto?
  visitor.write(<<-EOS)
require 'protobuf/message/message'
require 'protobuf/message/enum'
require 'protobuf/message/extend'
  EOS
  @children.each {|child| child.accept_message_visitor(visitor) }
  visitor.close_ruby
end

#accept_rpc_visitor(visitor) ⇒ Object



41
42
43
# File 'lib/protobuf/compiler/nodes.rb', line 41

def accept_rpc_visitor(visitor)
  @children.each {|child| child.accept_rpc_visitor(visitor) }
end