mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-25 01:55:39 +01: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,20 +506,22 @@ 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
|
||||||
p <- (#peek msgpack_object, via.array.ptr) ptr
|
let size = fromIntegral (csize :: Word32)
|
||||||
objs <- mapM (\i -> peekObject $ p `plusPtr`
|
p <- (#peek msgpack_object, via.array.ptr) ptr
|
||||||
|
objs <- mapM (\i -> peekObject $ p `plusPtr`
|
||||||
((#size msgpack_object) * i))
|
((#size msgpack_object) * i))
|
||||||
[0..size-1]
|
[0..size-1]
|
||||||
return $ ObjectArray objs
|
return $ ObjectArray objs
|
||||||
|
|
||||||
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
|
||||||
p <- (#peek msgpack_object, via.map.ptr) ptr
|
let size = fromIntegral (csize :: Word32)
|
||||||
dat <- mapM (\i -> peekObjectKV $ p `plusPtr`
|
p <- (#peek msgpack_object, via.map.ptr) ptr
|
||||||
|
dat <- mapM (\i -> peekObjectKV $ p `plusPtr`
|
||||||
((#size msgpack_object_kv) * i))
|
((#size msgpack_object_kv) * i))
|
||||||
[0..size-1]
|
[0..size-1]
|
||||||
return $ ObjectMap dat
|
return $ ObjectMap dat
|
||||||
|
|
||||||
peekObjectKV :: Ptr a -> IO (Object, Object)
|
peekObjectKV :: Ptr a -> IO (Object, Object)
|
||||||
@ -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