fix tests to work on Windows (with standard paths?)
svn: r3735
This commit is contained in:
parent
5c21fee0a5
commit
7cb8b4536d
|
@ -2,51 +2,56 @@
|
|||
|
||||
typedef unsigned char byte;
|
||||
|
||||
int add1_int_int (int x) { return x + 1; }
|
||||
int add1_byte_int (byte x) { return x + 1; }
|
||||
byte add1_int_byte (int x) { return x + 1; }
|
||||
byte add1_byte_byte (byte x) { return x + 1; }
|
||||
int decimal_int_int_int (int x, int y) { return 10*x + y; }
|
||||
int decimal_byte_int_int (byte x, int y) { return 10*x + y; }
|
||||
int decimal_int_byte_int (int x, byte y) { return 10*x + y; }
|
||||
int decimal_byte_byte_int (byte x, byte y) { return 10*x + y; }
|
||||
byte decimal_int_int_byte (int x, int y) { return 10*x + y; }
|
||||
byte decimal_byte_int_byte (byte x, int y) { return 10*x + y; }
|
||||
byte decimal_int_byte_byte (int x, byte y) { return 10*x + y; }
|
||||
byte decimal_byte_byte_byte (byte x, byte y) { return 10*x + y; }
|
||||
#ifdef _WIN32
|
||||
#define X __declspec(dllexport)
|
||||
#else
|
||||
#define X
|
||||
#endif
|
||||
|
||||
int callback3_int_int_int (int(*f)(int)) { return f(3); }
|
||||
int callback3_byte_int_int (int(*f)(byte)) { return f(3); }
|
||||
int callback3_int_byte_int (byte(*f)(int)) { return f(3); }
|
||||
int callback3_byte_byte_int (byte(*f)(byte)) { return f(3); }
|
||||
byte callback3_int_int_byte (int(*f)(int)) { return f(3); }
|
||||
byte callback3_byte_int_byte (int(*f)(byte)) { return f(3); }
|
||||
byte callback3_int_byte_byte (byte(*f)(int)) { return f(3); }
|
||||
byte callback3_byte_byte_byte (byte(*f)(byte)) { return f(3); }
|
||||
X int add1_int_int (int x) { return x + 1; }
|
||||
X int add1_byte_int (byte x) { return x + 1; }
|
||||
X byte add1_int_byte (int x) { return x + 1; }
|
||||
X byte add1_byte_byte (byte x) { return x + 1; }
|
||||
X int decimal_int_int_int (int x, int y) { return 10*x + y; }
|
||||
X int decimal_byte_int_int (byte x, int y) { return 10*x + y; }
|
||||
X int decimal_int_byte_int (int x, byte y) { return 10*x + y; }
|
||||
X int decimal_byte_byte_int (byte x, byte y) { return 10*x + y; }
|
||||
X byte decimal_int_int_byte (int x, int y) { return 10*x + y; }
|
||||
X byte decimal_byte_int_byte (byte x, int y) { return 10*x + y; }
|
||||
X byte decimal_int_byte_byte (int x, byte y) { return 10*x + y; }
|
||||
X byte decimal_byte_byte_byte (byte x, byte y) { return 10*x + y; }
|
||||
|
||||
int g1;
|
||||
int curry_return_int_int (int x) { return g1 + x; }
|
||||
int curry_return_byte_int (byte x) { return g1 + x; }
|
||||
byte curry_return_int_byte (int x) { return g1 + x; }
|
||||
byte curry_return_byte_byte (byte x) { return g1 + x; }
|
||||
void* curry_int_int_int (int x) { g1 = x; return &curry_return_int_int; }
|
||||
void* curry_byte_int_int (byte x) { g1 = x; return &curry_return_int_int; }
|
||||
void* curry_int_byte_int (int x) { g1 = x; return &curry_return_byte_int; }
|
||||
void* curry_byte_byte_int (byte x) { g1 = x; return &curry_return_byte_int; }
|
||||
void* curry_int_int_byte (int x) { g1 = x; return &curry_return_int_byte; }
|
||||
void* curry_byte_int_byte (byte x) { g1 = x; return &curry_return_int_byte; }
|
||||
void* curry_int_byte_byte (int x) { g1 = x; return &curry_return_byte_byte; }
|
||||
void* curry_byte_byte_byte(byte x) { g1 = x; return &curry_return_byte_byte; }
|
||||
X int callback3_int_int_int (int(*f)(int)) { return f(3); }
|
||||
X int callback3_byte_int_int (int(*f)(byte)) { return f(3); }
|
||||
X int callback3_int_byte_int (byte(*f)(int)) { return f(3); }
|
||||
X int callback3_byte_byte_int (byte(*f)(byte)) { return f(3); }
|
||||
X byte callback3_int_int_byte (int(*f)(int)) { return f(3); }
|
||||
X byte callback3_byte_int_byte (int(*f)(byte)) { return f(3); }
|
||||
X byte callback3_int_byte_byte (byte(*f)(int)) { return f(3); }
|
||||
X byte callback3_byte_byte_byte (byte(*f)(byte)) { return f(3); }
|
||||
|
||||
int g2;
|
||||
int ho_return(int x) { return g2 + x; }
|
||||
void* ho(int(*f)(int), int x) { g2 = f(x); return ho_return; }
|
||||
X int g1;
|
||||
X int curry_ret_int_int (int x) { return g1 + x; }
|
||||
X int curry_ret_byte_int (byte x) { return g1 + x; }
|
||||
X byte curry_ret_int_byte (int x) { return g1 + x; }
|
||||
X byte curry_ret_byte_byte (byte x) { return g1 + x; }
|
||||
X void* curry_int_int_int (int x) { g1 = x; return &curry_ret_int_int; }
|
||||
X void* curry_byte_int_int (byte x) { g1 = x; return &curry_ret_int_int; }
|
||||
X void* curry_int_byte_int (int x) { g1 = x; return &curry_ret_byte_int; }
|
||||
X void* curry_byte_byte_int (byte x) { g1 = x; return &curry_ret_byte_int; }
|
||||
X void* curry_int_int_byte (int x) { g1 = x; return &curry_ret_int_byte; }
|
||||
X void* curry_byte_int_byte (byte x) { g1 = x; return &curry_ret_int_byte; }
|
||||
X void* curry_int_byte_byte (int x) { g1 = x; return &curry_ret_byte_byte; }
|
||||
X void* curry_byte_byte_byte(byte x) { g1 = x; return &curry_ret_byte_byte; }
|
||||
|
||||
X int g2;
|
||||
X int ho_return(int x) { return g2 + x; }
|
||||
X void* ho(int(*f)(int), int x) { g2 = f(x); return ho_return; }
|
||||
|
||||
void *g3 = NULL;
|
||||
int use_g3(int x) { return ((int(*)(int))g3)(x); }
|
||||
X void *g3 = NULL;
|
||||
X int use_g3(int x) { return ((int(*)(int))g3)(x); }
|
||||
|
||||
/* typedef int(*int2int)(int); */
|
||||
/* typedef int2int(*int_to_int2int)(int); */
|
||||
/* int hoho(int x, int_to_int2int f) { */
|
||||
int hoho(int x, int(*(*f)(int))(int)) { return (f(x+1))(x-1); }
|
||||
X int hoho(int x, int(*(*f)(int))(int)) { return (f(x+1))(x-1); }
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
(require (lib "foreign.ss"))
|
||||
(unsafe!)
|
||||
|
||||
(let ([big/little
|
||||
(if (system-big-endian?) (lambda (x y) x) (lambda (x y) y))]
|
||||
(let ([big/little (if (system-big-endian?) (lambda (x y) x) (lambda (x y) y))]
|
||||
[p (malloc _int32)])
|
||||
(ptr-set! p _int32 0)
|
||||
(test 0 ptr-ref p _int32)
|
||||
|
@ -18,17 +17,41 @@
|
|||
(test (big/little 2 3) ptr-ref p _int8 1)
|
||||
(test (big/little 3 2) ptr-ref p _int8 2)
|
||||
(test (big/little 4 1) ptr-ref p _int8 3))
|
||||
(flush-output)
|
||||
|
||||
(when (eq? 'windows (system-type))
|
||||
(let* ([concat string-append]
|
||||
[studio "c:/Program Files/Microsoft Visual Studio 8"]
|
||||
[scommon (concat studio "/Common7")]
|
||||
[vc (concat studio "/VC")])
|
||||
(putenv "PATH" (concat (getenv "PATH")
|
||||
";" vc "/bin"
|
||||
";" scommon "/IDE"
|
||||
";" scommon "/Tools"
|
||||
";" scommon "/Tools/bin"))
|
||||
(putenv "INCLUDE" (concat ";" vc "/include"
|
||||
";" vc "/atlmfc/include"
|
||||
";" vc "/PlatformSDK/Include"))
|
||||
(putenv "LIB" (concat ";" vc "/lib"
|
||||
";" vc "/atlmfc/lib"
|
||||
";" vc "/PlatformSDK/lib"))))
|
||||
|
||||
(require (lib "compile.ss" "dynext") (lib "link.ss" "dynext") (lib "etc.ss"))
|
||||
(let ([c (build-path (this-expression-source-directory) "foreign-test.c")]
|
||||
[o (build-path (current-directory) "foreign-test.o")]
|
||||
[so (build-path (current-directory) "foreign-test.so")])
|
||||
[so (build-path (current-directory)
|
||||
(string-append "foreign-test."
|
||||
(case (system-type)
|
||||
[(unix) "so"]
|
||||
[(macosx) "dylib"]
|
||||
[(windows) "dll"])))])
|
||||
(when (file-exists? o) (delete-file o))
|
||||
(when (file-exists? so) (delete-file so))
|
||||
(compile-extension #t c o '())
|
||||
(link-extension #t (list o) so))
|
||||
(parameterize ([current-standard-link-libraries '()])
|
||||
(compile-extension #t c o '())
|
||||
(link-extension #t (list o) so)))
|
||||
|
||||
(let* ([lib (ffi-lib "./foreign-test.so")]
|
||||
(let* ([lib (ffi-lib "./foreign-test")]
|
||||
[ffi (lambda (name type) (get-ffi-obj name lib type))]
|
||||
[test* (lambda (expected name type proc)
|
||||
(test expected name (proc (ffi name type))))]
|
||||
|
|
Loading…
Reference in New Issue
Block a user