Class: Ronin::Support::Binary::CTypes::Type Private
- Inherits:
-
Object
- Object
- Ronin::Support::Binary::CTypes::Type
- Defined in:
- lib/ronin/support/binary/ctypes/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.
Base class for all types.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pack_string ⇒ String?
readonly
private
The String for
Array#pack
orString#unpack
.
Instance Method Summary collapse
-
#[](length = nil) ⇒ ArrayType, UnboundedArrayType
private
Creates an Array type around the scalar type.
-
#align(new_alignment) ⇒ Type
abstract
Creates a copy of the type with a different #alignment.
-
#alignment ⇒ Integer
abstract
The alignment, in bytes, for the type.
-
#dequeue_value(values) ⇒ Object
abstract
private
Dequeues a value from the flat list of values.
-
#enqueue_value(values, value) ⇒ Object
abstract
private
Enqueues a value onto the flat list of values.
-
#initialize(pack_string:) ⇒ Type
constructor
private
Initializes the type.
-
#pack(value) ⇒ String
abstract
Packs the value into the type's binary format.
-
#size ⇒ Integer
abstract
The size of the type.
-
#uninitialized_value ⇒ nil
abstract
private
The default uniniitalized value for the type.
-
#unpack(data) ⇒ Object
abstract
Unpacks the binary data.
Constructor Details
#initialize(pack_string:) ⇒ 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.
Initializes the type.
46 47 48 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 46 def initialize(pack_string: ) @pack_string = pack_string end |
Instance Attribute Details
#pack_string ⇒ String? (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.
May return nil
if the type does not map to a Ruby pack-string.
The String for Array#pack
or String#unpack
.
38 39 40 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 38 def pack_string @pack_string end |
Instance Method Details
#[](length = nil) ⇒ ArrayType, UnboundedArrayType
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 an Array type around the scalar type.
60 61 62 63 64 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 60 def [](length=nil) if length then ArrayType.new(self,length) else UnboundedArrayType.new(self) end end |
#align(new_alignment) ⇒ Type
Creates a copy of the type with a different #alignment.
117 118 119 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 117 def align(new_alignment) raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |
#alignment ⇒ Integer
The alignment, in bytes, for the type.
100 101 102 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 100 def alignment raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |
#dequeue_value(values) ⇒ 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.
Dequeues a value from the flat list of values.
185 186 187 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 185 def dequeue_value(values) raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |
#enqueue_value(values, value) ⇒ 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 a value onto the flat list of values.
168 169 170 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 168 def enqueue_value(values,value) raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |
#pack(value) ⇒ String
Packs the value into the type's binary format.
134 135 136 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 134 def pack(value) raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |
#size ⇒ Integer
The size of the type.
87 88 89 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 87 def size raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |
#uninitialized_value ⇒ nil
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 default uniniitalized value for the type.
73 74 75 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 73 def uninitialized_value nil end |
#unpack(data) ⇒ Object
Unpacks the binary data.
151 152 153 |
# File 'lib/ronin/support/binary/ctypes/type.rb', line 151 def unpack(data) raise(NotImplementedError,"#{self.class}##{__method__} was not implemented") end |