Rice  2.1.1
Functions
protect.hpp File Reference

A collection of functions (overloaded on number of arguments) for calling C functions that might raise Ruby exceptions. More...

#include "Object_defn.hpp"
#include "protect.ipp"

Go to the source code of this file.

Functions

VALUE Rice::protect (Function f, T1 arg1, T2 arg2,...)
 Call the C function f with arguments (arg1, arg2, ...). More...
 

Detailed Description

A collection of functions (overloaded on number of arguments) for calling C functions that might raise Ruby exceptions.

Function Documentation

§ protect()

VALUE Rice::protect ( Function  f,
T1  arg1,
T2  arg2,
  ... 
)

Call the C function f with arguments (arg1, arg2, ...).

E.g.:

VALUE x = protect(rb_ary_new);
protect(rb_ary_push, x, INT2NUM(42));

Note that this function makes copies of all of its arguments; it does not take anything by reference. All of the copies are const so that protect will not work if f takes a non-const reference to any of its arguments (though you can use non-const pointers).

Examples:
map/map.cpp.