Class: Ronin::Support::Binary::CTypes::StructType::Member Private
- Inherits:
-
Object
- Object
- Ronin::Support::Binary::CTypes::StructType::Member
- Defined in:
- lib/ronin/support/binary/ctypes/struct_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 member within a struct.
Instance Attribute Summary collapse
-
#offset ⇒ Integer
readonly
private
The offset, in bytes, of the member from the beginning of the struct.
-
#type ⇒ Type
readonly
private
The type of the member.
Class Method Summary collapse
-
.pack_string_for(type, padding = 0) ⇒ String
private
Calculates the pack string for the given type and optional padding.
-
.padding_for(offset, type) ⇒ Integer
private
Calculates padding for the given type at the given offset.
Instance Method Summary collapse
-
#alignment ⇒ Integer
private
The alignment, in bytes, of the member within the struct.
-
#initialize(offset, type) ⇒ Member
constructor
private
Initializes the member.
-
#size ⇒ Integer
private
The size, in bytes, of the member within the struct.
Constructor Details
#initialize(offset, type) ⇒ 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.
Initializes the member.
64 65 66 67 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 64 def initialize(offset,type) @offset = offset @type = type end |
Instance Attribute Details
#offset ⇒ Integer (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 offset, in bytes, of the member from the beginning of the struct.
47 48 49 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 47 def offset @offset end |
#type ⇒ Type (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 of the member.
52 53 54 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 52 def type @type end |
Class Method Details
.pack_string_for(type, padding = 0) ⇒ 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.
Calculates the pack string for the given type and optional padding.
99 100 101 102 103 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 99 def self.pack_string_for(type,padding=0) if padding > 0 then "#{'x' * padding}#{type.pack_string}" else type.pack_string end end |
.padding_for(offset, type) ⇒ 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.
Calculates padding for the given type at the given offset.
82 83 84 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 82 def self.padding_for(offset,type) (type.alignment - (offset % type.alignment)) % type.alignment end |
Instance Method Details
#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 member within the struct.
119 120 121 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 119 def alignment @type.alignment end |
#size ⇒ 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 size, in bytes, of the member within the struct.
110 111 112 |
# File 'lib/ronin/support/binary/ctypes/struct_type.rb', line 110 def size @type.size end |