diff --git a/haskell/msgpack.cabal b/haskell/msgpack.cabal
index 505a2b9..31cad3b 100644
--- a/haskell/msgpack.cabal
+++ b/haskell/msgpack.cabal
@@ -1,5 +1,5 @@
Name: msgpack
-Version: 0.2.0
+Version: 0.2.1
License: BSD3
License-File: LICENSE
Author: Hideyuki Tanaka
diff --git a/haskell/src/Data/MessagePack/Base.hsc b/haskell/src/Data/MessagePack/Base.hsc
index ad71712..72c421c 100644
--- a/haskell/src/Data/MessagePack/Base.hsc
+++ b/haskell/src/Data/MessagePack/Base.hsc
@@ -297,7 +297,7 @@ foreign import ccall "msgpack_pack_raw_body_wrap" msgpack_pack_raw_body ::
-- | Pack a single byte stream. It calls 'packRAW' and 'packRAWBody'.
packRAW' :: Packer -> ByteString -> IO Int
packRAW' pc bs = do
- packRAW pc (BS.length bs)
+ _ <- packRAW pc (BS.length bs)
packRAWBody pc bs
type Unpacker = ForeignPtr ()
@@ -475,7 +475,7 @@ peekObject ptr = do
(#const MSGPACK_OBJECT_MAP) ->
peekObjectMap ptr
_ ->
- fail "peekObject: unknown object type"
+ fail $ "peekObject: unknown object type (" ++ show typ ++ ")"
peekObjectBool :: Ptr a -> IO Object
peekObjectBool ptr = do
@@ -541,11 +541,11 @@ packObject pc (ObjectDouble d) = packDouble pc d >> return ()
packObject pc (ObjectRAW bs) = packRAW' pc bs >> return ()
packObject pc (ObjectArray ls) = do
- packArray pc (length ls)
+ _ <- packArray pc (length ls)
mapM_ (packObject pc) ls
packObject pc (ObjectMap ls) = do
- packMap pc (length ls)
+ _ <- packMap pc (length ls)
mapM_ (\(a, b) -> packObject pc a >> packObject pc b) ls
data UnpackReturn =
diff --git a/haskell/src/Data/MessagePack/Class.hs b/haskell/src/Data/MessagePack/Class.hs
index f50a4d8..365acc5 100644
--- a/haskell/src/Data/MessagePack/Class.hs
+++ b/haskell/src/Data/MessagePack/Class.hs
@@ -27,7 +27,6 @@ module Data.MessagePack.Class(
import Control.Monad.Error
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as C8
-import Data.Either
import Data.MessagePack.Base
@@ -46,6 +45,11 @@ instance OBJECT Object where
fromObjectError :: String
fromObjectError = "fromObject: cannot cast"
+instance OBJECT () where
+ toObject = const ObjectNil
+ fromObject ObjectNil = Right ()
+ fromObject _ = Left fromObjectError
+
instance OBJECT Int where
toObject = ObjectInteger
fromObject (ObjectInteger n) = Right n
diff --git a/haskell/src/Data/MessagePack/Feed.hs b/haskell/src/Data/MessagePack/Feed.hs
index afd3f6c..4b48639 100644
--- a/haskell/src/Data/MessagePack/Feed.hs
+++ b/haskell/src/Data/MessagePack/Feed.hs
@@ -21,7 +21,6 @@ module Data.MessagePack.Feed(
feederFromString,
) where
-import Control.Monad
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import Data.IORef
@@ -33,12 +32,16 @@ type Feeder = IO (Maybe ByteString)
-- | Feeder from Handle
feederFromHandle :: Handle -> IO Feeder
feederFromHandle h = return $ do
- bs <- BS.hGet h bufSize
+ bs <- BS.hGetNonBlocking h bufSize
if BS.length bs > 0
- then return $ Just bs
+ then do return $ Just bs
else do
- hClose h
- return Nothing
+ c <- BS.hGet h 1
+ if BS.length c > 0
+ then do return $ Just c
+ else do
+ hClose h
+ return Nothing
where
bufSize = 4096
diff --git a/haskell/src/Data/MessagePack/Monad.hs b/haskell/src/Data/MessagePack/Monad.hs
index bf1514f..c718b8a 100644
--- a/haskell/src/Data/MessagePack/Monad.hs
+++ b/haskell/src/Data/MessagePack/Monad.hs
@@ -79,7 +79,7 @@ packToString :: MonadIO m => PackerT m r -> m ByteString
packToString m = do
sb <- liftIO $ newSimpleBuffer
pc <- liftIO $ newPacker sb
- runPackerT m pc
+ _ <- runPackerT m pc
liftIO $ simpleBufferData sb
-- | Execcute given serializer and write byte sequence to Handle.
@@ -115,18 +115,21 @@ instance MonadIO m => MonadIO (UnpackerT m) where
instance MonadIO m => MonadUnpacker (UnpackerT m) where
get = UnpackerT $ \up feed -> liftIO $ do
- resp <- unpackerExecute up
- guard $ resp>=0
- when (resp==0) $ do
- Just bs <- feed
- unpackerFeed up bs
- resp2 <- unpackerExecute up
- guard $ resp2==1
+ executeOne up feed
obj <- unpackerData up
freeZone =<< unpackerReleaseZone up
unpackerReset up
let Right r = fromObject obj
return r
+
+ where
+ executeOne up feed = do
+ resp <- unpackerExecute up
+ guard $ resp>=0
+ when (resp==0) $ do
+ Just bs <- feed
+ unpackerFeed up bs
+ executeOne up feed
-- | Execute deserializer using given feeder.
unpackFrom :: MonadIO m => Feeder -> UnpackerT m r -> m r
diff --git a/haskell/src/Data/MessagePack/Stream.hs b/haskell/src/Data/MessagePack/Stream.hs
index bd17f46..c56fe8d 100644
--- a/haskell/src/Data/MessagePack/Stream.hs
+++ b/haskell/src/Data/MessagePack/Stream.hs
@@ -19,9 +19,7 @@ module Data.MessagePack.Stream(
unpackObjectsFromString,
) where
-import Control.Monad
import Data.ByteString (ByteString)
-import qualified Data.ByteString as BS
import System.IO
import System.IO.Unsafe
diff --git a/java/pom.xml b/java/pom.xml
index 321e8d5..d1f6c34 100755
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -3,10 +3,12 @@
4.0.0
org.msgpack
msgpack
- MessagePack for Java
- 1.0-SNAPSHOT
+ 0.2
MessagePack for Java
+ MessagePack for Java
+ http://msgpack.sourceforge.net/
+
The Apache Software License, Version 2.0
@@ -16,9 +18,19 @@
- scm:git://github.com/msgpack/msgpack.git
+ scm:git:git://github.com/msgpack/msgpack.git
+ scm:git:git://github.com/msgpack/msgpack.git
+
+
+ junit
+ junit
+ 4.8.1
+ test
+
+
+
@@ -83,27 +95,50 @@
+
+
+ msgpack.sourceforge.net
+ MessagePack Maven2 Repository
+ http://msgpack.sourceforge.net/maven2
+
+
+ msgpack.sourceforge.net
+ MessagePack Maven2 Snapshot Repository
+ http://msgpack.sourceforge.net/maven2-snapshot
+
+
+
+
+
+ false
+ shell.sourceforge.net
+ Repository at sourceforge.net
+ scp://shell.sourceforge.net/home/groups/m/ms/msgpack/htdocs/maven2/
+
+
+ true
+ shell.sourceforge.net
+ Repository Name
+ scp://shell.sourceforge.net/home/groups/m/ms/msgpack/htdocs/maven2-snapshot/
+
+
+
-
- sourceforge
-
-
- sourceforge.net
- Repository at sourceforge.net
- scpexe://shell.sourceforge.net/home/groups/m/ms/msgpack/htdocs/maven2/
-
-
+ release
+
+
+
+ true
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ 2.4
+
+ true
+
+
+
+
-
-
-
- junit
- junit
- 4.8.1
- test
-
-
-
diff --git a/perl/Changes b/perl/Changes
index 47323a5..b03a9d0 100644
--- a/perl/Changes
+++ b/perl/Changes
@@ -1,3 +1,17 @@
+0.12
+
+ - PERL_NO_GET_CONTEXT makes horrible dTHXs. remove it.
+
+0.11
+
+ - oops(no feature changes)
+
+0.10
+
+ - added more test cases.
+ - fixed portability issue
+ - (reviewed by gfx++)
+
0.09_01
- fixed memory leak issue(reported by Maxime Soulé)
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index 61afc3d..58ab7c7 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -1,7 +1,7 @@
use inc::Module::Install;
name 'Data-MessagePack';
all_from 'lib/Data/MessagePack.pm';
-readme_from 'lib/Data/MessagePack.pm';
+readme_from('lib/Data/MessagePack.pm');
perl_version '5.008005';
license 'perl';
@@ -32,11 +32,10 @@ if ($Module::Install::AUTHOR && -d File::Spec->catfile('..', 'msgpack')) {
}
}
-requires 'Test::More' => 0.95; # done_testing
+requires 'Test::More' => 0.94; # done_testing
+test_requires('Test::Requires');
-auto_set_repository;
-build_requires 'Test::More';
-use_test_base;
+auto_set_repository();
auto_include;
WriteAll;
diff --git a/perl/README b/perl/README
new file mode 100644
index 0000000..31aae99
--- /dev/null
+++ b/perl/README
@@ -0,0 +1,34 @@
+NAME
+ Data::MessagePack - messagepack
+
+SYNOPSIS
+ my $packed = Data::MessagePack->pack($dat);
+ my $unpacked = Data::MessagePack->unpack($dat);
+
+DESCRIPTION
+ Data::MessagePack is a binary packer for perl.
+
+METHODS
+ my $packed = Data::MessagePack->pack($data);
+ pack the $data to messagepack format string.
+
+ my $unpacked = Data::MessagePack->unpack($msgpackstr);
+ unpack the $msgpackstr to messagepack format string.
+
+Configuration Variables
+ $Data::MessagePack::PreferInteger
+ Pack the string as int when the value looks like int(EXPERIMENTAL).
+
+AUTHORS
+ Tokuhiro Matsuno
+
+THANKS TO
+ Jun Kuriyama
+
+LICENSE
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+SEE ALSO
+
+
diff --git a/perl/lib/Data/MessagePack.pm b/perl/lib/Data/MessagePack.pm
index 52f89bb..dcc713d 100644
--- a/perl/lib/Data/MessagePack.pm
+++ b/perl/lib/Data/MessagePack.pm
@@ -4,7 +4,7 @@ use warnings;
use XSLoader;
use 5.008001;
-our $VERSION = '0.09_01';
+our $VERSION = '0.12';
our $PreferInteger = 0;
our $true = do { bless \(my $dummy = 1), "Data::MessagePack::Boolean" };
diff --git a/perl/t/06_stream_unpack2.t b/perl/t/06_stream_unpack2.t
index dc82c41..eaf2cb4 100644
--- a/perl/t/06_stream_unpack2.t
+++ b/perl/t/06_stream_unpack2.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use Data::MessagePack;
-use Test::More;
+use Test::More tests => 6;
my $input = [(undef)x16];
my $packed = Data::MessagePack->pack($input);
@@ -22,5 +22,4 @@ is_deeply(Data::MessagePack->unpack($packed), $input);
is_deeply $up->data, $input;
}
-done_testing;
diff --git a/perl/t/07_break.t b/perl/t/07_break.t
new file mode 100644
index 0000000..dd27ad2
--- /dev/null
+++ b/perl/t/07_break.t
@@ -0,0 +1,12 @@
+use Test::More;
+use Data::MessagePack;
+use t::Util;
+no warnings 'uninitialized'; # i need this. i need this.
+
+plan tests => 1;
+
+my $d = Data::MessagePack->unpack(Data::MessagePack->pack([{x => undef}]));
+$d->[0]->{x} = 1;
+ok delete $d->[0]->{x};
+$d->[0] = 4;
+
diff --git a/perl/unpack.c b/perl/unpack.c
index 1bb1f47..eb6e0dd 100644
--- a/perl/unpack.c
+++ b/perl/unpack.c
@@ -40,7 +40,7 @@ typedef struct {
static INLINE SV *
get_bool (const char *name) {
- SV * sv = get_sv( name, 1 );
+ SV * sv = sv_mortalcopy(get_sv( name, 1 ));
SvREADONLY_on(sv);
SvREADONLY_on( SvRV(sv) );
@@ -73,7 +73,14 @@ static INLINE int template_callback_uint32(unpack_user* u, uint32_t d, SV** o)
{ *o = sv_2mortal(newSVuv(d)); return 0; }
static INLINE int template_callback_uint64(unpack_user* u, uint64_t d, SV** o)
-{ *o = sv_2mortal(newSVuv(d)); return 0; }
+{
+#if IVSIZE==4
+ *o = sv_2mortal(newSVnv(d));
+#else
+ *o = sv_2mortal(newSVuv(d));
+#endif
+ return 0;
+}
static INLINE int template_callback_int8(unpack_user* u, int8_t d, SV** o)
{ *o = sv_2mortal(newSViv((long)d)); return 0; }
@@ -93,8 +100,9 @@ static INLINE int template_callback_float(unpack_user* u, float d, SV** o)
static INLINE int template_callback_double(unpack_user* u, double d, SV** o)
{ *o = sv_2mortal(newSVnv(d)); return 0; }
+/* &PL_sv_undef is not so good. see http://gist.github.com/387743 */
static INLINE int template_callback_nil(unpack_user* u, SV** o)
-{ *o = &PL_sv_undef; return 0; }
+{ *o = sv_newmortal(); return 0; }
static INLINE int template_callback_true(unpack_user* u, SV** o)
{ *o = get_bool("Data::MessagePack::true") ; return 0; }
@@ -115,7 +123,8 @@ static INLINE int template_callback_map_item(unpack_user* u, SV** c, SV* k, SV*
{ hv_store_ent((HV*)SvRV(*c), k, v, 0); SvREFCNT_inc(v); return 0; }
static INLINE int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, SV** o)
-{ *o = sv_2mortal((l == 0) ? newSVpv("", 0) : newSVpv(p, l)); return 0; }
+{ *o = sv_2mortal((l==0) ? newSVpv("", 0) : newSVpv(p, l)); return 0; }
+/* { *o = newSVpvn_flags(p, l, SVs_TEMP); return 0; } <= this does not works. */
#define UNPACKER(from, name) \
msgpack_unpack_t *name; \
diff --git a/perl/xt/leaks/stream.t b/perl/xt/leaks/stream.t
index 09ec984..7765d73 100644
--- a/perl/xt/leaks/stream.t
+++ b/perl/xt/leaks/stream.t
@@ -2,7 +2,6 @@ use strict;
use warnings;
use Test::More;
use Data::MessagePack;
-use Test::Requires 'Test::LeakTrace';
use Devel::Peek;
plan skip_all => '$ENV{LEAK_TEST} is required' unless $ENV{LEAK_TEST};