mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-04-03 01:54:45 +02:00
Merge branch 'master' of ssh://github.com/msgpack/msgpack
This commit is contained in:
commit
f40ebe5b43
@ -1,5 +1,5 @@
|
|||||||
Name: msgpack
|
Name: msgpack
|
||||||
Version: 0.2.1
|
Version: 0.2.2
|
||||||
License: BSD3
|
License: BSD3
|
||||||
License-File: LICENSE
|
License-File: LICENSE
|
||||||
Author: Hideyuki Tanaka
|
Author: Hideyuki Tanaka
|
||||||
|
@ -506,7 +506,8 @@ peekObjectRAW ptr = do
|
|||||||
|
|
||||||
peekObjectArray :: Ptr a -> IO Object
|
peekObjectArray :: Ptr a -> IO Object
|
||||||
peekObjectArray ptr = do
|
peekObjectArray ptr = do
|
||||||
size <- (#peek msgpack_object, via.array.size) ptr
|
csize <- (#peek msgpack_object, via.array.size) ptr
|
||||||
|
let size = fromIntegral (csize :: Word32)
|
||||||
p <- (#peek msgpack_object, via.array.ptr) ptr
|
p <- (#peek msgpack_object, via.array.ptr) ptr
|
||||||
objs <- mapM (\i -> peekObject $ p `plusPtr`
|
objs <- mapM (\i -> peekObject $ p `plusPtr`
|
||||||
((#size msgpack_object) * i))
|
((#size msgpack_object) * i))
|
||||||
@ -515,7 +516,8 @@ peekObjectArray ptr = do
|
|||||||
|
|
||||||
peekObjectMap :: Ptr a -> IO Object
|
peekObjectMap :: Ptr a -> IO Object
|
||||||
peekObjectMap ptr = do
|
peekObjectMap ptr = do
|
||||||
size <- (#peek msgpack_object, via.map.size) ptr
|
csize <- (#peek msgpack_object, via.map.size) ptr
|
||||||
|
let size = fromIntegral (csize :: Word32)
|
||||||
p <- (#peek msgpack_object, via.map.ptr) ptr
|
p <- (#peek msgpack_object, via.map.ptr) ptr
|
||||||
dat <- mapM (\i -> peekObjectKV $ p `plusPtr`
|
dat <- mapM (\i -> peekObjectKV $ p `plusPtr`
|
||||||
((#size msgpack_object_kv) * i))
|
((#size msgpack_object_kv) * i))
|
||||||
@ -560,6 +562,7 @@ unpackObject z dat =
|
|||||||
allocaBytes (#size msgpack_object) $ \ptr ->
|
allocaBytes (#size msgpack_object) $ \ptr ->
|
||||||
BS.useAsCStringLen dat $ \(str, len) ->
|
BS.useAsCStringLen dat $ \(str, len) ->
|
||||||
alloca $ \poff -> do
|
alloca $ \poff -> do
|
||||||
|
poke poff 0
|
||||||
ret <- msgpack_unpack str (fromIntegral len) poff z ptr
|
ret <- msgpack_unpack str (fromIntegral len) poff z ptr
|
||||||
case ret of
|
case ret of
|
||||||
(#const MSGPACK_UNPACK_SUCCESS) -> do
|
(#const MSGPACK_UNPACK_SUCCESS) -> do
|
||||||
|
@ -82,7 +82,7 @@ packToString m = do
|
|||||||
_ <- runPackerT m pc
|
_ <- runPackerT m pc
|
||||||
liftIO $ simpleBufferData sb
|
liftIO $ simpleBufferData sb
|
||||||
|
|
||||||
-- | Execcute given serializer and write byte sequence to Handle.
|
-- | Execute given serializer and write byte sequence to Handle.
|
||||||
packToHandle :: MonadIO m => Handle -> PackerT m r -> m ()
|
packToHandle :: MonadIO m => Handle -> PackerT m r -> m ()
|
||||||
packToHandle h m = do
|
packToHandle h m = do
|
||||||
sb <- packToString m
|
sb <- packToString m
|
||||||
|
Loading…
x
Reference in New Issue
Block a user