mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-19 09:49:33 -06:00
added readTriple in libsg and its Haskell binding
This commit is contained in:
@@ -219,6 +219,9 @@ foreign import ccall "pgf/expr.h pgf_expr_arity"
|
||||
foreign import ccall "pgf/expr.h pgf_print_expr"
|
||||
pgf_print_expr :: PgfExpr -> Ptr PgfPrintContext -> CInt -> Ptr GuOut -> Ptr GuExn -> IO ()
|
||||
|
||||
foreign import ccall "pgf/expr.h pgf_print_expr_tuple"
|
||||
pgf_print_expr_tuple :: CInt -> Ptr PgfExpr -> Ptr PgfPrintContext -> Ptr GuOut -> Ptr GuExn -> IO ()
|
||||
|
||||
foreign import ccall "pgf/pgf.h pgf_generate_all"
|
||||
pgf_generate_all :: Ptr PgfPGF -> CString -> Ptr GuExn -> Ptr GuPool -> Ptr GuPool -> IO (Ptr GuEnum)
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ module SG( SG, openSG, closeSG
|
||||
, beginTrans, commit, rollback, inTransaction
|
||||
, SgId
|
||||
, insertExpr, getExpr
|
||||
, readTriple, insertTriple, getTriple
|
||||
, readTriple, showTriple
|
||||
, insertTriple, getTriple
|
||||
, queryTriple
|
||||
) where
|
||||
|
||||
@@ -128,6 +129,21 @@ readTriple str =
|
||||
else do gu_pool_free exprPl
|
||||
return Nothing
|
||||
|
||||
showTriple :: Expr -> Expr -> Expr -> String
|
||||
showTriple (Expr expr1 _) (Expr expr2 _) (Expr expr3 _) =
|
||||
unsafePerformIO $
|
||||
withGuPool $ \tmpPl ->
|
||||
withTriple $ \triple -> do
|
||||
(sb,out) <- newOut tmpPl
|
||||
let printCtxt = nullPtr
|
||||
exn <- gu_new_exn tmpPl
|
||||
pokeElemOff triple 0 expr1
|
||||
pokeElemOff triple 1 expr2
|
||||
pokeElemOff triple 2 expr3
|
||||
pgf_print_expr_tuple 3 triple printCtxt out exn
|
||||
s <- gu_string_buf_freeze sb tmpPl
|
||||
peekCString s
|
||||
|
||||
insertTriple :: SG -> Expr -> Expr -> Expr -> IO SgId
|
||||
insertTriple (SG sg) (Expr expr1 _) (Expr expr2 _) (Expr expr3 _) =
|
||||
withGuPool $ \tmpPl ->
|
||||
|
||||
Reference in New Issue
Block a user