diff options
author | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-08 20:14:31 +0000 |
---|---|---|
committer | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-08 20:14:31 +0000 |
commit | 11d0680a9600c3ba1835ed0a921f1ce721e10db2 (patch) | |
tree | f520e9dec78464f1a8b1ca36b0d98dd41657ca68 /ext/dl | |
parent | 4d0d4ee3fe549224bb954b9b4b287b11ab045594 (diff) |
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
Diffstat (limited to 'ext/dl')
-rw-r--r-- | ext/dl/dl.c | 16 |
1 files changed, 15 insertions, 1 deletions
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); |