infraruby-java 0.0.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ if RUBY_PLATFORM =~ /java/
2
+ File.write("Makefile", <<-END)
3
+ install:
4
+ END
5
+ else
6
+ require "mkmf"
7
+ create_makefile("primitive/primitive")
8
+ end
@@ -0,0 +1,4075 @@
1
+ #include <ruby.h>
2
+ #include <math.h>
3
+ static VALUE r_Int32_0;
4
+ static VALUE r_Int32_1;
5
+ static VALUE r_Int32_M1;
6
+ static int32_t
7
+ __int32_div(int32_t x, int32_t y)
8
+ {
9
+ if (y == 0)
10
+ rb_raise(rb_eZeroDivError, "divided by 0");
11
+ return x / y;
12
+ }
13
+ static int32_t
14
+ __int32_mod(int32_t x, int32_t y)
15
+ {
16
+ if (y == 0)
17
+ rb_raise(rb_eZeroDivError, "divided by 0");
18
+ return x % y;
19
+ }
20
+ static int32_t
21
+ __int32_hash(int32_t value)
22
+ {
23
+ return value;
24
+ }
25
+ static VALUE
26
+ __int32_to_i(int32_t value)
27
+ {
28
+ return LONG2NUM((long) value);
29
+ }
30
+ static VALUE
31
+ __int32_to_f(int32_t value)
32
+ {
33
+ return DBL2NUM((double) value);
34
+ }
35
+ static VALUE
36
+ __int32_to_s(int32_t value)
37
+ {
38
+ char s[11 + 1];
39
+ snprintf(s, 11 + 1, "%d", value);
40
+ return rb_usascii_str_new2(s);
41
+ }
42
+ static VALUE
43
+ __int32_to_hex(int32_t value)
44
+ {
45
+ char s[010 + 1];
46
+ int i = 010;
47
+ s[i] = 0;
48
+ while (1) {
49
+ i -= 1;
50
+ int c = (int32_t) value & 0x0F;
51
+ s[i] = (c < 10 ? c + 0x30 : c + 0x41 - 10);
52
+ if (i == 0)
53
+ break;
54
+ value >>= 4;
55
+ }
56
+ return rb_usascii_str_new2(s);
57
+ }
58
+ static VALUE
59
+ __int32_chr(int32_t value)
60
+ {
61
+ if (value < 0x00)
62
+ rb_raise(rb_eRangeError, "out of range");
63
+ if (value <= 0x7F) {
64
+ char s = (char) value;
65
+ return rb_usascii_str_new(&s, 1);
66
+ }
67
+ if (value <= 0xFF) {
68
+ char s = (char) value;
69
+ return rb_str_new(&s, 1);
70
+ }
71
+ rb_raise(rb_eRangeError, "out of range");
72
+ }
73
+ static int64_t
74
+ __int64_div(int64_t x, int64_t y)
75
+ {
76
+ if (y == 0)
77
+ rb_raise(rb_eZeroDivError, "divided by 0");
78
+ return x / y;
79
+ }
80
+ static int64_t
81
+ __int64_mod(int64_t x, int64_t y)
82
+ {
83
+ if (y == 0)
84
+ rb_raise(rb_eZeroDivError, "divided by 0");
85
+ return x % y;
86
+ }
87
+ static int32_t
88
+ __int64_hash(int64_t value)
89
+ {
90
+ return (int32_t) value ^ (int32_t) (value >> 32);
91
+ }
92
+ static VALUE
93
+ __int64_to_i(int64_t value)
94
+ {
95
+ return LONG2NUM((long) value);
96
+ }
97
+ static VALUE
98
+ __int64_to_f(int64_t value)
99
+ {
100
+ return DBL2NUM((double) value);
101
+ }
102
+ static VALUE
103
+ __int64_to_s(int64_t value)
104
+ {
105
+ char s[20 + 1];
106
+ snprintf(s, 20 + 1, "%ld", value);
107
+ return rb_usascii_str_new2(s);
108
+ }
109
+ static VALUE
110
+ __int64_to_hex(int64_t value)
111
+ {
112
+ char s[020 + 1];
113
+ int i = 020;
114
+ s[i] = 0;
115
+ while (1) {
116
+ i -= 1;
117
+ int c = (int32_t) value & 0x0F;
118
+ s[i] = (c < 10 ? c + 0x30 : c + 0x41 - 10);
119
+ if (i == 0)
120
+ break;
121
+ value >>= 4;
122
+ }
123
+ return rb_usascii_str_new2(s);
124
+ }
125
+ static float
126
+ __float32_div(float x, float y)
127
+ {
128
+ return x / y;
129
+ }
130
+ static float
131
+ __float32_mod(float x, float y)
132
+ {
133
+ return fmodf(x, y);
134
+ }
135
+ static int32_t
136
+ __float32_hash(float value)
137
+ {
138
+ union {
139
+ int32_t i32;
140
+ float f32;
141
+ } u;
142
+ u.f32 = value;
143
+ return __int32_hash(u.i32);
144
+ }
145
+ static VALUE
146
+ __float32_to_i(float value)
147
+ {
148
+ if (isnan(value))
149
+ rb_raise(rb_eFloatDomainError, "NaN");
150
+ if (isinf(value))
151
+ rb_raise(rb_eFloatDomainError, value < 0 ? "-Infinity" : "Infinity");
152
+ if (value < FIXNUM_MIN || value >= FIXNUM_MAX + 1)
153
+ return rb_dbl2big((double) value);
154
+ return LONG2FIX((long) value);
155
+ }
156
+ static VALUE
157
+ __float32_to_f(float value)
158
+ {
159
+ return DBL2NUM((double) value);
160
+ }
161
+ static VALUE
162
+ __float32_to_s(float value)
163
+ {
164
+ if (isnan(value))
165
+ return rb_usascii_str_new2("NaN");
166
+ if (value == INFINITY)
167
+ return rb_usascii_str_new2("Infinity");
168
+ if (value == -INFINITY)
169
+ return rb_usascii_str_new2("-Infinity");
170
+ char s[15 + 1];
171
+ snprintf(s, 15 + 1, "%.9G", value);
172
+ return rb_usascii_str_new2(s);
173
+ }
174
+ static double
175
+ __float64_div(double x, double y)
176
+ {
177
+ return x / y;
178
+ }
179
+ static double
180
+ __float64_mod(double x, double y)
181
+ {
182
+ return fmod(x, y);
183
+ }
184
+ static int32_t
185
+ __float64_hash(double value)
186
+ {
187
+ union {
188
+ int64_t i64;
189
+ double f64;
190
+ } u;
191
+ u.f64 = value;
192
+ return __int64_hash(u.i64);
193
+ }
194
+ static VALUE
195
+ __float64_to_i(double value)
196
+ {
197
+ if (isnan(value))
198
+ rb_raise(rb_eFloatDomainError, "NaN");
199
+ if (isinf(value))
200
+ rb_raise(rb_eFloatDomainError, value < 0 ? "-Infinity" : "Infinity");
201
+ if (value < FIXNUM_MIN || value >= FIXNUM_MAX + 1)
202
+ return rb_dbl2big(value);
203
+ return LONG2FIX((long) value);
204
+ }
205
+ static VALUE
206
+ __float64_to_f(double value)
207
+ {
208
+ return DBL2NUM((double) value);
209
+ }
210
+ static VALUE
211
+ __float64_to_s(double value)
212
+ {
213
+ if (isnan(value))
214
+ return rb_usascii_str_new2("NaN");
215
+ if (value == INFINITY)
216
+ return rb_usascii_str_new2("Infinity");
217
+ if (value == -INFINITY)
218
+ return rb_usascii_str_new2("-Infinity");
219
+ char s[24 + 1];
220
+ snprintf(s, 24 + 1, "%.17G", value);
221
+ return rb_usascii_str_new2(s);
222
+ }
223
+ struct Byte {
224
+ int8_t value;
225
+ };
226
+ typedef struct Byte Byte;
227
+ static VALUE r_Byte;
228
+ struct Char {
229
+ uint16_t value;
230
+ };
231
+ typedef struct Char Char;
232
+ static VALUE r_Char;
233
+ struct Int16 {
234
+ int16_t value;
235
+ };
236
+ typedef struct Int16 Int16;
237
+ static VALUE r_Int16;
238
+ struct Int32 {
239
+ int32_t value;
240
+ };
241
+ typedef struct Int32 Int32;
242
+ static VALUE r_Int32;
243
+ struct Int64 {
244
+ int64_t value;
245
+ };
246
+ typedef struct Int64 Int64;
247
+ static VALUE r_Int64;
248
+ struct Float32 {
249
+ float value;
250
+ };
251
+ typedef struct Float32 Float32;
252
+ static VALUE r_Float32;
253
+ struct Float64 {
254
+ double value;
255
+ };
256
+ typedef struct Float64 Float64;
257
+ static VALUE r_Float64;
258
+ static VALUE
259
+ __allocate_Byte(int8_t value)
260
+ {
261
+ Byte *p = ALLOC(Byte);
262
+ if (p == NULL)
263
+ rb_raise(rb_eNoMemError, "NoMemoryError");
264
+ p->value = value;
265
+ return Data_Wrap_Struct(r_Byte, NULL, NULL, p);
266
+ }
267
+ static VALUE
268
+ __allocate_Char(uint16_t value)
269
+ {
270
+ Char *p = ALLOC(Char);
271
+ if (p == NULL)
272
+ rb_raise(rb_eNoMemError, "NoMemoryError");
273
+ p->value = value;
274
+ return Data_Wrap_Struct(r_Char, NULL, NULL, p);
275
+ }
276
+ static VALUE
277
+ __allocate_Int16(int16_t value)
278
+ {
279
+ Int16 *p = ALLOC(Int16);
280
+ if (p == NULL)
281
+ rb_raise(rb_eNoMemError, "NoMemoryError");
282
+ p->value = value;
283
+ return Data_Wrap_Struct(r_Int16, NULL, NULL, p);
284
+ }
285
+ static VALUE
286
+ __allocate_Int32(int32_t value)
287
+ {
288
+ Int32 *p = ALLOC(Int32);
289
+ if (p == NULL)
290
+ rb_raise(rb_eNoMemError, "NoMemoryError");
291
+ p->value = value;
292
+ return Data_Wrap_Struct(r_Int32, NULL, NULL, p);
293
+ }
294
+ static VALUE
295
+ __allocate_Int64(int64_t value)
296
+ {
297
+ Int64 *p = ALLOC(Int64);
298
+ if (p == NULL)
299
+ rb_raise(rb_eNoMemError, "NoMemoryError");
300
+ p->value = value;
301
+ return Data_Wrap_Struct(r_Int64, NULL, NULL, p);
302
+ }
303
+ static VALUE
304
+ __allocate_Float32(float value)
305
+ {
306
+ Float32 *p = ALLOC(Float32);
307
+ if (p == NULL)
308
+ rb_raise(rb_eNoMemError, "NoMemoryError");
309
+ p->value = value;
310
+ return Data_Wrap_Struct(r_Float32, NULL, NULL, p);
311
+ }
312
+ static VALUE
313
+ __allocate_Float64(double value)
314
+ {
315
+ Float64 *p = ALLOC(Float64);
316
+ if (p == NULL)
317
+ rb_raise(rb_eNoMemError, "NoMemoryError");
318
+ p->value = value;
319
+ return Data_Wrap_Struct(r_Float64, NULL, NULL, p);
320
+ }
321
+ static VALUE r_Java;
322
+ static ID NEW_ID;
323
+ static ID INNER_ID;
324
+ static ID OUTER_ID;
325
+ static ID COPY_ID;
326
+ struct ObjectArray {
327
+ int32_t length;
328
+ VALUE data[];
329
+ };
330
+ typedef struct ObjectArray ObjectArray;
331
+ static VALUE r_ObjectArray;
332
+ struct BooleanArray {
333
+ int32_t length;
334
+ int8_t data[];
335
+ };
336
+ typedef struct BooleanArray BooleanArray;
337
+ static VALUE r_BooleanArray;
338
+ struct ByteArray {
339
+ int32_t length;
340
+ int8_t data[];
341
+ };
342
+ typedef struct ByteArray ByteArray;
343
+ static VALUE r_ByteArray;
344
+ struct CharArray {
345
+ int32_t length;
346
+ uint16_t data[];
347
+ };
348
+ typedef struct CharArray CharArray;
349
+ static VALUE r_CharArray;
350
+ struct Int16Array {
351
+ int32_t length;
352
+ int16_t data[];
353
+ };
354
+ typedef struct Int16Array Int16Array;
355
+ static VALUE r_Int16Array;
356
+ struct Int32Array {
357
+ int32_t length;
358
+ int32_t data[];
359
+ };
360
+ typedef struct Int32Array Int32Array;
361
+ static VALUE r_Int32Array;
362
+ struct Int64Array {
363
+ int32_t length;
364
+ int64_t data[];
365
+ };
366
+ typedef struct Int64Array Int64Array;
367
+ static VALUE r_Int64Array;
368
+ struct Float32Array {
369
+ int32_t length;
370
+ float data[];
371
+ };
372
+ typedef struct Float32Array Float32Array;
373
+ static VALUE r_Float32Array;
374
+ struct Float64Array {
375
+ int32_t length;
376
+ double data[];
377
+ };
378
+ typedef struct Float64Array Float64Array;
379
+ static VALUE r_Float64Array;
380
+ static void
381
+ __mark_ObjectArray(void *__p)
382
+ {
383
+ ObjectArray *p = __p;
384
+ int32_t i;
385
+ for (i = 0; i < p->length; i += 1) {
386
+ VALUE e = p->data[i];
387
+ rb_gc_mark(e);
388
+ }
389
+ return;
390
+ }
391
+ static void
392
+ __free_ObjectArray(void *__p)
393
+ {
394
+ ObjectArray *p = __p;
395
+ xfree(p);
396
+ return;
397
+ }
398
+ static VALUE
399
+ __allocate_ObjectArray(VALUE self, int32_t n)
400
+ {
401
+ ObjectArray *p = xmalloc(sizeof(ObjectArray) + sizeof(VALUE) * n);
402
+ if (p == NULL)
403
+ rb_raise(rb_eNoMemError, "NoMemoryError");
404
+ p->length = n;
405
+ int32_t i;
406
+ for (i = 0; i < n; i += 1)
407
+ p->data[i] = Qnil;
408
+ return Data_Wrap_Struct(self, __mark_ObjectArray, __free_ObjectArray, p);
409
+ }
410
+ static VALUE
411
+ __allocate_BooleanArray(VALUE self, int32_t n)
412
+ {
413
+ BooleanArray *p = xmalloc(sizeof(BooleanArray) + sizeof(int8_t) * n);
414
+ if (p == NULL)
415
+ rb_raise(rb_eNoMemError, "NoMemoryError");
416
+ p->length = n;
417
+ int32_t i;
418
+ for (i = 0; i < n; i += 1)
419
+ p->data[i] = 0;
420
+ return Data_Wrap_Struct(self, NULL, NULL, p);
421
+ }
422
+ static VALUE
423
+ __allocate_ByteArray(VALUE self, int32_t n)
424
+ {
425
+ ByteArray *p = xmalloc(sizeof(ByteArray) + sizeof(int8_t) * n);
426
+ if (p == NULL)
427
+ rb_raise(rb_eNoMemError, "NoMemoryError");
428
+ p->length = n;
429
+ int32_t i;
430
+ for (i = 0; i < n; i += 1)
431
+ p->data[i] = 0;
432
+ return Data_Wrap_Struct(self, NULL, NULL, p);
433
+ }
434
+ static VALUE
435
+ __allocate_CharArray(VALUE self, int32_t n)
436
+ {
437
+ CharArray *p = xmalloc(sizeof(CharArray) + sizeof(uint16_t) * n);
438
+ if (p == NULL)
439
+ rb_raise(rb_eNoMemError, "NoMemoryError");
440
+ p->length = n;
441
+ int32_t i;
442
+ for (i = 0; i < n; i += 1)
443
+ p->data[i] = 0;
444
+ return Data_Wrap_Struct(self, NULL, NULL, p);
445
+ }
446
+ static VALUE
447
+ __allocate_Int16Array(VALUE self, int32_t n)
448
+ {
449
+ Int16Array *p = xmalloc(sizeof(Int16Array) + sizeof(int16_t) * n);
450
+ if (p == NULL)
451
+ rb_raise(rb_eNoMemError, "NoMemoryError");
452
+ p->length = n;
453
+ int32_t i;
454
+ for (i = 0; i < n; i += 1)
455
+ p->data[i] = 0;
456
+ return Data_Wrap_Struct(self, NULL, NULL, p);
457
+ }
458
+ static VALUE
459
+ __allocate_Int32Array(VALUE self, int32_t n)
460
+ {
461
+ Int32Array *p = xmalloc(sizeof(Int32Array) + sizeof(int32_t) * n);
462
+ if (p == NULL)
463
+ rb_raise(rb_eNoMemError, "NoMemoryError");
464
+ p->length = n;
465
+ int32_t i;
466
+ for (i = 0; i < n; i += 1)
467
+ p->data[i] = 0;
468
+ return Data_Wrap_Struct(self, NULL, NULL, p);
469
+ }
470
+ static VALUE
471
+ __allocate_Int64Array(VALUE self, int32_t n)
472
+ {
473
+ Int64Array *p = xmalloc(sizeof(Int64Array) + sizeof(int64_t) * n);
474
+ if (p == NULL)
475
+ rb_raise(rb_eNoMemError, "NoMemoryError");
476
+ p->length = n;
477
+ int32_t i;
478
+ for (i = 0; i < n; i += 1)
479
+ p->data[i] = 0;
480
+ return Data_Wrap_Struct(self, NULL, NULL, p);
481
+ }
482
+ static VALUE
483
+ __allocate_Float32Array(VALUE self, int32_t n)
484
+ {
485
+ Float32Array *p = xmalloc(sizeof(Float32Array) + sizeof(float) * n);
486
+ if (p == NULL)
487
+ rb_raise(rb_eNoMemError, "NoMemoryError");
488
+ p->length = n;
489
+ int32_t i;
490
+ for (i = 0; i < n; i += 1)
491
+ p->data[i] = 0;
492
+ return Data_Wrap_Struct(self, NULL, NULL, p);
493
+ }
494
+ static VALUE
495
+ __allocate_Float64Array(VALUE self, int32_t n)
496
+ {
497
+ Float64Array *p = xmalloc(sizeof(Float64Array) + sizeof(double) * n);
498
+ if (p == NULL)
499
+ rb_raise(rb_eNoMemError, "NoMemoryError");
500
+ p->length = n;
501
+ int32_t i;
502
+ for (i = 0; i < n; i += 1)
503
+ p->data[i] = 0;
504
+ return Data_Wrap_Struct(self, NULL, NULL, p);
505
+ }
506
+ static int32_t
507
+ __Int32_value(VALUE o)
508
+ {
509
+ if (TYPE(o) != T_DATA || RBASIC(o)->klass != r_Int32)
510
+ rb_raise(rb_eTypeError, "expected Int32");
511
+ Int32 *p;
512
+ Data_Get_Struct(o, Int32, p);
513
+ return p->value;
514
+ }
515
+ static VALUE
516
+ r_ObjectArray_new(VALUE self, VALUE n)
517
+ {
518
+ int32_t __n = __Int32_value(n);
519
+ return __allocate_ObjectArray(self, __n);
520
+ }
521
+ static VALUE
522
+ r_BooleanArray_new(VALUE self, VALUE n)
523
+ {
524
+ int32_t __n = __Int32_value(n);
525
+ return __allocate_BooleanArray(self, __n);
526
+ }
527
+ static VALUE
528
+ r_ByteArray_new(VALUE self, VALUE n)
529
+ {
530
+ int32_t __n = __Int32_value(n);
531
+ return __allocate_ByteArray(self, __n);
532
+ }
533
+ static VALUE
534
+ r_CharArray_new(VALUE self, VALUE n)
535
+ {
536
+ int32_t __n = __Int32_value(n);
537
+ return __allocate_CharArray(self, __n);
538
+ }
539
+ static VALUE
540
+ r_Int16Array_new(VALUE self, VALUE n)
541
+ {
542
+ int32_t __n = __Int32_value(n);
543
+ return __allocate_Int16Array(self, __n);
544
+ }
545
+ static VALUE
546
+ r_Int32Array_new(VALUE self, VALUE n)
547
+ {
548
+ int32_t __n = __Int32_value(n);
549
+ return __allocate_Int32Array(self, __n);
550
+ }
551
+ static VALUE
552
+ r_Int64Array_new(VALUE self, VALUE n)
553
+ {
554
+ int32_t __n = __Int32_value(n);
555
+ return __allocate_Int64Array(self, __n);
556
+ }
557
+ static VALUE
558
+ r_Float32Array_new(VALUE self, VALUE n)
559
+ {
560
+ int32_t __n = __Int32_value(n);
561
+ return __allocate_Float32Array(self, __n);
562
+ }
563
+ static VALUE
564
+ r_Float64Array_new(VALUE self, VALUE n)
565
+ {
566
+ int32_t __n = __Int32_value(n);
567
+ return __allocate_Float64Array(self, __n);
568
+ }
569
+ static VALUE
570
+ __new_Array(VALUE klass, VALUE *data, int b, int c)
571
+ {
572
+ VALUE o = data[b];
573
+ if (b + 1 == c)
574
+ return rb_funcall(klass, NEW_ID, 1, o);
575
+ int32_t n = __Int32_value(o);
576
+ VALUE r = __allocate_ObjectArray(klass, n);
577
+ ObjectArray *p;
578
+ Data_Get_Struct(r, ObjectArray, p);
579
+ int32_t i;
580
+ for (i = 0; i < n; i += 1)
581
+ p->data[i] = __new_Array(rb_ivar_get(klass, INNER_ID), data, b + 1, c);
582
+ return r;
583
+ }
584
+ struct ArrayFactory {
585
+ VALUE klass;
586
+ int32_t length;
587
+ VALUE data[];
588
+ };
589
+ typedef struct ArrayFactory ArrayFactory;
590
+ static VALUE r_ArrayFactory;
591
+ struct ArrayFactoryFactory {
592
+ VALUE klass;
593
+ };
594
+ typedef struct ArrayFactoryFactory ArrayFactoryFactory;
595
+ static VALUE r_ArrayFactoryFactory;
596
+ static VALUE r_BOOLEAN_ARRAY_FACTORY_FACTORY;
597
+ static VALUE r_BYTE_ARRAY_FACTORY_FACTORY;
598
+ static VALUE r_CHAR_ARRAY_FACTORY_FACTORY;
599
+ static VALUE r_INT16_ARRAY_FACTORY_FACTORY;
600
+ static VALUE r_INT32_ARRAY_FACTORY_FACTORY;
601
+ static VALUE r_INT64_ARRAY_FACTORY_FACTORY;
602
+ static VALUE r_FLOAT32_ARRAY_FACTORY_FACTORY;
603
+ static VALUE r_FLOAT64_ARRAY_FACTORY_FACTORY;
604
+ static VALUE
605
+ r_Java_boolean(VALUE self)
606
+ {
607
+ return r_BOOLEAN_ARRAY_FACTORY_FACTORY;
608
+ }
609
+ static VALUE
610
+ r_Java_byte(VALUE self)
611
+ {
612
+ return r_BYTE_ARRAY_FACTORY_FACTORY;
613
+ }
614
+ static VALUE
615
+ r_Java_char(VALUE self)
616
+ {
617
+ return r_CHAR_ARRAY_FACTORY_FACTORY;
618
+ }
619
+ static VALUE
620
+ r_Java_int16(VALUE self)
621
+ {
622
+ return r_INT16_ARRAY_FACTORY_FACTORY;
623
+ }
624
+ static VALUE
625
+ r_Java_int32(VALUE self)
626
+ {
627
+ return r_INT32_ARRAY_FACTORY_FACTORY;
628
+ }
629
+ static VALUE
630
+ r_Java_int64(VALUE self)
631
+ {
632
+ return r_INT64_ARRAY_FACTORY_FACTORY;
633
+ }
634
+ static VALUE
635
+ r_Java_float32(VALUE self)
636
+ {
637
+ return r_FLOAT32_ARRAY_FACTORY_FACTORY;
638
+ }
639
+ static VALUE
640
+ r_Java_float64(VALUE self)
641
+ {
642
+ return r_FLOAT64_ARRAY_FACTORY_FACTORY;
643
+ }
644
+ static VALUE r_Integer_x8000000000000000;
645
+ static VALUE r_Integer_xFFFFFFFFFFFFFFFF;
646
+ static VALUE r_Integer_xM8000000000000000;
647
+ static int64_t
648
+ __bignum_to_int64(VALUE o)
649
+ {
650
+ o = rb_big_plus(r_Integer_x8000000000000000, o);
651
+ o = rb_big_and(r_Integer_xFFFFFFFFFFFFFFFF, o);
652
+ o = rb_big_plus(r_Integer_xM8000000000000000, o);
653
+ return NUM2LONG(o);
654
+ }
655
+ static int32_t
656
+ __object_i32(VALUE o)
657
+ {
658
+ VALUE klass;
659
+ switch (TYPE(o)) {
660
+ case T_FIXNUM:
661
+ return (int32_t) FIX2LONG(o);
662
+ case T_BIGNUM:
663
+ return (int32_t) __bignum_to_int64(o);
664
+ case T_DATA:
665
+ klass = RBASIC(o)->klass;
666
+ if (klass == r_Byte) {
667
+ Byte *p;
668
+ Data_Get_Struct(o, Byte, p);
669
+ return (int32_t) p->value;
670
+ }
671
+ if (klass == r_Char) {
672
+ Char *p;
673
+ Data_Get_Struct(o, Char, p);
674
+ return (int32_t) p->value;
675
+ }
676
+ if (klass == r_Int16) {
677
+ Int16 *p;
678
+ Data_Get_Struct(o, Int16, p);
679
+ return (int32_t) p->value;
680
+ }
681
+ if (klass == r_Int32) {
682
+ Int32 *p;
683
+ Data_Get_Struct(o, Int32, p);
684
+ return (int32_t) p->value;
685
+ }
686
+ }
687
+ rb_raise(rb_eTypeError, "expected int32");
688
+ }
689
+ static int64_t
690
+ __object_i64(VALUE o)
691
+ {
692
+ VALUE klass;
693
+ switch (TYPE(o)) {
694
+ case T_FIXNUM:
695
+ return (int64_t) FIX2LONG(o);
696
+ case T_BIGNUM:
697
+ return (int64_t) __bignum_to_int64(o);
698
+ case T_DATA:
699
+ klass = RBASIC(o)->klass;
700
+ if (klass == r_Int64) {
701
+ Int64 *p;
702
+ Data_Get_Struct(o, Int64, p);
703
+ return (int64_t) p->value;
704
+ }
705
+ }
706
+ rb_raise(rb_eTypeError, "expected int64");
707
+ }
708
+ static float
709
+ __object_f32(VALUE o)
710
+ {
711
+ VALUE klass;
712
+ switch (TYPE(o)) {
713
+ case T_FIXNUM:
714
+ return (float) FIX2LONG(o);
715
+ case T_BIGNUM:
716
+ return (float) NUM2DBL(o);
717
+ case T_FLOAT:
718
+ return (float) NUM2DBL(o);
719
+ case T_DATA:
720
+ klass = RBASIC(o)->klass;
721
+ if (klass == r_Float32) {
722
+ Float32 *p;
723
+ Data_Get_Struct(o, Float32, p);
724
+ return (float) p->value;
725
+ }
726
+ }
727
+ rb_raise(rb_eTypeError, "expected float32");
728
+ }
729
+ static double
730
+ __object_f64(VALUE o)
731
+ {
732
+ VALUE klass;
733
+ switch (TYPE(o)) {
734
+ case T_FIXNUM:
735
+ return (double) FIX2LONG(o);
736
+ case T_BIGNUM:
737
+ return (double) NUM2DBL(o);
738
+ case T_FLOAT:
739
+ return (double) NUM2DBL(o);
740
+ case T_DATA:
741
+ klass = RBASIC(o)->klass;
742
+ if (klass == r_Float64) {
743
+ Float64 *p;
744
+ Data_Get_Struct(o, Float64, p);
745
+ return (double) p->value;
746
+ }
747
+ }
748
+ rb_raise(rb_eTypeError, "expected float64");
749
+ }
750
+ static int8_t
751
+ __object_to_boolean(VALUE o)
752
+ {
753
+ switch (TYPE(o)) {
754
+ case T_TRUE:
755
+ return Qtrue;
756
+ case T_FALSE:
757
+ return Qfalse;
758
+ }
759
+ rb_raise(rb_eTypeError, "expected boolean");
760
+ }
761
+ static int32_t
762
+ __assert_bounds(VALUE i, int32_t n)
763
+ {
764
+ Check_Type(i, T_FIXNUM);
765
+ long __i = FIX2LONG(i);
766
+ if (__i < 0 || __i >= n)
767
+ rb_raise(rb_eArgError, "index out of bounds");
768
+ return (int32_t) __i;
769
+ }
770
+ static int32_t
771
+ __assert_nat32(VALUE i)
772
+ {
773
+ Check_Type(i, T_FIXNUM);
774
+ long __i = FIX2LONG(i);
775
+ if (__i < 0 || __i > 0x7FFFFFFFL)
776
+ rb_raise(rb_eArgError, "out of range");
777
+ return (int32_t) __i;
778
+ }
779
+ static VALUE
780
+ r_Byte_new(VALUE self, VALUE o)
781
+ {
782
+ int32_t v = __object_i32(o);
783
+ return __allocate_Byte((int8_t) v);
784
+ }
785
+ static VALUE
786
+ r_Byte_is_eql(VALUE self, VALUE o)
787
+ {
788
+ Byte *p;
789
+ Data_Get_Struct(self, Byte, p);
790
+ VALUE klass;
791
+ switch (TYPE(o)) {
792
+ case T_DATA:
793
+ klass = RBASIC(o)->klass;
794
+ if (klass == r_Byte) {
795
+ Byte *op;
796
+ Data_Get_Struct(o, Byte, op);
797
+ return p->value == op->value ? Qtrue : Qfalse;
798
+ }
799
+ }
800
+ return Qfalse;
801
+ }
802
+ static VALUE
803
+ r_Byte_hash(VALUE self)
804
+ {
805
+ Byte *p;
806
+ Data_Get_Struct(self, Byte, p);
807
+ int32_t value = p->value;
808
+ return LONG2NUM((long) __int32_hash(value));
809
+ }
810
+ static VALUE
811
+ r_Byte_to_byte(VALUE self)
812
+ {
813
+ Byte *p;
814
+ Data_Get_Struct(self, Byte, p);
815
+ int32_t value = p->value;
816
+ return __allocate_Byte((int8_t) value);
817
+ }
818
+ static VALUE
819
+ r_Byte_to_char(VALUE self)
820
+ {
821
+ Byte *p;
822
+ Data_Get_Struct(self, Byte, p);
823
+ int32_t value = p->value;
824
+ return __allocate_Char((uint16_t) value);
825
+ }
826
+ static VALUE
827
+ r_Byte_to_int16(VALUE self)
828
+ {
829
+ Byte *p;
830
+ Data_Get_Struct(self, Byte, p);
831
+ int32_t value = p->value;
832
+ return __allocate_Int16((int16_t) value);
833
+ }
834
+ static VALUE
835
+ r_Byte_to_int32(VALUE self)
836
+ {
837
+ Byte *p;
838
+ Data_Get_Struct(self, Byte, p);
839
+ int32_t value = p->value;
840
+ return __allocate_Int32((int32_t) value);
841
+ }
842
+ static VALUE
843
+ r_Byte_to_int64(VALUE self)
844
+ {
845
+ Byte *p;
846
+ Data_Get_Struct(self, Byte, p);
847
+ int32_t value = p->value;
848
+ return __allocate_Int64((int64_t) value);
849
+ }
850
+ static VALUE
851
+ r_Byte_to_float32(VALUE self)
852
+ {
853
+ Byte *p;
854
+ Data_Get_Struct(self, Byte, p);
855
+ int32_t value = p->value;
856
+ return __allocate_Float32((float) value);
857
+ }
858
+ static VALUE
859
+ r_Byte_to_float64(VALUE self)
860
+ {
861
+ Byte *p;
862
+ Data_Get_Struct(self, Byte, p);
863
+ int32_t value = p->value;
864
+ return __allocate_Float64((double) value);
865
+ }
866
+ static VALUE
867
+ r_Byte_to_i(VALUE self)
868
+ {
869
+ Byte *p;
870
+ Data_Get_Struct(self, Byte, p);
871
+ int32_t value = p->value;
872
+ return __int32_to_i(value);
873
+ }
874
+ static VALUE
875
+ r_Byte_to_f(VALUE self)
876
+ {
877
+ Byte *p;
878
+ Data_Get_Struct(self, Byte, p);
879
+ int32_t value = p->value;
880
+ return __int32_to_f(value);
881
+ }
882
+ static VALUE
883
+ r_Byte_to_s(VALUE self)
884
+ {
885
+ Byte *p;
886
+ Data_Get_Struct(self, Byte, p);
887
+ int32_t value = p->value;
888
+ return __int32_to_s(value);
889
+ }
890
+ static VALUE
891
+ r_Byte_eq(VALUE self, VALUE o)
892
+ {
893
+ Byte *p;
894
+ Data_Get_Struct(self, Byte, p);
895
+ int32_t value = p->value;
896
+ int32_t v = __object_i32(o);
897
+ return value == v ? Qtrue : Qfalse;
898
+ }
899
+ static VALUE
900
+ r_Byte_ne(VALUE self, VALUE o)
901
+ {
902
+ Byte *p;
903
+ Data_Get_Struct(self, Byte, p);
904
+ int32_t value = p->value;
905
+ int32_t v = __object_i32(o);
906
+ return value != v ? Qtrue : Qfalse;
907
+ }
908
+ static VALUE
909
+ r_Byte_pos(VALUE self)
910
+ {
911
+ Byte *p;
912
+ Data_Get_Struct(self, Byte, p);
913
+ int32_t value = p->value;
914
+ return __allocate_Int32(+value);
915
+ }
916
+ static VALUE
917
+ r_Byte_neg(VALUE self)
918
+ {
919
+ Byte *p;
920
+ Data_Get_Struct(self, Byte, p);
921
+ int32_t value = p->value;
922
+ return __allocate_Int32(-value);
923
+ }
924
+ static VALUE
925
+ r_Byte_mul(VALUE self, VALUE o)
926
+ {
927
+ Byte *p;
928
+ Data_Get_Struct(self, Byte, p);
929
+ int32_t value = p->value;
930
+ int32_t v = __object_i32(o);
931
+ return __allocate_Int32(value * v);
932
+ }
933
+ static VALUE
934
+ r_Byte_div(VALUE self, VALUE o)
935
+ {
936
+ Byte *p;
937
+ Data_Get_Struct(self, Byte, p);
938
+ int32_t value = p->value;
939
+ int32_t v = __object_i32(o);
940
+ return __allocate_Int32(__int32_div(value, v));
941
+ }
942
+ static VALUE
943
+ r_Byte_mod(VALUE self, VALUE o)
944
+ {
945
+ Byte *p;
946
+ Data_Get_Struct(self, Byte, p);
947
+ int32_t value = p->value;
948
+ int32_t v = __object_i32(o);
949
+ return __allocate_Int32(__int32_mod(value, v));
950
+ }
951
+ static VALUE
952
+ r_Byte_add(VALUE self, VALUE o)
953
+ {
954
+ Byte *p;
955
+ Data_Get_Struct(self, Byte, p);
956
+ int32_t value = p->value;
957
+ int32_t v = __object_i32(o);
958
+ return __allocate_Int32(value + v);
959
+ }
960
+ static VALUE
961
+ r_Byte_sub(VALUE self, VALUE o)
962
+ {
963
+ Byte *p;
964
+ Data_Get_Struct(self, Byte, p);
965
+ int32_t value = p->value;
966
+ int32_t v = __object_i32(o);
967
+ return __allocate_Int32(value - v);
968
+ }
969
+ static VALUE
970
+ r_Byte_cmp(VALUE self, VALUE o)
971
+ {
972
+ Byte *p;
973
+ Data_Get_Struct(self, Byte, p);
974
+ int32_t value = p->value;
975
+ int32_t v = __object_i32(o);
976
+ if (value < v)
977
+ return r_Int32_M1;
978
+ if (value > v)
979
+ return r_Int32_1;
980
+ return r_Int32_0;
981
+ }
982
+ static VALUE
983
+ r_Byte_lt(VALUE self, VALUE o)
984
+ {
985
+ Byte *p;
986
+ Data_Get_Struct(self, Byte, p);
987
+ int32_t value = p->value;
988
+ int32_t v = __object_i32(o);
989
+ return value < v ? Qtrue : Qfalse;
990
+ }
991
+ static VALUE
992
+ r_Byte_le(VALUE self, VALUE o)
993
+ {
994
+ Byte *p;
995
+ Data_Get_Struct(self, Byte, p);
996
+ int32_t value = p->value;
997
+ int32_t v = __object_i32(o);
998
+ return value <= v ? Qtrue : Qfalse;
999
+ }
1000
+ static VALUE
1001
+ r_Byte_ge(VALUE self, VALUE o)
1002
+ {
1003
+ Byte *p;
1004
+ Data_Get_Struct(self, Byte, p);
1005
+ int32_t value = p->value;
1006
+ int32_t v = __object_i32(o);
1007
+ return value >= v ? Qtrue : Qfalse;
1008
+ }
1009
+ static VALUE
1010
+ r_Byte_gt(VALUE self, VALUE o)
1011
+ {
1012
+ Byte *p;
1013
+ Data_Get_Struct(self, Byte, p);
1014
+ int32_t value = p->value;
1015
+ int32_t v = __object_i32(o);
1016
+ return value > v ? Qtrue : Qfalse;
1017
+ }
1018
+ static VALUE
1019
+ r_Byte_inv(VALUE self)
1020
+ {
1021
+ Byte *p;
1022
+ Data_Get_Struct(self, Byte, p);
1023
+ int32_t value = p->value;
1024
+ return __allocate_Int32(~value);
1025
+ }
1026
+ static VALUE
1027
+ r_Byte_shl(VALUE self, VALUE o)
1028
+ {
1029
+ Byte *p;
1030
+ Data_Get_Struct(self, Byte, p);
1031
+ int32_t value = p->value;
1032
+ int32_t v = __object_i32(o);
1033
+ return __allocate_Int32(value << v);
1034
+ }
1035
+ static VALUE
1036
+ r_Byte_shr(VALUE self, VALUE o)
1037
+ {
1038
+ Byte *p;
1039
+ Data_Get_Struct(self, Byte, p);
1040
+ int32_t value = p->value;
1041
+ int32_t v = __object_i32(o);
1042
+ return __allocate_Int32(value >> v);
1043
+ }
1044
+ static VALUE
1045
+ r_Byte_ushr(VALUE self, VALUE o)
1046
+ {
1047
+ Byte *p;
1048
+ Data_Get_Struct(self, Byte, p);
1049
+ uint32_t uvalue = (uint32_t) p->value;
1050
+ int32_t v = __object_i32(o);
1051
+ return __allocate_Int32((int32_t) (uvalue >> v));
1052
+ }
1053
+ static VALUE
1054
+ r_Byte_and(VALUE self, VALUE o)
1055
+ {
1056
+ Byte *p;
1057
+ Data_Get_Struct(self, Byte, p);
1058
+ int32_t value = p->value;
1059
+ int32_t v = __object_i32(o);
1060
+ return __allocate_Int32(value & v);
1061
+ }
1062
+ static VALUE
1063
+ r_Byte_xor(VALUE self, VALUE o)
1064
+ {
1065
+ Byte *p;
1066
+ Data_Get_Struct(self, Byte, p);
1067
+ int32_t value = p->value;
1068
+ int32_t v = __object_i32(o);
1069
+ return __allocate_Int32(value ^ v);
1070
+ }
1071
+ static VALUE
1072
+ r_Byte_or(VALUE self, VALUE o)
1073
+ {
1074
+ Byte *p;
1075
+ Data_Get_Struct(self, Byte, p);
1076
+ int32_t value = p->value;
1077
+ int32_t v = __object_i32(o);
1078
+ return __allocate_Int32(value | v);
1079
+ }
1080
+ static VALUE
1081
+ r_Byte_is_zero(VALUE self)
1082
+ {
1083
+ Byte *p;
1084
+ Data_Get_Struct(self, Byte, p);
1085
+ int32_t value = p->value;
1086
+ return value == 0 ? Qtrue : Qfalse;
1087
+ }
1088
+ static VALUE
1089
+ r_Char_new(VALUE self, VALUE o)
1090
+ {
1091
+ int32_t v = __object_i32(o);
1092
+ return __allocate_Char((uint16_t) v);
1093
+ }
1094
+ static VALUE
1095
+ r_Char_is_eql(VALUE self, VALUE o)
1096
+ {
1097
+ Char *p;
1098
+ Data_Get_Struct(self, Char, p);
1099
+ VALUE klass;
1100
+ switch (TYPE(o)) {
1101
+ case T_DATA:
1102
+ klass = RBASIC(o)->klass;
1103
+ if (klass == r_Char) {
1104
+ Char *op;
1105
+ Data_Get_Struct(o, Char, op);
1106
+ return p->value == op->value ? Qtrue : Qfalse;
1107
+ }
1108
+ }
1109
+ return Qfalse;
1110
+ }
1111
+ static VALUE
1112
+ r_Char_hash(VALUE self)
1113
+ {
1114
+ Char *p;
1115
+ Data_Get_Struct(self, Char, p);
1116
+ int32_t value = p->value;
1117
+ return LONG2NUM((long) __int32_hash(value));
1118
+ }
1119
+ static VALUE
1120
+ r_Char_to_byte(VALUE self)
1121
+ {
1122
+ Char *p;
1123
+ Data_Get_Struct(self, Char, p);
1124
+ int32_t value = p->value;
1125
+ return __allocate_Byte((int8_t) value);
1126
+ }
1127
+ static VALUE
1128
+ r_Char_to_char(VALUE self)
1129
+ {
1130
+ Char *p;
1131
+ Data_Get_Struct(self, Char, p);
1132
+ int32_t value = p->value;
1133
+ return __allocate_Char((uint16_t) value);
1134
+ }
1135
+ static VALUE
1136
+ r_Char_to_int16(VALUE self)
1137
+ {
1138
+ Char *p;
1139
+ Data_Get_Struct(self, Char, p);
1140
+ int32_t value = p->value;
1141
+ return __allocate_Int16((int16_t) value);
1142
+ }
1143
+ static VALUE
1144
+ r_Char_to_int32(VALUE self)
1145
+ {
1146
+ Char *p;
1147
+ Data_Get_Struct(self, Char, p);
1148
+ int32_t value = p->value;
1149
+ return __allocate_Int32((int32_t) value);
1150
+ }
1151
+ static VALUE
1152
+ r_Char_to_int64(VALUE self)
1153
+ {
1154
+ Char *p;
1155
+ Data_Get_Struct(self, Char, p);
1156
+ int32_t value = p->value;
1157
+ return __allocate_Int64((int64_t) value);
1158
+ }
1159
+ static VALUE
1160
+ r_Char_to_float32(VALUE self)
1161
+ {
1162
+ Char *p;
1163
+ Data_Get_Struct(self, Char, p);
1164
+ int32_t value = p->value;
1165
+ return __allocate_Float32((float) value);
1166
+ }
1167
+ static VALUE
1168
+ r_Char_to_float64(VALUE self)
1169
+ {
1170
+ Char *p;
1171
+ Data_Get_Struct(self, Char, p);
1172
+ int32_t value = p->value;
1173
+ return __allocate_Float64((double) value);
1174
+ }
1175
+ static VALUE
1176
+ r_Char_to_i(VALUE self)
1177
+ {
1178
+ Char *p;
1179
+ Data_Get_Struct(self, Char, p);
1180
+ int32_t value = p->value;
1181
+ return __int32_to_i(value);
1182
+ }
1183
+ static VALUE
1184
+ r_Char_to_f(VALUE self)
1185
+ {
1186
+ Char *p;
1187
+ Data_Get_Struct(self, Char, p);
1188
+ int32_t value = p->value;
1189
+ return __int32_to_f(value);
1190
+ }
1191
+ static VALUE
1192
+ r_Char_to_s(VALUE self)
1193
+ {
1194
+ Char *p;
1195
+ Data_Get_Struct(self, Char, p);
1196
+ int32_t value = p->value;
1197
+ return __int32_to_s(value);
1198
+ }
1199
+ static VALUE
1200
+ r_Char_eq(VALUE self, VALUE o)
1201
+ {
1202
+ Char *p;
1203
+ Data_Get_Struct(self, Char, p);
1204
+ int32_t value = p->value;
1205
+ int32_t v = __object_i32(o);
1206
+ return value == v ? Qtrue : Qfalse;
1207
+ }
1208
+ static VALUE
1209
+ r_Char_ne(VALUE self, VALUE o)
1210
+ {
1211
+ Char *p;
1212
+ Data_Get_Struct(self, Char, p);
1213
+ int32_t value = p->value;
1214
+ int32_t v = __object_i32(o);
1215
+ return value != v ? Qtrue : Qfalse;
1216
+ }
1217
+ static VALUE
1218
+ r_Char_pos(VALUE self)
1219
+ {
1220
+ Char *p;
1221
+ Data_Get_Struct(self, Char, p);
1222
+ int32_t value = p->value;
1223
+ return __allocate_Int32(+value);
1224
+ }
1225
+ static VALUE
1226
+ r_Char_neg(VALUE self)
1227
+ {
1228
+ Char *p;
1229
+ Data_Get_Struct(self, Char, p);
1230
+ int32_t value = p->value;
1231
+ return __allocate_Int32(-value);
1232
+ }
1233
+ static VALUE
1234
+ r_Char_mul(VALUE self, VALUE o)
1235
+ {
1236
+ Char *p;
1237
+ Data_Get_Struct(self, Char, p);
1238
+ int32_t value = p->value;
1239
+ int32_t v = __object_i32(o);
1240
+ return __allocate_Int32(value * v);
1241
+ }
1242
+ static VALUE
1243
+ r_Char_div(VALUE self, VALUE o)
1244
+ {
1245
+ Char *p;
1246
+ Data_Get_Struct(self, Char, p);
1247
+ int32_t value = p->value;
1248
+ int32_t v = __object_i32(o);
1249
+ return __allocate_Int32(__int32_div(value, v));
1250
+ }
1251
+ static VALUE
1252
+ r_Char_mod(VALUE self, VALUE o)
1253
+ {
1254
+ Char *p;
1255
+ Data_Get_Struct(self, Char, p);
1256
+ int32_t value = p->value;
1257
+ int32_t v = __object_i32(o);
1258
+ return __allocate_Int32(__int32_mod(value, v));
1259
+ }
1260
+ static VALUE
1261
+ r_Char_add(VALUE self, VALUE o)
1262
+ {
1263
+ Char *p;
1264
+ Data_Get_Struct(self, Char, p);
1265
+ int32_t value = p->value;
1266
+ int32_t v = __object_i32(o);
1267
+ return __allocate_Int32(value + v);
1268
+ }
1269
+ static VALUE
1270
+ r_Char_sub(VALUE self, VALUE o)
1271
+ {
1272
+ Char *p;
1273
+ Data_Get_Struct(self, Char, p);
1274
+ int32_t value = p->value;
1275
+ int32_t v = __object_i32(o);
1276
+ return __allocate_Int32(value - v);
1277
+ }
1278
+ static VALUE
1279
+ r_Char_cmp(VALUE self, VALUE o)
1280
+ {
1281
+ Char *p;
1282
+ Data_Get_Struct(self, Char, p);
1283
+ int32_t value = p->value;
1284
+ int32_t v = __object_i32(o);
1285
+ if (value < v)
1286
+ return r_Int32_M1;
1287
+ if (value > v)
1288
+ return r_Int32_1;
1289
+ return r_Int32_0;
1290
+ }
1291
+ static VALUE
1292
+ r_Char_lt(VALUE self, VALUE o)
1293
+ {
1294
+ Char *p;
1295
+ Data_Get_Struct(self, Char, p);
1296
+ int32_t value = p->value;
1297
+ int32_t v = __object_i32(o);
1298
+ return value < v ? Qtrue : Qfalse;
1299
+ }
1300
+ static VALUE
1301
+ r_Char_le(VALUE self, VALUE o)
1302
+ {
1303
+ Char *p;
1304
+ Data_Get_Struct(self, Char, p);
1305
+ int32_t value = p->value;
1306
+ int32_t v = __object_i32(o);
1307
+ return value <= v ? Qtrue : Qfalse;
1308
+ }
1309
+ static VALUE
1310
+ r_Char_ge(VALUE self, VALUE o)
1311
+ {
1312
+ Char *p;
1313
+ Data_Get_Struct(self, Char, p);
1314
+ int32_t value = p->value;
1315
+ int32_t v = __object_i32(o);
1316
+ return value >= v ? Qtrue : Qfalse;
1317
+ }
1318
+ static VALUE
1319
+ r_Char_gt(VALUE self, VALUE o)
1320
+ {
1321
+ Char *p;
1322
+ Data_Get_Struct(self, Char, p);
1323
+ int32_t value = p->value;
1324
+ int32_t v = __object_i32(o);
1325
+ return value > v ? Qtrue : Qfalse;
1326
+ }
1327
+ static VALUE
1328
+ r_Char_inv(VALUE self)
1329
+ {
1330
+ Char *p;
1331
+ Data_Get_Struct(self, Char, p);
1332
+ int32_t value = p->value;
1333
+ return __allocate_Int32(~value);
1334
+ }
1335
+ static VALUE
1336
+ r_Char_shl(VALUE self, VALUE o)
1337
+ {
1338
+ Char *p;
1339
+ Data_Get_Struct(self, Char, p);
1340
+ int32_t value = p->value;
1341
+ int32_t v = __object_i32(o);
1342
+ return __allocate_Int32(value << v);
1343
+ }
1344
+ static VALUE
1345
+ r_Char_shr(VALUE self, VALUE o)
1346
+ {
1347
+ Char *p;
1348
+ Data_Get_Struct(self, Char, p);
1349
+ int32_t value = p->value;
1350
+ int32_t v = __object_i32(o);
1351
+ return __allocate_Int32(value >> v);
1352
+ }
1353
+ static VALUE
1354
+ r_Char_ushr(VALUE self, VALUE o)
1355
+ {
1356
+ Char *p;
1357
+ Data_Get_Struct(self, Char, p);
1358
+ uint32_t uvalue = (uint32_t) p->value;
1359
+ int32_t v = __object_i32(o);
1360
+ return __allocate_Int32((int32_t) (uvalue >> v));
1361
+ }
1362
+ static VALUE
1363
+ r_Char_and(VALUE self, VALUE o)
1364
+ {
1365
+ Char *p;
1366
+ Data_Get_Struct(self, Char, p);
1367
+ int32_t value = p->value;
1368
+ int32_t v = __object_i32(o);
1369
+ return __allocate_Int32(value & v);
1370
+ }
1371
+ static VALUE
1372
+ r_Char_xor(VALUE self, VALUE o)
1373
+ {
1374
+ Char *p;
1375
+ Data_Get_Struct(self, Char, p);
1376
+ int32_t value = p->value;
1377
+ int32_t v = __object_i32(o);
1378
+ return __allocate_Int32(value ^ v);
1379
+ }
1380
+ static VALUE
1381
+ r_Char_or(VALUE self, VALUE o)
1382
+ {
1383
+ Char *p;
1384
+ Data_Get_Struct(self, Char, p);
1385
+ int32_t value = p->value;
1386
+ int32_t v = __object_i32(o);
1387
+ return __allocate_Int32(value | v);
1388
+ }
1389
+ static VALUE
1390
+ r_Char_is_zero(VALUE self)
1391
+ {
1392
+ Char *p;
1393
+ Data_Get_Struct(self, Char, p);
1394
+ int32_t value = p->value;
1395
+ return value == 0 ? Qtrue : Qfalse;
1396
+ }
1397
+ static VALUE
1398
+ r_Int16_new(VALUE self, VALUE o)
1399
+ {
1400
+ int32_t v = __object_i32(o);
1401
+ return __allocate_Int16((int16_t) v);
1402
+ }
1403
+ static VALUE
1404
+ r_Int16_is_eql(VALUE self, VALUE o)
1405
+ {
1406
+ Int16 *p;
1407
+ Data_Get_Struct(self, Int16, p);
1408
+ VALUE klass;
1409
+ switch (TYPE(o)) {
1410
+ case T_DATA:
1411
+ klass = RBASIC(o)->klass;
1412
+ if (klass == r_Int16) {
1413
+ Int16 *op;
1414
+ Data_Get_Struct(o, Int16, op);
1415
+ return p->value == op->value ? Qtrue : Qfalse;
1416
+ }
1417
+ }
1418
+ return Qfalse;
1419
+ }
1420
+ static VALUE
1421
+ r_Int16_hash(VALUE self)
1422
+ {
1423
+ Int16 *p;
1424
+ Data_Get_Struct(self, Int16, p);
1425
+ int32_t value = p->value;
1426
+ return LONG2NUM((long) __int32_hash(value));
1427
+ }
1428
+ static VALUE
1429
+ r_Int16_to_byte(VALUE self)
1430
+ {
1431
+ Int16 *p;
1432
+ Data_Get_Struct(self, Int16, p);
1433
+ int32_t value = p->value;
1434
+ return __allocate_Byte((int8_t) value);
1435
+ }
1436
+ static VALUE
1437
+ r_Int16_to_char(VALUE self)
1438
+ {
1439
+ Int16 *p;
1440
+ Data_Get_Struct(self, Int16, p);
1441
+ int32_t value = p->value;
1442
+ return __allocate_Char((uint16_t) value);
1443
+ }
1444
+ static VALUE
1445
+ r_Int16_to_int16(VALUE self)
1446
+ {
1447
+ Int16 *p;
1448
+ Data_Get_Struct(self, Int16, p);
1449
+ int32_t value = p->value;
1450
+ return __allocate_Int16((int16_t) value);
1451
+ }
1452
+ static VALUE
1453
+ r_Int16_to_int32(VALUE self)
1454
+ {
1455
+ Int16 *p;
1456
+ Data_Get_Struct(self, Int16, p);
1457
+ int32_t value = p->value;
1458
+ return __allocate_Int32((int32_t) value);
1459
+ }
1460
+ static VALUE
1461
+ r_Int16_to_int64(VALUE self)
1462
+ {
1463
+ Int16 *p;
1464
+ Data_Get_Struct(self, Int16, p);
1465
+ int32_t value = p->value;
1466
+ return __allocate_Int64((int64_t) value);
1467
+ }
1468
+ static VALUE
1469
+ r_Int16_to_float32(VALUE self)
1470
+ {
1471
+ Int16 *p;
1472
+ Data_Get_Struct(self, Int16, p);
1473
+ int32_t value = p->value;
1474
+ return __allocate_Float32((float) value);
1475
+ }
1476
+ static VALUE
1477
+ r_Int16_to_float64(VALUE self)
1478
+ {
1479
+ Int16 *p;
1480
+ Data_Get_Struct(self, Int16, p);
1481
+ int32_t value = p->value;
1482
+ return __allocate_Float64((double) value);
1483
+ }
1484
+ static VALUE
1485
+ r_Int16_to_i(VALUE self)
1486
+ {
1487
+ Int16 *p;
1488
+ Data_Get_Struct(self, Int16, p);
1489
+ int32_t value = p->value;
1490
+ return __int32_to_i(value);
1491
+ }
1492
+ static VALUE
1493
+ r_Int16_to_f(VALUE self)
1494
+ {
1495
+ Int16 *p;
1496
+ Data_Get_Struct(self, Int16, p);
1497
+ int32_t value = p->value;
1498
+ return __int32_to_f(value);
1499
+ }
1500
+ static VALUE
1501
+ r_Int16_to_s(VALUE self)
1502
+ {
1503
+ Int16 *p;
1504
+ Data_Get_Struct(self, Int16, p);
1505
+ int32_t value = p->value;
1506
+ return __int32_to_s(value);
1507
+ }
1508
+ static VALUE
1509
+ r_Int16_eq(VALUE self, VALUE o)
1510
+ {
1511
+ Int16 *p;
1512
+ Data_Get_Struct(self, Int16, p);
1513
+ int32_t value = p->value;
1514
+ int32_t v = __object_i32(o);
1515
+ return value == v ? Qtrue : Qfalse;
1516
+ }
1517
+ static VALUE
1518
+ r_Int16_ne(VALUE self, VALUE o)
1519
+ {
1520
+ Int16 *p;
1521
+ Data_Get_Struct(self, Int16, p);
1522
+ int32_t value = p->value;
1523
+ int32_t v = __object_i32(o);
1524
+ return value != v ? Qtrue : Qfalse;
1525
+ }
1526
+ static VALUE
1527
+ r_Int16_pos(VALUE self)
1528
+ {
1529
+ Int16 *p;
1530
+ Data_Get_Struct(self, Int16, p);
1531
+ int32_t value = p->value;
1532
+ return __allocate_Int32(+value);
1533
+ }
1534
+ static VALUE
1535
+ r_Int16_neg(VALUE self)
1536
+ {
1537
+ Int16 *p;
1538
+ Data_Get_Struct(self, Int16, p);
1539
+ int32_t value = p->value;
1540
+ return __allocate_Int32(-value);
1541
+ }
1542
+ static VALUE
1543
+ r_Int16_mul(VALUE self, VALUE o)
1544
+ {
1545
+ Int16 *p;
1546
+ Data_Get_Struct(self, Int16, p);
1547
+ int32_t value = p->value;
1548
+ int32_t v = __object_i32(o);
1549
+ return __allocate_Int32(value * v);
1550
+ }
1551
+ static VALUE
1552
+ r_Int16_div(VALUE self, VALUE o)
1553
+ {
1554
+ Int16 *p;
1555
+ Data_Get_Struct(self, Int16, p);
1556
+ int32_t value = p->value;
1557
+ int32_t v = __object_i32(o);
1558
+ return __allocate_Int32(__int32_div(value, v));
1559
+ }
1560
+ static VALUE
1561
+ r_Int16_mod(VALUE self, VALUE o)
1562
+ {
1563
+ Int16 *p;
1564
+ Data_Get_Struct(self, Int16, p);
1565
+ int32_t value = p->value;
1566
+ int32_t v = __object_i32(o);
1567
+ return __allocate_Int32(__int32_mod(value, v));
1568
+ }
1569
+ static VALUE
1570
+ r_Int16_add(VALUE self, VALUE o)
1571
+ {
1572
+ Int16 *p;
1573
+ Data_Get_Struct(self, Int16, p);
1574
+ int32_t value = p->value;
1575
+ int32_t v = __object_i32(o);
1576
+ return __allocate_Int32(value + v);
1577
+ }
1578
+ static VALUE
1579
+ r_Int16_sub(VALUE self, VALUE o)
1580
+ {
1581
+ Int16 *p;
1582
+ Data_Get_Struct(self, Int16, p);
1583
+ int32_t value = p->value;
1584
+ int32_t v = __object_i32(o);
1585
+ return __allocate_Int32(value - v);
1586
+ }
1587
+ static VALUE
1588
+ r_Int16_cmp(VALUE self, VALUE o)
1589
+ {
1590
+ Int16 *p;
1591
+ Data_Get_Struct(self, Int16, p);
1592
+ int32_t value = p->value;
1593
+ int32_t v = __object_i32(o);
1594
+ if (value < v)
1595
+ return r_Int32_M1;
1596
+ if (value > v)
1597
+ return r_Int32_1;
1598
+ return r_Int32_0;
1599
+ }
1600
+ static VALUE
1601
+ r_Int16_lt(VALUE self, VALUE o)
1602
+ {
1603
+ Int16 *p;
1604
+ Data_Get_Struct(self, Int16, p);
1605
+ int32_t value = p->value;
1606
+ int32_t v = __object_i32(o);
1607
+ return value < v ? Qtrue : Qfalse;
1608
+ }
1609
+ static VALUE
1610
+ r_Int16_le(VALUE self, VALUE o)
1611
+ {
1612
+ Int16 *p;
1613
+ Data_Get_Struct(self, Int16, p);
1614
+ int32_t value = p->value;
1615
+ int32_t v = __object_i32(o);
1616
+ return value <= v ? Qtrue : Qfalse;
1617
+ }
1618
+ static VALUE
1619
+ r_Int16_ge(VALUE self, VALUE o)
1620
+ {
1621
+ Int16 *p;
1622
+ Data_Get_Struct(self, Int16, p);
1623
+ int32_t value = p->value;
1624
+ int32_t v = __object_i32(o);
1625
+ return value >= v ? Qtrue : Qfalse;
1626
+ }
1627
+ static VALUE
1628
+ r_Int16_gt(VALUE self, VALUE o)
1629
+ {
1630
+ Int16 *p;
1631
+ Data_Get_Struct(self, Int16, p);
1632
+ int32_t value = p->value;
1633
+ int32_t v = __object_i32(o);
1634
+ return value > v ? Qtrue : Qfalse;
1635
+ }
1636
+ static VALUE
1637
+ r_Int16_inv(VALUE self)
1638
+ {
1639
+ Int16 *p;
1640
+ Data_Get_Struct(self, Int16, p);
1641
+ int32_t value = p->value;
1642
+ return __allocate_Int32(~value);
1643
+ }
1644
+ static VALUE
1645
+ r_Int16_shl(VALUE self, VALUE o)
1646
+ {
1647
+ Int16 *p;
1648
+ Data_Get_Struct(self, Int16, p);
1649
+ int32_t value = p->value;
1650
+ int32_t v = __object_i32(o);
1651
+ return __allocate_Int32(value << v);
1652
+ }
1653
+ static VALUE
1654
+ r_Int16_shr(VALUE self, VALUE o)
1655
+ {
1656
+ Int16 *p;
1657
+ Data_Get_Struct(self, Int16, p);
1658
+ int32_t value = p->value;
1659
+ int32_t v = __object_i32(o);
1660
+ return __allocate_Int32(value >> v);
1661
+ }
1662
+ static VALUE
1663
+ r_Int16_ushr(VALUE self, VALUE o)
1664
+ {
1665
+ Int16 *p;
1666
+ Data_Get_Struct(self, Int16, p);
1667
+ uint32_t uvalue = (uint32_t) p->value;
1668
+ int32_t v = __object_i32(o);
1669
+ return __allocate_Int32((int32_t) (uvalue >> v));
1670
+ }
1671
+ static VALUE
1672
+ r_Int16_and(VALUE self, VALUE o)
1673
+ {
1674
+ Int16 *p;
1675
+ Data_Get_Struct(self, Int16, p);
1676
+ int32_t value = p->value;
1677
+ int32_t v = __object_i32(o);
1678
+ return __allocate_Int32(value & v);
1679
+ }
1680
+ static VALUE
1681
+ r_Int16_xor(VALUE self, VALUE o)
1682
+ {
1683
+ Int16 *p;
1684
+ Data_Get_Struct(self, Int16, p);
1685
+ int32_t value = p->value;
1686
+ int32_t v = __object_i32(o);
1687
+ return __allocate_Int32(value ^ v);
1688
+ }
1689
+ static VALUE
1690
+ r_Int16_or(VALUE self, VALUE o)
1691
+ {
1692
+ Int16 *p;
1693
+ Data_Get_Struct(self, Int16, p);
1694
+ int32_t value = p->value;
1695
+ int32_t v = __object_i32(o);
1696
+ return __allocate_Int32(value | v);
1697
+ }
1698
+ static VALUE
1699
+ r_Int16_is_zero(VALUE self)
1700
+ {
1701
+ Int16 *p;
1702
+ Data_Get_Struct(self, Int16, p);
1703
+ int32_t value = p->value;
1704
+ return value == 0 ? Qtrue : Qfalse;
1705
+ }
1706
+ static VALUE
1707
+ r_Int32_new(VALUE self, VALUE o)
1708
+ {
1709
+ int32_t v = __object_i32(o);
1710
+ return __allocate_Int32((int32_t) v);
1711
+ }
1712
+ static VALUE
1713
+ r_Int32_is_eql(VALUE self, VALUE o)
1714
+ {
1715
+ Int32 *p;
1716
+ Data_Get_Struct(self, Int32, p);
1717
+ VALUE klass;
1718
+ switch (TYPE(o)) {
1719
+ case T_DATA:
1720
+ klass = RBASIC(o)->klass;
1721
+ if (klass == r_Int32) {
1722
+ Int32 *op;
1723
+ Data_Get_Struct(o, Int32, op);
1724
+ return p->value == op->value ? Qtrue : Qfalse;
1725
+ }
1726
+ }
1727
+ return Qfalse;
1728
+ }
1729
+ static VALUE
1730
+ r_Int32_hash(VALUE self)
1731
+ {
1732
+ Int32 *p;
1733
+ Data_Get_Struct(self, Int32, p);
1734
+ int32_t value = p->value;
1735
+ return LONG2NUM((long) __int32_hash(value));
1736
+ }
1737
+ static VALUE
1738
+ r_Int32_to_byte(VALUE self)
1739
+ {
1740
+ Int32 *p;
1741
+ Data_Get_Struct(self, Int32, p);
1742
+ int32_t value = p->value;
1743
+ return __allocate_Byte((int8_t) value);
1744
+ }
1745
+ static VALUE
1746
+ r_Int32_to_char(VALUE self)
1747
+ {
1748
+ Int32 *p;
1749
+ Data_Get_Struct(self, Int32, p);
1750
+ int32_t value = p->value;
1751
+ return __allocate_Char((uint16_t) value);
1752
+ }
1753
+ static VALUE
1754
+ r_Int32_to_int16(VALUE self)
1755
+ {
1756
+ Int32 *p;
1757
+ Data_Get_Struct(self, Int32, p);
1758
+ int32_t value = p->value;
1759
+ return __allocate_Int16((int16_t) value);
1760
+ }
1761
+ static VALUE
1762
+ r_Int32_to_int32(VALUE self)
1763
+ {
1764
+ Int32 *p;
1765
+ Data_Get_Struct(self, Int32, p);
1766
+ int32_t value = p->value;
1767
+ return __allocate_Int32((int32_t) value);
1768
+ }
1769
+ static VALUE
1770
+ r_Int32_to_int64(VALUE self)
1771
+ {
1772
+ Int32 *p;
1773
+ Data_Get_Struct(self, Int32, p);
1774
+ int32_t value = p->value;
1775
+ return __allocate_Int64((int64_t) value);
1776
+ }
1777
+ static VALUE
1778
+ r_Int32_to_float32(VALUE self)
1779
+ {
1780
+ Int32 *p;
1781
+ Data_Get_Struct(self, Int32, p);
1782
+ int32_t value = p->value;
1783
+ return __allocate_Float32((float) value);
1784
+ }
1785
+ static VALUE
1786
+ r_Int32_to_float64(VALUE self)
1787
+ {
1788
+ Int32 *p;
1789
+ Data_Get_Struct(self, Int32, p);
1790
+ int32_t value = p->value;
1791
+ return __allocate_Float64((double) value);
1792
+ }
1793
+ static VALUE
1794
+ r_Int32_to_i(VALUE self)
1795
+ {
1796
+ Int32 *p;
1797
+ Data_Get_Struct(self, Int32, p);
1798
+ int32_t value = p->value;
1799
+ return __int32_to_i(value);
1800
+ }
1801
+ static VALUE
1802
+ r_Int32_to_f(VALUE self)
1803
+ {
1804
+ Int32 *p;
1805
+ Data_Get_Struct(self, Int32, p);
1806
+ int32_t value = p->value;
1807
+ return __int32_to_f(value);
1808
+ }
1809
+ static VALUE
1810
+ r_Int32_to_s(VALUE self)
1811
+ {
1812
+ Int32 *p;
1813
+ Data_Get_Struct(self, Int32, p);
1814
+ int32_t value = p->value;
1815
+ return __int32_to_s(value);
1816
+ }
1817
+ static VALUE
1818
+ r_Int32_eq(VALUE self, VALUE o)
1819
+ {
1820
+ Int32 *p;
1821
+ Data_Get_Struct(self, Int32, p);
1822
+ int32_t value = p->value;
1823
+ int32_t v = __object_i32(o);
1824
+ return value == v ? Qtrue : Qfalse;
1825
+ }
1826
+ static VALUE
1827
+ r_Int32_ne(VALUE self, VALUE o)
1828
+ {
1829
+ Int32 *p;
1830
+ Data_Get_Struct(self, Int32, p);
1831
+ int32_t value = p->value;
1832
+ int32_t v = __object_i32(o);
1833
+ return value != v ? Qtrue : Qfalse;
1834
+ }
1835
+ static VALUE
1836
+ r_Int32_pos(VALUE self)
1837
+ {
1838
+ Int32 *p;
1839
+ Data_Get_Struct(self, Int32, p);
1840
+ int32_t value = p->value;
1841
+ return __allocate_Int32(+value);
1842
+ }
1843
+ static VALUE
1844
+ r_Int32_neg(VALUE self)
1845
+ {
1846
+ Int32 *p;
1847
+ Data_Get_Struct(self, Int32, p);
1848
+ int32_t value = p->value;
1849
+ return __allocate_Int32(-value);
1850
+ }
1851
+ static VALUE
1852
+ r_Int32_mul(VALUE self, VALUE o)
1853
+ {
1854
+ Int32 *p;
1855
+ Data_Get_Struct(self, Int32, p);
1856
+ int32_t value = p->value;
1857
+ int32_t v = __object_i32(o);
1858
+ return __allocate_Int32(value * v);
1859
+ }
1860
+ static VALUE
1861
+ r_Int32_div(VALUE self, VALUE o)
1862
+ {
1863
+ Int32 *p;
1864
+ Data_Get_Struct(self, Int32, p);
1865
+ int32_t value = p->value;
1866
+ int32_t v = __object_i32(o);
1867
+ return __allocate_Int32(__int32_div(value, v));
1868
+ }
1869
+ static VALUE
1870
+ r_Int32_mod(VALUE self, VALUE o)
1871
+ {
1872
+ Int32 *p;
1873
+ Data_Get_Struct(self, Int32, p);
1874
+ int32_t value = p->value;
1875
+ int32_t v = __object_i32(o);
1876
+ return __allocate_Int32(__int32_mod(value, v));
1877
+ }
1878
+ static VALUE
1879
+ r_Int32_add(VALUE self, VALUE o)
1880
+ {
1881
+ Int32 *p;
1882
+ Data_Get_Struct(self, Int32, p);
1883
+ int32_t value = p->value;
1884
+ int32_t v = __object_i32(o);
1885
+ return __allocate_Int32(value + v);
1886
+ }
1887
+ static VALUE
1888
+ r_Int32_sub(VALUE self, VALUE o)
1889
+ {
1890
+ Int32 *p;
1891
+ Data_Get_Struct(self, Int32, p);
1892
+ int32_t value = p->value;
1893
+ int32_t v = __object_i32(o);
1894
+ return __allocate_Int32(value - v);
1895
+ }
1896
+ static VALUE
1897
+ r_Int32_cmp(VALUE self, VALUE o)
1898
+ {
1899
+ Int32 *p;
1900
+ Data_Get_Struct(self, Int32, p);
1901
+ int32_t value = p->value;
1902
+ int32_t v = __object_i32(o);
1903
+ if (value < v)
1904
+ return r_Int32_M1;
1905
+ if (value > v)
1906
+ return r_Int32_1;
1907
+ return r_Int32_0;
1908
+ }
1909
+ static VALUE
1910
+ r_Int32_lt(VALUE self, VALUE o)
1911
+ {
1912
+ Int32 *p;
1913
+ Data_Get_Struct(self, Int32, p);
1914
+ int32_t value = p->value;
1915
+ int32_t v = __object_i32(o);
1916
+ return value < v ? Qtrue : Qfalse;
1917
+ }
1918
+ static VALUE
1919
+ r_Int32_le(VALUE self, VALUE o)
1920
+ {
1921
+ Int32 *p;
1922
+ Data_Get_Struct(self, Int32, p);
1923
+ int32_t value = p->value;
1924
+ int32_t v = __object_i32(o);
1925
+ return value <= v ? Qtrue : Qfalse;
1926
+ }
1927
+ static VALUE
1928
+ r_Int32_ge(VALUE self, VALUE o)
1929
+ {
1930
+ Int32 *p;
1931
+ Data_Get_Struct(self, Int32, p);
1932
+ int32_t value = p->value;
1933
+ int32_t v = __object_i32(o);
1934
+ return value >= v ? Qtrue : Qfalse;
1935
+ }
1936
+ static VALUE
1937
+ r_Int32_gt(VALUE self, VALUE o)
1938
+ {
1939
+ Int32 *p;
1940
+ Data_Get_Struct(self, Int32, p);
1941
+ int32_t value = p->value;
1942
+ int32_t v = __object_i32(o);
1943
+ return value > v ? Qtrue : Qfalse;
1944
+ }
1945
+ static VALUE
1946
+ r_Int32_inv(VALUE self)
1947
+ {
1948
+ Int32 *p;
1949
+ Data_Get_Struct(self, Int32, p);
1950
+ int32_t value = p->value;
1951
+ return __allocate_Int32(~value);
1952
+ }
1953
+ static VALUE
1954
+ r_Int32_shl(VALUE self, VALUE o)
1955
+ {
1956
+ Int32 *p;
1957
+ Data_Get_Struct(self, Int32, p);
1958
+ int32_t value = p->value;
1959
+ int32_t v = __object_i32(o);
1960
+ return __allocate_Int32(value << v);
1961
+ }
1962
+ static VALUE
1963
+ r_Int32_shr(VALUE self, VALUE o)
1964
+ {
1965
+ Int32 *p;
1966
+ Data_Get_Struct(self, Int32, p);
1967
+ int32_t value = p->value;
1968
+ int32_t v = __object_i32(o);
1969
+ return __allocate_Int32(value >> v);
1970
+ }
1971
+ static VALUE
1972
+ r_Int32_ushr(VALUE self, VALUE o)
1973
+ {
1974
+ Int32 *p;
1975
+ Data_Get_Struct(self, Int32, p);
1976
+ uint32_t uvalue = (uint32_t) p->value;
1977
+ int32_t v = __object_i32(o);
1978
+ return __allocate_Int32((int32_t) (uvalue >> v));
1979
+ }
1980
+ static VALUE
1981
+ r_Int32_and(VALUE self, VALUE o)
1982
+ {
1983
+ Int32 *p;
1984
+ Data_Get_Struct(self, Int32, p);
1985
+ int32_t value = p->value;
1986
+ int32_t v = __object_i32(o);
1987
+ return __allocate_Int32(value & v);
1988
+ }
1989
+ static VALUE
1990
+ r_Int32_xor(VALUE self, VALUE o)
1991
+ {
1992
+ Int32 *p;
1993
+ Data_Get_Struct(self, Int32, p);
1994
+ int32_t value = p->value;
1995
+ int32_t v = __object_i32(o);
1996
+ return __allocate_Int32(value ^ v);
1997
+ }
1998
+ static VALUE
1999
+ r_Int32_or(VALUE self, VALUE o)
2000
+ {
2001
+ Int32 *p;
2002
+ Data_Get_Struct(self, Int32, p);
2003
+ int32_t value = p->value;
2004
+ int32_t v = __object_i32(o);
2005
+ return __allocate_Int32(value | v);
2006
+ }
2007
+ static VALUE
2008
+ r_Int32_is_zero(VALUE self)
2009
+ {
2010
+ Int32 *p;
2011
+ Data_Get_Struct(self, Int32, p);
2012
+ int32_t value = p->value;
2013
+ return value == 0 ? Qtrue : Qfalse;
2014
+ }
2015
+ static VALUE
2016
+ r_Int32_bang_to_int32(VALUE self)
2017
+ {
2018
+ return self;
2019
+ }
2020
+ static VALUE
2021
+ r_Int32_bang_to_int64(VALUE self)
2022
+ {
2023
+ Int32 *p;
2024
+ Data_Get_Struct(self, Int32, p);
2025
+ int32_t value = p->value;
2026
+ return __allocate_Int64((int64_t) value);
2027
+ }
2028
+ static VALUE
2029
+ r_Int32_to_fixnum(VALUE self)
2030
+ {
2031
+ Int32 *p;
2032
+ Data_Get_Struct(self, Int32, p);
2033
+ int32_t value = p->value;
2034
+ return LONG2NUM((long) value);
2035
+ }
2036
+ static VALUE
2037
+ r_Int32_to_hex(VALUE self)
2038
+ {
2039
+ Int32 *p;
2040
+ Data_Get_Struct(self, Int32, p);
2041
+ int32_t value = p->value;
2042
+ return __int32_to_hex(value);
2043
+ }
2044
+ static VALUE
2045
+ r_Int32_chr(VALUE self)
2046
+ {
2047
+ Int32 *p;
2048
+ Data_Get_Struct(self, Int32, p);
2049
+ int32_t value = p->value;
2050
+ return __int32_chr(value);
2051
+ }
2052
+ static VALUE
2053
+ r_Int32_rol(VALUE self, VALUE o)
2054
+ {
2055
+ Int32 *p;
2056
+ Data_Get_Struct(self, Int32, p);
2057
+ uint32_t uvalue = (uint32_t) p->value;
2058
+ int32_t v = __object_i32(o);
2059
+ return __allocate_Int32((int32_t) (uvalue << v | uvalue >> (32 - v)));
2060
+ }
2061
+ static VALUE
2062
+ r_Int32_ror(VALUE self, VALUE o)
2063
+ {
2064
+ Int32 *p;
2065
+ Data_Get_Struct(self, Int32, p);
2066
+ uint32_t uvalue = (uint32_t) p->value;
2067
+ int32_t v = __object_i32(o);
2068
+ return __allocate_Int32((int32_t) (uvalue >> v | uvalue << (32 - v)));
2069
+ }
2070
+ static VALUE
2071
+ r_Int32_count(VALUE self)
2072
+ {
2073
+ Int32 *p;
2074
+ Data_Get_Struct(self, Int32, p);
2075
+ int32_t value = p->value;
2076
+ int32_t c = 0;
2077
+ while (value != 0) {
2078
+ value &= value - 1;
2079
+ c += 1;
2080
+ }
2081
+ return __allocate_Int32(c);
2082
+ }
2083
+ static VALUE
2084
+ r_Int32_signum(VALUE self)
2085
+ {
2086
+ Int32 *p;
2087
+ Data_Get_Struct(self, Int32, p);
2088
+ int32_t value = p->value;
2089
+ if (value < 0)
2090
+ return r_Int32_M1;
2091
+ if (value > 0)
2092
+ return r_Int32_1;
2093
+ return r_Int32_0;
2094
+ }
2095
+ static VALUE
2096
+ r_Int32_times(VALUE self)
2097
+ {
2098
+ Int32 *p;
2099
+ Data_Get_Struct(self, Int32, p);
2100
+ int32_t value = p->value;
2101
+ int32_t i = 0;
2102
+ while (i < value) {
2103
+ rb_yield(__allocate_Int32(i));
2104
+ i += 1;
2105
+ }
2106
+ return Qnil;
2107
+ }
2108
+ static VALUE
2109
+ r_Int32_upto(VALUE self, VALUE o)
2110
+ {
2111
+ Int32 *p;
2112
+ Data_Get_Struct(self, Int32, p);
2113
+ int32_t i = p->value;
2114
+ int32_t v = __object_i32(o);
2115
+ if (i <= v) {
2116
+ while (1) {
2117
+ rb_yield(__allocate_Int32(i));
2118
+ if (i == v)
2119
+ break;
2120
+ i += 1;
2121
+ }
2122
+ }
2123
+ return Qnil;
2124
+ }
2125
+ static VALUE
2126
+ r_Int32_downto(VALUE self, VALUE o)
2127
+ {
2128
+ Int32 *p;
2129
+ Data_Get_Struct(self, Int32, p);
2130
+ int32_t i = p->value;
2131
+ int32_t v = __object_i32(o);
2132
+ if (i >= v) {
2133
+ while (1) {
2134
+ rb_yield(__allocate_Int32(i));
2135
+ if (i == v)
2136
+ break;
2137
+ i -= 1;
2138
+ }
2139
+ }
2140
+ return Qnil;
2141
+ }
2142
+ static VALUE
2143
+ r_Int64_new(VALUE self, VALUE o)
2144
+ {
2145
+ int64_t v = __object_i64(o);
2146
+ return __allocate_Int64((int64_t) v);
2147
+ }
2148
+ static VALUE
2149
+ r_Int64_is_eql(VALUE self, VALUE o)
2150
+ {
2151
+ Int64 *p;
2152
+ Data_Get_Struct(self, Int64, p);
2153
+ VALUE klass;
2154
+ switch (TYPE(o)) {
2155
+ case T_DATA:
2156
+ klass = RBASIC(o)->klass;
2157
+ if (klass == r_Int64) {
2158
+ Int64 *op;
2159
+ Data_Get_Struct(o, Int64, op);
2160
+ return p->value == op->value ? Qtrue : Qfalse;
2161
+ }
2162
+ }
2163
+ return Qfalse;
2164
+ }
2165
+ static VALUE
2166
+ r_Int64_hash(VALUE self)
2167
+ {
2168
+ Int64 *p;
2169
+ Data_Get_Struct(self, Int64, p);
2170
+ int64_t value = p->value;
2171
+ return LONG2NUM((long) __int64_hash(value));
2172
+ }
2173
+ static VALUE
2174
+ r_Int64_to_byte(VALUE self)
2175
+ {
2176
+ Int64 *p;
2177
+ Data_Get_Struct(self, Int64, p);
2178
+ int64_t value = p->value;
2179
+ return __allocate_Byte((int8_t) value);
2180
+ }
2181
+ static VALUE
2182
+ r_Int64_to_char(VALUE self)
2183
+ {
2184
+ Int64 *p;
2185
+ Data_Get_Struct(self, Int64, p);
2186
+ int64_t value = p->value;
2187
+ return __allocate_Char((uint16_t) value);
2188
+ }
2189
+ static VALUE
2190
+ r_Int64_to_int16(VALUE self)
2191
+ {
2192
+ Int64 *p;
2193
+ Data_Get_Struct(self, Int64, p);
2194
+ int64_t value = p->value;
2195
+ return __allocate_Int16((int16_t) value);
2196
+ }
2197
+ static VALUE
2198
+ r_Int64_to_int32(VALUE self)
2199
+ {
2200
+ Int64 *p;
2201
+ Data_Get_Struct(self, Int64, p);
2202
+ int64_t value = p->value;
2203
+ return __allocate_Int32((int32_t) value);
2204
+ }
2205
+ static VALUE
2206
+ r_Int64_to_int64(VALUE self)
2207
+ {
2208
+ Int64 *p;
2209
+ Data_Get_Struct(self, Int64, p);
2210
+ int64_t value = p->value;
2211
+ return __allocate_Int64((int64_t) value);
2212
+ }
2213
+ static VALUE
2214
+ r_Int64_to_float32(VALUE self)
2215
+ {
2216
+ Int64 *p;
2217
+ Data_Get_Struct(self, Int64, p);
2218
+ int64_t value = p->value;
2219
+ return __allocate_Float32((float) value);
2220
+ }
2221
+ static VALUE
2222
+ r_Int64_to_float64(VALUE self)
2223
+ {
2224
+ Int64 *p;
2225
+ Data_Get_Struct(self, Int64, p);
2226
+ int64_t value = p->value;
2227
+ return __allocate_Float64((double) value);
2228
+ }
2229
+ static VALUE
2230
+ r_Int64_to_i(VALUE self)
2231
+ {
2232
+ Int64 *p;
2233
+ Data_Get_Struct(self, Int64, p);
2234
+ int64_t value = p->value;
2235
+ return __int64_to_i(value);
2236
+ }
2237
+ static VALUE
2238
+ r_Int64_to_f(VALUE self)
2239
+ {
2240
+ Int64 *p;
2241
+ Data_Get_Struct(self, Int64, p);
2242
+ int64_t value = p->value;
2243
+ return __int64_to_f(value);
2244
+ }
2245
+ static VALUE
2246
+ r_Int64_to_s(VALUE self)
2247
+ {
2248
+ Int64 *p;
2249
+ Data_Get_Struct(self, Int64, p);
2250
+ int64_t value = p->value;
2251
+ return __int64_to_s(value);
2252
+ }
2253
+ static VALUE
2254
+ r_Int64_eq(VALUE self, VALUE o)
2255
+ {
2256
+ Int64 *p;
2257
+ Data_Get_Struct(self, Int64, p);
2258
+ int64_t value = p->value;
2259
+ int64_t v = __object_i64(o);
2260
+ return value == v ? Qtrue : Qfalse;
2261
+ }
2262
+ static VALUE
2263
+ r_Int64_ne(VALUE self, VALUE o)
2264
+ {
2265
+ Int64 *p;
2266
+ Data_Get_Struct(self, Int64, p);
2267
+ int64_t value = p->value;
2268
+ int64_t v = __object_i64(o);
2269
+ return value != v ? Qtrue : Qfalse;
2270
+ }
2271
+ static VALUE
2272
+ r_Int64_pos(VALUE self)
2273
+ {
2274
+ Int64 *p;
2275
+ Data_Get_Struct(self, Int64, p);
2276
+ int64_t value = p->value;
2277
+ return __allocate_Int64(+value);
2278
+ }
2279
+ static VALUE
2280
+ r_Int64_neg(VALUE self)
2281
+ {
2282
+ Int64 *p;
2283
+ Data_Get_Struct(self, Int64, p);
2284
+ int64_t value = p->value;
2285
+ return __allocate_Int64(-value);
2286
+ }
2287
+ static VALUE
2288
+ r_Int64_mul(VALUE self, VALUE o)
2289
+ {
2290
+ Int64 *p;
2291
+ Data_Get_Struct(self, Int64, p);
2292
+ int64_t value = p->value;
2293
+ int64_t v = __object_i64(o);
2294
+ return __allocate_Int64(value * v);
2295
+ }
2296
+ static VALUE
2297
+ r_Int64_div(VALUE self, VALUE o)
2298
+ {
2299
+ Int64 *p;
2300
+ Data_Get_Struct(self, Int64, p);
2301
+ int64_t value = p->value;
2302
+ int64_t v = __object_i64(o);
2303
+ return __allocate_Int64(__int64_div(value, v));
2304
+ }
2305
+ static VALUE
2306
+ r_Int64_mod(VALUE self, VALUE o)
2307
+ {
2308
+ Int64 *p;
2309
+ Data_Get_Struct(self, Int64, p);
2310
+ int64_t value = p->value;
2311
+ int64_t v = __object_i64(o);
2312
+ return __allocate_Int64(__int64_mod(value, v));
2313
+ }
2314
+ static VALUE
2315
+ r_Int64_add(VALUE self, VALUE o)
2316
+ {
2317
+ Int64 *p;
2318
+ Data_Get_Struct(self, Int64, p);
2319
+ int64_t value = p->value;
2320
+ int64_t v = __object_i64(o);
2321
+ return __allocate_Int64(value + v);
2322
+ }
2323
+ static VALUE
2324
+ r_Int64_sub(VALUE self, VALUE o)
2325
+ {
2326
+ Int64 *p;
2327
+ Data_Get_Struct(self, Int64, p);
2328
+ int64_t value = p->value;
2329
+ int64_t v = __object_i64(o);
2330
+ return __allocate_Int64(value - v);
2331
+ }
2332
+ static VALUE
2333
+ r_Int64_cmp(VALUE self, VALUE o)
2334
+ {
2335
+ Int64 *p;
2336
+ Data_Get_Struct(self, Int64, p);
2337
+ int64_t value = p->value;
2338
+ int64_t v = __object_i64(o);
2339
+ if (value < v)
2340
+ return r_Int32_M1;
2341
+ if (value > v)
2342
+ return r_Int32_1;
2343
+ return r_Int32_0;
2344
+ }
2345
+ static VALUE
2346
+ r_Int64_lt(VALUE self, VALUE o)
2347
+ {
2348
+ Int64 *p;
2349
+ Data_Get_Struct(self, Int64, p);
2350
+ int64_t value = p->value;
2351
+ int64_t v = __object_i64(o);
2352
+ return value < v ? Qtrue : Qfalse;
2353
+ }
2354
+ static VALUE
2355
+ r_Int64_le(VALUE self, VALUE o)
2356
+ {
2357
+ Int64 *p;
2358
+ Data_Get_Struct(self, Int64, p);
2359
+ int64_t value = p->value;
2360
+ int64_t v = __object_i64(o);
2361
+ return value <= v ? Qtrue : Qfalse;
2362
+ }
2363
+ static VALUE
2364
+ r_Int64_ge(VALUE self, VALUE o)
2365
+ {
2366
+ Int64 *p;
2367
+ Data_Get_Struct(self, Int64, p);
2368
+ int64_t value = p->value;
2369
+ int64_t v = __object_i64(o);
2370
+ return value >= v ? Qtrue : Qfalse;
2371
+ }
2372
+ static VALUE
2373
+ r_Int64_gt(VALUE self, VALUE o)
2374
+ {
2375
+ Int64 *p;
2376
+ Data_Get_Struct(self, Int64, p);
2377
+ int64_t value = p->value;
2378
+ int64_t v = __object_i64(o);
2379
+ return value > v ? Qtrue : Qfalse;
2380
+ }
2381
+ static VALUE
2382
+ r_Int64_inv(VALUE self)
2383
+ {
2384
+ Int64 *p;
2385
+ Data_Get_Struct(self, Int64, p);
2386
+ int64_t value = p->value;
2387
+ return __allocate_Int64(~value);
2388
+ }
2389
+ static VALUE
2390
+ r_Int64_shl(VALUE self, VALUE o)
2391
+ {
2392
+ Int64 *p;
2393
+ Data_Get_Struct(self, Int64, p);
2394
+ int64_t value = p->value;
2395
+ int32_t v = __object_i32(o);
2396
+ return __allocate_Int64(value << v);
2397
+ }
2398
+ static VALUE
2399
+ r_Int64_shr(VALUE self, VALUE o)
2400
+ {
2401
+ Int64 *p;
2402
+ Data_Get_Struct(self, Int64, p);
2403
+ int64_t value = p->value;
2404
+ int32_t v = __object_i32(o);
2405
+ return __allocate_Int64(value >> v);
2406
+ }
2407
+ static VALUE
2408
+ r_Int64_ushr(VALUE self, VALUE o)
2409
+ {
2410
+ Int64 *p;
2411
+ Data_Get_Struct(self, Int64, p);
2412
+ uint64_t uvalue = (uint64_t) p->value;
2413
+ int32_t v = __object_i32(o);
2414
+ return __allocate_Int64((int64_t) (uvalue >> v));
2415
+ }
2416
+ static VALUE
2417
+ r_Int64_and(VALUE self, VALUE o)
2418
+ {
2419
+ Int64 *p;
2420
+ Data_Get_Struct(self, Int64, p);
2421
+ int64_t value = p->value;
2422
+ int64_t v = __object_i64(o);
2423
+ return __allocate_Int64(value & v);
2424
+ }
2425
+ static VALUE
2426
+ r_Int64_xor(VALUE self, VALUE o)
2427
+ {
2428
+ Int64 *p;
2429
+ Data_Get_Struct(self, Int64, p);
2430
+ int64_t value = p->value;
2431
+ int64_t v = __object_i64(o);
2432
+ return __allocate_Int64(value ^ v);
2433
+ }
2434
+ static VALUE
2435
+ r_Int64_or(VALUE self, VALUE o)
2436
+ {
2437
+ Int64 *p;
2438
+ Data_Get_Struct(self, Int64, p);
2439
+ int64_t value = p->value;
2440
+ int64_t v = __object_i64(o);
2441
+ return __allocate_Int64(value | v);
2442
+ }
2443
+ static VALUE
2444
+ r_Int64_is_zero(VALUE self)
2445
+ {
2446
+ Int64 *p;
2447
+ Data_Get_Struct(self, Int64, p);
2448
+ int64_t value = p->value;
2449
+ return value == 0 ? Qtrue : Qfalse;
2450
+ }
2451
+ static VALUE
2452
+ r_Int64_bang_to_int32(VALUE self)
2453
+ {
2454
+ Int64 *p;
2455
+ Data_Get_Struct(self, Int64, p);
2456
+ int64_t value = p->value;
2457
+ if (value < -0x80000000L || value > 0x7FFFFFFFL)
2458
+ rb_raise(rb_eRangeError, "int64 too big to convert to int32");
2459
+ return __allocate_Int32((int32_t) value);
2460
+ }
2461
+ static VALUE
2462
+ r_Int64_bang_to_int64(VALUE self)
2463
+ {
2464
+ return self;
2465
+ }
2466
+ static VALUE
2467
+ r_Int64_to_fixnum(VALUE self)
2468
+ {
2469
+ Int64 *p;
2470
+ Data_Get_Struct(self, Int64, p);
2471
+ int64_t value = p->value;
2472
+ return LONG2NUM((long) value);
2473
+ }
2474
+ static VALUE
2475
+ r_Int64_to_hex(VALUE self)
2476
+ {
2477
+ Int64 *p;
2478
+ Data_Get_Struct(self, Int64, p);
2479
+ int64_t value = p->value;
2480
+ return __int64_to_hex(value);
2481
+ }
2482
+ static VALUE
2483
+ r_Int64_rol(VALUE self, VALUE o)
2484
+ {
2485
+ Int64 *p;
2486
+ Data_Get_Struct(self, Int64, p);
2487
+ uint64_t uvalue = (uint64_t) p->value;
2488
+ int32_t v = __object_i32(o);
2489
+ return __allocate_Int64((int64_t) (uvalue << v | uvalue >> (64 - v)));
2490
+ }
2491
+ static VALUE
2492
+ r_Int64_ror(VALUE self, VALUE o)
2493
+ {
2494
+ Int64 *p;
2495
+ Data_Get_Struct(self, Int64, p);
2496
+ uint64_t uvalue = (uint64_t) p->value;
2497
+ int32_t v = __object_i32(o);
2498
+ return __allocate_Int64((int64_t) (uvalue >> v | uvalue << (64 - v)));
2499
+ }
2500
+ static VALUE
2501
+ r_Int64_count(VALUE self)
2502
+ {
2503
+ Int64 *p;
2504
+ Data_Get_Struct(self, Int64, p);
2505
+ int64_t value = p->value;
2506
+ int32_t c = 0;
2507
+ while (value != 0) {
2508
+ value &= value - 1;
2509
+ c += 1;
2510
+ }
2511
+ return __allocate_Int32(c);
2512
+ }
2513
+ static VALUE
2514
+ r_Int64_signum(VALUE self)
2515
+ {
2516
+ Int64 *p;
2517
+ Data_Get_Struct(self, Int64, p);
2518
+ int64_t value = p->value;
2519
+ if (value < 0)
2520
+ return r_Int32_M1;
2521
+ if (value > 0)
2522
+ return r_Int32_1;
2523
+ return r_Int32_0;
2524
+ }
2525
+ static VALUE
2526
+ r_Int64_times(VALUE self)
2527
+ {
2528
+ Int64 *p;
2529
+ Data_Get_Struct(self, Int64, p);
2530
+ int64_t value = p->value;
2531
+ int64_t i = 0;
2532
+ while (i < value) {
2533
+ rb_yield(__allocate_Int64(i));
2534
+ i += 1;
2535
+ }
2536
+ return Qnil;
2537
+ }
2538
+ static VALUE
2539
+ r_Float32_new(VALUE self, VALUE o)
2540
+ {
2541
+ float v = __object_f32(o);
2542
+ return __allocate_Float32((float) v);
2543
+ }
2544
+ static VALUE
2545
+ r_Float32_is_eql(VALUE self, VALUE o)
2546
+ {
2547
+ Float32 *p;
2548
+ Data_Get_Struct(self, Float32, p);
2549
+ VALUE klass;
2550
+ switch (TYPE(o)) {
2551
+ case T_DATA:
2552
+ klass = RBASIC(o)->klass;
2553
+ if (klass == r_Float32) {
2554
+ Float32 *op;
2555
+ Data_Get_Struct(o, Float32, op);
2556
+ return p->value == op->value ? Qtrue : Qfalse;
2557
+ }
2558
+ }
2559
+ return Qfalse;
2560
+ }
2561
+ static VALUE
2562
+ r_Float32_hash(VALUE self)
2563
+ {
2564
+ Float32 *p;
2565
+ Data_Get_Struct(self, Float32, p);
2566
+ float value = p->value;
2567
+ return LONG2NUM((long) __float32_hash(value));
2568
+ }
2569
+ static VALUE
2570
+ r_Float32_to_byte(VALUE self)
2571
+ {
2572
+ Float32 *p;
2573
+ Data_Get_Struct(self, Float32, p);
2574
+ float value = p->value;
2575
+ return __allocate_Byte((int8_t) value);
2576
+ }
2577
+ static VALUE
2578
+ r_Float32_to_char(VALUE self)
2579
+ {
2580
+ Float32 *p;
2581
+ Data_Get_Struct(self, Float32, p);
2582
+ float value = p->value;
2583
+ return __allocate_Char((uint16_t) value);
2584
+ }
2585
+ static VALUE
2586
+ r_Float32_to_int16(VALUE self)
2587
+ {
2588
+ Float32 *p;
2589
+ Data_Get_Struct(self, Float32, p);
2590
+ float value = p->value;
2591
+ return __allocate_Int16((int16_t) value);
2592
+ }
2593
+ static VALUE
2594
+ r_Float32_to_int32(VALUE self)
2595
+ {
2596
+ Float32 *p;
2597
+ Data_Get_Struct(self, Float32, p);
2598
+ float value = p->value;
2599
+ return __allocate_Int32((int32_t) value);
2600
+ }
2601
+ static VALUE
2602
+ r_Float32_to_int64(VALUE self)
2603
+ {
2604
+ Float32 *p;
2605
+ Data_Get_Struct(self, Float32, p);
2606
+ float value = p->value;
2607
+ return __allocate_Int64((int64_t) value);
2608
+ }
2609
+ static VALUE
2610
+ r_Float32_to_float32(VALUE self)
2611
+ {
2612
+ Float32 *p;
2613
+ Data_Get_Struct(self, Float32, p);
2614
+ float value = p->value;
2615
+ return __allocate_Float32((float) value);
2616
+ }
2617
+ static VALUE
2618
+ r_Float32_to_float64(VALUE self)
2619
+ {
2620
+ Float32 *p;
2621
+ Data_Get_Struct(self, Float32, p);
2622
+ float value = p->value;
2623
+ return __allocate_Float64((double) value);
2624
+ }
2625
+ static VALUE
2626
+ r_Float32_to_i(VALUE self)
2627
+ {
2628
+ Float32 *p;
2629
+ Data_Get_Struct(self, Float32, p);
2630
+ float value = p->value;
2631
+ return __float32_to_i(value);
2632
+ }
2633
+ static VALUE
2634
+ r_Float32_to_f(VALUE self)
2635
+ {
2636
+ Float32 *p;
2637
+ Data_Get_Struct(self, Float32, p);
2638
+ float value = p->value;
2639
+ return __float32_to_f(value);
2640
+ }
2641
+ static VALUE
2642
+ r_Float32_to_s(VALUE self)
2643
+ {
2644
+ Float32 *p;
2645
+ Data_Get_Struct(self, Float32, p);
2646
+ float value = p->value;
2647
+ return __float32_to_s(value);
2648
+ }
2649
+ static VALUE
2650
+ r_Float32_eq(VALUE self, VALUE o)
2651
+ {
2652
+ Float32 *p;
2653
+ Data_Get_Struct(self, Float32, p);
2654
+ float value = p->value;
2655
+ float v = __object_f32(o);
2656
+ return value == v ? Qtrue : Qfalse;
2657
+ }
2658
+ static VALUE
2659
+ r_Float32_ne(VALUE self, VALUE o)
2660
+ {
2661
+ Float32 *p;
2662
+ Data_Get_Struct(self, Float32, p);
2663
+ float value = p->value;
2664
+ float v = __object_f32(o);
2665
+ return value != v ? Qtrue : Qfalse;
2666
+ }
2667
+ static VALUE
2668
+ r_Float32_pos(VALUE self)
2669
+ {
2670
+ Float32 *p;
2671
+ Data_Get_Struct(self, Float32, p);
2672
+ float value = p->value;
2673
+ return __allocate_Float32(+value);
2674
+ }
2675
+ static VALUE
2676
+ r_Float32_neg(VALUE self)
2677
+ {
2678
+ Float32 *p;
2679
+ Data_Get_Struct(self, Float32, p);
2680
+ float value = p->value;
2681
+ return __allocate_Float32(-value);
2682
+ }
2683
+ static VALUE
2684
+ r_Float32_mul(VALUE self, VALUE o)
2685
+ {
2686
+ Float32 *p;
2687
+ Data_Get_Struct(self, Float32, p);
2688
+ float value = p->value;
2689
+ float v = __object_f32(o);
2690
+ return __allocate_Float32(value * v);
2691
+ }
2692
+ static VALUE
2693
+ r_Float32_div(VALUE self, VALUE o)
2694
+ {
2695
+ Float32 *p;
2696
+ Data_Get_Struct(self, Float32, p);
2697
+ float value = p->value;
2698
+ float v = __object_f32(o);
2699
+ return __allocate_Float32(__float32_div(value, v));
2700
+ }
2701
+ static VALUE
2702
+ r_Float32_mod(VALUE self, VALUE o)
2703
+ {
2704
+ Float32 *p;
2705
+ Data_Get_Struct(self, Float32, p);
2706
+ float value = p->value;
2707
+ float v = __object_f32(o);
2708
+ return __allocate_Float32(__float32_mod(value, v));
2709
+ }
2710
+ static VALUE
2711
+ r_Float32_add(VALUE self, VALUE o)
2712
+ {
2713
+ Float32 *p;
2714
+ Data_Get_Struct(self, Float32, p);
2715
+ float value = p->value;
2716
+ float v = __object_f32(o);
2717
+ return __allocate_Float32(value + v);
2718
+ }
2719
+ static VALUE
2720
+ r_Float32_sub(VALUE self, VALUE o)
2721
+ {
2722
+ Float32 *p;
2723
+ Data_Get_Struct(self, Float32, p);
2724
+ float value = p->value;
2725
+ float v = __object_f32(o);
2726
+ return __allocate_Float32(value - v);
2727
+ }
2728
+ static VALUE
2729
+ r_Float32_cmp(VALUE self, VALUE o)
2730
+ {
2731
+ Float32 *p;
2732
+ Data_Get_Struct(self, Float32, p);
2733
+ float value = p->value;
2734
+ float v = __object_f32(o);
2735
+ if (value < v)
2736
+ return r_Int32_M1;
2737
+ if (value > v)
2738
+ return r_Int32_1;
2739
+ return r_Int32_0;
2740
+ }
2741
+ static VALUE
2742
+ r_Float32_lt(VALUE self, VALUE o)
2743
+ {
2744
+ Float32 *p;
2745
+ Data_Get_Struct(self, Float32, p);
2746
+ float value = p->value;
2747
+ float v = __object_f32(o);
2748
+ return value < v ? Qtrue : Qfalse;
2749
+ }
2750
+ static VALUE
2751
+ r_Float32_le(VALUE self, VALUE o)
2752
+ {
2753
+ Float32 *p;
2754
+ Data_Get_Struct(self, Float32, p);
2755
+ float value = p->value;
2756
+ float v = __object_f32(o);
2757
+ return value <= v ? Qtrue : Qfalse;
2758
+ }
2759
+ static VALUE
2760
+ r_Float32_ge(VALUE self, VALUE o)
2761
+ {
2762
+ Float32 *p;
2763
+ Data_Get_Struct(self, Float32, p);
2764
+ float value = p->value;
2765
+ float v = __object_f32(o);
2766
+ return value >= v ? Qtrue : Qfalse;
2767
+ }
2768
+ static VALUE
2769
+ r_Float32_gt(VALUE self, VALUE o)
2770
+ {
2771
+ Float32 *p;
2772
+ Data_Get_Struct(self, Float32, p);
2773
+ float value = p->value;
2774
+ float v = __object_f32(o);
2775
+ return value > v ? Qtrue : Qfalse;
2776
+ }
2777
+ static VALUE
2778
+ r_Float32_is_zero(VALUE self)
2779
+ {
2780
+ Float32 *p;
2781
+ Data_Get_Struct(self, Float32, p);
2782
+ float value = p->value;
2783
+ return value == 0 ? Qtrue : Qfalse;
2784
+ }
2785
+ static VALUE
2786
+ r_Float32_is_nan(VALUE self)
2787
+ {
2788
+ Float32 *p;
2789
+ Data_Get_Struct(self, Float32, p);
2790
+ float value = p->value;
2791
+ return isnan(value) ? Qtrue : Qfalse;
2792
+ }
2793
+ static VALUE
2794
+ r_Float32_is_infinite(VALUE self)
2795
+ {
2796
+ Float32 *p;
2797
+ Data_Get_Struct(self, Float32, p);
2798
+ float value = p->value;
2799
+ return isinf(value) ? Qtrue : Qfalse;
2800
+ }
2801
+ static VALUE
2802
+ r_Float32_is_finite(VALUE self)
2803
+ {
2804
+ Float32 *p;
2805
+ Data_Get_Struct(self, Float32, p);
2806
+ float value = p->value;
2807
+ return !isnan(value) && !isinf(value) ? Qtrue : Qfalse;
2808
+ }
2809
+ static VALUE
2810
+ r_Float64_new(VALUE self, VALUE o)
2811
+ {
2812
+ double v = __object_f64(o);
2813
+ return __allocate_Float64((double) v);
2814
+ }
2815
+ static VALUE
2816
+ r_Float64_is_eql(VALUE self, VALUE o)
2817
+ {
2818
+ Float64 *p;
2819
+ Data_Get_Struct(self, Float64, p);
2820
+ VALUE klass;
2821
+ switch (TYPE(o)) {
2822
+ case T_DATA:
2823
+ klass = RBASIC(o)->klass;
2824
+ if (klass == r_Float64) {
2825
+ Float64 *op;
2826
+ Data_Get_Struct(o, Float64, op);
2827
+ return p->value == op->value ? Qtrue : Qfalse;
2828
+ }
2829
+ }
2830
+ return Qfalse;
2831
+ }
2832
+ static VALUE
2833
+ r_Float64_hash(VALUE self)
2834
+ {
2835
+ Float64 *p;
2836
+ Data_Get_Struct(self, Float64, p);
2837
+ double value = p->value;
2838
+ return LONG2NUM((long) __float64_hash(value));
2839
+ }
2840
+ static VALUE
2841
+ r_Float64_to_byte(VALUE self)
2842
+ {
2843
+ Float64 *p;
2844
+ Data_Get_Struct(self, Float64, p);
2845
+ double value = p->value;
2846
+ return __allocate_Byte((int8_t) value);
2847
+ }
2848
+ static VALUE
2849
+ r_Float64_to_char(VALUE self)
2850
+ {
2851
+ Float64 *p;
2852
+ Data_Get_Struct(self, Float64, p);
2853
+ double value = p->value;
2854
+ return __allocate_Char((uint16_t) value);
2855
+ }
2856
+ static VALUE
2857
+ r_Float64_to_int16(VALUE self)
2858
+ {
2859
+ Float64 *p;
2860
+ Data_Get_Struct(self, Float64, p);
2861
+ double value = p->value;
2862
+ return __allocate_Int16((int16_t) value);
2863
+ }
2864
+ static VALUE
2865
+ r_Float64_to_int32(VALUE self)
2866
+ {
2867
+ Float64 *p;
2868
+ Data_Get_Struct(self, Float64, p);
2869
+ double value = p->value;
2870
+ return __allocate_Int32((int32_t) value);
2871
+ }
2872
+ static VALUE
2873
+ r_Float64_to_int64(VALUE self)
2874
+ {
2875
+ Float64 *p;
2876
+ Data_Get_Struct(self, Float64, p);
2877
+ double value = p->value;
2878
+ return __allocate_Int64((int64_t) value);
2879
+ }
2880
+ static VALUE
2881
+ r_Float64_to_float32(VALUE self)
2882
+ {
2883
+ Float64 *p;
2884
+ Data_Get_Struct(self, Float64, p);
2885
+ double value = p->value;
2886
+ return __allocate_Float32((float) value);
2887
+ }
2888
+ static VALUE
2889
+ r_Float64_to_float64(VALUE self)
2890
+ {
2891
+ Float64 *p;
2892
+ Data_Get_Struct(self, Float64, p);
2893
+ double value = p->value;
2894
+ return __allocate_Float64((double) value);
2895
+ }
2896
+ static VALUE
2897
+ r_Float64_to_i(VALUE self)
2898
+ {
2899
+ Float64 *p;
2900
+ Data_Get_Struct(self, Float64, p);
2901
+ double value = p->value;
2902
+ return __float64_to_i(value);
2903
+ }
2904
+ static VALUE
2905
+ r_Float64_to_f(VALUE self)
2906
+ {
2907
+ Float64 *p;
2908
+ Data_Get_Struct(self, Float64, p);
2909
+ double value = p->value;
2910
+ return __float64_to_f(value);
2911
+ }
2912
+ static VALUE
2913
+ r_Float64_to_s(VALUE self)
2914
+ {
2915
+ Float64 *p;
2916
+ Data_Get_Struct(self, Float64, p);
2917
+ double value = p->value;
2918
+ return __float64_to_s(value);
2919
+ }
2920
+ static VALUE
2921
+ r_Float64_eq(VALUE self, VALUE o)
2922
+ {
2923
+ Float64 *p;
2924
+ Data_Get_Struct(self, Float64, p);
2925
+ double value = p->value;
2926
+ double v = __object_f64(o);
2927
+ return value == v ? Qtrue : Qfalse;
2928
+ }
2929
+ static VALUE
2930
+ r_Float64_ne(VALUE self, VALUE o)
2931
+ {
2932
+ Float64 *p;
2933
+ Data_Get_Struct(self, Float64, p);
2934
+ double value = p->value;
2935
+ double v = __object_f64(o);
2936
+ return value != v ? Qtrue : Qfalse;
2937
+ }
2938
+ static VALUE
2939
+ r_Float64_pos(VALUE self)
2940
+ {
2941
+ Float64 *p;
2942
+ Data_Get_Struct(self, Float64, p);
2943
+ double value = p->value;
2944
+ return __allocate_Float64(+value);
2945
+ }
2946
+ static VALUE
2947
+ r_Float64_neg(VALUE self)
2948
+ {
2949
+ Float64 *p;
2950
+ Data_Get_Struct(self, Float64, p);
2951
+ double value = p->value;
2952
+ return __allocate_Float64(-value);
2953
+ }
2954
+ static VALUE
2955
+ r_Float64_mul(VALUE self, VALUE o)
2956
+ {
2957
+ Float64 *p;
2958
+ Data_Get_Struct(self, Float64, p);
2959
+ double value = p->value;
2960
+ double v = __object_f64(o);
2961
+ return __allocate_Float64(value * v);
2962
+ }
2963
+ static VALUE
2964
+ r_Float64_div(VALUE self, VALUE o)
2965
+ {
2966
+ Float64 *p;
2967
+ Data_Get_Struct(self, Float64, p);
2968
+ double value = p->value;
2969
+ double v = __object_f64(o);
2970
+ return __allocate_Float64(__float64_div(value, v));
2971
+ }
2972
+ static VALUE
2973
+ r_Float64_mod(VALUE self, VALUE o)
2974
+ {
2975
+ Float64 *p;
2976
+ Data_Get_Struct(self, Float64, p);
2977
+ double value = p->value;
2978
+ double v = __object_f64(o);
2979
+ return __allocate_Float64(__float64_mod(value, v));
2980
+ }
2981
+ static VALUE
2982
+ r_Float64_add(VALUE self, VALUE o)
2983
+ {
2984
+ Float64 *p;
2985
+ Data_Get_Struct(self, Float64, p);
2986
+ double value = p->value;
2987
+ double v = __object_f64(o);
2988
+ return __allocate_Float64(value + v);
2989
+ }
2990
+ static VALUE
2991
+ r_Float64_sub(VALUE self, VALUE o)
2992
+ {
2993
+ Float64 *p;
2994
+ Data_Get_Struct(self, Float64, p);
2995
+ double value = p->value;
2996
+ double v = __object_f64(o);
2997
+ return __allocate_Float64(value - v);
2998
+ }
2999
+ static VALUE
3000
+ r_Float64_cmp(VALUE self, VALUE o)
3001
+ {
3002
+ Float64 *p;
3003
+ Data_Get_Struct(self, Float64, p);
3004
+ double value = p->value;
3005
+ double v = __object_f64(o);
3006
+ if (value < v)
3007
+ return r_Int32_M1;
3008
+ if (value > v)
3009
+ return r_Int32_1;
3010
+ return r_Int32_0;
3011
+ }
3012
+ static VALUE
3013
+ r_Float64_lt(VALUE self, VALUE o)
3014
+ {
3015
+ Float64 *p;
3016
+ Data_Get_Struct(self, Float64, p);
3017
+ double value = p->value;
3018
+ double v = __object_f64(o);
3019
+ return value < v ? Qtrue : Qfalse;
3020
+ }
3021
+ static VALUE
3022
+ r_Float64_le(VALUE self, VALUE o)
3023
+ {
3024
+ Float64 *p;
3025
+ Data_Get_Struct(self, Float64, p);
3026
+ double value = p->value;
3027
+ double v = __object_f64(o);
3028
+ return value <= v ? Qtrue : Qfalse;
3029
+ }
3030
+ static VALUE
3031
+ r_Float64_ge(VALUE self, VALUE o)
3032
+ {
3033
+ Float64 *p;
3034
+ Data_Get_Struct(self, Float64, p);
3035
+ double value = p->value;
3036
+ double v = __object_f64(o);
3037
+ return value >= v ? Qtrue : Qfalse;
3038
+ }
3039
+ static VALUE
3040
+ r_Float64_gt(VALUE self, VALUE o)
3041
+ {
3042
+ Float64 *p;
3043
+ Data_Get_Struct(self, Float64, p);
3044
+ double value = p->value;
3045
+ double v = __object_f64(o);
3046
+ return value > v ? Qtrue : Qfalse;
3047
+ }
3048
+ static VALUE
3049
+ r_Float64_is_zero(VALUE self)
3050
+ {
3051
+ Float64 *p;
3052
+ Data_Get_Struct(self, Float64, p);
3053
+ double value = p->value;
3054
+ return value == 0 ? Qtrue : Qfalse;
3055
+ }
3056
+ static VALUE
3057
+ r_Float64_is_nan(VALUE self)
3058
+ {
3059
+ Float64 *p;
3060
+ Data_Get_Struct(self, Float64, p);
3061
+ double value = p->value;
3062
+ return isnan(value) ? Qtrue : Qfalse;
3063
+ }
3064
+ static VALUE
3065
+ r_Float64_is_infinite(VALUE self)
3066
+ {
3067
+ Float64 *p;
3068
+ Data_Get_Struct(self, Float64, p);
3069
+ double value = p->value;
3070
+ return isinf(value) ? Qtrue : Qfalse;
3071
+ }
3072
+ static VALUE
3073
+ r_Float64_is_finite(VALUE self)
3074
+ {
3075
+ Float64 *p;
3076
+ Data_Get_Struct(self, Float64, p);
3077
+ double value = p->value;
3078
+ return !isnan(value) && !isinf(value) ? Qtrue : Qfalse;
3079
+ }
3080
+ static VALUE
3081
+ r_ObjectArray_length(VALUE self)
3082
+ {
3083
+ ObjectArray *p;
3084
+ Data_Get_Struct(self, ObjectArray, p);
3085
+ return LONG2NUM(p->length);
3086
+ }
3087
+ static VALUE
3088
+ r_ObjectArray_get(VALUE self, VALUE i)
3089
+ {
3090
+ ObjectArray *p;
3091
+ Data_Get_Struct(self, ObjectArray, p);
3092
+ int32_t __i = __assert_bounds(i, p->length);
3093
+ return p->data[__i];
3094
+ }
3095
+ static VALUE
3096
+ r_ObjectArray_set(VALUE self, VALUE i, VALUE e)
3097
+ {
3098
+ ObjectArray *p;
3099
+ Data_Get_Struct(self, ObjectArray, p);
3100
+ int32_t __i = __assert_bounds(i, p->length);
3101
+ p->data[__i] = e;
3102
+ return Qnil;
3103
+ }
3104
+ static void
3105
+ __copy_ObjectArray(ObjectArray *p0, int32_t i0, ObjectArray *p1, int32_t i1, int32_t n)
3106
+ {
3107
+ int32_t j0 = i0 + n;
3108
+ int32_t j1 = i1 + n;
3109
+ if (j0 < 0 || j0 > p0->length)
3110
+ rb_raise(rb_eArgError, "index out of bounds");
3111
+ if (j1 < 0 || j1 > p1->length)
3112
+ rb_raise(rb_eArgError, "index out of bounds");
3113
+ while (n-- > 0)
3114
+ p1->data[i1++] = p0->data[i0++];
3115
+ return;
3116
+ }
3117
+ static VALUE
3118
+ r_ObjectArray_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3119
+ {
3120
+ ObjectArray *p0;
3121
+ Data_Get_Struct(self, ObjectArray, p0);
3122
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_ObjectArray)
3123
+ rb_raise(rb_eTypeError, "expected array");
3124
+ ObjectArray *p1;
3125
+ Data_Get_Struct(m1, ObjectArray, p1);
3126
+ __copy_ObjectArray(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3127
+ return Qnil;
3128
+ }
3129
+ static VALUE
3130
+ r_BooleanArray_length(VALUE self)
3131
+ {
3132
+ BooleanArray *p;
3133
+ Data_Get_Struct(self, BooleanArray, p);
3134
+ return LONG2NUM(p->length);
3135
+ }
3136
+ static VALUE
3137
+ r_BooleanArray_get(VALUE self, VALUE i)
3138
+ {
3139
+ BooleanArray *p;
3140
+ Data_Get_Struct(self, BooleanArray, p);
3141
+ int32_t __i = __assert_bounds(i, p->length);
3142
+ return p->data[__i] != 0 ? Qtrue : Qfalse;
3143
+ }
3144
+ static VALUE
3145
+ r_BooleanArray_set(VALUE self, VALUE i, VALUE e)
3146
+ {
3147
+ BooleanArray *p;
3148
+ Data_Get_Struct(self, BooleanArray, p);
3149
+ int32_t __i = __assert_bounds(i, p->length);
3150
+ p->data[__i] = __object_to_boolean(e);
3151
+ return Qnil;
3152
+ }
3153
+ static void
3154
+ __copy_BooleanArray(BooleanArray *p0, int32_t i0, BooleanArray *p1, int32_t i1, int32_t n)
3155
+ {
3156
+ int32_t j0 = i0 + n;
3157
+ int32_t j1 = i1 + n;
3158
+ if (j0 < 0 || j0 > p0->length)
3159
+ rb_raise(rb_eArgError, "index out of bounds");
3160
+ if (j1 < 0 || j1 > p1->length)
3161
+ rb_raise(rb_eArgError, "index out of bounds");
3162
+ while (n-- > 0)
3163
+ p1->data[i1++] = p0->data[i0++];
3164
+ return;
3165
+ }
3166
+ static VALUE
3167
+ r_BooleanArray_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3168
+ {
3169
+ BooleanArray *p0;
3170
+ Data_Get_Struct(self, BooleanArray, p0);
3171
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_BooleanArray)
3172
+ rb_raise(rb_eTypeError, "expected array");
3173
+ BooleanArray *p1;
3174
+ Data_Get_Struct(m1, BooleanArray, p1);
3175
+ __copy_BooleanArray(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3176
+ return Qnil;
3177
+ }
3178
+ static VALUE
3179
+ r_ByteArray_length(VALUE self)
3180
+ {
3181
+ ByteArray *p;
3182
+ Data_Get_Struct(self, ByteArray, p);
3183
+ return LONG2NUM(p->length);
3184
+ }
3185
+ static VALUE
3186
+ r_ByteArray_get(VALUE self, VALUE i)
3187
+ {
3188
+ ByteArray *p;
3189
+ Data_Get_Struct(self, ByteArray, p);
3190
+ int32_t __i = __assert_bounds(i, p->length);
3191
+ return LONG2NUM((long) p->data[__i]);
3192
+ }
3193
+ static VALUE
3194
+ r_ByteArray_set(VALUE self, VALUE i, VALUE e)
3195
+ {
3196
+ ByteArray *p;
3197
+ Data_Get_Struct(self, ByteArray, p);
3198
+ int32_t __i = __assert_bounds(i, p->length);
3199
+ p->data[__i] = (int8_t) __object_i32(e);
3200
+ return Qnil;
3201
+ }
3202
+ static void
3203
+ __copy_ByteArray(ByteArray *p0, int32_t i0, ByteArray *p1, int32_t i1, int32_t n)
3204
+ {
3205
+ int32_t j0 = i0 + n;
3206
+ int32_t j1 = i1 + n;
3207
+ if (j0 < 0 || j0 > p0->length)
3208
+ rb_raise(rb_eArgError, "index out of bounds");
3209
+ if (j1 < 0 || j1 > p1->length)
3210
+ rb_raise(rb_eArgError, "index out of bounds");
3211
+ while (n-- > 0)
3212
+ p1->data[i1++] = p0->data[i0++];
3213
+ return;
3214
+ }
3215
+ static VALUE
3216
+ r_ByteArray_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3217
+ {
3218
+ ByteArray *p0;
3219
+ Data_Get_Struct(self, ByteArray, p0);
3220
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_ByteArray)
3221
+ rb_raise(rb_eTypeError, "expected array");
3222
+ ByteArray *p1;
3223
+ Data_Get_Struct(m1, ByteArray, p1);
3224
+ __copy_ByteArray(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3225
+ return Qnil;
3226
+ }
3227
+ static VALUE
3228
+ r_CharArray_length(VALUE self)
3229
+ {
3230
+ CharArray *p;
3231
+ Data_Get_Struct(self, CharArray, p);
3232
+ return LONG2NUM(p->length);
3233
+ }
3234
+ static VALUE
3235
+ r_CharArray_get(VALUE self, VALUE i)
3236
+ {
3237
+ CharArray *p;
3238
+ Data_Get_Struct(self, CharArray, p);
3239
+ int32_t __i = __assert_bounds(i, p->length);
3240
+ return LONG2NUM((long) p->data[__i]);
3241
+ }
3242
+ static VALUE
3243
+ r_CharArray_set(VALUE self, VALUE i, VALUE e)
3244
+ {
3245
+ CharArray *p;
3246
+ Data_Get_Struct(self, CharArray, p);
3247
+ int32_t __i = __assert_bounds(i, p->length);
3248
+ p->data[__i] = (uint16_t) __object_i32(e);
3249
+ return Qnil;
3250
+ }
3251
+ static void
3252
+ __copy_CharArray(CharArray *p0, int32_t i0, CharArray *p1, int32_t i1, int32_t n)
3253
+ {
3254
+ int32_t j0 = i0 + n;
3255
+ int32_t j1 = i1 + n;
3256
+ if (j0 < 0 || j0 > p0->length)
3257
+ rb_raise(rb_eArgError, "index out of bounds");
3258
+ if (j1 < 0 || j1 > p1->length)
3259
+ rb_raise(rb_eArgError, "index out of bounds");
3260
+ while (n-- > 0)
3261
+ p1->data[i1++] = p0->data[i0++];
3262
+ return;
3263
+ }
3264
+ static VALUE
3265
+ r_CharArray_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3266
+ {
3267
+ CharArray *p0;
3268
+ Data_Get_Struct(self, CharArray, p0);
3269
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_CharArray)
3270
+ rb_raise(rb_eTypeError, "expected array");
3271
+ CharArray *p1;
3272
+ Data_Get_Struct(m1, CharArray, p1);
3273
+ __copy_CharArray(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3274
+ return Qnil;
3275
+ }
3276
+ static VALUE
3277
+ r_Int16Array_length(VALUE self)
3278
+ {
3279
+ Int16Array *p;
3280
+ Data_Get_Struct(self, Int16Array, p);
3281
+ return LONG2NUM(p->length);
3282
+ }
3283
+ static VALUE
3284
+ r_Int16Array_get(VALUE self, VALUE i)
3285
+ {
3286
+ Int16Array *p;
3287
+ Data_Get_Struct(self, Int16Array, p);
3288
+ int32_t __i = __assert_bounds(i, p->length);
3289
+ return LONG2NUM((long) p->data[__i]);
3290
+ }
3291
+ static VALUE
3292
+ r_Int16Array_set(VALUE self, VALUE i, VALUE e)
3293
+ {
3294
+ Int16Array *p;
3295
+ Data_Get_Struct(self, Int16Array, p);
3296
+ int32_t __i = __assert_bounds(i, p->length);
3297
+ p->data[__i] = (int16_t) __object_i32(e);
3298
+ return Qnil;
3299
+ }
3300
+ static void
3301
+ __copy_Int16Array(Int16Array *p0, int32_t i0, Int16Array *p1, int32_t i1, int32_t n)
3302
+ {
3303
+ int32_t j0 = i0 + n;
3304
+ int32_t j1 = i1 + n;
3305
+ if (j0 < 0 || j0 > p0->length)
3306
+ rb_raise(rb_eArgError, "index out of bounds");
3307
+ if (j1 < 0 || j1 > p1->length)
3308
+ rb_raise(rb_eArgError, "index out of bounds");
3309
+ while (n-- > 0)
3310
+ p1->data[i1++] = p0->data[i0++];
3311
+ return;
3312
+ }
3313
+ static VALUE
3314
+ r_Int16Array_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3315
+ {
3316
+ Int16Array *p0;
3317
+ Data_Get_Struct(self, Int16Array, p0);
3318
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_Int16Array)
3319
+ rb_raise(rb_eTypeError, "expected array");
3320
+ Int16Array *p1;
3321
+ Data_Get_Struct(m1, Int16Array, p1);
3322
+ __copy_Int16Array(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3323
+ return Qnil;
3324
+ }
3325
+ static VALUE
3326
+ r_Int32Array_length(VALUE self)
3327
+ {
3328
+ Int32Array *p;
3329
+ Data_Get_Struct(self, Int32Array, p);
3330
+ return LONG2NUM(p->length);
3331
+ }
3332
+ static VALUE
3333
+ r_Int32Array_get(VALUE self, VALUE i)
3334
+ {
3335
+ Int32Array *p;
3336
+ Data_Get_Struct(self, Int32Array, p);
3337
+ int32_t __i = __assert_bounds(i, p->length);
3338
+ return LONG2NUM((long) p->data[__i]);
3339
+ }
3340
+ static VALUE
3341
+ r_Int32Array_set(VALUE self, VALUE i, VALUE e)
3342
+ {
3343
+ Int32Array *p;
3344
+ Data_Get_Struct(self, Int32Array, p);
3345
+ int32_t __i = __assert_bounds(i, p->length);
3346
+ p->data[__i] = (int32_t) __object_i32(e);
3347
+ return Qnil;
3348
+ }
3349
+ static void
3350
+ __copy_Int32Array(Int32Array *p0, int32_t i0, Int32Array *p1, int32_t i1, int32_t n)
3351
+ {
3352
+ int32_t j0 = i0 + n;
3353
+ int32_t j1 = i1 + n;
3354
+ if (j0 < 0 || j0 > p0->length)
3355
+ rb_raise(rb_eArgError, "index out of bounds");
3356
+ if (j1 < 0 || j1 > p1->length)
3357
+ rb_raise(rb_eArgError, "index out of bounds");
3358
+ while (n-- > 0)
3359
+ p1->data[i1++] = p0->data[i0++];
3360
+ return;
3361
+ }
3362
+ static VALUE
3363
+ r_Int32Array_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3364
+ {
3365
+ Int32Array *p0;
3366
+ Data_Get_Struct(self, Int32Array, p0);
3367
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_Int32Array)
3368
+ rb_raise(rb_eTypeError, "expected array");
3369
+ Int32Array *p1;
3370
+ Data_Get_Struct(m1, Int32Array, p1);
3371
+ __copy_Int32Array(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3372
+ return Qnil;
3373
+ }
3374
+ static VALUE
3375
+ r_Int64Array_length(VALUE self)
3376
+ {
3377
+ Int64Array *p;
3378
+ Data_Get_Struct(self, Int64Array, p);
3379
+ return LONG2NUM(p->length);
3380
+ }
3381
+ static VALUE
3382
+ r_Int64Array_get(VALUE self, VALUE i)
3383
+ {
3384
+ Int64Array *p;
3385
+ Data_Get_Struct(self, Int64Array, p);
3386
+ int32_t __i = __assert_bounds(i, p->length);
3387
+ return LONG2NUM((long) p->data[__i]);
3388
+ }
3389
+ static VALUE
3390
+ r_Int64Array_set(VALUE self, VALUE i, VALUE e)
3391
+ {
3392
+ Int64Array *p;
3393
+ Data_Get_Struct(self, Int64Array, p);
3394
+ int32_t __i = __assert_bounds(i, p->length);
3395
+ p->data[__i] = (int64_t) __object_i64(e);
3396
+ return Qnil;
3397
+ }
3398
+ static void
3399
+ __copy_Int64Array(Int64Array *p0, int32_t i0, Int64Array *p1, int32_t i1, int32_t n)
3400
+ {
3401
+ int32_t j0 = i0 + n;
3402
+ int32_t j1 = i1 + n;
3403
+ if (j0 < 0 || j0 > p0->length)
3404
+ rb_raise(rb_eArgError, "index out of bounds");
3405
+ if (j1 < 0 || j1 > p1->length)
3406
+ rb_raise(rb_eArgError, "index out of bounds");
3407
+ while (n-- > 0)
3408
+ p1->data[i1++] = p0->data[i0++];
3409
+ return;
3410
+ }
3411
+ static VALUE
3412
+ r_Int64Array_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3413
+ {
3414
+ Int64Array *p0;
3415
+ Data_Get_Struct(self, Int64Array, p0);
3416
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_Int64Array)
3417
+ rb_raise(rb_eTypeError, "expected array");
3418
+ Int64Array *p1;
3419
+ Data_Get_Struct(m1, Int64Array, p1);
3420
+ __copy_Int64Array(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3421
+ return Qnil;
3422
+ }
3423
+ static VALUE
3424
+ r_Float32Array_length(VALUE self)
3425
+ {
3426
+ Float32Array *p;
3427
+ Data_Get_Struct(self, Float32Array, p);
3428
+ return LONG2NUM(p->length);
3429
+ }
3430
+ static VALUE
3431
+ r_Float32Array_get(VALUE self, VALUE i)
3432
+ {
3433
+ Float32Array *p;
3434
+ Data_Get_Struct(self, Float32Array, p);
3435
+ int32_t __i = __assert_bounds(i, p->length);
3436
+ return DBL2NUM((double) p->data[__i]);
3437
+ }
3438
+ static VALUE
3439
+ r_Float32Array_set(VALUE self, VALUE i, VALUE e)
3440
+ {
3441
+ Float32Array *p;
3442
+ Data_Get_Struct(self, Float32Array, p);
3443
+ int32_t __i = __assert_bounds(i, p->length);
3444
+ p->data[__i] = (float) __object_f32(e);
3445
+ return Qnil;
3446
+ }
3447
+ static void
3448
+ __copy_Float32Array(Float32Array *p0, int32_t i0, Float32Array *p1, int32_t i1, int32_t n)
3449
+ {
3450
+ int32_t j0 = i0 + n;
3451
+ int32_t j1 = i1 + n;
3452
+ if (j0 < 0 || j0 > p0->length)
3453
+ rb_raise(rb_eArgError, "index out of bounds");
3454
+ if (j1 < 0 || j1 > p1->length)
3455
+ rb_raise(rb_eArgError, "index out of bounds");
3456
+ while (n-- > 0)
3457
+ p1->data[i1++] = p0->data[i0++];
3458
+ return;
3459
+ }
3460
+ static VALUE
3461
+ r_Float32Array_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3462
+ {
3463
+ Float32Array *p0;
3464
+ Data_Get_Struct(self, Float32Array, p0);
3465
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_Float32Array)
3466
+ rb_raise(rb_eTypeError, "expected array");
3467
+ Float32Array *p1;
3468
+ Data_Get_Struct(m1, Float32Array, p1);
3469
+ __copy_Float32Array(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3470
+ return Qnil;
3471
+ }
3472
+ static VALUE
3473
+ r_Float64Array_length(VALUE self)
3474
+ {
3475
+ Float64Array *p;
3476
+ Data_Get_Struct(self, Float64Array, p);
3477
+ return LONG2NUM(p->length);
3478
+ }
3479
+ static VALUE
3480
+ r_Float64Array_get(VALUE self, VALUE i)
3481
+ {
3482
+ Float64Array *p;
3483
+ Data_Get_Struct(self, Float64Array, p);
3484
+ int32_t __i = __assert_bounds(i, p->length);
3485
+ return DBL2NUM((double) p->data[__i]);
3486
+ }
3487
+ static VALUE
3488
+ r_Float64Array_set(VALUE self, VALUE i, VALUE e)
3489
+ {
3490
+ Float64Array *p;
3491
+ Data_Get_Struct(self, Float64Array, p);
3492
+ int32_t __i = __assert_bounds(i, p->length);
3493
+ p->data[__i] = (double) __object_f64(e);
3494
+ return Qnil;
3495
+ }
3496
+ static void
3497
+ __copy_Float64Array(Float64Array *p0, int32_t i0, Float64Array *p1, int32_t i1, int32_t n)
3498
+ {
3499
+ int32_t j0 = i0 + n;
3500
+ int32_t j1 = i1 + n;
3501
+ if (j0 < 0 || j0 > p0->length)
3502
+ rb_raise(rb_eArgError, "index out of bounds");
3503
+ if (j1 < 0 || j1 > p1->length)
3504
+ rb_raise(rb_eArgError, "index out of bounds");
3505
+ while (n-- > 0)
3506
+ p1->data[i1++] = p0->data[i0++];
3507
+ return;
3508
+ }
3509
+ static VALUE
3510
+ r_Float64Array_copy(VALUE self, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3511
+ {
3512
+ Float64Array *p0;
3513
+ Data_Get_Struct(self, Float64Array, p0);
3514
+ if (TYPE(m1) != T_DATA || RBASIC(m1)->klass != r_Float64Array)
3515
+ rb_raise(rb_eTypeError, "expected array");
3516
+ Float64Array *p1;
3517
+ Data_Get_Struct(m1, Float64Array, p1);
3518
+ __copy_Float64Array(p0, __assert_nat32(i0), p1, __assert_nat32(i1), __assert_nat32(n));
3519
+ return Qnil;
3520
+ }
3521
+ static VALUE
3522
+ __outer(VALUE self)
3523
+ {
3524
+ VALUE klass;
3525
+ klass = rb_ivar_get(self, OUTER_ID);
3526
+ if (NIL_P(klass)) {
3527
+ klass = rb_class_boot(r_ObjectArray);
3528
+ rb_singleton_class(klass);
3529
+ rb_undef_alloc_func(klass);
3530
+ rb_ivar_set(klass, INNER_ID, self);
3531
+ rb_ivar_set(self, OUTER_ID, klass);
3532
+ }
3533
+ return klass;
3534
+ }
3535
+ static VALUE
3536
+ __allocate_ArrayFactory(VALUE klass, int c)
3537
+ {
3538
+ ArrayFactory *p = xmalloc(sizeof(ArrayFactory) + sizeof(VALUE) * c);
3539
+ if (p == NULL)
3540
+ rb_raise(rb_eNoMemError, "NoMemoryError");
3541
+ int b;
3542
+ for (b = 1; b < c; b += 1)
3543
+ klass = __outer(klass);
3544
+ p->klass = klass;
3545
+ p->length = c;
3546
+ for (b = 0; b < c; b += 1)
3547
+ p->data[b] = Qnil;
3548
+ return Data_Wrap_Struct(r_ArrayFactory, NULL, NULL, p);
3549
+ }
3550
+ static VALUE
3551
+ __allocate_ArrayFactoryFactory(VALUE klass)
3552
+ {
3553
+ ArrayFactoryFactory *p = ALLOC(ArrayFactoryFactory);
3554
+ if (p == NULL)
3555
+ rb_raise(rb_eNoMemError, "NoMemoryError");
3556
+ p->klass = klass;
3557
+ return Data_Wrap_Struct(r_ArrayFactoryFactory, NULL, NULL, p);
3558
+ }
3559
+ static VALUE
3560
+ r_ArrayFactory_new(VALUE self)
3561
+ {
3562
+ ArrayFactory *p;
3563
+ Data_Get_Struct(self, ArrayFactory, p);
3564
+ return __new_Array(p->klass, p->data, 0, p->length);
3565
+ }
3566
+ static VALUE
3567
+ __new_ArrayFactory(VALUE klass, VALUE *data, int c)
3568
+ {
3569
+ VALUE r = __allocate_ArrayFactory(klass, c);
3570
+ ArrayFactory *p;
3571
+ Data_Get_Struct(r, ArrayFactory, p);
3572
+ int b;
3573
+ for (b = 0; b < c; b += 1) {
3574
+ VALUE e = data[b];
3575
+ int32_t n = __assert_nat32(e);
3576
+ p->data[b] = __allocate_Int32(n);
3577
+ }
3578
+ return r;
3579
+ }
3580
+ static VALUE
3581
+ __splat(VALUE self, VALUE args)
3582
+ {
3583
+ int c = RARRAY_LEN(args);
3584
+ if (c == 0)
3585
+ return self;
3586
+ VALUE *data = RARRAY_PTR(args);
3587
+ return __new_ArrayFactory(self, data, c);
3588
+ }
3589
+ static VALUE
3590
+ r_ArrayFactoryFactory_splat(VALUE self, VALUE args)
3591
+ {
3592
+ ArrayFactoryFactory *p;
3593
+ Data_Get_Struct(self, ArrayFactoryFactory, p);
3594
+ VALUE klass = p->klass;
3595
+ return __splat(klass, args);
3596
+ }
3597
+ static VALUE
3598
+ r_Array_splat(VALUE self, VALUE args)
3599
+ {
3600
+ VALUE klass = __outer(self);
3601
+ return __splat(klass, args);
3602
+ }
3603
+ static VALUE
3604
+ r_Java_ARRAYCOPY(VALUE self, VALUE m0, VALUE i0, VALUE m1, VALUE i1, VALUE n)
3605
+ {
3606
+ rb_funcall(m0, COPY_ID, 4, i0, m1, i1, n);
3607
+ return Qnil;
3608
+ }
3609
+ static VALUE
3610
+ r_String_from_java_bytes(VALUE self, VALUE a)
3611
+ {
3612
+ if (TYPE(a) != T_DATA || RBASIC(a)->klass != r_ByteArray)
3613
+ rb_raise(rb_eTypeError, "expected byte[]");
3614
+ ByteArray *p;
3615
+ Data_Get_Struct(a, ByteArray, p);
3616
+ return rb_str_new((char*) p->data, p->length);
3617
+ }
3618
+ static VALUE
3619
+ r_String_to_java_bytes(VALUE self)
3620
+ {
3621
+ int32_t n = RSTRING_LEN(self);
3622
+ char *data = RSTRING_PTR(self);
3623
+ ByteArray *p = xmalloc(sizeof(ByteArray) + sizeof(int8_t) * n);
3624
+ if (p == NULL)
3625
+ rb_raise(rb_eNoMemError, "NoMemoryError");
3626
+ p->length = n;
3627
+ int32_t i;
3628
+ for (i = 0; i < n; i += 1)
3629
+ p->data[i] = data[i];
3630
+ return Data_Wrap_Struct(r_ByteArray, NULL, NULL, p);
3631
+ }
3632
+ void
3633
+ Init_primitive()
3634
+ {
3635
+ r_Integer_x8000000000000000 = ULONG2NUM(0x8000000000000000UL);
3636
+ rb_global_variable(&r_Integer_x8000000000000000);
3637
+ r_Integer_xFFFFFFFFFFFFFFFF = ULONG2NUM(0xFFFFFFFFFFFFFFFFUL);
3638
+ rb_global_variable(&r_Integer_xFFFFFFFFFFFFFFFF);
3639
+ r_Integer_xM8000000000000000 = LONG2NUM(-0x8000000000000000L);
3640
+ rb_global_variable(&r_Integer_xM8000000000000000);
3641
+ r_Byte = rb_define_class("Byte", rb_cObject);
3642
+ rb_undef_alloc_func(r_Byte);
3643
+ rb_define_module_function(r_Byte, "[]", r_Byte_new, 1);
3644
+ rb_define_method(r_Byte, "eql?", r_Byte_is_eql, 1);
3645
+ rb_define_method(r_Byte, "hash", r_Byte_hash, 0);
3646
+ rb_define_method(r_Byte, "as_i", r_Byte_to_i, 0);
3647
+ rb_define_method(r_Byte, "as_f", r_Byte_to_f, 0);
3648
+ rb_define_method(r_Byte, "to_byte", r_Byte_to_byte, 0);
3649
+ rb_define_method(r_Byte, "to_char", r_Byte_to_char, 0);
3650
+ rb_define_method(r_Byte, "to_int16", r_Byte_to_int16, 0);
3651
+ rb_define_method(r_Byte, "to_int32", r_Byte_to_int32, 0);
3652
+ rb_define_method(r_Byte, "to_int64", r_Byte_to_int64, 0);
3653
+ rb_define_method(r_Byte, "to_float32", r_Byte_to_float32, 0);
3654
+ rb_define_method(r_Byte, "to_float64", r_Byte_to_float64, 0);
3655
+ rb_define_method(r_Byte, "to_i", r_Byte_to_i, 0);
3656
+ rb_define_method(r_Byte, "to_int", r_Byte_to_i, 0);
3657
+ rb_define_method(r_Byte, "to_f", r_Byte_to_f, 0);
3658
+ rb_define_method(r_Byte, "to_s", r_Byte_to_s, 0);
3659
+ rb_define_method(r_Byte, "inspect", r_Byte_to_s, 0);
3660
+ rb_define_method(r_Byte, "==", r_Byte_eq, 1);
3661
+ rb_define_method(r_Byte, "!=", r_Byte_ne, 1);
3662
+ rb_define_method(r_Byte, "+@", r_Byte_pos, 0);
3663
+ rb_define_method(r_Byte, "-@", r_Byte_neg, 0);
3664
+ rb_define_method(r_Byte, "*", r_Byte_mul, 1);
3665
+ rb_define_method(r_Byte, "/", r_Byte_div, 1);
3666
+ rb_define_method(r_Byte, "%", r_Byte_mod, 1);
3667
+ rb_define_method(r_Byte, "+", r_Byte_add, 1);
3668
+ rb_define_method(r_Byte, "-", r_Byte_sub, 1);
3669
+ rb_define_method(r_Byte, "<=>", r_Byte_cmp, 1);
3670
+ rb_define_method(r_Byte, "<", r_Byte_lt, 1);
3671
+ rb_define_method(r_Byte, "<=", r_Byte_le, 1);
3672
+ rb_define_method(r_Byte, ">=", r_Byte_ge, 1);
3673
+ rb_define_method(r_Byte, ">", r_Byte_gt, 1);
3674
+ rb_define_method(r_Byte, "~", r_Byte_inv, 0);
3675
+ rb_define_method(r_Byte, "<<", r_Byte_shl, 1);
3676
+ rb_define_method(r_Byte, ">>", r_Byte_shr, 1);
3677
+ rb_define_method(r_Byte, "ushr", r_Byte_ushr, 1);
3678
+ rb_define_method(r_Byte, "&", r_Byte_and, 1);
3679
+ rb_define_method(r_Byte, "^", r_Byte_xor, 1);
3680
+ rb_define_method(r_Byte, "|", r_Byte_or, 1);
3681
+ rb_define_method(r_Byte, "zero?", r_Byte_is_zero, 0);
3682
+ r_Char = rb_define_class("Char", rb_cObject);
3683
+ rb_undef_alloc_func(r_Char);
3684
+ rb_define_module_function(r_Char, "[]", r_Char_new, 1);
3685
+ rb_define_method(r_Char, "eql?", r_Char_is_eql, 1);
3686
+ rb_define_method(r_Char, "hash", r_Char_hash, 0);
3687
+ rb_define_method(r_Char, "as_i", r_Char_to_i, 0);
3688
+ rb_define_method(r_Char, "as_f", r_Char_to_f, 0);
3689
+ rb_define_method(r_Char, "to_byte", r_Char_to_byte, 0);
3690
+ rb_define_method(r_Char, "to_char", r_Char_to_char, 0);
3691
+ rb_define_method(r_Char, "to_int16", r_Char_to_int16, 0);
3692
+ rb_define_method(r_Char, "to_int32", r_Char_to_int32, 0);
3693
+ rb_define_method(r_Char, "to_int64", r_Char_to_int64, 0);
3694
+ rb_define_method(r_Char, "to_float32", r_Char_to_float32, 0);
3695
+ rb_define_method(r_Char, "to_float64", r_Char_to_float64, 0);
3696
+ rb_define_method(r_Char, "to_i", r_Char_to_i, 0);
3697
+ rb_define_method(r_Char, "to_int", r_Char_to_i, 0);
3698
+ rb_define_method(r_Char, "to_f", r_Char_to_f, 0);
3699
+ rb_define_method(r_Char, "to_s", r_Char_to_s, 0);
3700
+ rb_define_method(r_Char, "inspect", r_Char_to_s, 0);
3701
+ rb_define_method(r_Char, "==", r_Char_eq, 1);
3702
+ rb_define_method(r_Char, "!=", r_Char_ne, 1);
3703
+ rb_define_method(r_Char, "+@", r_Char_pos, 0);
3704
+ rb_define_method(r_Char, "-@", r_Char_neg, 0);
3705
+ rb_define_method(r_Char, "*", r_Char_mul, 1);
3706
+ rb_define_method(r_Char, "/", r_Char_div, 1);
3707
+ rb_define_method(r_Char, "%", r_Char_mod, 1);
3708
+ rb_define_method(r_Char, "+", r_Char_add, 1);
3709
+ rb_define_method(r_Char, "-", r_Char_sub, 1);
3710
+ rb_define_method(r_Char, "<=>", r_Char_cmp, 1);
3711
+ rb_define_method(r_Char, "<", r_Char_lt, 1);
3712
+ rb_define_method(r_Char, "<=", r_Char_le, 1);
3713
+ rb_define_method(r_Char, ">=", r_Char_ge, 1);
3714
+ rb_define_method(r_Char, ">", r_Char_gt, 1);
3715
+ rb_define_method(r_Char, "~", r_Char_inv, 0);
3716
+ rb_define_method(r_Char, "<<", r_Char_shl, 1);
3717
+ rb_define_method(r_Char, ">>", r_Char_shr, 1);
3718
+ rb_define_method(r_Char, "ushr", r_Char_ushr, 1);
3719
+ rb_define_method(r_Char, "&", r_Char_and, 1);
3720
+ rb_define_method(r_Char, "^", r_Char_xor, 1);
3721
+ rb_define_method(r_Char, "|", r_Char_or, 1);
3722
+ rb_define_method(r_Char, "zero?", r_Char_is_zero, 0);
3723
+ r_Int16 = rb_define_class("Int16", rb_cObject);
3724
+ rb_undef_alloc_func(r_Int16);
3725
+ rb_define_module_function(r_Int16, "[]", r_Int16_new, 1);
3726
+ rb_define_method(r_Int16, "eql?", r_Int16_is_eql, 1);
3727
+ rb_define_method(r_Int16, "hash", r_Int16_hash, 0);
3728
+ rb_define_method(r_Int16, "as_i", r_Int16_to_i, 0);
3729
+ rb_define_method(r_Int16, "as_f", r_Int16_to_f, 0);
3730
+ rb_define_method(r_Int16, "to_byte", r_Int16_to_byte, 0);
3731
+ rb_define_method(r_Int16, "to_char", r_Int16_to_char, 0);
3732
+ rb_define_method(r_Int16, "to_int16", r_Int16_to_int16, 0);
3733
+ rb_define_method(r_Int16, "to_int32", r_Int16_to_int32, 0);
3734
+ rb_define_method(r_Int16, "to_int64", r_Int16_to_int64, 0);
3735
+ rb_define_method(r_Int16, "to_float32", r_Int16_to_float32, 0);
3736
+ rb_define_method(r_Int16, "to_float64", r_Int16_to_float64, 0);
3737
+ rb_define_method(r_Int16, "to_i", r_Int16_to_i, 0);
3738
+ rb_define_method(r_Int16, "to_int", r_Int16_to_i, 0);
3739
+ rb_define_method(r_Int16, "to_f", r_Int16_to_f, 0);
3740
+ rb_define_method(r_Int16, "to_s", r_Int16_to_s, 0);
3741
+ rb_define_method(r_Int16, "inspect", r_Int16_to_s, 0);
3742
+ rb_define_method(r_Int16, "==", r_Int16_eq, 1);
3743
+ rb_define_method(r_Int16, "!=", r_Int16_ne, 1);
3744
+ rb_define_method(r_Int16, "+@", r_Int16_pos, 0);
3745
+ rb_define_method(r_Int16, "-@", r_Int16_neg, 0);
3746
+ rb_define_method(r_Int16, "*", r_Int16_mul, 1);
3747
+ rb_define_method(r_Int16, "/", r_Int16_div, 1);
3748
+ rb_define_method(r_Int16, "%", r_Int16_mod, 1);
3749
+ rb_define_method(r_Int16, "+", r_Int16_add, 1);
3750
+ rb_define_method(r_Int16, "-", r_Int16_sub, 1);
3751
+ rb_define_method(r_Int16, "<=>", r_Int16_cmp, 1);
3752
+ rb_define_method(r_Int16, "<", r_Int16_lt, 1);
3753
+ rb_define_method(r_Int16, "<=", r_Int16_le, 1);
3754
+ rb_define_method(r_Int16, ">=", r_Int16_ge, 1);
3755
+ rb_define_method(r_Int16, ">", r_Int16_gt, 1);
3756
+ rb_define_method(r_Int16, "~", r_Int16_inv, 0);
3757
+ rb_define_method(r_Int16, "<<", r_Int16_shl, 1);
3758
+ rb_define_method(r_Int16, ">>", r_Int16_shr, 1);
3759
+ rb_define_method(r_Int16, "ushr", r_Int16_ushr, 1);
3760
+ rb_define_method(r_Int16, "&", r_Int16_and, 1);
3761
+ rb_define_method(r_Int16, "^", r_Int16_xor, 1);
3762
+ rb_define_method(r_Int16, "|", r_Int16_or, 1);
3763
+ rb_define_method(r_Int16, "zero?", r_Int16_is_zero, 0);
3764
+ r_Int32 = rb_define_class("Int32", rb_cObject);
3765
+ rb_undef_alloc_func(r_Int32);
3766
+ rb_define_module_function(r_Int32, "[]", r_Int32_new, 1);
3767
+ rb_define_method(r_Int32, "eql?", r_Int32_is_eql, 1);
3768
+ rb_define_method(r_Int32, "hash", r_Int32_hash, 0);
3769
+ rb_define_method(r_Int32, "as_i", r_Int32_to_i, 0);
3770
+ rb_define_method(r_Int32, "as_f", r_Int32_to_f, 0);
3771
+ rb_define_method(r_Int32, "to_byte", r_Int32_to_byte, 0);
3772
+ rb_define_method(r_Int32, "to_char", r_Int32_to_char, 0);
3773
+ rb_define_method(r_Int32, "to_int16", r_Int32_to_int16, 0);
3774
+ rb_define_method(r_Int32, "to_int32", r_Int32_to_int32, 0);
3775
+ rb_define_method(r_Int32, "to_int64", r_Int32_to_int64, 0);
3776
+ rb_define_method(r_Int32, "to_float32", r_Int32_to_float32, 0);
3777
+ rb_define_method(r_Int32, "to_float64", r_Int32_to_float64, 0);
3778
+ rb_define_method(r_Int32, "to_i", r_Int32_to_i, 0);
3779
+ rb_define_method(r_Int32, "to_int", r_Int32_to_i, 0);
3780
+ rb_define_method(r_Int32, "to_f", r_Int32_to_f, 0);
3781
+ rb_define_method(r_Int32, "to_s", r_Int32_to_s, 0);
3782
+ rb_define_method(r_Int32, "inspect", r_Int32_to_s, 0);
3783
+ rb_define_method(r_Int32, "==", r_Int32_eq, 1);
3784
+ rb_define_method(r_Int32, "!=", r_Int32_ne, 1);
3785
+ rb_define_method(r_Int32, "+@", r_Int32_pos, 0);
3786
+ rb_define_method(r_Int32, "-@", r_Int32_neg, 0);
3787
+ rb_define_method(r_Int32, "*", r_Int32_mul, 1);
3788
+ rb_define_method(r_Int32, "/", r_Int32_div, 1);
3789
+ rb_define_method(r_Int32, "%", r_Int32_mod, 1);
3790
+ rb_define_method(r_Int32, "+", r_Int32_add, 1);
3791
+ rb_define_method(r_Int32, "-", r_Int32_sub, 1);
3792
+ rb_define_method(r_Int32, "<=>", r_Int32_cmp, 1);
3793
+ rb_define_method(r_Int32, "<", r_Int32_lt, 1);
3794
+ rb_define_method(r_Int32, "<=", r_Int32_le, 1);
3795
+ rb_define_method(r_Int32, ">=", r_Int32_ge, 1);
3796
+ rb_define_method(r_Int32, ">", r_Int32_gt, 1);
3797
+ rb_define_method(r_Int32, "~", r_Int32_inv, 0);
3798
+ rb_define_method(r_Int32, "<<", r_Int32_shl, 1);
3799
+ rb_define_method(r_Int32, ">>", r_Int32_shr, 1);
3800
+ rb_define_method(r_Int32, "ushr", r_Int32_ushr, 1);
3801
+ rb_define_method(r_Int32, "&", r_Int32_and, 1);
3802
+ rb_define_method(r_Int32, "^", r_Int32_xor, 1);
3803
+ rb_define_method(r_Int32, "|", r_Int32_or, 1);
3804
+ rb_define_method(r_Int32, "zero?", r_Int32_is_zero, 0);
3805
+ rb_define_method(r_Int32, "to_int32!", r_Int32_bang_to_int32, 0);
3806
+ rb_define_method(r_Int32, "to_int64!", r_Int32_bang_to_int64, 0);
3807
+ rb_define_method(r_Int32, "to_fixnum", r_Int32_to_fixnum, 0);
3808
+ rb_define_method(r_Int32, "new_fixnum", r_Int32_to_fixnum, 0);
3809
+ rb_define_method(r_Int32, "to_hex", r_Int32_to_hex, 0);
3810
+ rb_define_method(r_Int32, "chr", r_Int32_chr, 0);
3811
+ rb_define_method(r_Int32, "rol", r_Int32_rol, 1);
3812
+ rb_define_method(r_Int32, "ror", r_Int32_ror, 1);
3813
+ rb_define_method(r_Int32, "count", r_Int32_count, 0);
3814
+ rb_define_method(r_Int32, "signum", r_Int32_signum, 0);
3815
+ rb_define_method(r_Int32, "times", r_Int32_times, 0);
3816
+ rb_define_method(r_Int32, "upto", r_Int32_upto, 1);
3817
+ rb_define_method(r_Int32, "downto", r_Int32_downto, 1);
3818
+ r_Int64 = rb_define_class("Int64", rb_cObject);
3819
+ rb_undef_alloc_func(r_Int64);
3820
+ rb_define_module_function(r_Int64, "[]", r_Int64_new, 1);
3821
+ rb_define_method(r_Int64, "eql?", r_Int64_is_eql, 1);
3822
+ rb_define_method(r_Int64, "hash", r_Int64_hash, 0);
3823
+ rb_define_method(r_Int64, "as_i", r_Int64_to_i, 0);
3824
+ rb_define_method(r_Int64, "as_f", r_Int64_to_f, 0);
3825
+ rb_define_method(r_Int64, "to_byte", r_Int64_to_byte, 0);
3826
+ rb_define_method(r_Int64, "to_char", r_Int64_to_char, 0);
3827
+ rb_define_method(r_Int64, "to_int16", r_Int64_to_int16, 0);
3828
+ rb_define_method(r_Int64, "to_int32", r_Int64_to_int32, 0);
3829
+ rb_define_method(r_Int64, "to_int64", r_Int64_to_int64, 0);
3830
+ rb_define_method(r_Int64, "to_float32", r_Int64_to_float32, 0);
3831
+ rb_define_method(r_Int64, "to_float64", r_Int64_to_float64, 0);
3832
+ rb_define_method(r_Int64, "to_i", r_Int64_to_i, 0);
3833
+ rb_define_method(r_Int64, "to_int", r_Int64_to_i, 0);
3834
+ rb_define_method(r_Int64, "to_f", r_Int64_to_f, 0);
3835
+ rb_define_method(r_Int64, "to_s", r_Int64_to_s, 0);
3836
+ rb_define_method(r_Int64, "inspect", r_Int64_to_s, 0);
3837
+ rb_define_method(r_Int64, "==", r_Int64_eq, 1);
3838
+ rb_define_method(r_Int64, "!=", r_Int64_ne, 1);
3839
+ rb_define_method(r_Int64, "+@", r_Int64_pos, 0);
3840
+ rb_define_method(r_Int64, "-@", r_Int64_neg, 0);
3841
+ rb_define_method(r_Int64, "*", r_Int64_mul, 1);
3842
+ rb_define_method(r_Int64, "/", r_Int64_div, 1);
3843
+ rb_define_method(r_Int64, "%", r_Int64_mod, 1);
3844
+ rb_define_method(r_Int64, "+", r_Int64_add, 1);
3845
+ rb_define_method(r_Int64, "-", r_Int64_sub, 1);
3846
+ rb_define_method(r_Int64, "<=>", r_Int64_cmp, 1);
3847
+ rb_define_method(r_Int64, "<", r_Int64_lt, 1);
3848
+ rb_define_method(r_Int64, "<=", r_Int64_le, 1);
3849
+ rb_define_method(r_Int64, ">=", r_Int64_ge, 1);
3850
+ rb_define_method(r_Int64, ">", r_Int64_gt, 1);
3851
+ rb_define_method(r_Int64, "~", r_Int64_inv, 0);
3852
+ rb_define_method(r_Int64, "<<", r_Int64_shl, 1);
3853
+ rb_define_method(r_Int64, ">>", r_Int64_shr, 1);
3854
+ rb_define_method(r_Int64, "ushr", r_Int64_ushr, 1);
3855
+ rb_define_method(r_Int64, "&", r_Int64_and, 1);
3856
+ rb_define_method(r_Int64, "^", r_Int64_xor, 1);
3857
+ rb_define_method(r_Int64, "|", r_Int64_or, 1);
3858
+ rb_define_method(r_Int64, "zero?", r_Int64_is_zero, 0);
3859
+ rb_define_method(r_Int64, "to_int32!", r_Int64_bang_to_int32, 0);
3860
+ rb_define_method(r_Int64, "to_int64!", r_Int64_bang_to_int64, 0);
3861
+ rb_define_method(r_Int64, "to_fixnum", r_Int64_to_fixnum, 0);
3862
+ rb_define_method(r_Int64, "new_fixnum", r_Int64_to_fixnum, 0);
3863
+ rb_define_method(r_Int64, "to_hex", r_Int64_to_hex, 0);
3864
+ rb_define_method(r_Int64, "rol", r_Int64_rol, 1);
3865
+ rb_define_method(r_Int64, "ror", r_Int64_ror, 1);
3866
+ rb_define_method(r_Int64, "count", r_Int64_count, 0);
3867
+ rb_define_method(r_Int64, "signum", r_Int64_signum, 0);
3868
+ rb_define_method(r_Int64, "times", r_Int64_times, 0);
3869
+ r_Float32 = rb_define_class("Float32", rb_cObject);
3870
+ rb_undef_alloc_func(r_Float32);
3871
+ rb_define_module_function(r_Float32, "[]", r_Float32_new, 1);
3872
+ rb_define_method(r_Float32, "eql?", r_Float32_is_eql, 1);
3873
+ rb_define_method(r_Float32, "hash", r_Float32_hash, 0);
3874
+ rb_define_method(r_Float32, "as_i", r_Float32_to_i, 0);
3875
+ rb_define_method(r_Float32, "as_f", r_Float32_to_f, 0);
3876
+ rb_define_method(r_Float32, "to_byte", r_Float32_to_byte, 0);
3877
+ rb_define_method(r_Float32, "to_char", r_Float32_to_char, 0);
3878
+ rb_define_method(r_Float32, "to_int16", r_Float32_to_int16, 0);
3879
+ rb_define_method(r_Float32, "to_int32", r_Float32_to_int32, 0);
3880
+ rb_define_method(r_Float32, "to_int64", r_Float32_to_int64, 0);
3881
+ rb_define_method(r_Float32, "to_float32", r_Float32_to_float32, 0);
3882
+ rb_define_method(r_Float32, "to_float64", r_Float32_to_float64, 0);
3883
+ rb_define_method(r_Float32, "to_i", r_Float32_to_i, 0);
3884
+ rb_define_method(r_Float32, "to_int", r_Float32_to_i, 0);
3885
+ rb_define_method(r_Float32, "to_f", r_Float32_to_f, 0);
3886
+ rb_define_method(r_Float32, "to_s", r_Float32_to_s, 0);
3887
+ rb_define_method(r_Float32, "inspect", r_Float32_to_s, 0);
3888
+ rb_define_method(r_Float32, "==", r_Float32_eq, 1);
3889
+ rb_define_method(r_Float32, "!=", r_Float32_ne, 1);
3890
+ rb_define_method(r_Float32, "+@", r_Float32_pos, 0);
3891
+ rb_define_method(r_Float32, "-@", r_Float32_neg, 0);
3892
+ rb_define_method(r_Float32, "*", r_Float32_mul, 1);
3893
+ rb_define_method(r_Float32, "/", r_Float32_div, 1);
3894
+ rb_define_method(r_Float32, "%", r_Float32_mod, 1);
3895
+ rb_define_method(r_Float32, "+", r_Float32_add, 1);
3896
+ rb_define_method(r_Float32, "-", r_Float32_sub, 1);
3897
+ rb_define_method(r_Float32, "<=>", r_Float32_cmp, 1);
3898
+ rb_define_method(r_Float32, "<", r_Float32_lt, 1);
3899
+ rb_define_method(r_Float32, "<=", r_Float32_le, 1);
3900
+ rb_define_method(r_Float32, ">=", r_Float32_ge, 1);
3901
+ rb_define_method(r_Float32, ">", r_Float32_gt, 1);
3902
+ rb_define_method(r_Float32, "zero?", r_Float32_is_zero, 0);
3903
+ rb_define_method(r_Float32, "nan?", r_Float32_is_nan, 0);
3904
+ rb_define_method(r_Float32, "infinite?", r_Float32_is_infinite, 0);
3905
+ rb_define_method(r_Float32, "finite?", r_Float32_is_finite, 0);
3906
+ rb_define_const(r_Float32, "NEGATIVE_INFINITY", __allocate_Float32(-INFINITY));
3907
+ rb_define_const(r_Float32, "POSITIVE_INFINITY", __allocate_Float32(INFINITY));
3908
+ r_Float64 = rb_define_class("Float64", rb_cObject);
3909
+ rb_undef_alloc_func(r_Float64);
3910
+ rb_define_module_function(r_Float64, "[]", r_Float64_new, 1);
3911
+ rb_define_method(r_Float64, "eql?", r_Float64_is_eql, 1);
3912
+ rb_define_method(r_Float64, "hash", r_Float64_hash, 0);
3913
+ rb_define_method(r_Float64, "as_i", r_Float64_to_i, 0);
3914
+ rb_define_method(r_Float64, "as_f", r_Float64_to_f, 0);
3915
+ rb_define_method(r_Float64, "to_byte", r_Float64_to_byte, 0);
3916
+ rb_define_method(r_Float64, "to_char", r_Float64_to_char, 0);
3917
+ rb_define_method(r_Float64, "to_int16", r_Float64_to_int16, 0);
3918
+ rb_define_method(r_Float64, "to_int32", r_Float64_to_int32, 0);
3919
+ rb_define_method(r_Float64, "to_int64", r_Float64_to_int64, 0);
3920
+ rb_define_method(r_Float64, "to_float32", r_Float64_to_float32, 0);
3921
+ rb_define_method(r_Float64, "to_float64", r_Float64_to_float64, 0);
3922
+ rb_define_method(r_Float64, "to_i", r_Float64_to_i, 0);
3923
+ rb_define_method(r_Float64, "to_int", r_Float64_to_i, 0);
3924
+ rb_define_method(r_Float64, "to_f", r_Float64_to_f, 0);
3925
+ rb_define_method(r_Float64, "to_s", r_Float64_to_s, 0);
3926
+ rb_define_method(r_Float64, "inspect", r_Float64_to_s, 0);
3927
+ rb_define_method(r_Float64, "==", r_Float64_eq, 1);
3928
+ rb_define_method(r_Float64, "!=", r_Float64_ne, 1);
3929
+ rb_define_method(r_Float64, "+@", r_Float64_pos, 0);
3930
+ rb_define_method(r_Float64, "-@", r_Float64_neg, 0);
3931
+ rb_define_method(r_Float64, "*", r_Float64_mul, 1);
3932
+ rb_define_method(r_Float64, "/", r_Float64_div, 1);
3933
+ rb_define_method(r_Float64, "%", r_Float64_mod, 1);
3934
+ rb_define_method(r_Float64, "+", r_Float64_add, 1);
3935
+ rb_define_method(r_Float64, "-", r_Float64_sub, 1);
3936
+ rb_define_method(r_Float64, "<=>", r_Float64_cmp, 1);
3937
+ rb_define_method(r_Float64, "<", r_Float64_lt, 1);
3938
+ rb_define_method(r_Float64, "<=", r_Float64_le, 1);
3939
+ rb_define_method(r_Float64, ">=", r_Float64_ge, 1);
3940
+ rb_define_method(r_Float64, ">", r_Float64_gt, 1);
3941
+ rb_define_method(r_Float64, "zero?", r_Float64_is_zero, 0);
3942
+ rb_define_method(r_Float64, "nan?", r_Float64_is_nan, 0);
3943
+ rb_define_method(r_Float64, "infinite?", r_Float64_is_infinite, 0);
3944
+ rb_define_method(r_Float64, "finite?", r_Float64_is_finite, 0);
3945
+ rb_define_const(r_Float64, "NEGATIVE_INFINITY", __allocate_Float64(-INFINITY));
3946
+ rb_define_const(r_Float64, "POSITIVE_INFINITY", __allocate_Float64(INFINITY));
3947
+ r_Int32_0 = __allocate_Int32(0);
3948
+ rb_global_variable(&r_Int32_0);
3949
+ r_Int32_1 = __allocate_Int32(1);
3950
+ rb_global_variable(&r_Int32_1);
3951
+ r_Int32_M1 = __allocate_Int32(-1);
3952
+ rb_global_variable(&r_Int32_M1);
3953
+ NEW_ID = rb_intern("new");
3954
+ INNER_ID = rb_intern("inner");
3955
+ OUTER_ID = rb_intern("outer");
3956
+ COPY_ID = rb_intern("copy");
3957
+ r_ObjectArray = rb_class_boot(rb_cObject);
3958
+ rb_undef_alloc_func(r_ObjectArray);
3959
+ rb_global_variable(&r_ObjectArray);
3960
+ rb_define_module_function(r_ObjectArray, "new", r_ObjectArray_new, 1);
3961
+ rb_define_module_function(r_ObjectArray, "[]", r_Array_splat, -2);
3962
+ rb_define_method(r_ObjectArray, "length", r_ObjectArray_length, 0);
3963
+ rb_define_method(r_ObjectArray, "[]", r_ObjectArray_get, 1);
3964
+ rb_define_method(r_ObjectArray, "[]=", r_ObjectArray_set, 2);
3965
+ rb_define_method(r_ObjectArray, "copy", r_ObjectArray_copy, 4);
3966
+ r_BooleanArray = rb_class_boot(rb_cObject);
3967
+ rb_undef_alloc_func(r_BooleanArray);
3968
+ rb_global_variable(&r_BooleanArray);
3969
+ rb_define_module_function(r_BooleanArray, "new", r_BooleanArray_new, 1);
3970
+ rb_define_module_function(r_BooleanArray, "[]", r_Array_splat, -2);
3971
+ rb_define_method(r_BooleanArray, "length", r_BooleanArray_length, 0);
3972
+ rb_define_method(r_BooleanArray, "[]", r_BooleanArray_get, 1);
3973
+ rb_define_method(r_BooleanArray, "[]=", r_BooleanArray_set, 2);
3974
+ rb_define_method(r_BooleanArray, "copy", r_BooleanArray_copy, 4);
3975
+ r_ByteArray = rb_class_boot(rb_cObject);
3976
+ rb_undef_alloc_func(r_ByteArray);
3977
+ rb_global_variable(&r_ByteArray);
3978
+ rb_define_module_function(r_ByteArray, "new", r_ByteArray_new, 1);
3979
+ rb_define_module_function(r_ByteArray, "[]", r_Array_splat, -2);
3980
+ rb_define_method(r_ByteArray, "length", r_ByteArray_length, 0);
3981
+ rb_define_method(r_ByteArray, "[]", r_ByteArray_get, 1);
3982
+ rb_define_method(r_ByteArray, "[]=", r_ByteArray_set, 2);
3983
+ rb_define_method(r_ByteArray, "copy", r_ByteArray_copy, 4);
3984
+ r_CharArray = rb_class_boot(rb_cObject);
3985
+ rb_undef_alloc_func(r_CharArray);
3986
+ rb_global_variable(&r_CharArray);
3987
+ rb_define_module_function(r_CharArray, "new", r_CharArray_new, 1);
3988
+ rb_define_module_function(r_CharArray, "[]", r_Array_splat, -2);
3989
+ rb_define_method(r_CharArray, "length", r_CharArray_length, 0);
3990
+ rb_define_method(r_CharArray, "[]", r_CharArray_get, 1);
3991
+ rb_define_method(r_CharArray, "[]=", r_CharArray_set, 2);
3992
+ rb_define_method(r_CharArray, "copy", r_CharArray_copy, 4);
3993
+ r_Int16Array = rb_class_boot(rb_cObject);
3994
+ rb_undef_alloc_func(r_Int16Array);
3995
+ rb_global_variable(&r_Int16Array);
3996
+ rb_define_module_function(r_Int16Array, "new", r_Int16Array_new, 1);
3997
+ rb_define_module_function(r_Int16Array, "[]", r_Array_splat, -2);
3998
+ rb_define_method(r_Int16Array, "length", r_Int16Array_length, 0);
3999
+ rb_define_method(r_Int16Array, "[]", r_Int16Array_get, 1);
4000
+ rb_define_method(r_Int16Array, "[]=", r_Int16Array_set, 2);
4001
+ rb_define_method(r_Int16Array, "copy", r_Int16Array_copy, 4);
4002
+ r_Int32Array = rb_class_boot(rb_cObject);
4003
+ rb_undef_alloc_func(r_Int32Array);
4004
+ rb_global_variable(&r_Int32Array);
4005
+ rb_define_module_function(r_Int32Array, "new", r_Int32Array_new, 1);
4006
+ rb_define_module_function(r_Int32Array, "[]", r_Array_splat, -2);
4007
+ rb_define_method(r_Int32Array, "length", r_Int32Array_length, 0);
4008
+ rb_define_method(r_Int32Array, "[]", r_Int32Array_get, 1);
4009
+ rb_define_method(r_Int32Array, "[]=", r_Int32Array_set, 2);
4010
+ rb_define_method(r_Int32Array, "copy", r_Int32Array_copy, 4);
4011
+ r_Int64Array = rb_class_boot(rb_cObject);
4012
+ rb_undef_alloc_func(r_Int64Array);
4013
+ rb_global_variable(&r_Int64Array);
4014
+ rb_define_module_function(r_Int64Array, "new", r_Int64Array_new, 1);
4015
+ rb_define_module_function(r_Int64Array, "[]", r_Array_splat, -2);
4016
+ rb_define_method(r_Int64Array, "length", r_Int64Array_length, 0);
4017
+ rb_define_method(r_Int64Array, "[]", r_Int64Array_get, 1);
4018
+ rb_define_method(r_Int64Array, "[]=", r_Int64Array_set, 2);
4019
+ rb_define_method(r_Int64Array, "copy", r_Int64Array_copy, 4);
4020
+ r_Float32Array = rb_class_boot(rb_cObject);
4021
+ rb_undef_alloc_func(r_Float32Array);
4022
+ rb_global_variable(&r_Float32Array);
4023
+ rb_define_module_function(r_Float32Array, "new", r_Float32Array_new, 1);
4024
+ rb_define_module_function(r_Float32Array, "[]", r_Array_splat, -2);
4025
+ rb_define_method(r_Float32Array, "length", r_Float32Array_length, 0);
4026
+ rb_define_method(r_Float32Array, "[]", r_Float32Array_get, 1);
4027
+ rb_define_method(r_Float32Array, "[]=", r_Float32Array_set, 2);
4028
+ rb_define_method(r_Float32Array, "copy", r_Float32Array_copy, 4);
4029
+ r_Float64Array = rb_class_boot(rb_cObject);
4030
+ rb_undef_alloc_func(r_Float64Array);
4031
+ rb_global_variable(&r_Float64Array);
4032
+ rb_define_module_function(r_Float64Array, "new", r_Float64Array_new, 1);
4033
+ rb_define_module_function(r_Float64Array, "[]", r_Array_splat, -2);
4034
+ rb_define_method(r_Float64Array, "length", r_Float64Array_length, 0);
4035
+ rb_define_method(r_Float64Array, "[]", r_Float64Array_get, 1);
4036
+ rb_define_method(r_Float64Array, "[]=", r_Float64Array_set, 2);
4037
+ rb_define_method(r_Float64Array, "copy", r_Float64Array_copy, 4);
4038
+ r_ArrayFactory = rb_class_boot(rb_cObject);
4039
+ rb_undef_alloc_func(r_ArrayFactory);
4040
+ rb_global_variable(&r_ArrayFactory);
4041
+ rb_define_method(r_ArrayFactory, "new", r_ArrayFactory_new, 0);
4042
+ r_ArrayFactoryFactory = rb_class_boot(rb_cObject);
4043
+ rb_undef_alloc_func(r_ArrayFactoryFactory);
4044
+ rb_global_variable(&r_ArrayFactoryFactory);
4045
+ rb_define_method(r_ArrayFactoryFactory, "[]", r_ArrayFactoryFactory_splat, -2);
4046
+ r_BOOLEAN_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_BooleanArray);
4047
+ rb_global_variable(&r_BOOLEAN_ARRAY_FACTORY_FACTORY);
4048
+ r_BYTE_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_ByteArray);
4049
+ rb_global_variable(&r_BYTE_ARRAY_FACTORY_FACTORY);
4050
+ r_CHAR_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_CharArray);
4051
+ rb_global_variable(&r_CHAR_ARRAY_FACTORY_FACTORY);
4052
+ r_INT16_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_Int16Array);
4053
+ rb_global_variable(&r_INT16_ARRAY_FACTORY_FACTORY);
4054
+ r_INT32_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_Int32Array);
4055
+ rb_global_variable(&r_INT32_ARRAY_FACTORY_FACTORY);
4056
+ r_INT64_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_Int64Array);
4057
+ rb_global_variable(&r_INT64_ARRAY_FACTORY_FACTORY);
4058
+ r_FLOAT32_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_Float32Array);
4059
+ rb_global_variable(&r_FLOAT32_ARRAY_FACTORY_FACTORY);
4060
+ r_FLOAT64_ARRAY_FACTORY_FACTORY = __allocate_ArrayFactoryFactory(r_Float64Array);
4061
+ rb_global_variable(&r_FLOAT64_ARRAY_FACTORY_FACTORY);
4062
+ r_Java = rb_define_module("Java");
4063
+ rb_define_module_function(r_Java, "ARRAYCOPY", r_Java_ARRAYCOPY, 5);
4064
+ rb_define_module_function(r_Java, "boolean", r_Java_boolean, 0);
4065
+ rb_define_module_function(r_Java, "byte", r_Java_byte, 0);
4066
+ rb_define_module_function(r_Java, "char", r_Java_char, 0);
4067
+ rb_define_module_function(r_Java, "int16", r_Java_int16, 0);
4068
+ rb_define_module_function(r_Java, "int32", r_Java_int32, 0);
4069
+ rb_define_module_function(r_Java, "int64", r_Java_int64, 0);
4070
+ rb_define_module_function(r_Java, "float32", r_Java_float32, 0);
4071
+ rb_define_module_function(r_Java, "float64", r_Java_float64, 0);
4072
+ rb_define_module_function(rb_cString, "from_java_bytes", r_String_from_java_bytes, 1);
4073
+ rb_define_method(rb_cString, "to_java_bytes", r_String_to_java_bytes, 0);
4074
+ return;
4075
+ }