mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00

* ext/dl/function.c: DL::Function now uses libffi * ext/dl/cfunc.c (rb_dl_set_last_error): set to non static so errors can be exposed. * ext/dl/closure.c: DL::Closure will now be used in place of ext/dl/callback/*. * ext/dl/dl.c: legacy callbacks removed in favor of libffi * ext/dl/dl_converions.(c,h): used for converting ruby types to FFI types. * ext/dl/callback/*: replaced by libffi callbacks. * ext/dl/lib/dl/callback.rb: Converting internal callbacks to use DL::Closure * ext/dl/lib/dl/closure.rb: Ruby parts of the new DL::Closure object * ext/dl/lib/dl/import.rb: More conversion to use DL::Closure object * ext/dl/lib/dl/value.rb (ruby2ffi): adding private method for DL::CPtr to ffi value conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
38 lines
913 B
C
38 lines
913 B
C
#include <dl_conversions.h>
|
|
|
|
ffi_type * rb_dl_type_to_ffi_type(int dl_type)
|
|
{
|
|
int signed_p = 1;
|
|
|
|
if(dl_type < 0) {
|
|
dl_type = -1 * dl_type;
|
|
signed_p = 0;
|
|
}
|
|
|
|
switch(dl_type) {
|
|
case DLTYPE_VOID:
|
|
return &ffi_type_void;
|
|
case DLTYPE_VOIDP:
|
|
return &ffi_type_pointer;
|
|
case DLTYPE_CHAR:
|
|
return signed_p ? &ffi_type_schar : &ffi_type_uchar;
|
|
case DLTYPE_SHORT:
|
|
return signed_p ? &ffi_type_sshort : &ffi_type_ushort;
|
|
case DLTYPE_INT:
|
|
return signed_p ? &ffi_type_sint : &ffi_type_uint;
|
|
case DLTYPE_LONG:
|
|
return signed_p ? &ffi_type_slong : &ffi_type_ulong;
|
|
#if HAVE_LONG_LONG
|
|
case DLTYPE_LONG_LONG:
|
|
return &ffi_type_uint64;
|
|
break;
|
|
#endif
|
|
case DLTYPE_FLOAT:
|
|
return &ffi_type_float;
|
|
case DLTYPE_DOUBLE:
|
|
return &ffi_type_double;
|
|
default:
|
|
rb_raise(rb_eRuntimeError, "unknown type %d", dl_type);
|
|
}
|
|
return &ffi_type_pointer;
|
|
}
|