From 30b7ba04c701ef156992eb53a7b65accebfa9f21 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Tue, 5 Sep 2017 10:07:43 +0200 Subject: added exprFunctions in the Haskell binding --- src/runtime/haskell-bind/PGF2.hsc | 12 +++++++++++- src/runtime/haskell-bind/PGF2/FFI.hs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/runtime/haskell-bind') diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc index 4990a1926..dfddb9708 100644 --- a/src/runtime/haskell-bind/PGF2.hsc +++ b/src/runtime/haskell-bind/PGF2.hsc @@ -39,7 +39,7 @@ module PGF2 (-- * PGF mkFloat,unFloat, mkMeta,unMeta, mkCId, - exprHash, exprSize, + exprHash, exprSize, exprFunctions, treeProbability, -- ** Types @@ -338,6 +338,16 @@ exprSize (Expr c_expr touch1) = touch1 return (fromIntegral size) +exprFunctions :: Expr -> [Fun] +exprFunctions (Expr c_expr touch) = + unsafePerformIO $ + withGuPool $ \tmpPl -> do + seq <- pgf_expr_functions c_expr tmpPl + len <- (#peek GuSeq, len) seq + arr <- peekArray (fromIntegral (len :: CInt)) (seq `plusPtr` (#offset GuSeq, data)) + funs <- mapM peekUtf8CString arr + touch + return funs ----------------------------------------------------------------------------- -- Graphviz diff --git a/src/runtime/haskell-bind/PGF2/FFI.hs b/src/runtime/haskell-bind/PGF2/FFI.hs index 85c3a9793..a47655d8d 100644 --- a/src/runtime/haskell-bind/PGF2/FFI.hs +++ b/src/runtime/haskell-bind/PGF2/FFI.hs @@ -334,6 +334,9 @@ foreign import ccall "pgf/expr.h pgf_expr_hash" foreign import ccall "pgf/expr.h pgf_expr_size" pgf_expr_size :: PgfExpr -> IO CInt +foreign import ccall "pgf/expr.h pgf_expr_functions" + pgf_expr_functions :: PgfExpr -> Ptr GuPool -> IO (Ptr GuSeq) + foreign import ccall "pgf/expr.h pgf_compute_tree_probability" pgf_compute_tree_probability :: Ptr PgfPGF -> PgfExpr -> IO CFloat -- cgit v1.2.3