Hi, 
 
I'd like to use the ruby/dl library to access function in a C library from
ruby. 
Now these functions take 64 bit parameters und my machine (x86) is a 32 bit 
machine. 
As I saw in lib/ruby/1.8/dl/types.rb this is the place where the types are
listed 
which ruby/dl supports.  
Now if I could add a type uint64 or something and an appropriate pack/unpack

method, I guess everything would work. 
 
I tried pack("LL"), but this doesn't work. 
 
My C functions look like: 
 
void doSomething(uint64_t foo); 
 
and I need to access them: 
 
module Test 
... 
    extern "void doSomething(uint64)" 
end 
 
# call it 
Test.doSomething(7) 
 
when I insert the lines  
 
["uint64", "LL",  
proc{|v| [v].pack("LL").unpack("ll")[0]}, 
proc{|v| [v].pack("ll").unpack("LL")[0]}, 
proc{|v| [v].pack("LL").unpack("ll")[0]}, 
proc{|v| [v].pack("ll").unpack("LL")[0]}], 
 
into types.rb, it recognizes the type and imports the functions, but then
says 
when calling the function: 
 
/usr/local/lib/ruby/1.8/dl/types.rb:76:in `pack': too few arguments 
(ArgumentError) 
        from /usr/local/lib/ruby/1.8/dl/types.rb:76 
        from /usr/local/lib/ruby/1.8/dl/types.rb:76:in `call' 
        from /usr/local/lib/ruby/1.8/dl/import.rb:200:in `encode_types' 
        from /usr/local/lib/ruby/1.8/dl/import.rb:200:in `call' 
        from (eval):3:in `sLMS_Sqr3' 
        from test.rb:17 
 
I'm still quite new to ruby, any help would be very much appreciated. 
 
Bye 
Alex 
 
 
 
 

-- 
NEU F?R ALLE - GMX MediaCenter - f?r Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gru?, GMX FotoService

Jetzt kostenlos anmelden unter http://www.gmx.net

+++ GMX - die erste Adresse f?r Mail, Message, More! +++