summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authortokuhirom <tokuhirom@users.sourceforge.jp>2010-01-04 11:59:52 +0900
committertokuhirom <tokuhirom@users.sourceforge.jp>2010-01-04 11:59:52 +0900
commit9817e9b18df85ed8f6afdc24f9f5c2f8228b609d (patch)
tree787293fb248d732061013f3c8907f72eb20e4bdd /perl
parent519716bbe4a9716b23a53e07ba458c83c1a3e4c6 (diff)
downloadmsgpack-python-9817e9b18df85ed8f6afdc24f9f5c2f8228b609d.tar.gz
Perl: support NVTYPE=="long double" or IVTYPE="long long" environment.
Diffstat (limited to 'perl')
-rw-r--r--perl/pack.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/perl/pack.c b/perl/pack.c
index 01dd5b6..589cee8 100644
--- a/perl/pack.c
+++ b/perl/pack.c
@@ -37,10 +37,19 @@ static void need(enc_t *enc, STRLEN len);
#include "msgpack/pack_template.h"
-#define _PACK_WRAPPER(t) msgpack_pack_##t
-#define PACK_WRAPPER(t) _PACK_WRAPPER(t)
#define INIT_SIZE 32 /* initial scalar size to be allocated */
+#if IVSIZE == 8
+# define PACK_IV msgpack_pack_int64
+#elif IVSIZE == 4
+# define PACK_IV msgpack_pack_int32
+#elif IVSIZE == 2
+# define PACK_IV msgpack_pack_int16
+#else
+# error "msgpack only supports IVSIZE = 8,4,2 environment."
+#endif
+
+
static void need(enc_t *enc, STRLEN len)
{
if (enc->cur + len >= enc->end) {
@@ -155,11 +164,12 @@ static void _msgpack_pack_sv(enc_t *enc, SV* sv) {
msgpack_pack_raw_body(enc, csv, len);
}
} else if (SvNOKp(sv)) {
- PACK_WRAPPER(NVTYPE)(enc, SvNVX(sv));
+ /* XXX long double is not supported yet. */
+ msgpack_pack_double(enc, (double)SvNVX(sv));
} else if (SvIOK_UV(sv)) {
msgpack_pack_uint32(enc, SvUV(sv));
} else if (SvIOKp(sv)) {
- PACK_WRAPPER(IVTYPE)(enc, SvIV(sv));
+ PACK_IV(enc, SvIV(sv));
} else if (SvROK(sv)) {
_msgpack_pack_rv(enc, SvRV(sv));
} else if (!SvOK(sv)) {