Class: Google::Protobuf::FileDescriptor
- Inherits:
-
Object
- Object
- Google::Protobuf::FileDescriptor
- Extended by:
- FFI::DataConverter, Internal::PointerHelper, Internal::TypeSafety
- Defined in:
- lib/google/protobuf/ffi/file_descriptor.rb
Instance Attribute Summary collapse
-
#descriptor_pool ⇒ Object
readonly
Returns the value of attribute descriptor_pool.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_def, descriptor_pool) ⇒ FileDescriptor
constructor
A new instance of FileDescriptor.
- #inspect ⇒ Object
- #name ⇒ Object
- #options ⇒ Object
- #to_proto ⇒ Object
- #to_s ⇒ Object
Methods included from Internal::PointerHelper
Methods included from Internal::TypeSafety
Constructor Details
#initialize(file_def, descriptor_pool) ⇒ FileDescriptor
Returns a new instance of FileDescriptor.
47 48 49 50 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 47 def initialize(file_def, descriptor_pool) @descriptor_pool = descriptor_pool @file_def = file_def end |
Instance Attribute Details
#descriptor_pool ⇒ Object (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 |
Class Method Details
.from_native(file_def, _ = nil) ⇒ Object
41 42 43 44 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 41 def from_native(file_def, _ = nil) return nil if file_def.nil? or file_def.null? descriptor_from_file_def(file_def) end |
.to_native(value, _) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 31 def to_native(value, _) file_def_ptr = value.nil? ? nil : value.instance_variable_get(:@file_def) return ::FFI::Pointer::NULL if file_def_ptr.nil? raise "Underlying file_def was null!" if file_def_ptr.null? file_def_ptr end |
Instance Method Details
#inspect ⇒ Object
56 57 58 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 56 def inspect "#{self.class.name}: #{name}" end |
#name ⇒ Object
60 61 62 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 60 def name Google::Protobuf::FFI.file_def_name(@file_def) end |
#options ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 64 def @options ||= begin size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) temporary_arena = Google::Protobuf::FFI.create_arena buffer = Google::Protobuf::FFI.(@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_proto ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 75 def to_proto @to_proto ||= begin size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) temporary_arena = Google::Protobuf::FFI.create_arena buffer = Google::Protobuf::FFI.file_to_proto(@file_def, size_ptr, temporary_arena) Google::Protobuf::FileDescriptorProto.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze) end end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/google/protobuf/ffi/file_descriptor.rb', line 52 def to_s inspect end |