summaryrefslogtreecommitdiff
path: root/ext/-test-/bignum
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-07 15:02:39 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-07 15:02:39 +0000
commitf31aed6255a67be4f7c83d231ab4697f4f92821d (patch)
tree7b662ef8ab047a2ae44a548b75c444e7dac5a1cb /ext/-test-/bignum
parentfb4c8c3a2aea1993dacaafef454e1f12e0341e05 (diff)
* bignum.c (rb_integer_pack): Arguments changed. Use flags to
specify word order and byte order. (rb_integer_unpack): Ditto. (validate_integer_format): Follow the above change. (integer_format_loop_setup): Ditto. * pack.c: Ditto. * internal.h: Ditto. (INTEGER_PACK_MSWORD_FIRST): Defined. (INTEGER_PACK_LSWORD_FIRST): Ditto. (INTEGER_PACK_MSBYTE_FIRST): Ditto. (INTEGER_PACK_LSBYTE_FIRST): Ditto. (INTEGER_PACK_NATIVE_BYTE_ORDER): Ditto. (INTEGER_PACK_LITTLE_ENDIAN): Ditto. (INTEGER_PACK_BIG_ENDIAN): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/bignum')
-rw-r--r--ext/-test-/bignum/pack.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/ext/-test-/bignum/pack.c b/ext/-test-/bignum/pack.c
index 5307db6f4b..34c7a4728f 100644
--- a/ext/-test-/bignum/pack.c
+++ b/ext/-test-/bignum/pack.c
@@ -2,7 +2,7 @@
#include "internal.h"
static VALUE
-rb_integer_pack_m(VALUE val, VALUE buf, VALUE wordorder, VALUE wordsize_arg, VALUE endian, VALUE nails)
+rb_integer_pack_m(VALUE val, VALUE buf, VALUE wordsize_arg, VALUE nails, VALUE flags)
{
int sign;
size_t count = 0;
@@ -17,24 +17,31 @@ rb_integer_pack_m(VALUE val, VALUE buf, VALUE wordorder, VALUE wordsize_arg, VAL
ret = rb_integer_pack(val,
&sign, &count, NIL_P(buf) ? NULL : RSTRING_PTR(buf), count,
- NUM2INT(wordorder), wordsize, NUM2INT(endian), NUM2INT(nails));
+ wordsize, NUM2SIZET(nails), NUM2INT(flags));
return rb_ary_new_from_args(3, INT2NUM(sign), ret ? rb_str_new(ret, wordsize * count) : Qnil, SIZET2NUM(count));
}
static VALUE
-rb_integer_unpack_m(VALUE klass, VALUE sign, VALUE buf, VALUE wordcount, VALUE wordorder, VALUE wordsize, VALUE endian, VALUE nails)
+rb_integer_unpack_m(VALUE klass, VALUE sign, VALUE buf, VALUE wordcount, VALUE wordsize, VALUE nails, VALUE flags)
{
StringValue(buf);
return rb_integer_unpack(NUM2INT(sign), RSTRING_PTR(buf),
- NUM2SIZET(wordcount), NUM2INT(wordorder), NUM2SIZET(wordsize),
- NUM2INT(endian), NUM2SIZET(nails));
+ NUM2SIZET(wordcount), NUM2SIZET(wordsize),
+ NUM2SIZET(nails), NUM2INT(flags));
}
void
Init_pack(VALUE klass)
{
- rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 5);
- rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 7);
+ rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 4);
+ rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 6);
+ rb_define_const(rb_cInteger, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN));
}