From: Paul Brannan Date: 2008-09-24T23:24:04+09:00 Subject: [ruby-core:18860] Re: mv trunk/include/ruby/node.h to trunk/node.h On Wed, Sep 24, 2008 at 07:07:58AM +0900, SASADA Koichi wrote: > Paul Brannan wrote: > > Rice uses node.h to attach type conversion metadata to each method it > > defines. I would be happy to see node.h become private if I had an > > alternate way to attach and retrieve this information. > > What type of information Rice need? Conceptually, when a C++ function is wrapped in Rice, a wrapper is created that contains: - the number of parameters to the method - functions to call to convert parameters from Ruby type to corresponding C++ type - function to call to convert return value from C++ type to Ruby type - the wrapped function pointer or member function pointer The wrapper object has a static wrapper function that is passed to rb_define_method. When Ruby calls into a Rice wrapper function, it: - queries the method node for the wrapper's member data - converts incoming arguments - calls the wrapped function - converts the return value and returns it The wrapper function needs to be able to store and retrieve the above data at run-time in order to know how to call the wrapped function. It is not desirable to use Proc objects because of the high overhead of calling them, and because they behave differently from normal C function calls. Paul