summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-08 20:14:31 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-08 20:14:31 +0000
commitff924e6ede56f8daad39c4865a4f2a096eb190fc (patch)
treef520e9dec78464f1a8b1ca36b0d98dd41657ca68
parent317c35fcd9221137cfd75a57c8d5e359378e8760 (diff)
downloadruby-ff924e6ede56f8daad39c4865a4f2a096eb190fc.tar.gz
ruby-ff924e6ede56f8daad39c4865a4f2a096eb190fc.tar.xz
ruby-ff924e6ede56f8daad39c4865a4f2a096eb190fc.zip
Data object is automatically converted to a PtrData object using to_ptr().
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/dl/dl.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index 22abb754d..02cfcf011 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -435,7 +435,15 @@ c_parray(VALUE v, long *size)
ary[i] = (void*)(pdata->ptr);
}
else{
- rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ e = rb_funcall(e, rb_intern("to_ptr"), 0);
+ if (rb_obj_is_kind_of(e, rb_cDLPtrData)) {
+ struct ptr_data *pdata;
+ Data_Get_Struct(e, struct ptr_data, pdata);
+ ary[i] = (void*)(pdata->ptr);
+ }
+ else{
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ }
}
break;
}
@@ -495,6 +503,12 @@ rb_ary2cary(char t, VALUE v, long *size)
if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
return (void*)c_parray(v,size);
}
+ else{
+ val0 = rb_funcall(val0, rb_intern("to_ptr"), 0);
+ if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
+ return (void*)c_parray(v,size);
+ }
+ }
rb_raise(rb_eDLTypeError, "type mismatch");
case T_NIL:
return (void*)c_parray(v, size);