Class: Google::Protobuf::OneofDescriptor
- Inherits:
-
Object
- Object
- Google::Protobuf::OneofDescriptor
- Extended by:
- FFI::DataConverter, Internal::PointerHelper, Internal::TypeSafety
- Includes:
- Enumerable
- Defined in:
- lib/google/protobuf/ffi/oneof_descriptor.rb
Instance Attribute Summary collapse
-
#descriptor_pool ⇒ Object
readonly
Returns the value of attribute descriptor_pool.
Class Method Summary collapse
- .from_native(oneof_def, _ = nil) ⇒ Object
- .new(*arguments, &block) ⇒ Object
- .to_native(value, _ = nil) ⇒ Object
Instance Method Summary collapse
Methods included from Internal::PointerHelper
Methods included from Internal::TypeSafety
Instance Attribute Details
#descriptor_pool ⇒ Object (readonly)
Returns the value of attribute descriptor_pool.
11 12 13 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 11 def descriptor_pool @descriptor_pool end |
Class Method Details
.from_native(oneof_def, _ = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 31 def from_native(oneof_def, _ = nil) return nil if oneof_def.nil? or oneof_def.null? = Google::Protobuf::FFI.get_oneof_containing_type oneof_def raise RuntimeError.new "Message Descriptor is nil" if .nil? file_def = Google::Protobuf::FFI. .to_native descriptor_from_file_def(file_def, oneof_def) end |
.new(*arguments, &block) ⇒ Object
40 41 42 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 40 def self.new(*arguments, &block) raise "OneofDescriptor objects may not be created from Ruby." end |
.to_native(value, _ = nil) ⇒ Object
24 25 26 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 24 def to_native(value, _ = nil) value.instance_variable_get(:@oneof_def) || ::FFI::Pointer::NULL end |
Instance Method Details
#each(&block) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 48 def each &block n = Google::Protobuf::FFI.get_oneof_field_count(self) 0.upto(n-1) do |i| yield(Google::Protobuf::FFI.get_oneof_field_by_index(self, i)) end nil end |
#name ⇒ Object
44 45 46 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 44 def name Google::Protobuf::FFI.get_oneof_name(self) end |
#options ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/google/protobuf/ffi/oneof_descriptor.rb', line 56 def @options ||= begin size_ptr = ::FFI::MemoryPointer.new(:size_t, 1) temporary_arena = Google::Protobuf::FFI.create_arena buffer = Google::Protobuf::FFI.(self, size_ptr, temporary_arena) Google::Protobuf::OneofOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).send(:internal_deep_freeze) end end |