ruby-rice/rice

Passing and Returning VALUE

cfis opened this issue · 0 comments

cfis commented

Because VALUE is a typedef (to uint64_t on 64-bit machines), there is not a way to recognize it. Thus, when passing VALUEs as parameters to methods or returning them, Rice will consider them 64 bit integers and call To_Ruby or From_Ruby. Thus you see various Rice internal methods, like constructor calls, pass Object or Class or Module which are Rice's classes for wrapping the Ruby api. The one exception to this rule currently is SELF - Rice has special code that will allow SELF to be a value when calling a method defined by define_method (not define_function).

If you are wrapping a C++ extension, versus using Rice to manipulate the Ruby api, the extra conversion from VALUE to Object to VALUE is unneeded. This can be done by adding an extra function, isValue(), to the Arg and Return class. Rice can then see it should not convert those arguments and just pass them through to a native function or alternatively back to Ruby.