Class: Ronin::Support::Binary::CTypes::OS Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/support/binary/ctypes/os.rb,
lib/ronin/support/binary/ctypes/os/bsd.rb,
lib/ronin/support/binary/ctypes/os/unix.rb,
lib/ronin/support/binary/ctypes/os/linux.rb,
lib/ronin/support/binary/ctypes/os/macos.rb,
lib/ronin/support/binary/ctypes/os/netbsd.rb,
lib/ronin/support/binary/ctypes/os/freebsd.rb,
lib/ronin/support/binary/ctypes/os/openbsd.rb,
lib/ronin/support/binary/ctypes/os/windows.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 additional typedefs defined by an Operating System (OS).

Since:

  • 1.0.0

Direct Known Subclasses

UNIX, Windows

Defined Under Namespace

Classes: BSD, FreeBSD, Linux, MacOS, NetBSD, OpenBSD, UNIX, Windows

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ OS

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 OS with the given base types.

The base types that the OS builds upon.



70
71
72
73
# File 'lib/ronin/support/binary/ctypes/os.rb', line 70

def initialize(types)
  @types    = types
  @typedefs = {}
end

Instance Attribute Details

#typedefsHash{Symbol => 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 defined typedefs for the OS.

Returns:

  • (Hash{Symbol => Type})

Since:

  • 1.0.0



51
52
53
# File 'lib/ronin/support/binary/ctypes/os.rb', line 51

def typedefs
  @typedefs
end

#typesNative, ... (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 base types that the OS inherits.



46
47
48
# File 'lib/ronin/support/binary/ctypes/os.rb', line 46

def types
  @types
end

Instance Method Details

#[](name) ⇒ Type

Retrieves the type with the given name.

Parameters:

  • name (Symbol)

Returns:

Since:

  • 1.0.0



84
85
86
# File 'lib/ronin/support/binary/ctypes/os.rb', line 84

def [](name)
  @typedefs.fetch(name) { @types[name] }
end

#typedef(type, new_name) ⇒ 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.

Defines a typedef within the type system.

Examples:

os.typedef :uint, :foo_t

Parameters:

  • type (Symbol, Type)

    The original type to point to.

  • new_name (Symbol)

    The new type name.

Raises:

  • (ArgumentError)

    The given type was not a Symbol or a Type.

Since:

  • 1.0.0



103
104
105
106
107
108
109
110
# File 'lib/ronin/support/binary/ctypes/os.rb', line 103

def typedef(type,new_name)
  case type
  when Type   then @typedefs[new_name] = type
  when Symbol then @typedefs[new_name] = self[type]
  else
    raise(ArgumentError,"type must be either a Symbol or a #{Type}: #{type.inspect}")
  end
end