I successfully wrapped using swig a library I wrote in ruby, all its
simple
functions works very well.
I said simple because I have a function that takes a callback function
as
argument, and I look for the way how to give a pure ruby callback
function
as argument of this function wrapped by SWIG!
By the way, may I meet problems if some of my functions uses the
“callback-needing” function inside of them?
I said simple because I have a function that takes a callback function as
argument, and I look for the way how to give a pure ruby callback function
as argument of this function wrapped by SWIG
You haven’t supplied enough detail to provide specific advice so you’ll
need to adapt what follows. A generally effective way of dealing with
this is in SWIG to do something like:
Create a short ‘bridging’ function in C that converts arguments to
ruby and then calls rb_yield
Let’s say your callback function is expected to take a single int
argument and returns void. Put this is in as a SWIG literal in your .i
file.