diff options
Diffstat (limited to 'hsm-cam/Hsm/Cam')
-rw-r--r-- | hsm-cam/Hsm/Cam/Lib.cpp | 11 | ||||
-rw-r--r-- | hsm-cam/Hsm/Cam/Lib.hsc | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/hsm-cam/Hsm/Cam/Lib.cpp b/hsm-cam/Hsm/Cam/Lib.cpp new file mode 100644 index 0000000..5eda6d7 --- /dev/null +++ b/hsm-cam/Hsm/Cam/Lib.cpp @@ -0,0 +1,11 @@ +#include <string> + +#include "Lib_stub.h" + +void log_msg(const std::string &str) { + logMsg((HsPtr)str.c_str()); +} + +extern "C" void some_c_wrapper() { + log_msg("Hello from C++!"); +} diff --git a/hsm-cam/Hsm/Cam/Lib.hsc b/hsm-cam/Hsm/Cam/Lib.hsc new file mode 100644 index 0000000..4f6dadf --- /dev/null +++ b/hsm-cam/Hsm/Cam/Lib.hsc @@ -0,0 +1,20 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE OverloadedStrings #-} + +module Hsm.Cam.Lib + ( someCWrapper + ) where + +import Control.Monad ((>=>)) +import Data.Text (pack) +import Foreign.C.String (CString, peekCString) +import Hsm.Log qualified as L + +foreign export ccall logMsg :: CString -> IO () + +logMsg :: CString -> IO () +logMsg = peekCString >=> L.logMsg ["cam", "lib"] . pack + +foreign import ccall safe "Test.h some_c_wrapper" + someCWrapper :: IO () |