Ruby/DL - assigning to global variables?

A

ajwitte

Hi,

I know I can do:

module Foo
extend DL::Importable
dlload 'libquux.so'
@@bar = symbol 'bar'
end

where 'bar' is a variable in libquux. How do I assign a value to bar?

Specifically, I am trying to use libreadline via Ruby/DL (yes, I know
about ext/readline) and am trying to assign a callback to
rl_attempted_completion_function.

Thanks,

/Andrew
 
T

Takaaki Tateishi

module Foo
extend DL::Importable
dlload 'libquux.so'
@@bar = symbol 'bar'
end

where 'bar' is a variable in libquux. How do I assign a value to bar?

@@bar is considered as a pointer to a value. If its type is int, you can assign
an integer value as follows.

IntValue = struct ["int value"]
obj = IntValue.new(@@bar)
obj.value = 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top