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.



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

def initialize(children)
  @children = children
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



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

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.map{|child| child.accept_descriptor_visitor visitor}
  end
end

#accept_message_visitor(visitor) ⇒ Object



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

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/service'
require 'protobuf/message/extend'
  eos
  @children.map{|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.map{|child| child.accept_rpc_visitor visitor}
end