From: <cod...@go...> - 2008-11-01 11:29:29
|
Author: wol...@gm... Date: Sat Nov 1 04:27:26 2008 New Revision: 348 Modified: trunk/hoc/Bindings/AdditionalCode/AppKit/NSApplication.hs trunk/hoc/HOC/HOC/Arguments.hs trunk/hoc/HOC/HOC/Base.hs trunk/hoc/HOC/HOC/CannedCIFs.hs trunk/hoc/HOC/HOC/Class.hs trunk/hoc/HOC/HOC/DeclareSelector.hs trunk/hoc/HOC/HOC/Dyld.hs trunk/hoc/HOC/HOC/Exception.hs trunk/hoc/HOC/HOC/ExportClass.hs trunk/hoc/HOC/HOC/ExternConstants.hs trunk/hoc/HOC/HOC/ExternFunctions.hs trunk/hoc/HOC/HOC/FFICallInterface.hs trunk/hoc/HOC/HOC/ID.hs trunk/hoc/HOC/HOC/MessageTarget.hs trunk/hoc/HOC/HOC/MsgSend.hs trunk/hoc/HOC/HOC/NewClass.hs trunk/hoc/HOC/HOC/NewlyAllocated.hs trunk/hoc/HOC/HOC/SelectorMarshaller.hs trunk/hoc/HOC/HOC/StdArgumentTypes.hs trunk/hoc/HOC/HOC/Super.hs trunk/hoc/HOC/HOC/TH.hs trunk/hoc/HOC/HOC/Utilities.hs trunk/hoc/InterfaceGenerator/Enums.hs trunk/hoc/InterfaceGenerator2/Preprocessor.hs trunk/hoc/Tests/TestPreprocessor.hs Log: Cleanup whitespace (remove tabs) Use {-# LANGUAGE #-} in individual files instead of gobally enabling tons of extensions Modified: trunk/hoc/Bindings/AdditionalCode/AppKit/NSApplication.hs ============================================================================== --- trunk/hoc/Bindings/AdditionalCode/AppKit/NSApplication.hs (original) +++ trunk/hoc/Bindings/AdditionalCode/AppKit/NSApplication.hs Sat Nov 1 04:27:26 2008 @@ -8,12 +8,12 @@ -- CUT HERE foreign import ccall "NSApplicationMain" c_nsApplicationMain - :: CInt -> Ptr CString -> IO CInt + :: CInt -> Ptr CString -> IO CInt nsApplicationMain2 prog args = - withMany withCString (prog : args) $ \argvPtrs -> - withArray0 nullPtr argvPtrs $ \argvBuf -> - c_nsApplicationMain (1 + (fromIntegral $ length args)) argvBuf + withMany withCString (prog : args) $ \argvPtrs -> + withArray0 nullPtr argvPtrs $ \argvBuf -> + c_nsApplicationMain (1 + (fromIntegral $ length args)) argvBuf nsApplicationMain_ = do prog <- getProgName Modified: trunk/hoc/HOC/HOC/Arguments.hs ============================================================================== --- trunk/hoc/HOC/HOC/Arguments.hs (original) +++ trunk/hoc/HOC/HOC/Arguments.hs Sat Nov 1 04:27:26 2008 @@ -1,4 +1,6 @@ -{-# OPTIONS -fallow-undecidable-instances #-} +{-# LANGUAGE TemplateHaskell, EmptyDataDecls, + MultiParamTypeClasses, FunctionalDependencies, + UndecidableInstances, ScopedTypeVariables #-} module HOC.Arguments where import HOC.Base Modified: trunk/hoc/HOC/HOC/Base.hs ============================================================================== --- trunk/hoc/HOC/HOC/Base.hs (original) +++ trunk/hoc/HOC/HOC/Base.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls, GeneralizedNewtypeDeriving #-} module HOC.Base where import Foreign @@ -37,24 +38,3 @@ -- data ObjCObject - -{- -newtype ID a = ID (ForeignPtr ObjCObject) - -{- moved to Arguments.hs -class Object a where - toID :: a -> ID () - -instance Object (ID a) where - toID (ID a) = ID a --} - -castObject (ID a) = ID a - -instance Eq (ID a) where - (ID a) == (ID b) = a == b --} - --- - - Modified: trunk/hoc/HOC/HOC/CannedCIFs.hs ============================================================================== --- trunk/hoc/HOC/HOC/CannedCIFs.hs (original) +++ trunk/hoc/HOC/HOC/CannedCIFs.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} module HOC.CannedCIFs where import HOC.Base ( SEL ) Modified: trunk/hoc/HOC/HOC/Class.hs ============================================================================== --- trunk/hoc/HOC/HOC/Class.hs (original) +++ trunk/hoc/HOC/HOC/Class.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,6 @@ +{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls, + MultiParamTypeClasses, FunctionalDependencies, + TypeSynonymInstances #-} module HOC.Class where import HOC.Base @@ -18,13 +21,13 @@ foreign import ccall unsafe "Class.h getClassByName" - c_getClassByName :: CString -> IO (Ptr ObjCObject) - + c_getClassByName :: CString -> IO (Ptr ObjCObject) + getClassByName name = withCString name c_getClassByName - + {-# NOINLINE unsafeGetClassObject #-} -- called from generated code, save space unsafeGetClassObject name = unsafePerformIO $ - getClassByName name >>= importImmortal + getClassByName name >>= importImmortal Modified: trunk/hoc/HOC/HOC/DeclareSelector.hs ============================================================================== --- trunk/hoc/HOC/HOC/DeclareSelector.hs (original) +++ trunk/hoc/HOC/HOC/DeclareSelector.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell, EmptyDataDecls #-} module HOC.DeclareSelector where import HOC.Base @@ -248,8 +249,8 @@ -- $(infoName) = ... valD (varP $ mkName $ infoName) (normalB [| - let n = $(stringE name) - in $(selInfoMaker) n + let n = $(stringE name) + in $(selInfoMaker) n $(if haskellName == name then [|n|] else stringE haskellName) @@ -280,7 +281,7 @@ else valD (varP $ mkName haskellName) (normalB [| $(varE $ marshallerName nArgs isUnit `fromSameModuleAs_v` - 'marshallersUpTo + 'marshallersUpTo ) $(varE $ mkName infoName) |]) [] Modified: trunk/hoc/HOC/HOC/Dyld.hs ============================================================================== --- trunk/hoc/HOC/HOC/Dyld.hs (original) +++ trunk/hoc/HOC/HOC/Dyld.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE MagicHash #-} module HOC.Dyld( lookupSymbol, lookupSymbol# Modified: trunk/hoc/HOC/HOC/Exception.hs ============================================================================== --- trunk/hoc/HOC/HOC/Exception.hs (original) +++ trunk/hoc/HOC/HOC/Exception.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE ForeignFunctionInterface, DeriveDataTypeable #-} module HOC.Exception where import Data.Typeable Modified: trunk/hoc/HOC/HOC/ExportClass.hs ============================================================================== --- trunk/hoc/HOC/HOC/ExportClass.hs (original) +++ trunk/hoc/HOC/HOC/ExportClass.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FunctionalDependencies #-} module HOC.ExportClass where import Foreign @@ -60,11 +61,11 @@ exportClass :: String -- ^ Name of class you're exporting, e.g. "MyDocument" -> String -- ^ A prefix for function names which are methods - -- belonging to this class, e.g. "md_" - -> [ClassMember] -- ^ A list of class members, such as outlets - -- and instance variables - -> Q [Dec] -- ^ A Haskell declaration, which can be spliced in - -- with Template Haskell's $(...) syntax + -- belonging to this class, e.g. "md_" + -> [ClassMember] -- ^ A list of class members, such as outlets + -- and instance variables + -> Q [Dec] -- ^ A Haskell declaration, which can be spliced in + -- with Template Haskell's $(...) syntax exportClass name prefix members = sequence $ [ sigD (mkName exportFunName) [t| IO () |], valD (varP $ mkName exportFunName) Modified: trunk/hoc/HOC/HOC/ExternConstants.hs ============================================================================== --- trunk/hoc/HOC/HOC/ExternConstants.hs (original) +++ trunk/hoc/HOC/HOC/ExternConstants.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell, MagicHash #-} module HOC.ExternConstants(declareExternConst) where import HOC.TH @@ -10,20 +11,20 @@ declareExternConst :: String -> TypeQ -> Q [Dec] declareExternConst name typ - = sequence [ - sigD n typ, - valD (varP n) (normalB expr) [] - ] - where - n = mkName $ nameToLowercase name - expr = [| getGlobalVar $(stringE name) |] + = sequence [ + sigD n typ, + valD (varP n) (normalB expr) [] + ] + where + n = mkName $ nameToLowercase name + expr = [| getGlobalVar $(stringE name) |] getGlobalVar name = unsafePerformIO $ - lookupSymbol name - >>= peek . castFunPtrToPtr - >>= importArgument + lookupSymbol name + >>= peek . castFunPtrToPtr + >>= importArgument getGlobalVar# name# = unsafePerformIO $ - lookupSymbol# name# - >>= peek . castFunPtrToPtr - >>= importArgument \ No newline at end of file + lookupSymbol# name# + >>= peek . castFunPtrToPtr + >>= importArgument \ No newline at end of file Modified: trunk/hoc/HOC/HOC/ExternFunctions.hs ============================================================================== --- trunk/hoc/HOC/HOC/ExternFunctions.hs (original) +++ trunk/hoc/HOC/HOC/ExternFunctions.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} module HOC.ExternFunctions(declareExternFun) where import HOC.TH Modified: trunk/hoc/HOC/HOC/FFICallInterface.hs ============================================================================== --- trunk/hoc/HOC/HOC/FFICallInterface.hs (original) +++ trunk/hoc/HOC/HOC/FFICallInterface.hs Sat Nov 1 04:27:26 2008 @@ -1,11 +1,12 @@ +{-# LANGUAGE ForeignFunctionInterface, FlexibleContexts, GeneralizedNewtypeDeriving #-} module HOC.FFICallInterface( - FFICif, - FFIType, - FFITypeable(..), - ffiPrepCif, - makeStructType, - cifIsStret - ) where + FFICif, + FFIType, + FFITypeable(..), + ffiPrepCif, + makeStructType, + cifIsStret + ) where import Foreign.C.Types import Foreign @@ -73,11 +74,11 @@ foreign import ccall unsafe cifIsStret :: FFICif -> IO CInt promotedPeek p - = peek (castPtr p :: Ptr CLong) >>= return . fromIntegral - where - size = sizeOf (pointee p) - pointee :: Ptr p -> p - pointee = undefined + = peek (castPtr p :: Ptr CLong) >>= return . fromIntegral + where + size = sizeOf (pointee p) + pointee :: Ptr p -> p + pointee = undefined promotedAlloca f = alloca (\intPtr -> f $ castPtr (intPtr :: Ptr CLong)) @@ -104,7 +105,7 @@ instance FFITypeable Int32 where makeFFIType _ = return ffi_type_sint32 - peekRetval = promotedPeek -- only takes effect on 64-bit + peekRetval = promotedPeek -- only takes effect on 64-bit allocaRetval = promotedAlloca instance FFITypeable Int64 where @@ -125,7 +126,7 @@ instance FFITypeable Word32 where makeFFIType _ = return ffi_type_uint32 - peekRetval = promotedPeek -- only takes effect on 64-bit + peekRetval = promotedPeek -- only takes effect on 64-bit allocaRetval = promotedAlloca instance FFITypeable Word64 where Modified: trunk/hoc/HOC/HOC/ID.hs ============================================================================== --- trunk/hoc/HOC/HOC/ID.hs (original) +++ trunk/hoc/HOC/HOC/ID.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,5 @@ +{-# LANGUAGE ForeignFunctionInterface, RecursiveDo, + MultiParamTypeClasses, FlexibleInstances #-} module HOC.ID where import HOC.Base Modified: trunk/hoc/HOC/HOC/MessageTarget.hs ============================================================================== --- trunk/hoc/HOC/HOC/MessageTarget.hs (original) +++ trunk/hoc/HOC/HOC/MessageTarget.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE FlexibleContexts #-} module HOC.MessageTarget where import HOC.Base Modified: trunk/hoc/HOC/HOC/MsgSend.hs ============================================================================== --- trunk/hoc/HOC/HOC/MsgSend.hs (original) +++ trunk/hoc/HOC/HOC/MsgSend.hs Sat Nov 1 04:27:26 2008 @@ -1,4 +1,4 @@ -{-# OPTIONS -cpp #-} +{-# LANGUAGE CPP, ForeignFunctionInterface #-} module HOC.MsgSend( objSendMessageWithRetval, objSendMessageWithoutRetval, @@ -15,24 +15,24 @@ import Control.Monad.Fix(mfix) objSendMessageWithRetval - :: ObjCArgument a b + :: ObjCArgument a b => FFICif -> Ptr (Ptr ()) -> IO a objSendMessageWithoutRetval - :: FFICif + :: FFICif -> Ptr (Ptr ()) -> IO () superSendMessageWithRetval - :: ObjCArgument a b + :: ObjCArgument a b => FFICif -> Ptr (Ptr ()) -> IO a superSendMessageWithoutRetval - :: FFICif + :: FFICif -> Ptr (Ptr ()) -> IO () @@ -65,9 +65,9 @@ #else - -- the type signatures are essentially bogus - -- the return value is not necessarily (), and might even be a struct. - -- we only call them via libffi, so we couldn't care less. + -- the type signatures are essentially bogus + -- the return value is not necessarily (), and might even be a struct. + -- we only call them via libffi, so we couldn't care less. foreign import ccall "MsgSend.h &objc_msgSend" objc_msgSendPtr :: FunPtr (Ptr ObjCObject -> SEL -> IO ()) foreign import ccall "MsgSend.h &objc_msgSend_stret" @@ -82,22 +82,22 @@ withMarshalledDummy action = action undefined objSendMessageWithRetval cif args = - withMarshalledDummy $ \dummy -> - cifIsStret cif >>= \isStret -> - callWithRetval cif (if isStret /= 0 + withMarshalledDummy $ \dummy -> + cifIsStret cif >>= \isStret -> + callWithRetval cif (if isStret /= 0 then objc_msgSend_stretPtr - else objc_msgSendPtr) args + else objc_msgSendPtr) args objSendMessageWithoutRetval cif args = callWithoutRetval cif objc_msgSendPtr args superSendMessageWithRetval cif args = - withMarshalledDummy $ \dummy -> - cifIsStret cif >>= \isStret -> - callWithRetval cif (if isStret /= 0 + withMarshalledDummy $ \dummy -> + cifIsStret cif >>= \isStret -> + callWithRetval cif (if isStret /= 0 then objc_msgSendSuper_stretPtr - else objc_msgSendSuperPtr) args + else objc_msgSendSuperPtr) args superSendMessageWithoutRetval cif args = callWithoutRetval cif objc_msgSendSuperPtr args Modified: trunk/hoc/HOC/HOC/NewClass.hs ============================================================================== --- trunk/hoc/HOC/HOC/NewClass.hs (original) +++ trunk/hoc/HOC/HOC/NewClass.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE ForeignFunctionInterface #-} module HOC.NewClass( IMP, MethodList, Modified: trunk/hoc/HOC/HOC/NewlyAllocated.hs ============================================================================== --- trunk/hoc/HOC/HOC/NewlyAllocated.hs (original) +++ trunk/hoc/HOC/HOC/NewlyAllocated.hs Sat Nov 1 04:27:26 2008 @@ -1,4 +1,4 @@ -{-# OPTIONS -fallow-undecidable-instances #-} +{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances #-} module HOC.NewlyAllocated where {- Modified: trunk/hoc/HOC/HOC/SelectorMarshaller.hs ============================================================================== --- trunk/hoc/HOC/HOC/SelectorMarshaller.hs (original) +++ trunk/hoc/HOC/HOC/SelectorMarshaller.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE MagicHash, TemplateHaskell #-} module HOC.SelectorMarshaller( SelectorInfo(..), mkSelectorInfo, @@ -19,7 +20,7 @@ import Foreign ( withArray, Ptr, nullPtr ) import System.IO.Unsafe ( unsafePerformIO ) -import GHC.Base ( unpackCString# ) +import GHC.Base ( unpackCString# ) import HOC.TH @@ -33,38 +34,38 @@ {-# NOINLINE mkSelectorInfo #-} mkSelectorInfo objCName hsName cif - = SelectorInfo objCName hsName cif (getSelectorForName objCName) False + = SelectorInfo objCName hsName cif (getSelectorForName objCName) False {-# NOINLINE mkSelectorInfo# #-} mkSelectorInfo# objCName# hsName# cif - -- NOTE: Don't call mkSelectorInfo here, the rule would apply! - = SelectorInfo objCName hsName cif (getSelectorForName objCName) False - where - objCName = unpackCString# objCName# - hsName = unpackCString# hsName# + -- NOTE: Don't call mkSelectorInfo here, the rule would apply! + = SelectorInfo objCName hsName cif (getSelectorForName objCName) False + where + objCName = unpackCString# objCName# + hsName = unpackCString# hsName# {-# RULES "litstr" forall s1 s2 cif. - mkSelectorInfo (unpackCString# s1) (unpackCString# s2) cif - = mkSelectorInfo# s1 s2 cif + mkSelectorInfo (unpackCString# s1) (unpackCString# s2) cif + = mkSelectorInfo# s1 s2 cif #-} {-# NOINLINE mkSelectorInfoRetained #-} mkSelectorInfoRetained objCName hsName cif - = SelectorInfo objCName hsName cif (getSelectorForName objCName) True + = SelectorInfo objCName hsName cif (getSelectorForName objCName) True {-# NOINLINE mkSelectorInfoRetained# #-} mkSelectorInfoRetained# objCName# hsName# cif - -- NOTE: Don't call mkSelectorInfo here, the rule would apply! - = SelectorInfo objCName hsName cif (getSelectorForName objCName) True - where - objCName = unpackCString# objCName# - hsName = unpackCString# hsName# + -- NOTE: Don't call mkSelectorInfo here, the rule would apply! + = SelectorInfo objCName hsName cif (getSelectorForName objCName) True + where + objCName = unpackCString# objCName# + hsName = unpackCString# hsName# {-# RULES "litstr" forall s1 s2 cif. - mkSelectorInfoRetained (unpackCString# s1) (unpackCString# s2) cif - = mkSelectorInfoRetained# s1 s2 cif + mkSelectorInfoRetained (unpackCString# s1) (unpackCString# s2) cif + = mkSelectorInfoRetained# s1 s2 cif #-} @@ -105,13 +106,13 @@ $(lamE [varP $ mkName "args"] e) |] invoke | isUnit = [| sendMessageWithoutRetval $(targetVar) - (selectorInfoCif $(infoVar)) + (selectorInfoCif $(infoVar)) $(argsVar)|] | otherwise = [| sendMessageWithRetval $(targetVar) - (selectorInfoCif $(infoVar)) + (selectorInfoCif $(infoVar)) $(argsVar)|] where argsVar = varE $ mkName "args" - targetVar = varE $ mkName "target" + targetVar = varE $ mkName "target" purify e | isPure = [| unsafePerformIO $(e) |] | otherwise = e Modified: trunk/hoc/HOC/HOC/StdArgumentTypes.hs ============================================================================== --- trunk/hoc/HOC/HOC/StdArgumentTypes.hs (original) +++ trunk/hoc/HOC/HOC/StdArgumentTypes.hs Sat Nov 1 04:27:26 2008 @@ -1,4 +1,7 @@ -{-# OPTIONS -fallow-undecidable-instances #-} +{-# LANGUAGE TemplateHaskell, ForeignFunctionInterface, + MultiParamTypeClasses, UndecidableInstances, + TypeSynonymInstances, FlexibleInstances, + ScopedTypeVariables #-} module HOC.StdArgumentTypes where import HOC.Base @@ -83,6 +86,6 @@ autoreleaseObject nsstr return nsstr importArgument arg = nsStringToUTF8 arg >>= peekArray0 0 - >>= return . utf8ToUnicode + >>= return . utf8ToUnicode objCTypeString _ = "*" Modified: trunk/hoc/HOC/HOC/Super.hs ============================================================================== --- trunk/hoc/HOC/HOC/Super.hs (original) +++ trunk/hoc/HOC/HOC/Super.hs Sat Nov 1 04:27:26 2008 @@ -1,4 +1,5 @@ -{-# OPTIONS -fallow-undecidable-instances #-} +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + UndecidableInstances, FlexibleInstances #-} module HOC.Super( SuperClass, SuperTarget, Super(super), withExportedSuper ) where Modified: trunk/hoc/HOC/HOC/TH.hs ============================================================================== --- trunk/hoc/HOC/HOC/TH.hs (original) +++ trunk/hoc/HOC/HOC/TH.hs Sat Nov 1 04:27:26 2008 @@ -41,6 +41,6 @@ fromSameModule :: NameSpace -> String -> Name -> Name fromSameModule ns s n = Name (mkOccName s) $ - case n of - Name _ (NameG _ pkg mod) -> NameG ns pkg mod - Name _ other -> other + case n of + Name _ (NameG _ pkg mod) -> NameG ns pkg mod + Name _ other -> other Modified: trunk/hoc/HOC/HOC/Utilities.hs ============================================================================== --- trunk/hoc/HOC/HOC/Utilities.hs (original) +++ trunk/hoc/HOC/HOC/Utilities.hs Sat Nov 1 04:27:26 2008 @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} module HOC.Utilities where import HOC.Base Modified: trunk/hoc/InterfaceGenerator/Enums.hs ============================================================================== --- trunk/hoc/InterfaceGenerator/Enums.hs (original) +++ trunk/hoc/InterfaceGenerator/Enums.hs Sat Nov 1 04:27:26 2008 @@ -69,15 +69,15 @@ (map (nameToLowercase . fst) constants) pprEnumType (EnumType name constants) = - char '$' <> parens ( - declare - <+> brackets ( - hcat $ punctuate comma $ map pprAssoc constants - ) - ) - where - declare = case name of - Just cname -> text "declareCEnum" <+> doubleQuotes (text cname) - Nothing -> text "declareAnonymousCEnum" - pprAssoc (n, v) - = parens (doubleQuotes (text n) <> comma <+> integer v) + char '$' <> parens ( + declare + <+> brackets ( + hcat $ punctuate comma $ map pprAssoc constants + ) + ) + where + declare = case name of + Just cname -> text "declareCEnum" <+> doubleQuotes (text cname) + Nothing -> text "declareAnonymousCEnum" + pprAssoc (n, v) + = parens (doubleQuotes (text n) <> comma <+> integer v) Modified: trunk/hoc/InterfaceGenerator2/Preprocessor.hs ============================================================================== --- trunk/hoc/InterfaceGenerator2/Preprocessor.hs (original) +++ trunk/hoc/InterfaceGenerator2/Preprocessor.hs Sat Nov 1 04:27:26 2008 @@ -70,10 +70,10 @@ return (get >>= return . maybe 0 id . Map.lookup x) optable = [ [Infix (op "*" (*)) AssocLeft, - Infix (op "/" div) AssocLeft], - [Infix (op "+" (+)) AssocLeft, - Infix (op "-" (-)) AssocLeft], - [Infix (bop "<" (<)) AssocLeft, + Infix (op "/" div) AssocLeft], + [Infix (op "+" (+)) AssocLeft, + Infix (op "-" (-)) AssocLeft], + [Infix (bop "<" (<)) AssocLeft, Infix (bop "<=" (<=)) AssocLeft, Infix (bop "==" (==)) AssocLeft, Infix (bop "!=" (/=)) AssocLeft, Modified: trunk/hoc/Tests/TestPreprocessor.hs ============================================================================== --- trunk/hoc/Tests/TestPreprocessor.hs (original) +++ trunk/hoc/Tests/TestPreprocessor.hs Sat Nov 1 04:27:26 2008 @@ -10,132 +10,132 @@ a ==> b = rstrip (preprocess "test" a) ~?= rstrip b success a = (filter interesting $ lines $ preprocess "test" a) ~?= ["success"] - where - interesting ('/' : '/' : _ ) = False - interesting other | all isSpace other = False - | otherwise = True + where + interesting ('/' : '/' : _ ) = False + interesting other | all isSpace other = False + | otherwise = True tests = "TestPreprocessor" ~: test [ - "empty" ~: "" ==> "", - - "plainLines" ~: - let txt = "asfljkaslf\nasjfhaslkhf\naskfhaskjf\n" - in txt ==> txt, - - "comment1" ~: - "/* abc */\ndef\n/*ghi*/\n" ==> "/* abc */\ndef\n/*ghi*/\n", - "comment2" ~: - "/* abc\ndef */\nghi\n" ==> "/* abc*/\n/*def */\nghi\n", - - "ifthenelse1" ~: - "#include <foo>\n\ - \blah\n\ - \foo bar\n\ - \#if 42\n\ - \baz\n\ - \#else\n\ - \quux\n\ - \#endif\n" - ==> - "//#include <foo>\n\ - \blah\n\ - \foo bar\n\ - \//#if 1\n\ - \baz\n\ - \//#else\n\ - \//T quux\n\ - \//#endif", - - "elif1" ~: success - "#if 1\n\ - \success\n\ - \#elif 1\n\ - \failure2\n\ - \#else\n\ - \failure3\n\ - \#endif", - - "elif2" ~: success - "#if 0\n\ - \failure1\n\ - \#elif 1\n\ - \success\n\ - \#else\n\ - \failure2\n\ - \#endif", + "empty" ~: "" ==> "", + + "plainLines" ~: + let txt = "asfljkaslf\nasjfhaslkhf\naskfhaskjf\n" + in txt ==> txt, + + "comment1" ~: + "/* abc */\ndef\n/*ghi*/\n" ==> "/* abc */\ndef\n/*ghi*/\n", + "comment2" ~: + "/* abc\ndef */\nghi\n" ==> "/* abc*/\n/*def */\nghi\n", + + "ifthenelse1" ~: + "#include <foo>\n\ + \blah\n\ + \foo bar\n\ + \#if 42\n\ + \baz\n\ + \#else\n\ + \quux\n\ + \#endif\n" + ==> + "//#include <foo>\n\ + \blah\n\ + \foo bar\n\ + \//#if 1\n\ + \baz\n\ + \//#else\n\ + \//T quux\n\ + \//#endif", + + "elif1" ~: success + "#if 1\n\ + \success\n\ + \#elif 1\n\ + \failure2\n\ + \#else\n\ + \failure3\n\ + \#endif", + + "elif2" ~: success + "#if 0\n\ + \failure1\n\ + \#elif 1\n\ + \success\n\ + \#else\n\ + \failure2\n\ + \#endif", - "elif3" ~: success - "#if 0\n\ - \failure1\n\ - \#elif 0\n\ - \failure2\n\ - \#else\n\ - \success\n\ - \#endif", - - "elif4" ~: success - "#if 6 * 9 == 42\n\ - \No, that is not the question.\n\ - \#elif 2 + 2 == 5\n\ - \We love Big Brother!\n\ - \#else\n\ - \success\n\ - \#endif", - - "elif5" ~: success - "#if 6 * 7 == 42\n\ - \success\n\ - \#elif 2 + 2 == 5\n\ - \We love Big Brother!\n\ - \#else\n\ - \wrong, too.\n\ - \#endif", + "elif3" ~: success + "#if 0\n\ + \failure1\n\ + \#elif 0\n\ + \failure2\n\ + \#else\n\ + \success\n\ + \#endif", + + "elif4" ~: success + "#if 6 * 9 == 42\n\ + \No, that is not the question.\n\ + \#elif 2 + 2 == 5\n\ + \We love Big Brother!\n\ + \#else\n\ + \success\n\ + \#endif", + + "elif5" ~: success + "#if 6 * 7 == 42\n\ + \success\n\ + \#elif 2 + 2 == 5\n\ + \We love Big Brother!\n\ + \#else\n\ + \wrong, too.\n\ + \#endif", - "elif6" ~: success - "#if 6 * 9 == 42\n\ - \no.\n\ - \#elif MAC_OS_X_VERSION_10_5 == 1050\n\ - \success\n\ - \#else\n\ - \wrong, too.\n\ - \#endif", - - "nest1" ~: success - "#if 1\n\ - \#if 1\n\ - \success\n\ - \#else\n\ - \failure1\n\ - \#endif\n\ - \#else\n\ - \failure2\n\ - \#if 1\n\ - \failure3\n\ - \#else\n\ - \failure4\n\ - \#endif\n\ - \failure5\n\ - \#endif", + "elif6" ~: success + "#if 6 * 9 == 42\n\ + \no.\n\ + \#elif MAC_OS_X_VERSION_10_5 == 1050\n\ + \success\n\ + \#else\n\ + \wrong, too.\n\ + \#endif", + + "nest1" ~: success + "#if 1\n\ + \#if 1\n\ + \success\n\ + \#else\n\ + \failure1\n\ + \#endif\n\ + \#else\n\ + \failure2\n\ + \#if 1\n\ + \failure3\n\ + \#else\n\ + \failure4\n\ + \#endif\n\ + \failure5\n\ + \#endif", - "nest2" ~: success - "#if 0\n\ - \failure0\n\ - \#if 1\n\ - \failure1\n\ - \#else\n\ - \failure2\n\ - \#endif\n\ - \failure3\n\ - \#else\n\ - \#if 0\n\ - \failure4\n\ - \#else\n\ - \success\n\ - \#endif\n\ - \#endif", - - "defineBackslash" ~: success - "#define FOO bar\n\\\ - \ baz\n\ - \success" - ] + "nest2" ~: success + "#if 0\n\ + \failure0\n\ + \#if 1\n\ + \failure1\n\ + \#else\n\ + \failure2\n\ + \#endif\n\ + \failure3\n\ + \#else\n\ + \#if 0\n\ + \failure4\n\ + \#else\n\ + \success\n\ + \#endif\n\ + \#endif", + + "defineBackslash" ~: success + "#define FOO bar\\\n\ + \ baz\n\ + \success" + ] |