Class: Ronin::Support::Binary::CTypes::ArrayObjectType Private
- Inherits:
-
ObjectType
- Object
- Type
- ObjectType
- Ronin::Support::Binary::CTypes::ArrayObjectType
- Defined in:
- lib/ronin/support/binary/ctypes/array_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 Array in memory.
Instance Attribute Summary collapse
-
#array_type ⇒ ArrayType
readonly
private
The type used for packing literal Array values.
Attributes inherited from ObjectType
Attributes inherited from Type
Instance Method Summary collapse
-
#align(new_alignment) ⇒ ArrayObjectType
private
Creates a copy of the array object type with a different #alignment.
-
#alignment ⇒ Integer
private
The alignment, in bytes, of the memory-mapped array type.
-
#dequeue_value(values) ⇒ Binary::Array
private
Dequeues a memory object from the flat list of values.
-
#enqueue_value(values, array) ⇒ Object
private
Enqueues the memory-mapped array into the list of values.
-
#initialize(array_type) ⇒ ArrayObjectType
constructor
private
Initializes the memory-mapped array type.
-
#length ⇒ Integer
private
The number of elements in the memory-mapped array type.
-
#pack(array) ⇒ String
private
Packs the memory-mapped array.
-
#type ⇒ Type
private
The type of the element in the memory-mapped array type.
-
#unpack(data) ⇒ Binary::Array
private
Unpacks the memory-mapped array.
Methods inherited from Type
#[], #size, #uninitialized_value
Constructor Details
#initialize(array_type) ⇒ ArrayObjectType
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 array type.
46 47 48 49 50 |
# 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 |
Instance Attribute Details
#array_type ⇒ ArrayType (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 Array values.
38 39 40 |
# File 'lib/ronin/support/binary/ctypes/array_object_type.rb', line 38 def array_type @array_type end |
Instance Method Details
#align(new_alignment) ⇒ ArrayObjectType
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 array object type with a different #alignment.
89 90 91 |
# 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 |
#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 array type.
75 76 77 |
# File 'lib/ronin/support/binary/ctypes/array_object_type.rb', line 75 def alignment @array_type.alignment end |
#dequeue_value(values) ⇒ Binary::Array
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.
156 157 158 |
# 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 |
#enqueue_value(values, array) ⇒ 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 array into the list of values.
138 139 140 141 142 143 144 145 |
# 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 |
#length ⇒ 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 number of elements in the memory-mapped array type.
66 67 68 |
# File 'lib/ronin/support/binary/ctypes/array_object_type.rb', line 66 def length @array_type.length end |
#pack(array) ⇒ 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 array.
105 106 107 108 109 110 111 112 113 114 |
# 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 |
#type ⇒ Type
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 of the element in the memory-mapped array type.
57 58 59 |
# File 'lib/ronin/support/binary/ctypes/array_object_type.rb', line 57 def type @array_type.type end |
#unpack(data) ⇒ Binary::Array
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 array.
125 126 127 |
# File 'lib/ronin/support/binary/ctypes/array_object_type.rb', line 125 def unpack(data) Binary::Array.new(@array_type.type,data) end |