Restrict integer arguments to 32 bits

When built as 64-bit, use the 'i' and 'I' arguments for MiniFFI/Win32API
to specifically refer to a 32-bit integer.
'l', 'L', 'n' and 'N' continue to refer to the `long` sizes.
This commit is contained in:
Roza 2020-02-26 18:47:46 -05:00
parent 2bcdfdb23a
commit 901b2b6143

View file

@ -3,6 +3,7 @@
#include "fake-api.h" #include "fake-api.h"
#include <SDL.h> #include <SDL.h>
#include <cstdint>
#include "binding-util.h" #include "binding-util.h"
#include "debugwriter.h" #include "debugwriter.h"
@ -251,8 +252,12 @@ RB_METHOD(MiniFFI_call) {
lParam = RTEST(rb_ary_entry(args, i)); lParam = RTEST(rb_ary_entry(args, i));
break; break;
case _T_NUMBER:
case _T_INTEGER: case _T_INTEGER:
#if INTPTR_MAX == INT64_MAX
lParam = NUM2UINT(rb_ary_entry(args, i)) & UINT32_MAX;
break;
#endif
case _T_NUMBER:
default: default:
lParam = NUM2ULONG(rb_ary_entry(args, i)); lParam = NUM2ULONG(rb_ary_entry(args, i));
break; break;