Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ruby/DL - assigning to global variables?

0 views
Skip to first unread message

ajw...@gmail.com

unread,
Apr 6, 2005, 7:29:56 PM4/6/05
to
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

Takaaki Tateishi

unread,
Apr 8, 2005, 4:19:25 PM4/8/05
to
ajw...@gmail.com wrote:
> 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
--
Takaaki Tateishi <tt...@ttsky.net>

0 new messages