From 11d0680a9600c3ba1835ed0a921f1ce721e10db2 Mon Sep 17 00:00:00 2001 From: ttate Date: Wed, 8 Jun 2005 20:14:31 +0000 Subject: Data object is automatically converted to a PtrData object using to_ptr(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dl/dl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'ext/dl') diff --git a/ext/dl/dl.c b/ext/dl/dl.c index 22abb754d2..02cfcf011c 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); -- cgit v1.2.3