summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/ext/integer_spec.c
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 20:18:52 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 20:18:52 +0000
commit1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch)
treea3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/optional/capi/ext/integer_spec.c
parent75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff)
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional/capi/ext/integer_spec.c')
-rw-r--r--spec/ruby/optional/capi/ext/integer_spec.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/ext/integer_spec.c b/spec/ruby/optional/capi/ext/integer_spec.c
new file mode 100644
index 0000000000..821d8373c9
--- /dev/null
+++ b/spec/ruby/optional/capi/ext/integer_spec.c
@@ -0,0 +1,40 @@
+#include "ruby.h"
+#include "rubyspec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_RB_INTEGER_PACK
+static VALUE integer_spec_rb_integer_pack(VALUE self, VALUE value,
+ VALUE words, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags)
+{
+ int result = rb_integer_pack(value, (void*)RSTRING_PTR(words), FIX2INT(numwords),
+ FIX2INT(wordsize), FIX2INT(nails), FIX2INT(flags));
+ return INT2FIX(result);
+}
+#endif
+
+void Init_integer_spec(void) {
+#ifdef HAVE_RB_INTEGER_PACK
+ VALUE cls;
+ cls = rb_define_class("CApiIntegerSpecs", rb_cObject);
+
+ rb_define_const(cls, "MSWORD", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
+ rb_define_const(cls, "LSWORD", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
+ rb_define_const(cls, "MSBYTE", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
+ rb_define_const(cls, "LSBYTE", INT2NUM(INTEGER_PACK_LSBYTE_FIRST));
+ rb_define_const(cls, "NATIVE", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER));
+ rb_define_const(cls, "PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP));
+ rb_define_const(cls, "LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN));
+ rb_define_const(cls, "BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN));
+ rb_define_const(cls, "FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM));
+ rb_define_const(cls, "NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE));
+
+ rb_define_method(cls, "rb_integer_pack", integer_spec_rb_integer_pack, 6);
+#endif
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif