haskades 0.1.1 → 0.2.0
raw patch · 5 files changed
+511/−606 lines, 5 files
Files
- MustacheTemplates.hs +434/−488
- README +7/−5
- Records.hs +9/−22
- haskades.cabal +10/−8
- haskades.hs +51/−83
MustacheTemplates.hs view
@@ -7,621 +7,567 @@ import qualified Data.Text.Lazy.Builder as TL import Records -haskadesBindinghs escapeFunction ctx@(Template {modul=modul, slots=slots, signalTypes=signalTypes, signals=signals}) = mconcat [- {-# LINE 1 "HaskadesBinding.hs.mustache" #-}+haskadesBindinghsc escapeFunction ctx@(Template {headerPath=headerPath, modul=modul, toUItypes=toUItypes, toUI=toUI, fromUI=fromUI}) = mconcat [+ {-# LINE 1 "HaskadesBinding.hsc.mustache" #-} build "{",- {-# LINE 1 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 1 "HaskadesBinding.hsc.mustache" #-} build "-# LANGUAGE ForeignFunctionInterface #-}\n",- {-# LINE 2 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 2 "HaskadesBinding.hsc.mustache" #-} build "{",- {-# LINE 2 "HaskadesBinding.hs.mustache" #-}- build "-# OPTIONS_GHC -fno-warn-unused-imports #-}\nmodule HaskadesBinding (haskadesRun, emit) where\n\nimport Foreign.C.Types\nimport Foreign.C.String\nimport Foreign.Ptr\nimport System.Exit (exitWith, ExitCode(ExitFailure))\nimport Control.Monad (when, ap, join)\nimport Control.Monad.IO.Class (MonadIO, liftIO)\nimport Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)\nimport qualified Data.Text as Text\nimport qualified Data.Text.Encoding as Text\nimport qualified Data.Text.Lazy as LText\nimport qualified Data.Text.Lazy.Encoding as LText\nimport qualified Data.ByteString as ByteString\n\nimport ",- {-# LINE 18 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 2 "HaskadesBinding.hsc.mustache" #-}+ build "-# OPTIONS_GHC -fno-warn-unused-imports #-}\nmodule HaskadesBinding (\n#ifdef USE_SENSORS\n\tAccelerationMode,\n\tAxesOrientationMode,\n\taccelerometerStart,\n#endif\n\thaskadesRun,\n\temit\n) where\n\n#include \"",+ {-# LINE 13 "HaskadesBinding.hsc.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build headerPath,+ {-# LINE 13 "HaskadesBinding.hsc.mustache" #-}+ build "\"\n\nimport Control.Applicative (pure, (<*>))\nimport Control.Monad (when, ap, join, forever)\nimport Control.Monad.IO.Class (MonadIO, liftIO)\nimport Control.Concurrent (forkIO, killThread)\nimport System.Exit (exitWith, ExitCode(ExitFailure))\n\nimport Foreign.Storable\nimport Foreign.C.Types\nimport Foreign.C.String\nimport Foreign.Ptr\n\nimport Data.Time.Clock (UTCTime)\nimport Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)\nimport qualified Data.Text as Text\nimport qualified Data.Text.Encoding as Text\nimport qualified Data.Text.Lazy as LText\nimport qualified Data.Text.Lazy.Encoding as LText\nimport qualified Data.ByteString as ByteString\n\nimport ",+ {-# LINE 34 "HaskadesBinding.hsc.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build modul,- {-# LINE 18 "HaskadesBinding.hs.mustache" #-}- build "\n\nforeign import ccall safe \"haskades_run.cpp haskades_run\"\n\tc_haskades_run ::\n\tCString -> ",- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (slots0 escapeFunction) slots,- {-# LINE 23 "HaskadesBinding.hs.mustache" #-}- build "\tIO CInt\n\nforeign import ccall unsafe \"start.cpp emit_CustomSignalEvent\"\n\tc_emit_CustomSignalEvent ::\n\tCInt -> ",- {-# LINE 27 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (signalTypes2 escapeFunction) signalTypes,- {-# LINE 28 "HaskadesBinding.hs.mustache" #-}- build "\tIO ()\n\nemit :: (MonadIO m) => Signal -> m ()\n",- {-# LINE 31 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (signals3 escapeFunction) signals,- {-# LINE 37 "HaskadesBinding.hs.mustache" #-}- build "\n-- Function pointer wrappers\n",- {-# LINE 39 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (slots6 escapeFunction) slots,- {-# LINE 42 "HaskadesBinding.hs.mustache" #-}- build "\nhaskadesRun :: (MonadIO m) => String -> Slots -> m ()\nhaskadesRun qmlPath (Slots ",- {-# LINE 44 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (slots9 escapeFunction) slots,- {-# LINE 44 "HaskadesBinding.hs.mustache" #-}- build ") = liftIO $ do\n",- {-# LINE 45 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (slots10 escapeFunction) slots,- {-# LINE 48 "HaskadesBinding.hs.mustache" #-}- build "\n\tcode <- ByteString.useAsCString (Text.encodeUtf8 $ Text.pack qmlPath) (\\qmlPath ->\n\t\t\tc_haskades_run qmlPath ",- {-# LINE 50 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (slots15 escapeFunction) slots,- {-# LINE 51 "HaskadesBinding.hs.mustache" #-}- build "\t\t)\n\n",- {-# LINE 53 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (slots16 escapeFunction) slots,- {-# LINE 56 "HaskadesBinding.hs.mustache" #-}- build "\n\twhen (code /= 0) (exitWith $ ExitFailure $ fromIntegral code)\n\treturn ()\n"+ {-# LINE 34 "HaskadesBinding.hsc.mustache" #-}+ build "\n\nforeign import ccall safe \"haskades_run.cpp haskades_run\"\n\tc_haskades_run ::\n\tCString ->\n\t-- ^ QML file to load and render\n\tIO CInt\n\nforeign import ccall unsafe \"haskades_run.cpp emit_ToUIEvent\"\n\tc_emit_ToUIEvent ::\n\tCInt -> ",+ {-# LINE 44 "HaskadesBinding.hsc.mustache" #-}+ mconcat $ map (toUItypes0 escapeFunction) toUItypes,+ {-# LINE 45 "HaskadesBinding.hsc.mustache" #-}+ build "\tIO ()\n\nforeign import ccall safe \"haskades_run.cpp pop_SignalFromUI\"\n\tc_pop_SignalFromUI ::\n\tIO (Ptr SignalFromUI)\n\nemit :: (MonadIO m) => SignalToUI -> m ()\n",+ {-# LINE 52 "HaskadesBinding.hsc.mustache" #-}+ mconcat $ map (toUI1 escapeFunction) toUI,+ {-# LINE 58 "HaskadesBinding.hsc.mustache" #-}+ build "\npopSignalFromUI :: (MonadIO m) => m SignalFromUI\npopSignalFromUI = liftIO (c_pop_SignalFromUI >>= peekFromUI)\n\npeekFromUI :: Ptr SignalFromUI -> IO SignalFromUI\npeekFromUI ptr = do\n\ttag <- #",+ {-# LINE 64 "HaskadesBinding.hsc.mustache" #-}+ build "{",+ {-# LINE 64 "HaskadesBinding.hsc.mustache" #-}+ build "peek struct SignalFromUI, tag} ptr\n\tcase (tag :: CInt) of\n",+ {-# LINE 66 "HaskadesBinding.hsc.mustache" #-}+ mconcat $ map (fromUI4 escapeFunction) fromUI,+ {-# LINE 71 "HaskadesBinding.hsc.mustache" #-}+ build "\t\t_ -> error \"Corrupt SignalFromUI in peekFromUI (HaskadesBinding)\"\n\nhaskadesRun :: (MonadIO m) => String -> (SignalFromUI -> IO ()) -> m ()\nhaskadesRun qmlPath handler = liftIO $ do\n\n\tthreadId <- forkIO (forever $ popSignalFromUI >>= handler)\n\n\tcode <- ByteString.useAsCString (Text.encodeUtf8 $ Text.pack qmlPath) (\\qmlPath ->\n\t\t\tc_haskades_run qmlPath\n\t\t)\n\n\tkillThread threadId\n\n\twhen (code /= 0) (exitWith $ ExitFailure $ fromIntegral code)\n\treturn ()\n\n#ifdef USE_SENSORS\ndata AccelerationMode = AccelerationGravity | AccelerationUser | AccelerationCombined deriving (Show, Read, Eq, Enum)\ndata AxesOrientationMode = AxesOrientationFixed | AxesOrientationAutomatic | AxesOrientationUser deriving (Show, Read, Eq, Enum)\n\nforeign import ccall \"wrapper\" _wrap_accelerometerCallback :: (CDouble -> CDouble -> CDouble -> IO CInt) -> IO (FunPtr (CDouble -> CDouble -> CDouble -> IO CInt))\n\nforeign import ccall safe \"haskades_run.cpp accelerometer_start\"\n\tc_accelerometer_start ::\n\tCInt -> CInt -> FunPtr (CDouble -> CDouble -> CDouble -> IO CInt) ->\n\tIO ()\n\nenumToCInt :: (Enum a) => a -> CInt\nenumToCInt = fromIntegral . fromEnum\n\naccelerometerStart :: AccelerationMode -> AxesOrientationMode -> ((Double, Double, Double) -> IO Bool) -> IO ()\naccelerometerStart accelM axesM cb = _wrap_accelerometerCallback cb' >>= c_accelerometer_start (enumToCInt accelM) (enumToCInt axesM)\n\twhere\n\tcb' x y z = fmap enumToCInt $ cb $! (realToFrac $! x, realToFrac $! y, realToFrac $! z)\n#endif\n" ] where- slots0 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- build "FunPtr (",- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (args1 escapeFunction) args,- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- build " ",- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build crtype,- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- build ") -> "- ]- where- args1 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build ctype,- {-# LINE 22 "HaskadesBinding.hs.mustache" #-}- build " -> "- ]- signalTypes2 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [- {-# LINE 27 "HaskadesBinding.hs.mustache" #-}+ toUItypes0 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [+ {-# LINE 44 "HaskadesBinding.hsc.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build csigtype,- {-# LINE 27 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 44 "HaskadesBinding.hsc.mustache" #-} build " -> " ]- signals3 escapeFunction ctx@(Signal {signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}+ toUI1 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-} build "emit (",- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-} build " ",- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (sigargs4 escapeFunction) sigargs,- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-}+ mconcat $ map (sigargs2 escapeFunction) sigargs,+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-} build ") = liftIO (\n\t\t",- {-# LINE 33 "HaskadesBinding.hs.mustache" #-}- if mempty /= sigcwrap then sigcwrap5 escapeFunction ctx else mempty,- {-# LINE 34 "HaskadesBinding.hs.mustache" #-}- build "\t\t(c_emit_CustomSignalEvent ",- {-# LINE 34 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 54 "HaskadesBinding.hsc.mustache" #-}+ if mempty /= sigcwrap then sigcwrap3 escapeFunction ctx else mempty,+ {-# LINE 55 "HaskadesBinding.hsc.mustache" #-}+ build "\t\t(c_emit_ToUIEvent ",+ {-# LINE 55 "HaskadesBinding.hsc.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigevent,- {-# LINE 34 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 55 "HaskadesBinding.hsc.mustache" #-} build ")\n\t)\n" ] where- sigargs4 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, sigargsigtypename=sigargsigtypename}) = mconcat [- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}+ sigargs2 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build siganame,- {-# LINE 32 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 53 "HaskadesBinding.hsc.mustache" #-} build " " ]- sigcwrap5 escapeFunction ctx@(Signal {signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [- {-# LINE 33 "HaskadesBinding.hs.mustache" #-}+ sigcwrap3 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 54 "HaskadesBinding.hsc.mustache" #-} build "(",- {-# LINE 33 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 54 "HaskadesBinding.hsc.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigcwrap,- {-# LINE 33 "HaskadesBinding.hs.mustache" #-}+ {-# LINE 54 "HaskadesBinding.hsc.mustache" #-} build ")" ]- slots6 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build "foreign import ccall \"wrapper\" wrap_",- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build " :: (",- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (args7 escapeFunction) args,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build " ",- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build crtype,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build ") -> IO (FunPtr (",- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (args8 escapeFunction) args,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build " ",- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build crtype,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build "))\n"- ]- where- args7 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build ctype,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build " -> "- ]- args8 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build ctype,- {-# LINE 40 "HaskadesBinding.hs.mustache" #-}- build " -> "- ]- slots9 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 44 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 44 "HaskadesBinding.hs.mustache" #-}- build " "- ]- slots10 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build "\t",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build "Ptr <- wrap_",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build " (",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- if mempty /= (Any hasArgs) then hasArgs11 escapeFunction ctx else mempty,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (args12 escapeFunction) args,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- if mempty /= (Any hasArgs) then hasArgs13 escapeFunction ctx else mempty,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build "(join ((return ",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build monadic,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build ") ",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- mconcat $ map (args14 escapeFunction) args,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build ")) >>= ",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build crwrap,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build ")\n"+ fromUI4 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 67 "HaskadesBinding.hsc.mustache" #-}+ build "\t\t",+ {-# LINE 67 "HaskadesBinding.hsc.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigevent,+ {-# LINE 67 "HaskadesBinding.hsc.mustache" #-}+ build " ->\n\t\t\tpure ",+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ mconcat $ map (sigargs5 escapeFunction) sigargs,+ {-# LINE 69 "HaskadesBinding.hsc.mustache" #-}+ build "\n" ] where- hasArgs11 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build "\\"- ]- args12 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build aname,- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build " "- ]- hasArgs13 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build "-> "- ]- args14 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build " `ap` ",- {-# LINE 46 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build cwrap+ sigargs5 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build " <*> ((",+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigargfromc,+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build ") (#",+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build "{",+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build "peek struct SignalFromUI, ",+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build ".",+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build siganame,+ {-# LINE 68 "HaskadesBinding.hsc.mustache" #-}+ build "} ptr))" ]- slots15 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 50 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 50 "HaskadesBinding.hs.mustache" #-}- build "Ptr "- ]- slots16 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 54 "HaskadesBinding.hs.mustache" #-}- build "\tfreeHaskellFunPtr ",- {-# LINE 54 "HaskadesBinding.hs.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 54 "HaskadesBinding.hs.mustache" #-}- build "Ptr\n"- ] -haskades_runcpp escapeFunction ctx@(Template {modul=modul, slots=slots, signalTypes=signalTypes, signals=signals}) = mconcat [+haskades_runcpp escapeFunction ctx@(Template {headerPath=headerPath, modul=modul, toUItypes=toUItypes, toUI=toUI, fromUI=fromUI}) = mconcat [ {-# LINE 1 "haskades_run.cpp.mustache" #-}- build "#include <QtDebug>\n#include <QLocale>\n#include <QTranslator>\n#include <bb/cascades/Application>\n#include <bb/cascades/QmlDocument>\n#include <bb/cascades/AbstractPane>\n\n#ifdef USE_NOTIFICATIONS\n#include <bb/platform/Notification>\n#include <bb/platform/NotificationDialog>\n#endif\n\nQEvent::Type customSignalEventType;\n",- {-# LINE 14 "haskades_run.cpp.mustache" #-}- mconcat $ map (signals0 escapeFunction) signals,- {-# LINE 17 "haskades_run.cpp.mustache" #-}- build "\nclass CustomSignalEvent : public QEvent ",- {-# LINE 18 "haskades_run.cpp.mustache" #-}+ build "#include <QtDebug>\n#include <QLocale>\n#include <QTranslator>\n\n#include <QQueue>\n#include <QSemaphore>\n#include <QMutex>\n\n#include <bb/cascades/Application>\n#include <bb/cascades/QmlDocument>\n#include <bb/cascades/AbstractPane>\n\n#ifdef USE_SENSORS\n#include <QtSensors/QAccelerometer>\n#endif\n\n#ifdef USE_NOTIFICATIONS\n#include <bb/platform/Notification>\n#include <bb/platform/NotificationDialog>\n#endif\n\n#include \"",+ {-# LINE 22 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build headerPath,+ {-# LINE 22 "haskades_run.cpp.mustache" #-}+ build "\"\n\nQEvent::Type toUIEventType;\n\ntemplate<class T> class ThreadSafeQueue ",+ {-# LINE 26 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 18 "haskades_run.cpp.mustache" #-}- build "\n\npublic:\n\tCustomSignalEvent(int signalEvent",- {-# LINE 21 "haskades_run.cpp.mustache" #-}- mconcat $ map (signalTypes1 escapeFunction) signalTypes,- {-# LINE 21 "haskades_run.cpp.mustache" #-}- build ") : QEvent(customSignalEventType) ",- {-# LINE 21 "haskades_run.cpp.mustache" #-}+ {-# LINE 26 "haskades_run.cpp.mustache" #-}+ build "\npublic:\n\tThreadSafeQueue() : semFree(32), semUsed(0) ",+ {-# LINE 28 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 21 "haskades_run.cpp.mustache" #-}+ {-# LINE 28 "haskades_run.cpp.mustache" #-}+ build " }\n\n\tvoid enqueue(const T &value) ",+ {-# LINE 30 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 30 "haskades_run.cpp.mustache" #-}+ build "\n\t\tsemFree.acquire(1);\n\t\tmutex.lock();\n\t\tqueue.enqueue(value);\n\t\tmutex.unlock();\n\t\tsemUsed.release(1);\n\t}\n\n\tT dequeue() ",+ {-# LINE 38 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 38 "haskades_run.cpp.mustache" #-}+ build "\n\t\tsemUsed.acquire(1);\n\t\tmutex.lock();\n\t\tT val = queue.dequeue();\n\t\tmutex.unlock();\n\t\tsemFree.release(1);\n\t\treturn val;\n\t}\n\nprotected:\n\tQQueue<T> queue;\n\tQSemaphore semFree;\n\tQSemaphore semUsed;\n\tQMutex mutex;\n};\n\nThreadSafeQueue<SignalFromUI*> signalFromUIQ;\n\nclass ToUIEvent : public QEvent ",+ {-# LINE 56 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 56 "haskades_run.cpp.mustache" #-}+ build "\n\npublic:\n\tToUIEvent(int signalEvent",+ {-# LINE 59 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUItypes0 escapeFunction) toUItypes,+ {-# LINE 59 "haskades_run.cpp.mustache" #-}+ build ") : QEvent(toUIEventType) ",+ {-# LINE 59 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 59 "haskades_run.cpp.mustache" #-} build "\n\t\tthis->signalEvent = signalEvent;\n",- {-# LINE 23 "haskades_run.cpp.mustache" #-}- mconcat $ map (signalTypes2 escapeFunction) signalTypes,- {-# LINE 26 "haskades_run.cpp.mustache" #-}+ {-# LINE 61 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUItypes1 escapeFunction) toUItypes,+ {-# LINE 64 "haskades_run.cpp.mustache" #-} build "\t}\n\n\tint signalEvent;\n",- {-# LINE 29 "haskades_run.cpp.mustache" #-}- mconcat $ map (signalTypes3 escapeFunction) signalTypes,- {-# LINE 32 "haskades_run.cpp.mustache" #-}+ {-# LINE 67 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUItypes2 escapeFunction) toUItypes,+ {-# LINE 70 "haskades_run.cpp.mustache" #-} build "};\n\nclass AppWrapper: public QObject ",- {-# LINE 34 "haskades_run.cpp.mustache" #-}+ {-# LINE 72 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 34 "haskades_run.cpp.mustache" #-}- build "\nQ_OBJECT\n\npublic:\n\t// This is our constructor that sets up the recipe.\n\tAppWrapper(QString qml_path",- {-# LINE 39 "haskades_run.cpp.mustache" #-}- mconcat $ map (slots4 escapeFunction) slots,- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build ") :\n\tqmlPath(qml_path)",- {-# LINE 40 "haskades_run.cpp.mustache" #-}- mconcat $ map (slots7 escapeFunction) slots,- {-# LINE 42 "haskades_run.cpp.mustache" #-}- build "\t",- {-# LINE 42 "haskades_run.cpp.mustache" #-}+ {-# LINE 72 "haskades_run.cpp.mustache" #-}+ build "\nQ_OBJECT\n\npublic:\n\t// This is our constructor that sets up the recipe.\n\tAppWrapper(QString qml_path) : qmlPath(qml_path) ",+ {-# LINE 77 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 42 "haskades_run.cpp.mustache" #-}- build "\n#ifdef USE_NOTIFICATIONS\nqmlRegisterType<bb::platform::Notification>(\"bb.platform\", 1, 0, \"Notification\");\nqmlRegisterType<bb::platform::NotificationDialog>(\"bb.platform\", 1, 0, \"NotificationDialog\");\n#endif\n\t}\n\n\tvirtual void ready() ",- {-# LINE 49 "haskades_run.cpp.mustache" #-}+ {-# LINE 77 "haskades_run.cpp.mustache" #-}+ build "\n#ifdef USE_NOTIFICATIONS\n\t\tqmlRegisterType<bb::platform::Notification>(\"bb.platform\", 1, 0, \"Notification\");\n\t\tqmlRegisterType<bb::platform::NotificationDialog>(\"bb.platform\", 1, 0, \"NotificationDialog\");\n#endif\n\t}\n\n\tvirtual void ready() ",+ {-# LINE 84 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 49 "haskades_run.cpp.mustache" #-}+ {-# LINE 84 "haskades_run.cpp.mustache" #-} build "\n\t\t// Obtain a QMLDocument and load it into the qml variable, using build patterns.\n\t\tbb::cascades::QmlDocument *qml = bb::cascades::QmlDocument::create(this->qmlPath);\n\n\t\t// If the QML document is valid, we process it.\n\t\tif(!qml->hasErrors()) ",- {-# LINE 54 "haskades_run.cpp.mustache" #-}+ {-# LINE 89 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 54 "haskades_run.cpp.mustache" #-}+ {-# LINE 89 "haskades_run.cpp.mustache" #-} build "\n\t\t\tqml->setContextProperty(\"app\", this);\n\n\t\t\t// Create the application root from QMLDocument\n\t\t\tbb::cascades::AbstractPane *appPage = qml->createRootObject<bb::cascades::AbstractPane>();\n\n\t\t\tif (appPage) ",- {-# LINE 60 "haskades_run.cpp.mustache" #-}+ {-# LINE 95 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 60 "haskades_run.cpp.mustache" #-}+ {-# LINE 95 "haskades_run.cpp.mustache" #-} build "\n\t\t\t\t// Set the main scene for the application to the Page.\n\t\t\t\tbb::cascades::Application::instance()->setScene(appPage);\n\t\t\t}\n\t\t} else ",- {-# LINE 64 "haskades_run.cpp.mustache" #-}+ {-# LINE 99 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 64 "haskades_run.cpp.mustache" #-}+ {-# LINE 99 "haskades_run.cpp.mustache" #-} build "\n\t\t\tqCritical() << qml->errors();\n\t\t}\n\t}\n\n\tvirtual bool event(QEvent *e) ",- {-# LINE 69 "haskades_run.cpp.mustache" #-}+ {-# LINE 104 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 69 "haskades_run.cpp.mustache" #-}- build "\n\t\tif(e->type() == customSignalEventType) ",- {-# LINE 70 "haskades_run.cpp.mustache" #-}+ {-# LINE 104 "haskades_run.cpp.mustache" #-}+ build "\n\t\tif(e->type() == toUIEventType) ",+ {-# LINE 105 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 70 "haskades_run.cpp.mustache" #-}- build "\n\t\t\tCustomSignalEvent *ev = (CustomSignalEvent*)e;\n\t\t\tswitch(ev->signalEvent) ",- {-# LINE 72 "haskades_run.cpp.mustache" #-}+ {-# LINE 105 "haskades_run.cpp.mustache" #-}+ build "\n\t\t\tToUIEvent *ev = (ToUIEvent*)e;\n\t\t\tswitch(ev->signalEvent) ",+ {-# LINE 107 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 72 "haskades_run.cpp.mustache" #-}+ {-# LINE 107 "haskades_run.cpp.mustache" #-} build "\n",- {-# LINE 73 "haskades_run.cpp.mustache" #-}- mconcat $ map (signals8 escapeFunction) signals,- {-# LINE 79 "haskades_run.cpp.mustache" #-}+ {-# LINE 108 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUI3 escapeFunction) toUI,+ {-# LINE 114 "haskades_run.cpp.mustache" #-} build "\t\t\t}\n\t\t\treturn false;\n\t\t} else ",- {-# LINE 81 "haskades_run.cpp.mustache" #-}+ {-# LINE 116 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 81 "haskades_run.cpp.mustache" #-}- build "\n\t\t\treturn QObject::event(e);\n\t\t}\n\t}\n\npublic slots:\n",- {-# LINE 87 "haskades_run.cpp.mustache" #-}- mconcat $ map (slots11 escapeFunction) slots,- {-# LINE 92 "haskades_run.cpp.mustache" #-}+ {-# LINE 116 "haskades_run.cpp.mustache" #-}+ build "\n\t\t\treturn QObject::event(e);\n\t\t}\n\t}\n\n",+ {-# LINE 121 "haskades_run.cpp.mustache" #-}+ mconcat $ map (fromUI6 escapeFunction) fromUI,+ {-# LINE 131 "haskades_run.cpp.mustache" #-} build "\nsignals:\n",- {-# LINE 94 "haskades_run.cpp.mustache" #-}- mconcat $ map (signals16 escapeFunction) signals,- {-# LINE 97 "haskades_run.cpp.mustache" #-}- build "\nprotected:\n\tQString qmlPath;\n",- {-# LINE 100 "haskades_run.cpp.mustache" #-}- mconcat $ map (slots19 escapeFunction) slots,- {-# LINE 103 "haskades_run.cpp.mustache" #-}- build "};\n\nextern \"C\" ",- {-# LINE 105 "haskades_run.cpp.mustache" #-}+ {-# LINE 133 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUI10 escapeFunction) toUI,+ {-# LINE 136 "haskades_run.cpp.mustache" #-}+ build "\nprotected:\n\tQString qmlPath;\n};\n\n#ifdef USE_SENSORS\nclass AccelerometerHandler : public QObject ",+ {-# LINE 142 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 105 "haskades_run.cpp.mustache" #-}- build "\n\nQObject *mainAppGlobal;\n\nvoid emit_CustomSignalEvent(int signalEvent",- {-# LINE 109 "haskades_run.cpp.mustache" #-}- mconcat $ map (signalTypes22 escapeFunction) signalTypes,- {-# LINE 109 "haskades_run.cpp.mustache" #-}- build ") ",- {-# LINE 109 "haskades_run.cpp.mustache" #-}+ {-# LINE 142 "haskades_run.cpp.mustache" #-}+ build "\nQ_OBJECT\n\npublic:\n\tAccelerometerHandler(QtMobility::QAccelerometer::AccelerationMode accelM, QtMobility::QAccelerometer::AxesOrientationMode axesM, int (*cb)(double, double, double)) : _cb(cb) ",+ {-# LINE 146 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 109 "haskades_run.cpp.mustache" #-}- build "\n\tQEvent *e = (QEvent *)new CustomSignalEvent(signalEvent",- {-# LINE 110 "haskades_run.cpp.mustache" #-}- mconcat $ map (signalTypes23 escapeFunction) signalTypes,- {-# LINE 110 "haskades_run.cpp.mustache" #-}- build ");\n\tQCoreApplication::postEvent(mainAppGlobal, e);\n}\n\nint haskades_run(char *qml_path",- {-# LINE 114 "haskades_run.cpp.mustache" #-}- mconcat $ map (slots24 escapeFunction) slots,- {-# LINE 114 "haskades_run.cpp.mustache" #-}+ {-# LINE 146 "haskades_run.cpp.mustache" #-}+ build "\n\t\t_accel.setAccelerationMode(accelM);\n\t\t_accel.setAxesOrientationMode(axesM);\n\n\t\tconnect(&_accel, SIGNAL(readingChanged()), SLOT(callback()));\n\n\t\tif(!_accel.connectToBackend()) ",+ {-# LINE 152 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 152 "haskades_run.cpp.mustache" #-}+ build "\n\t\t\tqCritical() << \"CONNECT TO ACCELEROMETER BACKEND FAILED!\";\n\t\t} else if(!_accel.start()) ",+ {-# LINE 154 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 154 "haskades_run.cpp.mustache" #-}+ build "\n\t\t\tqCritical() << \"ACCELEROMETER START FAILED!\";\n\t\t}\n\t}\n\npublic slots:\n\tvoid callback() ",+ {-# LINE 160 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 160 "haskades_run.cpp.mustache" #-}+ build "\n\t\tQtMobility::QAccelerometerReading *r = _accel.reading();\n\t\tif(!_cb((double)r->x(), (double)r->y(), (double)r->z())) ",+ {-# LINE 162 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 162 "haskades_run.cpp.mustache" #-}+ build "\n\t\t\t_accel.stop();\n\t\t\tdelete this;\n\t\t}\n\t}\n\nprotected:\n\tQtMobility::QAccelerometer _accel;\n\tint (*_cb)(double, double, double);\n};\n#endif\n\nextern \"C\" ",+ {-# LINE 174 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 174 "haskades_run.cpp.mustache" #-}+ build "\n\nQObject *mainAppGlobal;\n\nQ_DECL_EXPORT void emit_ToUIEvent(int signalEvent",+ {-# LINE 178 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUItypes13 escapeFunction) toUItypes,+ {-# LINE 178 "haskades_run.cpp.mustache" #-} build ") ",- {-# LINE 114 "haskades_run.cpp.mustache" #-}+ {-# LINE 178 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 114 "haskades_run.cpp.mustache" #-}+ {-# LINE 178 "haskades_run.cpp.mustache" #-}+ build "\n\tQEvent *e = (QEvent *)new ToUIEvent(signalEvent",+ {-# LINE 179 "haskades_run.cpp.mustache" #-}+ mconcat $ map (toUItypes14 escapeFunction) toUItypes,+ {-# LINE 179 "haskades_run.cpp.mustache" #-}+ build ");\n\tQCoreApplication::postEvent(mainAppGlobal, e);\n}\n\nvoid destroySignalFromUI(SignalFromUI *s) ",+ {-# LINE 183 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 183 "haskades_run.cpp.mustache" #-}+ build "\n\tswitch(s->tag) ",+ {-# LINE 184 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 184 "haskades_run.cpp.mustache" #-}+ build "\n",+ {-# LINE 185 "haskades_run.cpp.mustache" #-}+ mconcat $ map (fromUI15 escapeFunction) fromUI,+ {-# LINE 194 "haskades_run.cpp.mustache" #-}+ build "\t}\n\n\tfree(s);\n}\n\nSignalFromUI *lastFromUI = NULL;\n\nQ_DECL_EXPORT SignalFromUI *pop_SignalFromUI(void) ",+ {-# LINE 201 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 201 "haskades_run.cpp.mustache" #-}+ build "\n\tif(lastFromUI) destroySignalFromUI(lastFromUI);\n\tlastFromUI = signalFromUIQ.dequeue();\n\treturn lastFromUI;\n}\n\nQ_DECL_EXPORT int haskades_run(char *qml_path) ",+ {-# LINE 207 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 207 "haskades_run.cpp.mustache" #-} build "\n\tint argc = 0;\n\tchar *argv[] = ",- {-# LINE 116 "haskades_run.cpp.mustache" #-}+ {-# LINE 209 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 116 "haskades_run.cpp.mustache" #-}+ {-# LINE 209 "haskades_run.cpp.mustache" #-} build " NULL };\n\t// Instantiate the main application constructor.\n\tbb::cascades::Application app(argc, argv);\n\n\t// Set up the translator.\n\tQTranslator translator;\n\tQString locale_string = QLocale().name();\n\tQString filename = QString(\"sample_%1\").arg(locale_string); // TODO\n\tif (translator.load(filename, \"app/native/qm\")) ",- {-# LINE 124 "haskades_run.cpp.mustache" #-}+ {-# LINE 217 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 124 "haskades_run.cpp.mustache" #-}- build "\n\t\tapp.installTranslator(&translator);\n\t}\n\n\tcustomSignalEventType = (QEvent::Type)QEvent::registerEventType();\n\n\t// Initialize our application.\n\tAppWrapper mainApp(QString::fromUtf8(qml_path)",- {-# LINE 131 "haskades_run.cpp.mustache" #-}- mconcat $ map (slots27 escapeFunction) slots,- {-# LINE 131 "haskades_run.cpp.mustache" #-}- build ");\n\tmainAppGlobal = (QObject*)&mainApp;\n\tmainApp.ready();\n\n\t// We complete the transaction started in the main application constructor and start the\n\t// client event loop here. When loop is exited the Application deletes the scene which\n\t// deletes all its children.\n\treturn bb::cascades::Application::exec();\n}\n\n}\n\n// Tell MOC to run on this file\n#include \"haskades_run.moc\"\n"+ {-# LINE 217 "haskades_run.cpp.mustache" #-}+ build "\n\t\tapp.installTranslator(&translator);\n\t}\n\n\ttoUIEventType = (QEvent::Type)QEvent::registerEventType();\n\n\t// Initialize our application.\n\tAppWrapper mainApp(QString::fromUtf8(qml_path));\n\tmainAppGlobal = (QObject*)&mainApp;\n\tmainApp.ready();\n\n\t// We complete the transaction started in the main application constructor and start the\n\t// client event loop here. When loop is exited the Application deletes the scene which\n\t// deletes all its children.\n\treturn bb::cascades::Application::exec();\n}\n\n#ifdef USE_SENSORS\nvoid accelerometer_start(int accelM, int axesM, int (*cb)(double, double, double)) ",+ {-# LINE 235 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 235 "haskades_run.cpp.mustache" #-}+ build "\n\tQtMobility::QAccelerometer::AccelerationMode _accelM;\n\tQtMobility::QAccelerometer::AxesOrientationMode _axesM;\n\n\tswitch(accelM) ",+ {-# LINE 239 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 239 "haskades_run.cpp.mustache" #-}+ build "\n\t\tcase 0:\n\t\t\t_accelM = QtMobility::QAccelerometer::Gravity;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\t_accelM = QtMobility::QAccelerometer::User;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\t_accelM = QtMobility::QAccelerometer::Combined;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tqWarning() << \"Unknown AccelerationMode, defaulting to Combined\";\n\t\t\t_accelM = QtMobility::QAccelerometer::Combined;\n\t}\n\n\tswitch(axesM) ",+ {-# LINE 254 "haskades_run.cpp.mustache" #-}+ build "{",+ {-# LINE 254 "haskades_run.cpp.mustache" #-}+ build "\n\t\tcase 0:\n\t\t\t_axesM = QtMobility::QAccelerometer::FixedOrientation;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\t_axesM = QtMobility::QAccelerometer::AutomaticOrientation;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\t_axesM = QtMobility::QAccelerometer::UserOrientation;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tqWarning() << \"Unknown AxesOrientationMode, defaulting to Automatic\";\n\t\t\t_axesM = QtMobility::QAccelerometer::AutomaticOrientation;\n\t}\n\n\tnew AccelerometerHandler(_accelM, _axesM, cb);\n}\n#endif\n\n}\n\n// Tell MOC to run on this file\n#include \"haskades_run.moc\"\n" ] where- signals0 escapeFunction ctx@(Signal {signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [- {-# LINE 15 "haskades_run.cpp.mustache" #-}- build "#define CUSTOM_SIGNAL_",- {-# LINE 15 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,- {-# LINE 15 "haskades_run.cpp.mustache" #-}- build " ",- {-# LINE 15 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigevent,- {-# LINE 15 "haskades_run.cpp.mustache" #-}- build "\n"- ]- signalTypes1 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [- {-# LINE 21 "haskades_run.cpp.mustache" #-}+ toUItypes0 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [+ {-# LINE 59 "haskades_run.cpp.mustache" #-} build ", ",- {-# LINE 21 "haskades_run.cpp.mustache" #-}+ {-# LINE 59 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qtsigtype,- {-# LINE 21 "haskades_run.cpp.mustache" #-}+ {-# LINE 59 "haskades_run.cpp.mustache" #-} build " ",- {-# LINE 21 "haskades_run.cpp.mustache" #-}+ {-# LINE 59 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigtypename ]- signalTypes2 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [- {-# LINE 24 "haskades_run.cpp.mustache" #-}+ toUItypes1 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [+ {-# LINE 62 "haskades_run.cpp.mustache" #-} build "\t\tthis->",- {-# LINE 24 "haskades_run.cpp.mustache" #-}+ {-# LINE 62 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigtypename,- {-# LINE 24 "haskades_run.cpp.mustache" #-}+ {-# LINE 62 "haskades_run.cpp.mustache" #-} build " = ",- {-# LINE 24 "haskades_run.cpp.mustache" #-}+ {-# LINE 62 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigtypename,- {-# LINE 24 "haskades_run.cpp.mustache" #-}+ {-# LINE 62 "haskades_run.cpp.mustache" #-} build ";\n" ]- signalTypes3 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [- {-# LINE 30 "haskades_run.cpp.mustache" #-}+ toUItypes2 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [+ {-# LINE 68 "haskades_run.cpp.mustache" #-} build "\t",- {-# LINE 30 "haskades_run.cpp.mustache" #-}+ {-# LINE 68 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qtsigtype,- {-# LINE 30 "haskades_run.cpp.mustache" #-}+ {-# LINE 68 "haskades_run.cpp.mustache" #-} build " ",- {-# LINE 30 "haskades_run.cpp.mustache" #-}+ {-# LINE 68 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigtypename,- {-# LINE 30 "haskades_run.cpp.mustache" #-}+ {-# LINE 68 "haskades_run.cpp.mustache" #-} build ";\n" ]- slots4 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build ", void (*_",- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build ")(",- {-# LINE 39 "haskades_run.cpp.mustache" #-}- mconcat $ map (args5 escapeFunction) args,- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build ")"- ]- where- args5 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 39 "haskades_run.cpp.mustache" #-}- if mempty == (Any firstarg) then firstarg6 escapeFunction ctx else mempty,- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build lowctype,- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build " ",- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build aname- ]- where- firstarg6 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 39 "haskades_run.cpp.mustache" #-}- build ", "- ]- slots7 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 40 "haskades_run.cpp.mustache" #-}- build ",\n\t_",- {-# LINE 41 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 41 "haskades_run.cpp.mustache" #-}- build "(_",- {-# LINE 41 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 41 "haskades_run.cpp.mustache" #-}- build ")"- ]- signals8 escapeFunction ctx@(Signal {signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [- {-# LINE 74 "haskades_run.cpp.mustache" #-}- build "\t\t\t\tcase CUSTOM_SIGNAL_",- {-# LINE 74 "haskades_run.cpp.mustache" #-}+ toUI3 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 109 "haskades_run.cpp.mustache" #-}+ build "\t\t\t\tcase TOUI_",+ {-# LINE 109 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,- {-# LINE 74 "haskades_run.cpp.mustache" #-}+ {-# LINE 109 "haskades_run.cpp.mustache" #-} build ":\n\t\t\t\t\temit ",- {-# LINE 75 "haskades_run.cpp.mustache" #-}+ {-# LINE 110 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,- {-# LINE 75 "haskades_run.cpp.mustache" #-}+ {-# LINE 110 "haskades_run.cpp.mustache" #-} build "(",- {-# LINE 75 "haskades_run.cpp.mustache" #-}- mconcat $ map (sigargs9 escapeFunction) sigargs,- {-# LINE 75 "haskades_run.cpp.mustache" #-}+ {-# LINE 110 "haskades_run.cpp.mustache" #-}+ mconcat $ map (sigargs4 escapeFunction) sigargs,+ {-# LINE 110 "haskades_run.cpp.mustache" #-} build ");\n\t\t\t\t\treturn true;\n\t\t\t\t\tbreak;\n" ] where- sigargs9 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, sigargsigtypename=sigargsigtypename}) = mconcat [- {-# LINE 75 "haskades_run.cpp.mustache" #-}- if mempty == (Any sigargfirst) then sigargfirst10 escapeFunction ctx else mempty,- {-# LINE 75 "haskades_run.cpp.mustache" #-}+ sigargs4 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 110 "haskades_run.cpp.mustache" #-}+ if mempty == (Any sigargfirst) then sigargfirst5 escapeFunction ctx else mempty,+ {-# LINE 110 "haskades_run.cpp.mustache" #-} build "ev->",- {-# LINE 75 "haskades_run.cpp.mustache" #-}+ {-# LINE 110 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigargsigtypename ] where- sigargfirst10 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, sigargsigtypename=sigargsigtypename}) = mconcat [- {-# LINE 75 "haskades_run.cpp.mustache" #-}+ sigargfirst5 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 110 "haskades_run.cpp.mustache" #-} build ", " ]- slots11 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 88 "haskades_run.cpp.mustache" #-}+ fromUI6 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 122 "haskades_run.cpp.mustache" #-} build "\tQ_INVOKABLE void ",- {-# LINE 88 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 88 "haskades_run.cpp.mustache" #-}+ {-# LINE 122 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 122 "haskades_run.cpp.mustache" #-} build "(",- {-# LINE 88 "haskades_run.cpp.mustache" #-}- mconcat $ map (args12 escapeFunction) args,- {-# LINE 88 "haskades_run.cpp.mustache" #-}+ {-# LINE 122 "haskades_run.cpp.mustache" #-}+ mconcat $ map (sigargs7 escapeFunction) sigargs,+ {-# LINE 122 "haskades_run.cpp.mustache" #-} build ") ",- {-# LINE 88 "haskades_run.cpp.mustache" #-}+ {-# LINE 122 "haskades_run.cpp.mustache" #-} build "{",- {-# LINE 88 "haskades_run.cpp.mustache" #-}- build "\n\t\t_",- {-# LINE 89 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 89 "haskades_run.cpp.mustache" #-}- build "(",- {-# LINE 89 "haskades_run.cpp.mustache" #-}- mconcat $ map (args14 escapeFunction) args,- {-# LINE 89 "haskades_run.cpp.mustache" #-}- build ");\n\t}\n"+ {-# LINE 122 "haskades_run.cpp.mustache" #-}+ build "\n\t\tSignalFromUI *s = new SignalFromUI;\n\t\ts->tag = ",+ {-# LINE 124 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigevent,+ {-# LINE 124 "haskades_run.cpp.mustache" #-}+ build ";\n",+ {-# LINE 125 "haskades_run.cpp.mustache" #-}+ mconcat $ map (sigargs9 escapeFunction) sigargs,+ {-# LINE 128 "haskades_run.cpp.mustache" #-}+ build "\t\tsignalFromUIQ.enqueue(s);\n\t}\n" ] where- args12 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 88 "haskades_run.cpp.mustache" #-}- if mempty == (Any firstarg) then firstarg13 escapeFunction ctx else mempty,- {-# LINE 88 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qttype,- {-# LINE 88 "haskades_run.cpp.mustache" #-}+ sigargs7 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 122 "haskades_run.cpp.mustache" #-}+ if mempty == (Any sigargfirst) then sigargfirst8 escapeFunction ctx else mempty,+ {-# LINE 122 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qtsigargtype,+ {-# LINE 122 "haskades_run.cpp.mustache" #-} build " ",- {-# LINE 88 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build aname+ {-# LINE 122 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build siganame ] where- firstarg13 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 88 "haskades_run.cpp.mustache" #-}+ sigargfirst8 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 122 "haskades_run.cpp.mustache" #-} build ", " ]- args14 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 89 "haskades_run.cpp.mustache" #-}- if mempty == (Any firstarg) then firstarg15 escapeFunction ctx else mempty,- {-# LINE 89 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qtunwrap+ sigargs9 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build "\t\ts->",+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build ".",+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build siganame,+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build " = ",+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigargfromqt,+ {-# LINE 126 "haskades_run.cpp.mustache" #-}+ build ";\n" ]- where- firstarg15 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 89 "haskades_run.cpp.mustache" #-}- build ", "- ]- signals16 escapeFunction ctx@(Signal {signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [- {-# LINE 95 "haskades_run.cpp.mustache" #-}+ toUI10 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 134 "haskades_run.cpp.mustache" #-} build "\tvoid ",- {-# LINE 95 "haskades_run.cpp.mustache" #-}+ {-# LINE 134 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,- {-# LINE 95 "haskades_run.cpp.mustache" #-}+ {-# LINE 134 "haskades_run.cpp.mustache" #-} build "(",- {-# LINE 95 "haskades_run.cpp.mustache" #-}- mconcat $ map (sigargs17 escapeFunction) sigargs,- {-# LINE 95 "haskades_run.cpp.mustache" #-}+ {-# LINE 134 "haskades_run.cpp.mustache" #-}+ mconcat $ map (sigargs11 escapeFunction) sigargs,+ {-# LINE 134 "haskades_run.cpp.mustache" #-} build ");\n" ] where- sigargs17 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, sigargsigtypename=sigargsigtypename}) = mconcat [- {-# LINE 95 "haskades_run.cpp.mustache" #-}- if mempty == (Any sigargfirst) then sigargfirst18 escapeFunction ctx else mempty,- {-# LINE 95 "haskades_run.cpp.mustache" #-}+ sigargs11 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 134 "haskades_run.cpp.mustache" #-}+ if mempty == (Any sigargfirst) then sigargfirst12 escapeFunction ctx else mempty,+ {-# LINE 134 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qtsigargtype ] where- sigargfirst18 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, sigargsigtypename=sigargsigtypename}) = mconcat [- {-# LINE 95 "haskades_run.cpp.mustache" #-}- build ", "- ]- slots19 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build "\tvoid (*_",- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build ")(",- {-# LINE 101 "haskades_run.cpp.mustache" #-}- mconcat $ map (args20 escapeFunction) args,- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build ");\n"- ]- where- args20 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 101 "haskades_run.cpp.mustache" #-}- if mempty == (Any firstarg) then firstarg21 escapeFunction ctx else mempty,- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build lowctype,- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build " ",- {-# LINE 101 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build aname- ]- where- firstarg21 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 101 "haskades_run.cpp.mustache" #-}+ sigargfirst12 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 134 "haskades_run.cpp.mustache" #-} build ", " ]- signalTypes22 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [- {-# LINE 109 "haskades_run.cpp.mustache" #-}+ toUItypes13 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [+ {-# LINE 178 "haskades_run.cpp.mustache" #-} build ", ",- {-# LINE 109 "haskades_run.cpp.mustache" #-}+ {-# LINE 178 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build lowcsigtype,- {-# LINE 109 "haskades_run.cpp.mustache" #-}+ {-# LINE 178 "haskades_run.cpp.mustache" #-} build " ",- {-# LINE 109 "haskades_run.cpp.mustache" #-}+ {-# LINE 178 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigtypename ]- signalTypes23 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [- {-# LINE 110 "haskades_run.cpp.mustache" #-}+ toUItypes14 escapeFunction ctx@(SignalType {csigtype=csigtype, qtsigtype=qtsigtype, qtwrapsig=qtwrapsig, lowcsigtype=lowcsigtype, sigtypename=sigtypename}) = mconcat [+ {-# LINE 179 "haskades_run.cpp.mustache" #-} build ", ",- {-# LINE 110 "haskades_run.cpp.mustache" #-}+ {-# LINE 179 "haskades_run.cpp.mustache" #-} build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build qtwrapsig ]- slots24 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build ", void (*_",- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name,- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build ")(",- {-# LINE 114 "haskades_run.cpp.mustache" #-}- mconcat $ map (args25 escapeFunction) args,- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build ")"+ fromUI15 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 186 "haskades_run.cpp.mustache" #-}+ build "\t\t\tcase FROMUI_",+ {-# LINE 186 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 186 "haskades_run.cpp.mustache" #-}+ build ":\n",+ {-# LINE 187 "haskades_run.cpp.mustache" #-}+ mconcat $ map (sigargs16 escapeFunction) sigargs,+ {-# LINE 192 "haskades_run.cpp.mustache" #-}+ build "\t\t\t\tbreak;\n" ] where- args25 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 114 "haskades_run.cpp.mustache" #-}- if mempty == (Any firstarg) then firstarg26 escapeFunction ctx else mempty,- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build lowctype,- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build " ",- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build aname+ sigargs16 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 188 "haskades_run.cpp.mustache" #-}+ if mempty /= sigargdestroy then sigargdestroy17 escapeFunction ctx else mempty ] where- firstarg26 escapeFunction ctx@(SlotArg {firstarg=firstarg, aname=aname, ctype=ctype, lowctype=lowctype, qttype=qttype, cwrap=cwrap, qtunwrap=qtunwrap}) = mconcat [- {-# LINE 114 "haskades_run.cpp.mustache" #-}- build ", "+ sigargdestroy17 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build "\t\t\t\t",+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigargdestroy,+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build "(s->",+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build ".",+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build siganame,+ {-# LINE 189 "haskades_run.cpp.mustache" #-}+ build ");\n" ]- slots27 escapeFunction ctx@(Slot {name=name, monadic=monadic, args=args, hasArgs=hasArgs, crtype=crtype, crwrap=crwrap}) = mconcat [- {-# LINE 131 "haskades_run.cpp.mustache" #-}- build ", _",- {-# LINE 131 "haskades_run.cpp.mustache" #-}- build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build name++haskades_runh escapeFunction ctx@(Template {headerPath=headerPath, modul=modul, toUItypes=toUItypes, toUI=toUI, fromUI=fromUI}) = mconcat [+ {-# LINE 1 "haskades_run.h.mustache" #-}+ build "#ifndef _HASKADES_RUN_H\n#define _HASKADES_RUN_H\n\n",+ {-# LINE 4 "haskades_run.h.mustache" #-}+ mconcat $ map (toUI0 escapeFunction) toUI,+ {-# LINE 7 "haskades_run.h.mustache" #-}+ build "\n",+ {-# LINE 8 "haskades_run.h.mustache" #-}+ mconcat $ map (fromUI1 escapeFunction) fromUI,+ {-# LINE 11 "haskades_run.h.mustache" #-}+ build "\nstruct SignalFromUI ",+ {-# LINE 12 "haskades_run.h.mustache" #-}+ build "{",+ {-# LINE 12 "haskades_run.h.mustache" #-}+ build "\n\tunsigned int tag;\n\tunion ",+ {-# LINE 14 "haskades_run.h.mustache" #-}+ build "{",+ {-# LINE 14 "haskades_run.h.mustache" #-}+ build "\n\t\t",+ {-# LINE 15 "haskades_run.h.mustache" #-}+ mconcat $ map (fromUI2 escapeFunction) fromUI,+ {-# LINE 22 "haskades_run.h.mustache" #-}+ build "\t};\n};\n\n#endif /* _HASKADES_RUN_H */\n"+ ]+ where+ toUI0 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 5 "haskades_run.h.mustache" #-}+ build "#define TOUI_",+ {-# LINE 5 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 5 "haskades_run.h.mustache" #-}+ build " ",+ {-# LINE 5 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigevent,+ {-# LINE 5 "haskades_run.h.mustache" #-}+ build "\n" ]+ fromUI1 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 9 "haskades_run.h.mustache" #-}+ build "#define FROMUI_",+ {-# LINE 9 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 9 "haskades_run.h.mustache" #-}+ build " ",+ {-# LINE 9 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build sigevent,+ {-# LINE 9 "haskades_run.h.mustache" #-}+ build "\n"+ ]+ fromUI2 escapeFunction ctx@(Signal {sigfirst=sigfirst, signame=signame, sigargs=sigargs, sigevent=sigevent, sigcwrap=sigcwrap}) = mconcat [+ {-# LINE 16 "haskades_run.h.mustache" #-}+ build "\t\tstruct ",+ {-# LINE 16 "haskades_run.h.mustache" #-}+ build "{",+ {-# LINE 16 "haskades_run.h.mustache" #-}+ build "\n\t\t\t",+ {-# LINE 17 "haskades_run.h.mustache" #-}+ mconcat $ map (sigargs3 escapeFunction) sigargs,+ {-# LINE 20 "haskades_run.h.mustache" #-}+ build "\t\t} ",+ {-# LINE 20 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build signame,+ {-# LINE 20 "haskades_run.h.mustache" #-}+ build ";\n\t\t"+ ]+ where+ sigargs3 escapeFunction ctx@(SignalArg {sigargfirst=sigargfirst, siganame=siganame, qtsigargtype=qtsigargtype, csigargtype=csigargtype, sigargfromc=sigargfromc, sigargfromqt=sigargfromqt, sigargdestroy=sigargdestroy, sigargsigtypename=sigargsigtypename}) = mconcat [+ {-# LINE 18 "haskades_run.h.mustache" #-}+ build "\t\t\t",+ {-# LINE 18 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build csigargtype,+ {-# LINE 18 "haskades_run.h.mustache" #-}+ build " ",+ {-# LINE 18 "haskades_run.h.mustache" #-}+ build $ escapeFunction $ TL.unpack $ TL.toLazyText $ build siganame,+ {-# LINE 18 "haskades_run.h.mustache" #-}+ build ";\n\t\t\t"+ ]
README view
@@ -3,13 +3,13 @@ Run as: -> ./haskades HaskadesBinding.hs haskades_run.cpp < Types.hs+> ./haskades HaskadesBinding.hs haskades_run.cpp haskades_run.h < Types.hs -Where Types.hs is a Haskell file containing a record type declaration-named 'Slots' and a sum type declaration named 'Signals' which fully-specifies the communication possible between the UI layer (which you+Where Types.hs is a Haskell file containing a a sum type declaration+named 'SignalToUI' and another named 'SignalFromUI' which fully+specify the communication possible between the UI layer (which you write in QML) and the Haskell backend. QML code can access these-signals and slots on the 'app' context object. Haskell code can emit+signals on the 'app' context object. Haskell code can emit signals by using the 'emit' function exported from the generated HaskadesBinding. The 'emit' call is threadsafe. @@ -17,3 +17,5 @@ work with them properly, and vice-versa. UTCTime becomes QDateTime. Int, Double, and () are passed through fairly directly. Other types may have support added as there is need.++A simple example lives at <https://github.com/singpolyma/haskades-sample>
Records.hs view
@@ -1,29 +1,11 @@ module Records where data Template = Template {+ headerPath :: String, modul :: String,- slots :: [Slot],- signalTypes :: [SignalType],- signals :: [Signal]-} deriving (Show)--data Slot = Slot {- name :: String,- monadic :: String,- args :: [SlotArg],- hasArgs :: Bool,- crtype :: String,- crwrap :: String-} deriving (Show)--data SlotArg = SlotArg {- firstarg :: Bool,- aname :: String,- ctype :: String,- lowctype :: String,- qttype :: String,- cwrap :: String,- qtunwrap :: String+ toUItypes :: [SignalType],+ toUI :: [Signal],+ fromUI :: [Signal] } deriving (Show) data SignalType = SignalType {@@ -35,6 +17,7 @@ } deriving (Show) data Signal = Signal {+ sigfirst :: Bool, signame :: String, sigargs :: [SignalArg], sigevent :: Integer,@@ -45,5 +28,9 @@ sigargfirst :: Bool, siganame :: String, qtsigargtype :: String,+ csigargtype :: String,+ sigargfromc :: String,+ sigargfromqt :: String,+ sigargdestroy :: String, sigargsigtypename :: String } deriving (Show)
haskades.cabal view
@@ -1,14 +1,14 @@ name: haskades-version: 0.1.1+version: 0.2.0 cabal-version: >= 1.8 license: OtherLicense license-file: COPYING category: Utility-copyright: © 2012 Stephen Paul Weber+copyright: © 2012-2013 Stephen Paul Weber author: Stephen Paul Weber <singpolyma@singpolyma.net> maintainer: Stephen Paul Weber <singpolyma@singpolyma.net> stability: experimental-tested-with: GHC == 7.0.3+tested-with: GHC == 7.4.2 synopsis: Utility to generate bindings for BlackBerry Cascades homepage: http://github.com/singpolyma/haskades bug-reports: http://github.com/singpolyma/haskades/issues@@ -19,13 +19,13 @@ . Run as: .- > ./haskades HaskadesBinding.hs haskades_run.cpp < Types.hs+ > ./haskades HaskadesBinding.hs haskades_run.cpp haskades_run.h < Types.hs .- Where Types.hs is a Haskell file containing a record type declaration- named 'Slots' and a sum type declaration named 'Signals' which fully- specifies the communication possible between the UI layer (which you+ Where Types.hs is a Haskell file containing a a sum type declaration+ named 'SignalToUI' and another named 'SignalFromUI' which fully+ specify the communication possible between the UI layer (which you write in QML) and the Haskell backend. QML code can access these- signals and slots on the 'app' context object. Haskell code can emit+ signals on the 'app' context object. Haskell code can emit signals by using the 'emit' function exported from the generated HaskadesBinding. The 'emit' call is threadsafe. .@@ -33,6 +33,8 @@ work with them properly, and vice-versa. UTCTime becomes QDateTime. Int, Double, and () are passed through fairly directly. Other types may have support added as there is need.+ .+ A simple example lives at <https://github.com/singpolyma/haskades-sample> extra-source-files: README
haskades.hs view
@@ -36,10 +36,6 @@ extractTypeFromBangType (HsBangedTy t) = t extractTypeFromBangType (HsUnBangedTy t) = t -flatTyFun :: HsType -> HsType -> ([HsType], HsType)-flatTyFun a (HsTyFun b c) = first (a:) (flatTyFun b c)-flatTyFun a b = ([a], b)- findType :: [(String, Module)] -> Module -> [(Module, Type)] -> Either String Type findType i (Module m) q = headErr ("No " ++ show q ++ " imports find, but one used as type.") matches@@ -70,38 +66,19 @@ resolveType i (HsTyCon (Qual m (HsIdent "UTCTime"))) = findUTCTimeType i m resolveType _ t = Left $ "Type not yet supported: " ++ show t -resolveRType :: [(String, Module)] -> HsType -> Either String RType-resolveRType _ (HsTyCon (Special HsUnitCon)) = Left "A pure function that returns () ?"-resolveRType _ (HsTyApp (HsTyCon (UnQual (HsIdent "IO"))) (HsTyCon (Special HsUnitCon))) = return RIOUnit-resolveRType i (HsTyApp (HsTyCon (UnQual (HsIdent "IO"))) t) = RIO <$> resolveType i t-resolveRType i t = RPure <$> resolveType i t--getSlots :: [(String, Module)] -> [HsDecl] -> Either String [(String, [Type], RType)]-getSlots i decls = slotsDecl >>= slotsFrom >>= mapM slotField- where- slotField ([HsIdent fname], t) = case extractTypeFromBangType t of- (HsTyFun a b) -> let (args, r) = flatTyFun a b in- (,,) <$> pure fname <*> mapM (resolveType i) args <*> resolveRType i r- x -> (,,) <$> pure fname <*> pure [] <*> resolveRType i x- slotField (x, _) = Left $ "Expected field name, found: " ++ show x- slotsFrom (HsDataDecl _ _ _ _ [HsRecDecl _ (HsIdent "Slots") fields] _) = Right fields- slotsFrom _ = Left "Type \"Slots\" must have a single record constructor named \"Slots\"."- slotsDecl = note "No record named \"Slots\" found." $- find (dataDeclNamed (HsIdent "Slots")) decls- flattenSum :: HsConDecl -> Either String (String, [HsType]) flattenSum (HsConDecl _ (HsIdent n) ts) = Right (n, map extractTypeFromBangType ts) flattenSum (HsRecDecl _ (HsIdent n) ts) = Right (n, map (extractTypeFromBangType.snd) ts) flattenSum x = Left $ "Cannot process sum type constructor: " ++ show x -getSignals :: [(String, Module)] -> [HsDecl] -> Either String [(String, [Type])]-getSignals i decls = signalDecl >>= signalsFrom >>= mapM signalConstr+getSignals :: String -> [(String, Module)] -> [HsDecl] -> Either String [(String, [Type])]+getSignals dataName i decls = signalDecl >>= signalsFrom >>= mapM signalConstr where signalConstr (n, ts) = (,) <$> pure n <*> mapM (resolveType i) ts signalsFrom (HsDataDecl _ _ _ _ cons _) = mapM flattenSum cons signalsFrom x = Left $ "Could not process signal near: " ++ show x- signalDecl = note "No sum type named \"Signal\" found." $- find (dataDeclNamed (HsIdent "Signal")) decls+ signalDecl = note "No sum type named \"SignalToUI\" found." $+ find (dataDeclNamed (HsIdent dataName)) decls mapQtType :: Type -> String mapQtType TInt = "int"@@ -113,12 +90,20 @@ mapLowCType :: Type -> String mapLowCType TInt = "int"-mapLowCType TUTCTime = "uint" -- Not time_t because of Qt+mapLowCType TUTCTime = "unsigned int" -- Not time_t because of Qt mapLowCType TDouble = "double"-mapLowCType TString = "const char *"-mapLowCType TText = "const char *"-mapLowCType TLText = "const char *"+mapLowCType TString = "char *"+mapLowCType TText = "char *"+mapLowCType TLText = "char *" +destroyLowCArg :: Type -> String+destroyLowCArg TInt = ""+destroyLowCArg TUTCTime = ""+destroyLowCArg TDouble = ""+destroyLowCArg TString = "free"+destroyLowCArg TText = "free"+destroyLowCArg TLText = "free"+ mapCType :: Type -> String mapCType TInt = "CInt" mapCType TUTCTime = "CUInt" -- Not CTime because of Qt@@ -127,20 +112,13 @@ mapCType TText = "CString" mapCType TLText = "CString" --- We always live in IO on the C side-mapCRType :: RType -> String-mapCRType RIOUnit = "IO ()"-mapCRType (RPure t) = "IO " ++ mapCType t-mapCRType (RIO t) = "IO " ++ mapCType t--wrapTypeFromC :: Type -> String -> String-wrapTypeFromC TInt arg = "(return $ fromIntegral " ++ arg ++ ")"-wrapTypeFromC TUTCTime arg = "(return $ posixSecondsToUTCTime $ realToFrac " ++ arg ++ ")"-wrapTypeFromC TDouble arg = "(return $ realToFrac " ++ arg ++ ")"-wrapTypeFromC TString arg = "(fmap (Text.unpack . Text.decodeUtf8) (ByteString.packCString " ++ arg ++ "))"-wrapTypeFromC TText arg = "(fmap Text.decodeUtf8 (ByteString.packCString " ++ arg ++ "))"-wrapTypeFromC TLText arg = "(fmap (LText.fromStrict . Text.decodeUtf8) (ByteString.packCString " ++ arg ++ "))"---wrapTypeFromC _ arg = "(return " ++ arg ++ ")"+wrapTypeFromC :: Type -> String+wrapTypeFromC TInt = "fmap (fromIntegral :: CInt -> Int)"+wrapTypeFromC TUTCTime = "fmap (posixSecondsToUTCTime . realToFrac :: CUInt -> UTCTime)"+wrapTypeFromC TDouble = "fmap (realToFrac :: CDouble -> Double)"+wrapTypeFromC TString = "fmap (Text.unpack . Text.decodeUtf8) . (ByteString.packCString =<<)"+wrapTypeFromC TText = "fmap Text.decodeUtf8 . (ByteString.packCString =<<)"+wrapTypeFromC TLText = "fmap (LText.fromStrict . Text.decodeUtf8) . (ByteString.packCString =<<)" wrapTypeToC :: Type -> String -> String wrapTypeToC TInt arg = "(flip ($) (fromIntegral " ++ arg ++ "))"@@ -152,9 +130,9 @@ wrapTypeFromQt :: Type -> String -> String wrapTypeFromQt TUTCTime arg = "(" ++ arg ++ ").toTime_t()"-wrapTypeFromQt TString arg = "(" ++ arg ++ ").toUtf8().constData()"-wrapTypeFromQt TText arg = "(" ++ arg ++ ").toUtf8().constData()"-wrapTypeFromQt TLText arg = "(" ++ arg ++ ").toUtf8().constData()"+wrapTypeFromQt TString arg = "qstrdup((" ++ arg ++ ").toUtf8().constData())"+wrapTypeFromQt TText arg = "qstrdup((" ++ arg ++ ").toUtf8().constData())"+wrapTypeFromQt TLText arg = "qstrdup((" ++ arg ++ ").toUtf8().constData())" wrapTypeFromQt _ arg = "(" ++ arg ++ ")" wrapTypeToQt :: Type -> String -> String@@ -172,27 +150,6 @@ defTypeToC TText = "(flip ($) nullPtr)" defTypeToC TLText = "(flip ($) nullPtr)" -templateSlot :: (String, [Type], RType) -> Slot-templateSlot (fname, args, rtype) = Slot {- name = fname,- monadic = case rtype of- RPure _ -> "(return " ++ fname ++ ")"- RIOUnit -> "(" ++ fname ++ ")"- RIO _ -> "(" ++ fname ++ ")",- hasArgs = not (null args),- args = zipWith (\i a -> SlotArg {- firstarg = i == 0,- aname = "arg" ++ show i,- ctype = mapCType a,- lowctype = mapLowCType a,- qttype = mapQtType a,- cwrap = wrapTypeFromC a ("arg" ++ show i),- qtunwrap = wrapTypeFromQt a ("arg" ++ show i)- }) [(0::Int)..] args,- crtype = mapCRType rtype,- crwrap = "(return)" -- TODO- }- sigCWrap' :: [(Int, Type)] -> [(Int, Type)] -> ([(Int, Int)], [String]) sigCWrap' [] _ = ([], []) sigCWrap' ((ei,e):es) ts@@ -215,11 +172,16 @@ templateSignal :: [Type] -> Integer -> (String, [Type]) -> Signal templateSignal signalTypes i (name, ts) = Signal {+ sigfirst = i == 1, -- This must be set to the initial eventid provided by main signame = name, sigargs = zipWith (\i t -> SignalArg { sigargfirst = i == 0, siganame = "arg" ++ show i, qtsigargtype = mapQtType t,+ csigargtype = mapLowCType t,+ sigargfromc = wrapTypeFromC t,+ sigargfromqt = wrapTypeFromQt t ("arg" ++ show i),+ sigargdestroy = destroyLowCArg t, sigargsigtypename = let Just x = lookup i idxs in "arg" ++ show x }) [0..] ts, sigevent = i,@@ -229,33 +191,39 @@ (idxs, cwrap) = sigCWrap signalTypes $ zip [0..] ts parseArgs :: [String] -> Either String [String]-parseArgs [a,b] = return [a,b]+parseArgs [a,b,c] = return [a,b,c] parseArgs _ =- Left "Usage: haskades HaskadesBinding.hs haskades_run.cpp < Types.hs"+ Left "Usage: haskades HaskadesBinding.hsc haskades_run.cpp haskades_run.h < Types.hs" main :: IO () main = runScript $ do- [hsout, cppout] <- hoistEither . parseArgs =<< scriptIO getArgs+ [hsout, cppout, headerPath] <- hoistEither . parseArgs =<< scriptIO getArgs (mod, importEnv, decls) <- fmap doParse (scriptIO getContents)- slots <- hoistEither $ getSlots importEnv decls- signals <- hoistEither $ getSignals importEnv decls- let signalTypes = concatMap (\(t,c) -> replicate c t) $ M.toAscList $- M.unionsWith max $ map (M.fromListWith (+) . (`zip` [1,1..]) . snd) signals- let sigs = zipWith (templateSignal signalTypes) [1..] signals- let sigTypes = zipWith (\i t -> SignalType {++ toUI <- hoistEither $ getSignals "SignalToUI" importEnv decls+ let toUItypes = concatMap (\(t,c) -> replicate c t) $ M.toAscList $+ M.unionsWith max $ map (M.fromListWith (+) . (`zip` [1,1..]) . snd) toUI+ let toUItmpl = zipWith (templateSignal toUItypes) [1..] toUI+ let toUItypeTmpl = zipWith (\i t -> SignalType { csigtype = mapCType t, qtsigtype = mapQtType t, qtwrapsig = wrapTypeToQt t ("arg" ++ show i), lowcsigtype = mapLowCType t, sigtypename = "arg" ++ show i- }) [(0::Int)..] signalTypes+ }) [(0::Int)..] toUItypes++ fromUI <- hoistEither $ getSignals "SignalFromUI" importEnv decls+ let fromUItmpl = zipWith (templateSignal []) [1..] fromUI+ let template = Template {+ headerPath = headerPath, modul = mod,- slots = map templateSlot slots,- signalTypes = sigTypes,- signals = sigs+ toUItypes = toUItypeTmpl,+ toUI = toUItmpl,+ fromUI = fromUItmpl } - scriptIO $ TL.writeFile hsout $ toLazyText $ haskadesBindinghs id template+ scriptIO $ TL.writeFile hsout $ toLazyText $ haskadesBindinghsc id template scriptIO $ TL.writeFile cppout $ toLazyText $ haskades_runcpp id template+ scriptIO $ TL.writeFile headerPath $ toLazyText $ haskades_runh id template