summaryrefslogtreecommitdiff
path: root/contrib/py-bindings/PyGF.hsc
diff options
context:
space:
mode:
authorjordi.saludes <jordi.saludes@upc.edu>2010-07-27 15:42:48 +0000
committerjordi.saludes <jordi.saludes@upc.edu>2010-07-27 15:42:48 +0000
commitdcac7254f3fc24cde44af516374b0b3ce3881481 (patch)
treec2e3f2cc6b702d38844e9b1529d6c75d2f51fa1c /contrib/py-bindings/PyGF.hsc
parentb9de5c36c0a62048abee457d89b994ebbeb7acf7 (diff)
Added 'functions' and 'functionType' to py-bindings.
Diffstat (limited to 'contrib/py-bindings/PyGF.hsc')
-rw-r--r--contrib/py-bindings/PyGF.hsc21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/py-bindings/PyGF.hsc b/contrib/py-bindings/PyGF.hsc
index 7b9991f3e..fc99d1a7d 100644
--- a/contrib/py-bindings/PyGF.hsc
+++ b/contrib/py-bindings/PyGF.hsc
@@ -1,4 +1,6 @@
{-# LANGUAGE ForeignFunctionInterface #-}
+-- GF Python bindings -- Jordi Saludes, upc.edu 2010
+
module PyGF where
import PGF
@@ -226,8 +228,27 @@ gf_inferexpr ppgf pexp ptype = do
let Right (_,t) = inferExpr pgf exp
poke ptype t
+
+foreign export ccall gf_functions :: Ptr PGF -> IO (Ptr ())
+gf_functions ppgf = do
+ pgf <- peek ppgf
+ listToPy pyCId $ functions pgf
+
+foreign export ccall gf_functiontype :: Ptr PGF -> Ptr CId -> IO (Ptr Type)
+gf_functiontype ppgf pcid = do
+ pgf <- peek ppgf
+ cid <- peek pcid
+ case functionType pgf cid of
+ Just t -> do
+ ptp <- pyType
+ poke ptp t
+ return ptp
+ _ -> return nullPtr
+
+
foreign import ccall "newLang" pyLang :: IO (Ptr Language)
foreign import ccall "newTree" pyTree :: IO (Ptr Tree)
+foreign import ccall "newgfType" pyType :: IO (Ptr Type)
foreign import ccall "newCId" pyCId :: IO (Ptr CId)
foreign import ccall "newExpr" pyExpr :: IO (Ptr Expr)
foreign import ccall "newList" pyList :: IO (Ptr ())