class Ronin::Support::Binary::CTypes::ArrayObjectType
Represents a {Binary::Array} in memory.
@api private
@since 1.0.0
Attributes
The type used for packing literal {::Array} values.
@return [ArrayType]
Public Class Methods
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 46 def initialize(array_type) @array_type = array_type super(@array_type.size) end
Initializes the memory-mapped array type.
@param [ArrayType] array_type
The array type.
Public Instance Methods
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 89 def align(new_alignment) self.class.new(@array_type.align(new_alignment)) end
Creates a copy of the array object type with a different {#alignment}.
@param [Integer] new_alignment
The new alignment for the new array object type.
@return [ArrayObjectType]
The new array object type.
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 75 def alignment @array_type.alignment end
The alignment, in bytes, of the memory-mapped array type.
@return [Integer]
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 156 def dequeue_value(values) Binary::Array.new(@array_type.type,values.shift) end
Dequeues a memory object from the flat list of values.
@param [::Array] values
The flat array of values.
@return [Binary::Array]
The dequeued memory-mapped array object.
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 138 def enqueue_value(values,array) case array when Binary::Array values.push(array.to_s) when ::Array values.push(@array_type.pack(array)) end end
Enqueues the memory-mapped array into the list of values.
@param [Binary::Array, ::Array
] values
The flat array of values.
@param [Binary::Array, ::Array
] array
The memory-mapped array object to enqueue.
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 66 def length @array_type.length end
The number of elements in the memory-mapped array type.
@return [Integer]
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 105 def pack(array) case array when Binary::Array array.to_s when ::Array @array_type.pack(array) else raise(ArgumentError,"value must be either a #{Binary::Array} or an #{::Array}: #{array.inspect}") end end
Packs the memory-mapped array.
@param [Binary::Array, ::Array
] array
The memory-mapped array.
@return [String]
The underlying binary data for the memory object.
@raise [ArgumentError]
The given value was not a {Binary::Array} or {::Array}.
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 57 def type @array_type.type end
The type of the element in the memory-mapped array type.
@return [Type]
Source
# File lib/ronin/support/binary/ctypes/array_object_type.rb, line 125 def unpack(data) Binary::Array.new(@array_type.type,data) end
Unpacks the memory-mapped array.
@param [String] data
The raw binary data to unpack.
@return [Binary::Array]
the memory-mapped Array.