HsSyck 0.4 → 0.42
raw patch · 3 files changed
+46/−45 lines, 3 filesdep +bytestringdep ~basenew-uploader
Dependencies added: bytestring
Dependency ranges changed: base
Files
- Changes +8/−0
- Data/Yaml/Syck.hsc +14/−31
- HsSyck.cabal +24/−14
Changes view
@@ -1,3 +1,10 @@+[Changes for 0.041 - 2008-02-19]++* Update the ByteString function calls for the ByteStrings packaged+ with GHC 6.8.2 (and up).+ Improve Cabal metadata.+ Contributed by: Gwern Branwen+ [Changes for 0.04 - 2007-06-16] * Add Haddock documentations; no functional changes.@@ -8,3 +15,4 @@ * First working Hackage release: Unbreak the build by adding missing extra-source-files. Requested by: Bryan O'Sullivan+
Data/Yaml/Syck.hsc view
@@ -1,15 +1,3 @@--- |--- Module : Data.Yaml.Syck--- Copyright : Copyright 2005, 2006, 2007 by Audrey Tang, Gaal Yahas--- License : MIT --- Maintainer : Audrey Tang <audreyt@audreyt.org>--- Stability : provisional--- Portability : ghc------ This is an interface to the @syck@ C library for parsing and--- dumping YAML data. It lets you transform textual YAML data into an--- object of type 'YamlNode', and vice versa, fast.- #include "syck.h" module Data.Yaml.Syck (@@ -36,7 +24,8 @@ import GHC.Ptr (Ptr(..)) import qualified Data.HashTable as Hash import qualified Data.ByteString.Char8 as Buf-import Data.ByteString.Char8 (copyCStringLen, useAsCStringLen, useAsCString, copyCString)+import Data.ByteString.Char8 (useAsCStringLen, useAsCString)+import Data.ByteString.Unsafe (unsafePackCString, unsafePackCStringLen) type Buf = Buf.ByteString type YamlTag = Maybe Buf@@ -76,7 +65,7 @@ type SyckErrorHandler = SyckParser -> CString -> IO () type SyckBadAnchorHandler = SyckParser -> CString -> IO SyckNodePtr type SyckNodePtr = Ptr CString-type SyckEmitter = Ptr () +type SyckEmitter = Ptr () type SyckEmitterHandler = SyckEmitter -> Ptr () -> IO () type SyckOutputHandler = SyckEmitter -> CString -> CLong -> IO () data SyckKind = SyckMap | SyckSeq | SyckStr@@ -88,7 +77,6 @@ nilNode :: YamlNode nilNode = MkNode maxId ENil Nothing ASingleton - -- | Convert a ByteString buffer into a regular Haskell string {-# INLINE unpackBuf #-}@@ -131,14 +119,9 @@ bracket syck_new_emitter syck_free_emitter $ \emitter -> do -- set up output port out <- newIORef []- #{poke SyckEmitter, style} emitter scalarFold #{poke SyckEmitter, anchor_format} emitter (Ptr "%d"## :: CString) - -- Uncomment this line if you want EMap to sort its keys.- -- (this is usually unnecessary because Data.Map is already sorted.)- -- #{poke SyckEmitter, sort_keys} emitter (1 :: CInt)- marks <- Hash.new (==) (Hash.hashInt) let freeze = freezeNode marks@@ -185,7 +168,7 @@ outputCallbackPS :: IORef [Buf] -> SyckEmitter -> CString -> CLong -> IO () outputCallbackPS out emitter buf len = do- str <- copyCStringLen (buf, fromEnum len)+ str <- unsafePackCStringLen (buf, fromEnum len) str `seq` modifyIORef out (str:) outputCallback :: SyckEmitter -> CString -> CLong -> IO ()@@ -209,20 +192,20 @@ emitNode _ e n | EStr s <- n_elem n = do withTag n (Ptr "string"##) $ \tag ->- useAsCStringLen s $ \(cs, l) -> + useAsCStringLen s $ \(cs, l) -> syck_emit_scalar e tag scalarFold 0 0 0 cs (toEnum l) emitNode freeze e n | ESeq sq <- n_elem n = do withTag n (Ptr "array"##) $ \tag ->--- syck_emit_seq e tag seqInline- syck_emit_seq e tag seqNone+-- syck_emit_seq e tag seqInline+ syck_emit_seq e tag seqNone mapM_ (syck_emit_item e) =<< mapM freeze sq syck_emit_end e emitNode freeze e n | EMap m <- n_elem n = do withTag n (Ptr "map"##) $ \tag ->--- syck_emit_map e tag mapInline- syck_emit_map e tag mapNone+-- syck_emit_map e tag mapInline+ syck_emit_map e tag mapNone flip mapM_ m (\(k,v) -> do syck_emit_item e =<< freeze k syck_emit_item e =<< freeze v)@@ -366,7 +349,7 @@ syckNodeTag syckNode = do tag <- #{peek SyckNode, type_id} syckNode if (tag == nullPtr) then (return Nothing) else do- p <- copyCString tag+ p <- unsafePackCString tag return $! case Buf.elemIndex '/' p of Just n -> let { pre = Buf.take n p; post = Buf.drop (n+1) p } in Just $ Buf.concat [_tagLiteral, pre, _colonLiteral, post]@@ -403,7 +386,7 @@ parseNode SyckStr _ syckNode len nid = do tag <- syckNodeTag syckNode cstr <- syck_str_read syckNode- buf <- copyCStringLen (cstr, fromEnum len)+ buf <- unsafePackCStringLen (cstr, fromEnum len) let node = nilNode{ n_elem = EStr buf, n_tag = tag, n_id = nid } if tag == Nothing && Buf.length buf == 1 && Buf.index buf 0 == '~' then do@@ -413,13 +396,13 @@ else return node else return node -foreign import ccall "wrapper" +foreign import ccall "wrapper" mkNodeCallback :: SyckNodeHandler -> IO (FunPtr SyckNodeHandler) -foreign import ccall "wrapper" +foreign import ccall "wrapper" mkErrorCallback :: SyckErrorHandler -> IO (FunPtr SyckErrorHandler) -foreign import ccall "wrapper" +foreign import ccall "wrapper" mkBadHandlerCallback :: SyckBadAnchorHandler -> IO (FunPtr SyckBadAnchorHandler) foreign import ccall "wrapper"
HsSyck.cabal view
@@ -1,24 +1,34 @@ Name: HsSyck-Version: 0.4-Category: Data+Version: 0.42+Category: Text Synopsis: Fast, lightweight YAML loader and dumper-Description: Fast, lightweight YAML loader and dumper- .- This is an interface to the @syck@ C library for parsing and- dumping YAML data. It lets you transform textual YAML data into an- object of type 'YamlNode', and vice versa, fast.-Copyright: Audrey Tang, Gaal Yahas, 2005, 2006, 2007+Description: This is a simple YAML ('Yet Another Markup Language') processor,+ used by the Pugs project for handling data serialization; this can be+ useful for optimization and caching purposes.+ .+ This is an interface to the @syck@ C library for parsing and+ dumping YAML data. It lets you transform textual YAML data into an+ object of type 'YamlNode', and vice versa, fast.++-- License is really "MIT", but Cabal doesn't have that constant yet License: OtherLicense--- MIT License, see ./LICENSE-License-file: LICENSE+License-File: LICENSE Author: Audrey Tang Maintainer: audreyt@audreyt.org-Build-Depends: base >= 0.2+Copyright: Audrey Tang, Gaal Yahas, 2005, 2006, 2007+ Exposed-modules: Data.Yaml.Syck++Build-Depends: base, bytestring>=0.9.0.1+Build-Type: Simple+Tested-With: GHC==6.8.2+ extensions: ForeignFunctionInterface-ghc-options: -fglasgow-exts -O2 -optc-w -funbox-strict-fields -fno-warn-orphans+ghc-options: -O2 -optc-w -funbox-strict-fields -fglasgow-exts++data-files: Changes c-sources: syck/bytecode.c syck/emitter.c syck/gram.c syck/handler.c syck/implicit.c syck/node.c syck/syck.c syck/syck_st.c syck/token.c- syck/yaml2byte.c -extra-source-files: Changes syck/syck.h syck/syck_st.h syck/gram.h syck/yamlbyte.h+ syck/yaml2byte.c+extra-source-files: syck/syck.h syck/syck_st.h syck/gram.h syck/yamlbyte.h include-dirs: syck