Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Ruby/DL - assigning to global variables? (http://www.velocityreviews.com/forums/t820852-ruby-dl-assigning-to-global-variables.html)

ajwitte@gmail.com 04-06-2005 11:29 PM

Ruby/DL - assigning to global variables?
 
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 04-08-2005 08:19 PM

Re: Ruby/DL - assigning to global variables?
 
ajwitte@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 <ttate@ttsky.net>





All times are GMT. The time now is 10:18 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.