Class: Google::Protobuf::FileDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/google/protobuf/ffi/file_descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_def, descriptor_pool) ⇒ FileDescriptor

Returns a new instance of FileDescriptor.



21
22
23
24
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 21

def initialize(file_def, descriptor_pool)
  @descriptor_pool = descriptor_pool
  @file_def = file_def
end

Instance Attribute Details

#descriptor_poolObject (readonly)

Returns the value of attribute descriptor_pool.



19
20
21
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 19

def descriptor_pool
  @descriptor_pool
end

Instance Method Details

#inspectObject



30
31
32
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 30

def inspect
  "#{self.class.name}: #{name}"
end

#nameObject



45
46
47
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 45

def name
  Google::Protobuf::FFI.file_def_name(@file_def)
end

#optionsObject



49
50
51
52
53
54
55
56
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 49

def options
  @options ||= begin
    size_ptr = ::FFI::MemoryPointer.new(:size_t, 1)
    temporary_arena = Google::Protobuf::FFI.create_arena
    buffer = Google::Protobuf::FFI.file_options(@file_def, size_ptr, temporary_arena)
    Google::Protobuf::FileOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).send(:internal_deep_freeze)
  end
end

#syntaxObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 34

def syntax
  case Google::Protobuf::FFI.file_def_syntax(@file_def)
  when :Proto3
    :proto3
  when :Proto2
    :proto2
  else
    nil
  end
end

#to_sObject



26
27
28
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 26

def to_s
  inspect
end