From 85cf2d9f5a1018219beb51c1172842cddda1f544 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Tue, 5 Sep 2017 09:50:29 +0200 Subject: added exprSize in the Haskell binding --- src/runtime/haskell-bind/PGF2.hsc | 10 ++++++++-- src/runtime/haskell-bind/PGF2/FFI.hs | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/runtime/haskell-bind') diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc index f2f1b4113..4990a1926 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, + exprHash, exprSize, treeProbability, -- ** Types @@ -331,7 +331,13 @@ exprHash h (Expr c_expr touch1) = touch1 return (fromIntegral h) - +exprSize :: Expr -> Int32 +exprSize (Expr c_expr touch1) = + unsafePerformIO $ do + size <- pgf_expr_size c_expr + touch1 + return (fromIntegral size) + ----------------------------------------------------------------------------- -- Graphviz diff --git a/src/runtime/haskell-bind/PGF2/FFI.hs b/src/runtime/haskell-bind/PGF2/FFI.hs index ce4dd6983..85c3a9793 100644 --- a/src/runtime/haskell-bind/PGF2/FFI.hs +++ b/src/runtime/haskell-bind/PGF2/FFI.hs @@ -331,6 +331,9 @@ foreign import ccall "pgf/expr.h pgf_expr_eq" foreign import ccall "pgf/expr.h pgf_expr_hash" pgf_expr_hash :: Word -> PgfExpr -> IO Word +foreign import ccall "pgf/expr.h pgf_expr_size" + pgf_expr_size :: PgfExpr -> IO CInt + foreign import ccall "pgf/expr.h pgf_compute_tree_probability" pgf_compute_tree_probability :: Ptr PgfPGF -> PgfExpr -> IO CFloat -- cgit v1.2.3