packages feed

emacs-module 0.2 → 0.2.1

raw patch · 8 files changed

+48/−9 lines, 8 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Emacs.Module: makeBinaryString :: (MonadEmacs m v, WithCallStack) => ByteString -> m s (v s)
+ Emacs.Module.Monad.Class: makeBinaryString :: (MonadEmacs m v, WithCallStack) => ByteString -> m s (v s)

Files

Changelog.md view
@@ -1,3 +1,7 @@+# 0.2.1++- Expose `make_unibyte_string` as `makeBinaryString`+ # 0.2  - Major rework of the package’s core
Readme.md view
@@ -29,8 +29,9 @@  ## FAQ ### How do I start writing my own extensions?-Some day there will be a proper tutorial for using this package.-For the time being the best place to start is+See tutorial at https://github.com/sergv/emacs-module/blob/master/Tutorial.md.++Also check out [this package’s tests](https://github.com/sergv/emacs-module/blob/master/test/src/Emacs/TestsInit.hs).  ### What about Windows?@@ -51,9 +52,6 @@ marhsalling. In this approach, an extension will look like a shared library/dll that can be loaded by standard emacs with `(load "/tmp/libmy-ext.so")`. -### Is there a tutorial?-It’s at https://github.com/sergv/emacs-module/blob/master/Tutorial.md.- ## Supported GHC versions -Tested with GHC `9.2`, `9.4`, `9.6`.+Tested with GHC `9.2`, `9.4`, `9.6`, `9.8`.
emacs-module.cabal view
@@ -3,7 +3,7 @@ name:   emacs-module version:-  0.2+  0.2.1 category: Foreign, Foreign binding  synopsis:@@ -29,7 +29,11 @@ maintainer:   Sergey Vinokurov <serg.foo@gmail.com> tested-with:-    GHC == 9.2.7, GHC == 9.4.5, GHC == 9.6.1+  , GHC == 9.2.8+  , GHC == 9.4.7+  , GHC == 9.6.3+  , GHC == 9.8.1+ extra-source-files:   cbits/emacs-module.h @@ -67,7 +71,6 @@     GHC2021    default-extensions:-    ImportQualifiedPost     LambdaCase    ghc-options:@@ -90,6 +93,11 @@   if impl(ghc >= 9.2)     ghc-options:       -Wno-missing-kind-signatures++  if impl(ghc >= 9.8)+    ghc-options:+      -Wno-missing-role-annotations+      -Wno-missing-poly-kind-signatures  library   import: ghc-options
src/Data/Emacs/Module/Raw/Env.hsc view
@@ -49,6 +49,7 @@   , makeFloat   , copyStringContents   , makeString+  , makeUnibyteString   , makeUserPtr   , getUserPtr   , setUserPtr@@ -411,6 +412,21 @@   -> CPtrdiff -- ^ Length.   -> m (RawValue 'Regular) makeString = makeStringTH+++$(wrapEmacsFunc "makeUnibyteStringTH" Unsafe+   [e| (#peek emacs_env, make_unibyte_string) |]+   [t| Env -> CString -> CPtrdiff -> IO (RawValue 'Regular) |])++{-# INLINE makeUnibyteString #-}+makeUnibyteString+  :: MonadIO m+  => Env+  -> CString  -- ^ Any string, may contain anything bytes and is+              -- not required to be terminated with null byte.+  -> CPtrdiff -- ^ Length.+  -> m (RawValue 'Regular)+makeUnibyteString = makeUnibyteStringTH   $(wrapEmacsFunc "makeUserPtrTH" Unsafe
src/Data/Emacs/Module/Raw/Value/Internal.hs view
@@ -6,6 +6,7 @@ -- Maintainer  :  serg.foo@gmail.com ---------------------------------------------------------------------------- +{-# LANGUAGE CPP          #-} {-# LANGUAGE DataKinds    #-} {-# LANGUAGE DerivingVia  #-} {-# LANGUAGE TypeFamilies #-}@@ -25,7 +26,9 @@ import Data.Vector.Generic.Mutable qualified as GM import Data.Vector.Primitive qualified as P import Data.Vector.Unboxed qualified as U+#if !MIN_VERSION_vector(0, 13, 1) import Data.Vector.Unboxed.Base qualified as U+#endif import Foreign import GHC.Generics (Generic) import Prettyprinter (Pretty(..))
src/Data/Emacs/Module/Value/Internal.hs view
@@ -6,6 +6,7 @@ -- Maintainer  :  serg.foo@gmail.com ---------------------------------------------------------------------------- +{-# LANGUAGE CPP                  #-} {-# LANGUAGE DataKinds            #-} {-# LANGUAGE DerivingVia          #-} {-# LANGUAGE TypeFamilies         #-}@@ -23,7 +24,9 @@ import Data.Vector.Generic.Mutable qualified as GM import Data.Vector.Primitive qualified as P import Data.Vector.Unboxed qualified as U+#if !MIN_VERSION_vector(0, 13, 1) import Data.Vector.Unboxed.Base qualified as U+#endif import GHC.Generics (Generic) import Prettyprinter (Pretty) 
src/Emacs/Module/Monad.hs view
@@ -336,6 +336,11 @@     BSU.unsafeUseAsCStringLen x $ \(pStr, len) ->       coerce $ Env.makeString @IO env pStr (fromIntegral len) +  makeBinaryString :: WithCallStack => BS.ByteString -> EmacsM s (Value s)+  makeBinaryString x = withEnv $ \env ->+    BSU.unsafeUseAsCStringLen x $ \(pStr, len) ->+      coerce $ Env.makeUnibyteString @IO env pStr (fromIntegral len)+   extractUserPtr :: WithCallStack => Value s -> EmacsM s (Ptr a)   extractUserPtr x = EmacsM $ do     Environment{eEnv, eNonLocalState, eArgsCache} <- ask
src/Emacs/Module/Monad/Class.hs view
@@ -174,6 +174,8 @@   -- | Convert a utf8-encoded ByteString into an Emacs value.   makeString :: WithCallStack => BS.ByteString -> m s (v s) +  -- | Convert any ByteString into an Emacs unibyte string.+  makeBinaryString :: WithCallStack => BS.ByteString -> m s (v s)    -- | Extract a user pointer from an Emacs value.   extractUserPtr :: WithCallStack => v s -> m s (Ptr a)