[ ffi ] Fix missing structure declarations in scheme ffi

This commit is contained in:
Steve Dunham 2023-11-07 18:18:51 -08:00 committed by G. Allais
parent db4c5e7fbb
commit a945b5d2df
6 changed files with 20 additions and 3 deletions

View File

@ -365,7 +365,7 @@ mkStruct (CFStruct n flds)
showFld : (String, CFType) -> Core Builder
showFld (n, ty) = pure $ "[" ++ fromString n ++ " " ++ !(cftySpec emptyFC ty) ++ "]"
mkStruct (CFIORes t) = mkStruct t
mkStruct (CFFun a b) = do ignore (mkStruct a); mkStruct b
mkStruct (CFFun a b) = do [| mkStruct a ++ mkStruct b |]
mkStruct _ = pure ""
schFgnDef : {auto c : Ref Ctxt Defs} ->

View File

@ -328,7 +328,7 @@ mkStruct (CFStruct n flds)
showFld : (String, CFType) -> Core Builder
showFld (n, ty) = pure $ "(" ++ fromString n ++ " " ++ !(cftySpec emptyFC ty) ++ ")"
mkStruct (CFIORes t) = mkStruct t
mkStruct (CFFun a b) = do ignore (mkStruct a); mkStruct b
mkStruct (CFFun a b) = [| mkStruct a ++ mkStruct b |]
mkStruct _ = pure ""
schFgnDef : {auto c : Ref Ctxt Defs} ->

View File

@ -311,7 +311,7 @@ mkStruct (CFStruct n flds)
showFld : (String, CFType) -> Core Builder
showFld (n, ty) = pure $ "[" ++ fromString n ++ " " ++ !(cftySpec emptyFC ty) ++ "]"
mkStruct (CFIORes t) = mkStruct t
mkStruct (CFFun a b) = do ignore (mkStruct a); mkStruct b
mkStruct (CFFun a b) = [| mkStruct a ++ mkStruct b |]
mkStruct _ = pure ""
schFgnDef : {auto f : Ref Done (List String) } ->

View File

@ -0,0 +1,13 @@
import System.FFI
PtrAST : Type
PtrAST = Struct "AST" [("value", AnyPtr)]
%foreign "C:freeAST,foo"
prim_freeAST : (PtrAST -> Int) -> PrimIO ()
freeAST : HasIO io => (PtrAST -> Int) -> io ()
freeAST ast = primIO $ prim_freeAST ast
main : IO ()
main = freeAST (\x => 1)

View File

4
tests/allschemes/ffi001/run Executable file
View File

@ -0,0 +1,4 @@
. ../../testutils.sh
# Previously reported: unrecognized foreign-callable argument ftype name AST
idris2 -c Struct.idr -o out </dev/null