Module: MemoryIO::Types

Defined in:
lib/memory_io/types/types.rb,
lib/memory_io/types/type.rb,
lib/memory_io/types/record.rb,
lib/memory_io/types/cpp/string.rb,
lib/memory_io/types/clang/c_str.rb,
lib/memory_io/types/basic/number.rb

Overview

Module that includes multiple types.

Supported types are all descendants of Type.

Defined Under Namespace

Modules: Basic, CPP, Clang Classes: Record, Type

Class Method Summary collapse

Class Method Details

.find(name) ⇒ Symbol, ...

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.

Returns the class whose name matches name.

This method will search all descendants of Type.

Examples:

Types.find(:c_str)
#=> MemoryIO::Types::CStr

Types.find(:u64)
#=> #<MemoryIO::Types::Number:0x000055ecc017a310 @bytes=8, @pack_str="Q", @signed=false>


32
33
34
35
# File 'lib/memory_io/types/types.rb', line 32

def find(name)
  obj = Types::Type.find(name)
  return obj.obj if obj
end

.get_proc(name, rw) ⇒ Proc?

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.

Returns a callable object according to name.

Examples:

Types.get_proc(:c_str, :write)
#=> #<Method: MemoryIO::Types::CStr.write>
Types.get_proc(:s32, :read)
#=> #<Method: MemoryIO::Types::Number#read>


54
55
56
57
# File 'lib/memory_io/types/types.rb', line 54

def get_proc(name, rw)
  klass = find(name)
  klass && klass.method(rw)
end