class Ronin::Support::Binary::CTypes::StructType::Member
Represents a member within a struct.
@api private
@since 1.0.0
Attributes
The offset, in bytes, of the member from the beginning of the struct.
@return [Integer]
The type of the member.
@return [Type]
Public Class Methods
Source
# File lib/ronin/support/binary/ctypes/struct_type.rb, line 64 def initialize(offset,type) @offset = offset @type = type end
Initializes the member.
@param [Integer] offset
The offset, in bytes, of the member from the beginning of the struct.
@param [Type] type
The type of the member.
Source
# 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
Calculates the pack string for the given type and optional padding.
@param [Type] type
@param [Integer] padding
@return [String]
The pack string for the member.
@api private
Source
# 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
Calculates padding for the given type at the given offset.
@param [Integer] offset
@param [Type] type
@return [Integer]
@api private
@see en.wikipedia.org/wiki/Data_structure_alignment#Computing_padding
Public Instance Methods
Source
# File lib/ronin/support/binary/ctypes/struct_type.rb, line 119 def alignment @type.alignment end
The alignment, in bytes, of the member within the struct.
@return [Integer]
Source
# File lib/ronin/support/binary/ctypes/struct_type.rb, line 110 def size @type.size end
The size, in bytes, of the member within the struct.
@return [Integer]