VALUE
rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
Ok, so if from C I want to call a Ruby method passing N VALUE
parameters, should I really create a Ruby Array and pass it as _data_
in rb_protect() ?? really? is there any other way?
I did not find another way after searching for a while, including the
source of all the extensions I could get my hands on. I was a little
surprised too.
I ended up writing my own wrappers around rb_funcall and rb_funcall2, using
rb_rescue2. Here's a gist:
These come from a program that embeds ruby, not an extension, so they were
written to suit those needs. For example, rescuing rb_eException might be
too broad, and registering/unregistering args with the GC might not be
necessary for all applications. I think this is most probably the reason
why ruby does not provide such functions.
In any event, I've been meaning to put these snippets out there in a
related thread in hope they might help someone. I hope they help you in
some way. I would be very interested in any feedback you might have.
Regards,
Ammar
···
On Thu, May 24, 2012 at 8:59 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
Ok, so if from C I want to call a Ruby method passing N VALUE
parameters, should I really create a Ruby Array and pass it as _data_
in rb_protect() ?? really? is there any other way?
On Thu, May 24, 2012 at 8:59 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
Ok, so if from C I want to call a Ruby method passing N VALUE
parameters, should I really create a Ruby Array and pass it as _data_
in rb_protect() ?? really? is there any other way?
I did not find another way after searching for a while, including the source
of all the extensions I could get my hands on. I was a little surprised too.
I ended up writing my own wrappers around rb_funcall and rb_funcall2, using
rb_rescue2. Here's a gist:
These come from a program that embeds ruby, not an extension, so they were
written to suit those needs. For example, rescuing rb_eException might be
too broad, and registering/unregistering args with the GC might not be
necessary for all applications. I think this is most probably the reason why
ruby does not provide such functions.
In any event, I've been meaning to put these snippets out there in a related
thread in hope they might help someone. I hope they help you in some way. I
would be very interested in any feedback you might have.
as paul have said, data is being treated as text. since you are using
csv lib, use the :converters option.. on your case, :converters=>:all
is good enough.
best regards -botp
···
On Fri, May 25, 2012 at 3:06 PM, Ivan Vilches Basaul <ivan_vilches@hotmail.com> wrote: