Class: Ronin::Support::Binary::CTypes::StructObjectType Private
- Inherits:
-
ObjectType
- Object
- Type
- ObjectType
- Ronin::Support::Binary::CTypes::StructObjectType
- Defined in:
- lib/ronin/support/binary/ctypes/struct_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 Struct type.
Instance Attribute Summary collapse
-
#struct_class ⇒ Class<Binary::Struct>
readonly
private
The Struct class.
-
#struct_type ⇒ StructType
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 struct object type with a different #alignment.
-
#alignment ⇒ Integer
private
The alignment, in bytes, of the memory-mapped Struct.
-
#dequeue_value(values) ⇒ Struct
private
Dequeues a memory object from the flat list of values.
-
#enqueue_value(values, struct) ⇒ Object
private
Enqueues the memory-mapped Struct into the list of values.
-
#initialize(struct_class, struct_type) ⇒ StructObjectType
constructor
private
Initializes the memory-mapped struct type.
-
#members ⇒ Hash{Symbol => StructType::Member}
private
The members of the struct type.
-
#pack(struct) ⇒ String
private
Packs the memory-mapped Struct.
-
#size ⇒ Integer, Float::INFINITY
private
The size of the struct type.
-
#unpack(data) ⇒ Binary::Struct
private
Unpacks the memory-mapped Struct.
Methods inherited from Type
Constructor Details
#initialize(struct_class, struct_type) ⇒ StructObjectType
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 struct type.
54 55 56 57 58 59 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 54 def initialize(struct_class,struct_type) @struct_class = struct_class @struct_type = struct_type super(@struct_type.size) end |
Instance Attribute Details
#struct_class ⇒ Class<Binary::Struct> (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 Struct class.
38 39 40 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 38 def struct_class @struct_class end |
#struct_type ⇒ StructType (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/struct_object_type.rb', line 43 def struct_type @struct_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 struct object type with a different #alignment.
89 90 91 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 89 def align(new_alignment) self.class.new(@struct_class,@struct_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 Struct.
75 76 77 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 75 def alignment @struct_type.alignment end |
#dequeue_value(values) ⇒ Struct
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/struct_object_type.rb', line 165 def dequeue_value(values) @struct_class.new(values.shift) end |
#enqueue_value(values, struct) ⇒ 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 Struct into the list of values.
147 148 149 150 151 152 153 154 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 147 def enqueue_value(values,struct) case struct when Binary::Struct values.push(struct.to_s) when Hash values.push(@struct_type.pack(struct)) end end |
#members ⇒ Hash{Symbol => StructType::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 struct type.
98 99 100 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 98 def members @struct_type.members end |
#pack(struct) ⇒ 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 Struct.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 114 def pack(struct) case struct when Binary::Struct struct.to_s when Hash @struct_type.pack(struct) else raise(ArgumentError,"value must be either a #{Binary::Struct} or an #{Hash}: #{struct.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 struct type.
66 67 68 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 66 def size @struct_type.size end |
#unpack(data) ⇒ Binary::Struct
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 Struct.
134 135 136 |
# File 'lib/ronin/support/binary/ctypes/struct_object_type.rb', line 134 def unpack(data) @struct_class.unpack(data) end |