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.



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

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.



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

def descriptor_pool
  @descriptor_pool
end

Instance Method Details

#inspectObject



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

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

#nameObject



33
34
35
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 33

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

#optionsObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 37

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)
    opts = Google::Protobuf::FileOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze)
    opts.clear_features()
    opts.freeze
  end
end

#to_sObject



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

def to_s
  inspect
end