summaryrefslogtreecommitdiff
path: root/src/runtime/haskell-bind/SG
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2015-09-02 07:12:36 +0000
committerkrasimir <krasimir@chalmers.se>2015-09-02 07:12:36 +0000
commit73b41687c8038ee69562fafd0693204509621c79 (patch)
tree92b6253470d1a57a3409ed40015cea1446763062 /src/runtime/haskell-bind/SG
parent4a1da62d841cb63dd4671dd3d46a4e150dd26485 (diff)
added the minimal Haskell API for storing expressions/triples in the semantic graph
Diffstat (limited to 'src/runtime/haskell-bind/SG')
-rw-r--r--src/runtime/haskell-bind/SG/FFI.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/runtime/haskell-bind/SG/FFI.hs b/src/runtime/haskell-bind/SG/FFI.hs
new file mode 100644
index 000000000..2874082bb
--- /dev/null
+++ b/src/runtime/haskell-bind/SG/FFI.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE ForeignFunctionInterface, MagicHash #-}
+module SG.FFI where
+
+import Foreign
+import Foreign.C
+import PGF2.FFI
+import GHC.Ptr
+import Data.Int
+
+data SgSG
+type SgId = Int64
+
+foreign import ccall "sg/sg.h sg_open"
+ sg_open :: CString -> Ptr GuExn -> IO (Ptr SgSG)
+
+foreign import ccall "sg/sg.h sg_close"
+ sg_close :: Ptr SgSG -> Ptr GuExn -> IO ()
+
+foreign import ccall "sg/sg.h sg_begin_trans"
+ sg_begin_trans :: Ptr SgSG -> Ptr GuExn -> IO ()
+
+foreign import ccall "sg/sg.h sg_commit"
+ sg_commit :: Ptr SgSG -> Ptr GuExn -> IO ()
+
+foreign import ccall "sg/sg.h sg_rollback"
+ sg_rollback :: Ptr SgSG -> Ptr GuExn -> IO ()
+
+foreign import ccall "sg/sg.h sg_insert_expr"
+ sg_insert_expr :: Ptr SgSG -> PgfExpr -> Ptr GuExn -> IO SgId
+
+foreign import ccall "sg/sg.h sg_insert_triple"
+ sg_insert_triple :: Ptr SgSG -> SgTriple -> Ptr GuExn -> IO SgId
+
+type SgTriple = Ptr SgId
+
+withTriple :: (SgTriple -> IO a) -> IO a
+withTriple = allocaArray 3
+
+gu_exn_type_SgError = Ptr "SgError"# :: CString