diff options
-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); |