Skip to content

Commit

Permalink
Move OsString into separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Oct 19, 2023
1 parent 97fc2e3 commit ee6b81f
Show file tree
Hide file tree
Showing 33 changed files with 112 additions and 4,313 deletions.
9 changes: 5 additions & 4 deletions Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ main = do
, "{-# LANGUAGE ViewPatterns #-}"
#endif
, "{-# LANGUAGE CPP #-}"
, "{-# LANGUAGE PackageImports #-}"
, "{-# OPTIONS_GHC -Wno-name-shadowing #-}"
, "{-# OPTIONS_GHC -Wno-orphans #-}"
,"module TestGen(tests) where"
Expand All @@ -34,11 +35,11 @@ main = do
,"import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )"
,"import GHC.IO.Encoding.UTF16 ( mkUTF16le )"
,"import GHC.IO.Encoding.UTF8 ( mkUTF8 )"
,"import System.OsString.Internal.Types"
,"import System.OsPath.Encoding.Internal"
,"import \"os-string\" System.OsString.Internal.Types"
,"import \"os-string\" System.OsString.Encoding.Internal"
,"import qualified Data.Char as C"
,"import qualified System.OsPath.Data.ByteString.Short as SBS"
,"import qualified System.OsPath.Data.ByteString.Short.Word16 as SBS16"
,"import qualified \"os-string\" System.OsString.Data.ByteString.Short as SBS"
,"import qualified \"os-string\" System.OsString.Data.ByteString.Short.Word16 as SBS16"
,"import qualified System.FilePath.Windows as W"
,"import qualified System.FilePath.Posix as P"
#ifdef GHC_MAKE
Expand Down
6 changes: 3 additions & 3 deletions System/FilePath/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
import GHC.IO.Encoding.UTF16 ( mkUTF16le )
import qualified GHC.Foreign as GHC
import Data.Word ( Word16 )
import System.OsPath.Data.ByteString.Short.Word16
import System.OsPath.Data.ByteString.Short ( packCStringLen )
import "os-string" System.OsString.Data.ByteString.Short.Word16
import "os-string" System.OsString.Data.ByteString.Short ( packCStringLen )
#define CHAR Word16
#define STRING ShortByteString
#define FILEPATH ShortByteString
Expand All @@ -148,7 +148,7 @@ import GHC.IO.Encoding.Failure ( CodingFailureMode(..) )
import qualified GHC.Foreign as GHC
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
import Data.Word ( Word8 )
import System.OsPath.Data.ByteString.Short
import "os-string" System.OsString.Data.ByteString.Short
#define CHAR Word8
#define STRING ShortByteString
#define FILEPATH ShortByteString
Expand Down
9 changes: 5 additions & 4 deletions System/OsPath/Common.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE PackageImports #-}
-- This template expects CPP definitions for:
--
-- WINDOWS defined? = no | yes | no
Expand Down Expand Up @@ -109,7 +110,7 @@ where

#ifdef WINDOWS
import System.OsPath.Types
import System.OsString.Windows as PS
import "os-string" System.OsString.Windows as PS
( unsafeFromChar
, toChar
, decodeUtf
Expand Down Expand Up @@ -141,7 +142,7 @@ import Language.Haskell.TH.Syntax

import GHC.IO.Encoding.UTF8 ( mkUTF8 )
import System.OsPath.Types
import System.OsString.Posix as PS
import "os-string" System.OsString.Posix as PS
( unsafeFromChar
, toChar
, decodeUtf
Expand Down Expand Up @@ -171,7 +172,7 @@ import System.OsPath.Internal as PS
)
import System.OsPath.Types
( OsPath )
import System.OsString ( unsafeFromChar, toChar )
import "os-string" System.OsString ( unsafeFromChar, toChar )

#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
import qualified System.OsPath.Windows as C
Expand All @@ -182,7 +183,7 @@ import qualified System.OsPath.Posix as C
import Data.Bifunctor
( bimap )
#endif
import System.OsString.Internal.Types
import "os-string" System.OsString.Internal.Types


------------------------
Expand Down
19 changes: 3 additions & 16 deletions System/OsPath/Data/ByteString/Short.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
--
-- > import qualified Data.ByteString.Short as B.Short
--
module System.OsPath.Data.ByteString.Short (
module System.OsPath.Data.ByteString.Short {-# DEPRECATED "Use System.OsString.Data.ByteString.Short from os-string package instead" #-} (

-- * The @ShortByteString@ type

Expand Down Expand Up @@ -174,18 +174,5 @@ module System.OsPath.Data.ByteString.Short (
useAsCStringLen,
) where

import Data.ByteString.Short.Internal
import System.OsPath.Data.ByteString.Short.Internal

import Prelude (Maybe(..), Ord(..), Num(..), ($), otherwise)
import Data.Word (Word8)

uncons2 :: ShortByteString -> Maybe (Word8, Word8, ShortByteString)
uncons2 = \sbs ->
let l = length sbs
nl = l - 2
in if | l <= 1 -> Nothing
| otherwise -> let h = indexWord8Array (asBA sbs) 0
h' = indexWord8Array (asBA sbs) 1
t = create nl $ \mba -> copyByteArray (asBA sbs) 1 mba 0 nl
in Just (h, h', t)
import System.OsString.Data.ByteString.Short

Loading

0 comments on commit ee6b81f

Please sign in to comment.