Commit 4543b6c5 authored by simonmar's avatar simonmar

[project @ 2004-10-18 13:37:56 by simonmar]

Add stdcall test
parent cbd9f01a
...@@ -51,3 +51,4 @@ test('ffi009', ways ,compile_and_run, ['']) ...@@ -51,3 +51,4 @@ test('ffi009', ways ,compile_and_run, [''])
test('ffi010', expect_fail_for(['extcore','optextcore']), compile_and_run, ['']) test('ffi010', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
test('ffi011', normal, compile_and_run, ['']) test('ffi011', normal, compile_and_run, [''])
test('ffi012', normal, compile_and_run, [''])
-- !!! Same as ffi006, but using the stdcall calling convention.
import Foreign
import Foreign.C
type IOF = Int -> IO Int
type F = Int -> Int
foreign import stdcall "wrapper" wrap_f :: F -> IO (FunPtr F)
foreign import stdcall "wrapper" wrap_f_io :: IOF -> IO (FunPtr IOF)
foreign import stdcall "dynamic" f :: FunPtr F -> F
foreign import stdcall "dynamic" f_io :: FunPtr IOF -> IOF
double :: Int -> Int
double x = x * 2
double_io :: Int -> IO Int
double_io x = return (x * 2)
main = do
double1 <- wrap_f double
print (f double1 42)
double2 <- wrap_f_io double_io
x <- f_io double2 42
print x
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment