From 0da8e90ad4d1a675040c3441b407c9f0503eb506 Mon Sep 17 00:00:00 2001 From: Chris Zhang Date: Thu, 10 Jul 2014 11:15:12 -0700 Subject: [PATCH] Adding initExpect. --- System/Expect/ExpectBindings.hsc | 6 ++++++ System/Expect/ExpectInterface.hs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/System/Expect/ExpectBindings.hsc b/System/Expect/ExpectBindings.hsc index 5367fea..57066fc 100644 --- a/System/Expect/ExpectBindings.hsc +++ b/System/Expect/ExpectBindings.hsc @@ -43,3 +43,9 @@ foreign import ccall "&" exp_loguser :: Ptr CInt foreign import ccall exp_popen :: CString -> IO (Ptr CFile) foreign import ccall exp_fexpectv :: Ptr CFile -> Ptr ExpCase -> IO CInt + +data TCL_Interp = TCL_Interp + +foreign import ccall "Tcl_Init" tcl_Init :: Ptr TCL_Interp -> IO () +foreign import ccall "Expect_Init" expect_Init :: Ptr TCL_Interp -> IO () +foreign import ccall "Tcl_CreateInterp" tcl_CreateInterp :: IO (Ptr TCL_Interp) diff --git a/System/Expect/ExpectInterface.hs b/System/Expect/ExpectInterface.hs index 39ee878..1b29c47 100644 --- a/System/Expect/ExpectInterface.hs +++ b/System/Expect/ExpectInterface.hs @@ -5,6 +5,7 @@ module System.Expect.ExpectInterface ({-- The contents of the binding that are to be further exposed --} ExpectType(ExpExact,ExpRegex,ExpGlob,ExpNull) {-- The custom interface --} + ,initExpect ,ExpectCase(ExpectCase,expectPattern,expectType,expectValue) ,ExpectProc(ExpectProc,expectHandle,expectFilePtr) ,muteExpect,unmuteExpect @@ -40,6 +41,13 @@ data ExpectCase = ExpectCase { -- | Pattern to match against. , expectValue :: Int } +-- | tcl and expect initialization. +initExpect :: IO () +initExpect = do + interp <- tcl_CreateInterp + tcl_Init interp + expect_Init interp + -- | Proc created by spawnExpect. Contains both the -- CFile pointer and a Haskell handle, so the -- translation needs only be done once.