Module: FFI

Defined in:
lib/ffi/extra.rb,
lib/ffi/executable_memory.rb

Overview

         DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                 Version 2, December 2004

Copyleft meh. [http://meh.paranoid.pk | [email protected]]

         DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

++

Defined Under Namespace

Modules: Library Classes: ExecutableMemoryPointer, Pointer

Class Method Summary collapse

Class Method Details

.function(function, arguments = [], ret = :void) ⇒ Object



36
37
38
# File 'lib/ffi/extra.rb', line 36

def self.function (function, arguments = [], ret = :void)
	@loader.instance_eval { attach_function function, arguments, ret }
end

.load(path) ⇒ Object



32
33
34
# File 'lib/ffi/extra.rb', line 32

def self.load (path)
	@loader.instance_eval { ffi_lib_add path }
end

.type_size(type) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ffi/extra.rb', line 14

def self.type_size (type)
	type = FFI.find_type(type) if type.is_a?(Symbol)

	if type.is_a?(Type::Builtin) || (type.is_a?(Class) && (type.ancestors.member?(FFI::Struct) || type.ancestors.member?(FFI::ManagedStruct)))
		type.size
	elsif type.respond_to? :from_native
		type.native_type.size
	else
		raise ArgumentError, 'you have to pass a Struct, a Builtin type or a Symbol'
	end
end