Class: FileDescriptorToD

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

Constant Summary

Constants included from FieldDescriptorProto::Label

FieldDescriptorProto::Label::LABEL_OPTIONAL, FieldDescriptorProto::Label::LABEL_REPEATED, FieldDescriptorProto::Label::LABEL_REQUIRED

Constants included from FieldDescriptorProto::Type

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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