Class: Ronin::Support::Binary::CTypes::TypeResolver Private
- Inherits:
-
Object
- Object
- Ronin::Support::Binary::CTypes::TypeResolver
- Defined in:
- lib/ronin/support/binary/ctypes/type_resolver.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.
Adds a type system that can be used by Memory objects.
Instance Attribute Summary collapse
-
#types ⇒ Native, ...
readonly
private
The Ronin::Support::Binary::CTypes module or object to lookup type names in.
Instance Method Summary collapse
-
#initialize(types) ⇒ TypeResolver
constructor
private
Initializes the type resolver.
-
#resolve(type_signature) ⇒ Type
private
Resolves C type short-hand syntax into a Type object.
Constructor Details
#initialize(types) ⇒ TypeResolver
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 resolver.
The types module or object that provides a #[]
method for
looking up type names.
74 75 76 |
# File 'lib/ronin/support/binary/ctypes/type_resolver.rb', line 74 def initialize(types) @types = types end |
Instance Attribute Details
#types ⇒ Native, ... (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 Ronin::Support::Binary::CTypes module or object to lookup type names in.
52 53 54 |
# File 'lib/ronin/support/binary/ctypes/type_resolver.rb', line 52 def types @types end |
Instance Method Details
#resolve(type_signature) ⇒ 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.
Resolves C type short-hand syntax into a Ronin::Support::Binary::CTypes::Type object.
The C type value. The value can be one of the following:
Symbol
- represents a single type (ex::int32
)(type, Integer)
- represents an Array type with the given element type and length (ex:[:int32, 10]
)Range(type)
- represents an unbounded Array type with the given element type. (ex::int32..
)Struct.class
- a subclass of Struct.Union.class
- a subclass of Union.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ronin/support/binary/ctypes/type_resolver.rb', line 102 def resolve(type_signature) case type_signature when ::Array then resolve_array(type_signature) when Range then resolve_range(type_signature) when Symbol then resolve_symbol(type_signature) when Type then type_signature when Class if type_signature < Binary::Union resolve_union(type_signature) elsif type_signature < Binary::Struct resolve_struct(type_signature) else raise(ArgumentError,"class must be either a #{Binary::Struct} or a #{Binary::Union} class") end else raise(ArgumentError,"type type_signature must be a Symbol, Array, Range, #{Binary::Struct}, #{Binary::Union}, or a #{CTypes::Type} object: #{type_signature.inspect}") end end |