From: Francis Cianfrocca Date: 2006-08-15T16:54:43+09:00 Subject: Re: Ruby extension and static function in C++ ------=_Part_12654_30989518.1155628481111 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/15/06, yue_nicholas@hotmail.com wrote: > > > I have a further question, the parameter I get in my call is an array > e.g. > > ["pos",[ 0, 0, 0],"dir",[1, 0, 1],"custom",[ 0, 1, 1, 2, 2, 2, > 3, 1, 1]] > > they are token-value pair > > Should I process the array in cmain.cpp or rubymain.cpp > > If in cmain.cpp I would need to include "ruby.h" for the definition of > "VALUE" right? You should follow whatever conventions make sense for your own code. For my code, I would answer your question by saying that all of the Ruby stuff belongs in the extension wrapper (called rubymain.cpp in my case), so your extension code should convert the Ruby array to something directly accessible from C. And therefore nothing but rubymain.cpp should include ruby.h. That especially makes sense if you're writing an extension to wrap up already-existing code that knows nothing about Ruby in the first place. EventMachine is completely new code, but it was designed to be completely independent of Ruby, and if you compile everything except rubymain, you get a fully-functional C++ library with a C interface that you can use from any language that can dynamically link code. It's nice to do things in well-defined layers like that. ------=_Part_12654_30989518.1155628481111--