Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support int64 in NativeCall signatures.
  • Loading branch information
jnthn committed Apr 4, 2015
1 parent d597a07 commit 5692768
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/NativeCall.pm
Expand Up @@ -130,6 +130,7 @@ my %type_map =
'int8' => 'char',
'int16' => 'short',
'int32' => 'int',
'int64' => 'longlong',
'long' => 'long',
'int' => 'long',
'Int' => 'longlong',
Expand Down
9 changes: 9 additions & 0 deletions t/04-nativecall/02-simple-args.c
Expand Up @@ -3,8 +3,10 @@

#ifdef WIN32
#define DLLEXPORT __declspec(dllexport)
typedef signed __int64 int64_t;
#else
#define DLLEXPORT extern
#include <inttypes.h>
#endif

DLLEXPORT int TakeInt(int x)
Expand Down Expand Up @@ -65,3 +67,10 @@ DLLEXPORT int wrapped(int n) {
return 8;
return 0;
}

DLLEXPORT int TakeInt64(int64_t x)
{
if (x == 0xFFFFFFFFFF)
return 9;
return 0;
}
7 changes: 5 additions & 2 deletions t/04-nativecall/02-simple-args.t
Expand Up @@ -4,7 +4,7 @@ use lib 'lib';
use NativeCall;
use Test;

plan 8;
plan 9;

compile_test_lib('02-simple-args');

Expand Down Expand Up @@ -37,7 +37,10 @@ is CheckString(), 7, 'checked previously passed string';
# Make sure wrapped subs work
sub wrapped(int32) returns int32 is native('./02-simple-args') { * }
sub wrapper(int32 $arg) { is wrapped($arg), 8, 'wrapped sub' }

wrapper(42);

# 64-bit integer
sub TakeInt64(int64) returns int32 is native('./02-simple-args') { * }
is TakeInt64(0xFFFFFFFFFF), 9, 'passed int64 0xFFFFFFFFFF';

# vim:ft=perl6

0 comments on commit 5692768

Please sign in to comment.