Class: ObjC::Function

ObjC::Function wraps C functions for manipulation from Ruby.


Public Class methods

wrap (p1, p2, p3)

Wrap a C function with a given name p1 so that it can be called from Ruby with the specified return type p2 and arguments p3. The return type and argument types are described with Objective-C type encodings. The argument types are passed in a Ruby array of strings.

For example, to wrap the C function

   int NSApplicationMain(int argc, char *argv[])

you would use the following in Ruby:

   f = ObjC::Function.wrap('NSApplicationMain', 'i', %w{i ^*})

You could then call it with

   f.call(0, [])

Alternately, you could first install it in a module:

   f >> ObjC

and then call it like this:

   ObjC.NSApplicationMain(0, [])

Public Instance methods

>> (p1)

Add the wrapped C function to the specified module p1 as a module function.

call (...)

Call a wrapped C function with the associated arguments.

name ()

Get the name of the corresponding function.

to_s ()

Get the name of the corresponding function.