I can't figure out what's wrong with the following code, so it's
hopefully a bug in GreenCard: :-)
-- Foo.gc -------------------------------------------------------------
module Foo where
import StdDIS
type CallbackList = [(Char,IO ())]
%dis callbackList x = stable x
%fun createCbackList :: CallbackList -> IO ()
%code cbackList = arg1;
%fun getCbackList :: IO CallbackList
%result (callbackList {cbackList})
-----------------------------------------------------------------------
panne@liesl: > /home/inst/panne/green-card/src/green-card --target ghc Foo.gc
"./Foo.gc", proc. spec "getCbackList", line 11:
Don't know how to unmarshall (declare { int } {cbackList} in (<<makeStablePtr
/deRefStablePtr / %%Int>> {cbackList}))
And here an example from the GreenCard docs:
-- Foo.gc -------------------------------------------------------------
module Foo where
import StdDIS
%fun foo :: Int -> IO ()
%call (declare {unsigned int} x in (int x))
data T = MkT Int
%fun faz :: T -> IO ()
%call (declare {c_t} x in MkT (int x))
-----------------------------------------------------------------------
And here is the generated program:
-- Foo.hs -------------------------------------------------------------
module Foo where
import StdDIS
data T = MkT Int
foo :: Int -> IO ()
foo x =
_casm_ ``do {unsigned int x; int x;
x = %0;
do {foo(x);} while(0);} while(0);'' x
faz :: T -> IO ()
faz gc_arg1 =
case gc_arg1 of { (MkT x) ->
_casm_ ``do {c_t x; int x;
x = %0;
do {faz(x);} while(0);} while(0);'' x}
-----------------------------------------------------------------------
Note the repeated definitions of x... :-(
--
Sven Panne Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen Oettingenstr. 67
mailto:[EMAIL PROTECTED] D-80538 Muenchen
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne