diff options
author | Aaron Patterson <[email protected]> | 2022-09-12 09:53:19 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2022-10-07 15:18:49 +0900 |
commit | 48a64984063532f4dedf62e8ac4958a3cf3b556d (patch) | |
tree | 751355eebdde0a0bf77e7697b129d0e6a996c5b6 /ext/fiddle/closure.c | |
parent | 6d01b66764b6dd3fc61c297bd1ec973f8ea686aa (diff) |
[ruby/fiddle] Add constants for unsigned values (https://github.com/ruby/fiddle/pull/111)
This commit adds constants for unsigned values. Currently we can use `-`
to mean "unsigned", but I think having a specific name makes Fiddle more
user friendly. This commit continues to support `-`, but introduces
negative constants with "unsigned" names
I think this will help to eliminate [this
code](https://github.com/ruby/ruby/blob/3a56bf0bcc66e14ffe5ec89efc32ecfceed180f4/lib/mjit/c_type.rb#L31-L38)
https://github.com/ruby/fiddle/commit/2bef0f1082
Co-authored-by: Sutou Kouhei <[email protected]>
Diffstat (limited to 'ext/fiddle/closure.c')
-rw-r--r-- | ext/fiddle/closure.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index a74cc53b78..2d340297d5 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -90,7 +90,7 @@ with_gvl_callback(void *ptr) case TYPE_INT: rb_ary_push(params, INT2NUM(*(int *)x->args[i])); break; - case -TYPE_INT: + case TYPE_UINT: rb_ary_push(params, UINT2NUM(*(unsigned int *)x->args[i])); break; case TYPE_VOIDP: @@ -101,19 +101,19 @@ with_gvl_callback(void *ptr) case TYPE_LONG: rb_ary_push(params, LONG2NUM(*(long *)x->args[i])); break; - case -TYPE_LONG: + case TYPE_ULONG: rb_ary_push(params, ULONG2NUM(*(unsigned long *)x->args[i])); break; case TYPE_CHAR: rb_ary_push(params, INT2NUM(*(signed char *)x->args[i])); break; - case -TYPE_CHAR: + case TYPE_UCHAR: rb_ary_push(params, UINT2NUM(*(unsigned char *)x->args[i])); break; case TYPE_SHORT: rb_ary_push(params, INT2NUM(*(signed short *)x->args[i])); break; - case -TYPE_SHORT: + case TYPE_USHORT: rb_ary_push(params, UINT2NUM(*(unsigned short *)x->args[i])); break; case TYPE_DOUBLE: @@ -126,7 +126,7 @@ with_gvl_callback(void *ptr) case TYPE_LONG_LONG: rb_ary_push(params, LL2NUM(*(LONG_LONG *)x->args[i])); break; - case -TYPE_LONG_LONG: + case TYPE_ULONG_LONG: rb_ary_push(params, ULL2NUM(*(unsigned LONG_LONG *)x->args[i])); break; #endif @@ -149,7 +149,7 @@ with_gvl_callback(void *ptr) case TYPE_LONG: *(long *)x->resp = NUM2LONG(ret); break; - case -TYPE_LONG: + case TYPE_ULONG: *(unsigned long *)x->resp = NUM2ULONG(ret); break; case TYPE_CHAR: @@ -157,9 +157,9 @@ with_gvl_callback(void *ptr) case TYPE_INT: *(ffi_sarg *)x->resp = NUM2INT(ret); break; - case -TYPE_CHAR: - case -TYPE_SHORT: - case -TYPE_INT: + case TYPE_UCHAR: + case TYPE_USHORT: + case TYPE_UINT: *(ffi_arg *)x->resp = NUM2UINT(ret); break; case TYPE_VOIDP: @@ -175,7 +175,7 @@ with_gvl_callback(void *ptr) case TYPE_LONG_LONG: *(LONG_LONG *)x->resp = NUM2LL(ret); break; - case -TYPE_LONG_LONG: + case TYPE_ULONG_LONG: *(unsigned LONG_LONG *)x->resp = NUM2ULL(ret); break; #endif |