Class: FileDescriptorToD

Inherits:
Struct
  • Object
show all
Includes:
Google::Protobuf::FieldDescriptorProto::Label, Google::Protobuf::FieldDescriptorProto::Type
Defined in:
lib/protocol_buffers/compiler/file_descriptor_to_d.rb

Constant Summary

Constants included from Google::Protobuf::FieldDescriptorProto::Label

Google::Protobuf::FieldDescriptorProto::Label::LABEL_OPTIONAL, Google::Protobuf::FieldDescriptorProto::Label::LABEL_REPEATED, Google::Protobuf::FieldDescriptorProto::Label::LABEL_REQUIRED

Constants included from Google::Protobuf::FieldDescriptorProto::Type

Google::Protobuf::FieldDescriptorProto::Type::TYPE_BOOL, Google::Protobuf::FieldDescriptorProto::Type::TYPE_BYTES, Google::Protobuf::FieldDescriptorProto::Type::TYPE_DOUBLE, Google::Protobuf::FieldDescriptorProto::Type::TYPE_ENUM, Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED32, Google::Protobuf::FieldDescriptorProto::Type::TYPE_FIXED64, Google::Protobuf::FieldDescriptorProto::Type::TYPE_FLOAT, Google::Protobuf::FieldDescriptorProto::Type::TYPE_GROUP, Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT32, Google::Protobuf::FieldDescriptorProto::Type::TYPE_INT64, Google::Protobuf::FieldDescriptorProto::Type::TYPE_MESSAGE, Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED32, Google::Protobuf::FieldDescriptorProto::Type::TYPE_SFIXED64, Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT32, Google::Protobuf::FieldDescriptorProto::Type::TYPE_SINT64, Google::Protobuf::FieldDescriptorProto::Type::TYPE_STRING, Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT32, Google::Protobuf::FieldDescriptorProto::Type::TYPE_UINT64

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ProtocolBuffers::Enum

included

Constructor Details

#initialize(descriptor) ⇒ FileDescriptorToD

Returns a new instance of FileDescriptorToD.



9
10
11
12
13
# File 'lib/protocol_buffers/compiler/file_descriptor_to_d.rb', line 9

def initialize(descriptor)
  super
  @module = descriptor.package_
  @ns = []
end

Instance Attribute Details

#descriptorObject

Returns the value of attribute descriptor

Returns:

  • (Object)

    the current value of descriptor



4
5
6
# File 'lib/protocol_buffers/compiler/file_descriptor_to_d.rb', line 4

def descriptor
  @descriptor
end

Instance Method Details

#class_name(klass) ⇒ Object



19
20
21
# File 'lib/protocol_buffers/compiler/file_descriptor_to_d.rb', line 19

def class_name(klass)
  klass
end

#module_nameObject



15
16
17
# File 'lib/protocol_buffers/compiler/file_descriptor_to_d.rb', line 15

def module_name
  @module
end

#write(io) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/protocol_buffers/compiler/file_descriptor_to_d.rb', line 23

def write(io)
  @io = io

  @io.write <<HEADER
// Generated by the protocol buffer compiler. DO NOT EDIT!

static import std.string;
import protocol_buffers.message;

HEADER

  descriptor.message_type.each do |message|
    dump_message(message)
  end
end