summaryrefslogtreecommitdiff
path: root/ext/fiddle/closure.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-15 10:57:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-15 10:57:05 +0000
commit34be46a32e6a8c88866c6dd9e42705ed63ed5d2a (patch)
treed763c9a7485543bc32f9a5700e691b8943f10442 /ext/fiddle/closure.c
parentfa65df0d084077f6766c8a2580016de49cbf42f9 (diff)
* ext/fiddle/closure.c (callback): deal with unsinged integers.
[ruby-core:42458][Bug #5991][Bug #6022] * ext/fiddle/conversions.c (value_to_generic, generic_to_value): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/fiddle/closure.c')
-rw-r--r--ext/fiddle/closure.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index c601818ad40..a9a5e145112 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -72,6 +72,9 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
case TYPE_INT:
rb_ary_push(params, INT2NUM(*(int *)args[i]));
break;
+ case -TYPE_INT:
+ rb_ary_push(params, UINT2NUM(*(unsigned int *)args[i]));
+ break;
case TYPE_VOIDP:
rb_ary_push(params,
rb_funcall(cPointer, rb_intern("[]"), 1,
@@ -80,8 +83,20 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
case TYPE_LONG:
rb_ary_push(params, LONG2NUM(*(long *)args[i]));
break;
+ case -TYPE_LONG:
+ rb_ary_push(params, ULONG2NUM(*(unsigned long *)args[i]));
+ break;
case TYPE_CHAR:
- rb_ary_push(params, INT2NUM(*(char *)args[i]));
+ rb_ary_push(params, INT2NUM(*(signed char *)args[i]));
+ break;
+ case -TYPE_CHAR:
+ rb_ary_push(params, UINT2NUM(*(unsigned char *)args[i]));
+ break;
+ case TYPE_SHORT:
+ rb_ary_push(params, INT2NUM(*(signed short *)args[i]));
+ break;
+ case -TYPE_SHORT:
+ rb_ary_push(params, UINT2NUM(*(unsigned short *)args[i]));
break;
case TYPE_DOUBLE:
rb_ary_push(params, rb_float_new(*(double *)args[i]));
@@ -91,7 +106,10 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
break;
#if HAVE_LONG_LONG
case TYPE_LONG_LONG:
- rb_ary_push(params, rb_ull2inum(*(unsigned LONG_LONG *)args[i]));
+ rb_ary_push(params, LL2NUM(*(LONG_LONG *)args[i]));
+ break;
+ case -TYPE_LONG_LONG:
+ rb_ary_push(params, ULL2NUM(*(unsigned LONG_LONG *)args[i]));
break;
#endif
default:
@@ -109,11 +127,19 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
case TYPE_LONG:
*(long *)resp = NUM2LONG(ret);
break;
+ case -TYPE_LONG:
+ *(unsigned long *)resp = NUM2ULONG(ret);
+ break;
case TYPE_CHAR:
case TYPE_SHORT:
case TYPE_INT:
*(ffi_sarg *)resp = NUM2INT(ret);
break;
+ case -TYPE_CHAR:
+ case -TYPE_SHORT:
+ case -TYPE_INT:
+ *(ffi_arg *)resp = NUM2UINT(ret);
+ break;
case TYPE_VOIDP:
*(void **)resp = NUM2PTR(ret);
break;
@@ -125,6 +151,9 @@ callback(ffi_cif *cif, void *resp, void **args, void *ctx)
break;
#if HAVE_LONG_LONG
case TYPE_LONG_LONG:
+ *(LONG_LONG *)resp = NUM2LL(ret);
+ break;
+ case -TYPE_LONG_LONG:
*(unsigned LONG_LONG *)resp = NUM2ULL(ret);
break;
#endif