From 3cbc5823a9ab63337f144395eefea5ff18eee416 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sun, 11 Feb 2024 17:53:36 -0700 Subject: Added some more comments --- src/Wetterhorn/FFI.hs | 8 +++++++- src/harness_adapter.c | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Wetterhorn/FFI.hs b/src/Wetterhorn/FFI.hs index c27c129..bfb3cbd 100644 --- a/src/Wetterhorn/FFI.hs +++ b/src/Wetterhorn/FFI.hs @@ -1,6 +1,6 @@ -- | This module does not export anything. It exists simply to provide C-symbols -- for the plugin. -module Wetterhorn.FFI() where +module Wetterhorn.FFI () where import Control.Monad (forM_) import qualified Data.ByteString as BS @@ -18,6 +18,8 @@ import Foreign import Foreign.C (CChar) import Wetterhorn.Core +-- | This function should be defined somewhere in the code. This is kind of like +-- the "main" function in XMonad. foreign import ccall wetterhorn :: IO Wetterhorn -- | This function is the implementation of the "hotstart" mechanism. It gives a @@ -35,12 +37,16 @@ pluginHotStart chars len = do freeStablePtr wtrPtr newStablePtr . (conf,) =<< readWState bs +-- | This function is called when a "coldstart" request is receieved. It just +-- calles the function "wetterhorn". This function should be defined in the main +-- code as it's sort-of the equivalent of XMonad's "main" function. foreign export ccall "plugin_cold_start" pluginColdStart :: IO Wetterhorn pluginColdStart :: IO Wetterhorn pluginColdStart = wetterhorn +-- | Marshals the opaque state to a C-style byte array and size pointer. foreign export ccall "plugin_marshal_state" pluginMarshalState :: Wetterhorn -> Ptr Word32 -> IO (Ptr Word8) diff --git a/src/harness_adapter.c b/src/harness_adapter.c index 15a2269..82e8caf 100644 --- a/src/harness_adapter.c +++ b/src/harness_adapter.c @@ -1,3 +1,8 @@ +// This file provides functions for the wetterhorn harness that are not +// expressible directly in haskell. +// +// Currently these functions exclusively enable/disable the Haskell runtime. + #include "HsFFI.h" #include "plugin_interface.h" -- cgit