Need pointers of Ruby blocks (JRuby FFI)
----------------------------------------
Key: JRUBY-3346
URL: http://jira.codehaus.org/browse/JRUBY-3346
Project: JRuby
Issue Type: Improvement
Components: Extensions
Affects Versions: JRuby 1.2
Reporter: Koichiro Ohba
Hi,
I am now developing ffi wrapper library of GNU Readline library,
thanks to Wayne's great work.
Currently, my ffi-readline works on simple one line input and
supports histories.
I'm going to implement completion next, and I have a question for it.
Looking sample/qsort.rb, I understood that a Ruby block can be
passed as an argument of extension library's function on JRuby
FFI callback system.
I need to do similar thing.
How can I set a pointer of a Ruby block to a export variable?
For example, I would use that way on cases like this, in which a
function pointer is set to a variable.
http://tiswww.case.edu/php/chet/readline/readline.html#SEC47
{code}
rl_completion_func_t * rl_attempted_completion_function
{code}
It's just my image but it could be something like this.
{code}
module Readline
extend FFI::Library
ffi_lib "readline"
attach_variable :attempted_completion_function,
:rl_attempted_completion_function, :pointer
end
block = FFI::Callback.new do |str|
....any processing...
end
Readline.attempted_completion_function = block.pointer
{code}
Please give me some advise about the right way.
--
Koichiro Ohba <[email protected]>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email