Class: Ronin::Support::Binary::CTypes::UnionObjectType Private
- Inherits:
-
ObjectType
- Object
- Type
- ObjectType
- Ronin::Support::Binary::CTypes::UnionObjectType
- Defined in:
- lib/ronin/support/binary/ctypes/union_object_type.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a Union type.
Instance Attribute Summary collapse
-
#union_class ⇒ Union.class
readonly
private
The Union class.
-
#union_type ⇒ UnionType
readonly
private
The type used for packing literal
Hash
values.
Attributes inherited from Type
Instance Method Summary collapse
-
#align(new_alignment) ⇒ ScalarType
private
Creates a copy of the union object type with a different #alignment.
-
#alignment ⇒ Integer
private
The alignment, in bytes, of the memory-mapped Union.
-
#dequeue_value(values) ⇒ Union
private
Dequeues a memory object from the flat list of values.
-
#enqueue_value(values, union) ⇒ Object
private
Enqueues the memory-mapped Union into the list of values.
-
#initialize(union_class, union_type) ⇒ UnionObjectType
constructor
private
Initializes the memory-mapped union type.
-
#members ⇒ Hash{Symbol => UnionType::Member}
private
The members of the union type.
-
#pack(union) ⇒ String
private
Packs the memory-mapped Union.
-
#size ⇒ Integer, Float::INFINITY
private
The size of the union type.
-
#unpack(data) ⇒ Binary::Union
private
Unpacks the memory-mapped Union.
Methods inherited from Type
Constructor Details
#initialize(union_class, union_type) ⇒ UnionObjectType
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the memory-mapped union type.
54 55 56 57 58 59 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 54 def initialize(union_class,union_type) @union_class = union_class @union_type = union_type super(@union_type.size) end |
Instance Attribute Details
#union_class ⇒ Union.class (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The Union class.
38 39 40 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 38 def union_class @union_class end |
#union_type ⇒ UnionType (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The type used for packing literal Hash
values.
43 44 45 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 43 def union_type @union_type end |
Instance Method Details
#align(new_alignment) ⇒ ScalarType
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a copy of the union object type with a different #alignment.
89 90 91 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 89 def align(new_alignment) self.class.new(@union_class,@union_type.align(new_alignment)) end |
#alignment ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The alignment, in bytes, of the memory-mapped Union.
75 76 77 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 75 def alignment @union_type.alignment end |
#dequeue_value(values) ⇒ Union
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Dequeues a memory object from the flat list of values.
165 166 167 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 165 def dequeue_value(values) @union_class.new(values.shift) end |
#enqueue_value(values, union) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enqueues the memory-mapped Union into the list of values.
147 148 149 150 151 152 153 154 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 147 def enqueue_value(values,union) case union when Binary::Union values.push(union.to_s) when Hash values.push(@union_type.pack(union)) end end |
#members ⇒ Hash{Symbol => UnionType::Member}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The members of the union type.
98 99 100 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 98 def members @union_type.members end |
#pack(union) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Packs the memory-mapped Union.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 114 def pack(union) case union when Binary::Union union.to_s when Hash @union_type.pack(union) else raise(ArgumentError,"value must be either a #{Binary::Union} or an #{Hash}: #{union.inspect}") end end |
#size ⇒ Integer, Float::INFINITY
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The size of the union type.
66 67 68 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 66 def size @union_type.size end |
#unpack(data) ⇒ Binary::Union
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Unpacks the memory-mapped Union.
134 135 136 |
# File 'lib/ronin/support/binary/ctypes/union_object_type.rb', line 134 def unpack(data) @union_class.unpack(data) end |