Class: Google::Protobuf::EnumDescriptor
- Inherits:
-
Object
- Object
- Google::Protobuf::EnumDescriptor
- Extended by:
- FFI::DataConverter, Internal::PointerHelper, Internal::TypeSafety
- Includes:
- Enumerable
- Defined in:
- lib/google/protobuf/ffi/enum_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
- #each(&block) ⇒ Object
- #enummodule ⇒ Object
- #file_descriptor ⇒ Object
- #inspect ⇒ Object
- #lookup_name(name) ⇒ Object
- #lookup_value(number) ⇒ Object
- #name ⇒ Object
- #options ⇒ Object
- #to_s ⇒ Object
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/enum_descriptor.rb', line 11 def descriptor_pool @descriptor_pool end |
Class Method Details
.from_native(enum_def, _) ⇒ Object
31 32 33 34 35 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 31 def from_native(enum_def, _) return nil if enum_def.nil? or enum_def.null? file_def = Google::Protobuf::FFI. enum_def descriptor_from_file_def(file_def, enum_def) end |
.new(*arguments, &block) ⇒ Object
38 39 40 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 38 def self.new(*arguments, &block) raise "Descriptor objects may not be created from Ruby." end |
.to_native(value, _) ⇒ Object
24 25 26 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 24 def to_native(value, _) value.instance_variable_get(:@enum_def) || ::FFI::Pointer::NULL end |
Instance Method Details
#each(&block) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 66 def each &block n = Google::Protobuf::FFI.enum_value_count(self) 0.upto(n - 1) do |i| enum_value = Google::Protobuf::FFI.enum_value_by_index(self, i) yield(Google::Protobuf::FFI.enum_name(enum_value).to_sym, Google::Protobuf::FFI.enum_number(enum_value)) end nil end |
#enummodule ⇒ Object
75 76 77 78 79 80 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 75 def enummodule if @module.nil? @module = build_enum_module end @module end |
#file_descriptor ⇒ Object
42 43 44 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 42 def file_descriptor @descriptor_pool.send(:get_file_descriptor, Google::Protobuf::FFI.get_enum_file_descriptor(self)) end |
#inspect ⇒ Object
54 55 56 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 54 def inspect "#{self.class.name}: #{name}" end |
#lookup_name(name) ⇒ Object
58 59 60 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 58 def lookup_name(name) self.class.send(:lookup_name, self, name) end |
#lookup_value(number) ⇒ Object
62 63 64 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 62 def lookup_value(number) self.class.send(:lookup_value, self, number) end |
#name ⇒ Object
46 47 48 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 46 def name Google::Protobuf::FFI.get_enum_fullname(self) end |
#options ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 82 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::EnumOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).send(:internal_deep_freeze) end end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/google/protobuf/ffi/enum_descriptor.rb', line 50 def to_s inspect end |