mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
4d0d4ee3fe
commit
11d0680a96
1 changed files with 15 additions and 1 deletions
16
ext/dl/dl.c
16
ext/dl/dl.c
|
@ -435,7 +435,15 @@ c_parray(VALUE v, long *size)
|
||||||
ary[i] = (void*)(pdata->ptr);
|
ary[i] = (void*)(pdata->ptr);
|
||||||
}
|
}
|
||||||
else{
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -495,6 +503,12 @@ rb_ary2cary(char t, VALUE v, long *size)
|
||||||
if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
|
if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
|
||||||
return (void*)c_parray(v,size);
|
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");
|
rb_raise(rb_eDLTypeError, "type mismatch");
|
||||||
case T_NIL:
|
case T_NIL:
|
||||||
return (void*)c_parray(v, size);
|
return (void*)c_parray(v, size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue