Ruby DL::Importable struct issue

K

Kevin Howe

Hi,

The ruby182-14RC9.exe (one click installer) version of Ruby breaks some DL
code in a gem of mine (tidy on rubyforge). The problem is with the first
struct item which defines "byte* bp". I get the following error when I run
the script at the bottom. If "byte*" is deliberately no longer supported,
what would be a valid equivalent?

(eval):2 in '[]': unsupported type 'p' (DL::DLTypeError)
from (eval):2:in 'bp'

#-------
require 'dl/import'
require 'dl/struct'

extend DL::Importable

# http://tidy.sourceforge.net/docs/api/struct__TidyBuffer.html
TidyBuffer = struct [
"byte* bp",
"uint size",
"uint allocated",
"uint next"
]

struct = TidyBuffer.malloc
puts struct.bp
#-------
 
T

Tim Sutherland

Hi,

The ruby182-14RC9.exe (one click installer) version of Ruby breaks some DL
code in a gem of mine (tidy on rubyforge). The problem is with the first
struct item which defines "byte* bp". I get the following error when I run
the script at the bottom. If "byte*" is deliberately no longer supported,
what would be a valid equivalent?

(eval):2 in '[]': unsupported type 'p' (DL::DLTypeError)
from (eval):2:in 'bp'

#-------
require 'dl/import'
require 'dl/struct'

extend DL::Importable

# http://tidy.sourceforge.net/docs/api/struct__TidyBuffer.html
TidyBuffer = struct [
"byte* bp",
"uint size",
"uint allocated",
"uint next"
]

struct = TidyBuffer.malloc
puts struct.bp
#-------

Try "char* bp" or "unsigned char* bp".
 
K

Kevin Howe

I get the following error
(eval):2 in '[]': unsupported type 'p' (DL::DLTypeError)
from (eval):2:in 'bp'
Try "char* bp" or "unsigned char* bp".

"char* bp" produces the same error, but with type 's' instead of type 'p'.
"unsigned char*" produces an "invalid element" error. I also tried "uint*
bp" and "int* bp", but they give the same original error.
 
T

Tim Sutherland

I get the following error
(eval):2 in '[]': unsupported type 'p' (DL::DLTypeError)
from (eval):2:in 'bp'
Try "char* bp" or "unsigned char* bp".

"char* bp" produces the same error, but with type 's' instead of type 'p'.
"unsigned char*" produces an "invalid element" error. I also tried "uint*
bp" and "int* bp", but they give the same original error.

Okay, this is a bug in newer versions of the dl extension.

e.g. current CVS ruby/ext/dl/sample/libc.rb fails with
10
true
false
"ab"
(eval):5:in `call': unsupported type `p' (DL::DLTypeError)
from (eval):5:in `qsort'
from libc.rb:62


$ ruby -v
ruby 1.9.0 (2004-11-24) [i686-linux]

There are a couple of places in ptr.c which do a `switch' on the type ('I',
'S' etc.) but only handle upper-case types like 'P' and not lower-case like
'p' (the latter are the pointer versions).

`rb_dlptr_aref' and `cary2ary' in particular.
 
T

Takaaki Tateishi

Kevin Howe said:
When I use these files I get the following error:
types.rb:236:in 'encode_type': unknown type: uint (TypeError)

Could you try again?

Thanks,
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top