class Ronin::Support::Binary::CTypes::UnionObjectType
Represents a {Binary::Union} type.
@api private
@since 1.0.0
Attributes
The {Union} class.
@return [Union.class]
The type used for packing literal ‘Hash` values.
@return [UnionType]
Public Class Methods
Source
# 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
Initializes the memory-mapped union type.
@param [Union.class] union_class
The {Union} class.
@param [UnionType] union_type
The union type for the union class.
Ronin::Support::Binary::CTypes::ObjectType::new
Public Instance Methods
Source
# 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
Creates a copy of the union object type with a different {#alignment}.
@param [Integer] new_alignment
The new alignment for the new union object type.
@return [ScalarType]
The new union object type.
Source
# File lib/ronin/support/binary/ctypes/union_object_type.rb, line 75 def alignment @union_type.alignment end
The alignment, in bytes, of the memory-mapped {Union}.
@return [Integer]
Source
# File lib/ronin/support/binary/ctypes/union_object_type.rb, line 165 def dequeue_value(values) @union_class.new(values.shift) end
Dequeues a memory object from the flat list of values.
@param [Array] values
The flat array of values.
@return [Union]
The dequued {Union} object.
Source
# 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
Enqueues the memory-mapped {Union} into the list of values.
@param [Array] values
The flat array of values.
@param [Binary::Union, Hash] union
The {Union} object to enqueue.
Source
# File lib/ronin/support/binary/ctypes/union_object_type.rb, line 98 def members @union_type.members end
The members of the union type.
@return [Hash{Symbol => UnionType::Member
}]
Source
# 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
Packs the memory-mapped {Union}.
@param [Binary::Union, Hash] union
The memory-mapped {Union} object.
@return [String]
The underlying binary data for the memory object.
@raise [ArgumentError]
The given value was not a {Binary::Union} or `Hash`.
Source
# File lib/ronin/support/binary/ctypes/union_object_type.rb, line 66 def size @union_type.size end
The size of the union type.
@return [Integer, Float::INFINITY]
Source
# File lib/ronin/support/binary/ctypes/union_object_type.rb, line 134 def unpack(data) @union_class.unpack(data) end
Unpacks the memory-mapped {Union}.
@param [String] data
The raw binary data to unpack.
@return [Binary::Union]
the unpacked {Union} object.