Class: Byte

Inherits:
JAVA::Value show all
Defined in:
ext/primitive/primitive.c

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from JAVA::Value

const_missing

Class Method Details

.[](o) ⇒ Object



518
519
520
521
522
523
# File 'ext/primitive/primitive.c', line 518

static VALUE
r_Byte_new(VALUE self, VALUE o)
{
	int8_t value = __accept_byte(o);
	return __allocate_Byte(value);
}

Instance Method Details

#!=(o) ⇒ Object



636
637
638
639
640
641
642
643
# File 'ext/primitive/primitive.c', line 636

static VALUE
r_Byte_ne(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return p->value != v ? Qtrue : Qfalse;
}

#%(o) ⇒ Object



674
675
676
677
678
679
680
681
# File 'ext/primitive/primitive.c', line 674

static VALUE
r_Byte_mod(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(__mod_int32(p->value, v));
}

#&(o) ⇒ Object



774
775
776
777
778
779
780
781
# File 'ext/primitive/primitive.c', line 774

static VALUE
r_Byte_and(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(p->value & v);
}

#*(o) ⇒ Object



658
659
660
661
662
663
664
665
# File 'ext/primitive/primitive.c', line 658

static VALUE
r_Byte_mul(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(p->value * v);
}

#+(o) ⇒ Object



682
683
684
685
686
687
688
689
# File 'ext/primitive/primitive.c', line 682

static VALUE
r_Byte_add(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(p->value + v);
}

#+@Object



644
645
646
647
648
649
650
# File 'ext/primitive/primitive.c', line 644

static VALUE
r_Byte_pos(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int32(+p->value);
}

#-(o) ⇒ Object



690
691
692
693
694
695
696
697
# File 'ext/primitive/primitive.c', line 690

static VALUE
r_Byte_sub(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(p->value - v);
}

#-@Object



651
652
653
654
655
656
657
# File 'ext/primitive/primitive.c', line 651

static VALUE
r_Byte_neg(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int32(-p->value);
}

#/(o) ⇒ Object



666
667
668
669
670
671
672
673
# File 'ext/primitive/primitive.c', line 666

static VALUE
r_Byte_div(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(__div_int32(p->value, v));
}

#<(o) ⇒ Object



710
711
712
713
714
715
716
717
# File 'ext/primitive/primitive.c', line 710

static VALUE
r_Byte_lt(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return p->value < v ? Qtrue : Qfalse;
}

#<<(o) ⇒ Object



749
750
751
752
753
754
755
756
# File 'ext/primitive/primitive.c', line 749

static VALUE
r_Byte_shl(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t d = __accept_int32(o);
	return __allocate_Int32(p->value << d);
}

#<=(o) ⇒ Object



718
719
720
721
722
723
724
725
# File 'ext/primitive/primitive.c', line 718

static VALUE
r_Byte_le(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return p->value <= v ? Qtrue : Qfalse;
}

#<=>(o) ⇒ Object



698
699
700
701
702
703
704
705
706
707
708
709
# File 'ext/primitive/primitive.c', line 698

static VALUE
r_Byte_cmp(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	if (p->value < v)
		return r_INT32_M1;
	if (p->value > v)
		return r_INT32_1;
	return r_INT32_0;
}

#==(o) ⇒ Object



628
629
630
631
632
633
634
635
# File 'ext/primitive/primitive.c', line 628

static VALUE
r_Byte_eq(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return p->value == v ? Qtrue : Qfalse;
}

#===(o) ⇒ Object



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'ext/primitive/primitive.c', line 524

static VALUE
r_Byte_equals(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	if (TYPE(o) == T_DATA) {
		if (RBASIC(o)->klass == r_Byte) {
			Byte *op;
			Data_Get_Struct(o, Byte, op);
			if (p->value == op->value)
				return Qtrue;
		}
	}
	return Qfalse;
}

#>(o) ⇒ Object



734
735
736
737
738
739
740
741
# File 'ext/primitive/primitive.c', line 734

static VALUE
r_Byte_gt(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return p->value > v ? Qtrue : Qfalse;
}

#>=(o) ⇒ Object



726
727
728
729
730
731
732
733
# File 'ext/primitive/primitive.c', line 726

static VALUE
r_Byte_ge(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return p->value >= v ? Qtrue : Qfalse;
}

#>>(o) ⇒ Object



757
758
759
760
761
762
763
764
# File 'ext/primitive/primitive.c', line 757

static VALUE
r_Byte_shr(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t d = __accept_int32(o);
	return __allocate_Int32(p->value >> d);
}

#^(o) ⇒ Object



782
783
784
785
786
787
788
789
# File 'ext/primitive/primitive.c', line 782

static VALUE
r_Byte_xor(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(p->value ^ v);
}

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'ext/primitive/primitive.c', line 524

static VALUE
r_Byte_equals(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	if (TYPE(o) == T_DATA) {
		if (RBASIC(o)->klass == r_Byte) {
			Byte *op;
			Data_Get_Struct(o, Byte, op);
			if (p->value == op->value)
				return Qtrue;
		}
	}
	return Qfalse;
}

#equals(o) ⇒ Object



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'ext/primitive/primitive.c', line 524

static VALUE
r_Byte_equals(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	if (TYPE(o) == T_DATA) {
		if (RBASIC(o)->klass == r_Byte) {
			Byte *op;
			Data_Get_Struct(o, Byte, op);
			if (p->value == op->value)
				return Qtrue;
		}
	}
	return Qfalse;
}

#hashObject



553
554
555
556
557
558
559
# File 'ext/primitive/primitive.c', line 553

static VALUE
r_Byte_hash(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return LONG2NUM((long) __hash_int32(p->value));
}

#hashCodeObject



539
540
541
542
543
544
545
# File 'ext/primitive/primitive.c', line 539

static VALUE
r_Byte_hashCode(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int32(__hash_int32(p->value));
}

#inspectObject



560
561
562
563
564
565
566
# File 'ext/primitive/primitive.c', line 560

static VALUE
r_Byte_to_s(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __int32_to_s(p->value);
}

#to_byteObject



567
568
569
570
571
# File 'ext/primitive/primitive.c', line 567

static VALUE
r_Byte_to_byte(VALUE self)
{
	return self;
}

#to_charObject



572
573
574
575
576
577
578
# File 'ext/primitive/primitive.c', line 572

static VALUE
r_Byte_to_char(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Char((uint16_t) p->value);
}

#to_fObject



621
622
623
624
625
626
627
# File 'ext/primitive/primitive.c', line 621

static VALUE
r_Byte_to_f(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __int32_to_f(p->value);
}

#to_float32Object



600
601
602
603
604
605
606
# File 'ext/primitive/primitive.c', line 600

static VALUE
r_Byte_to_float32(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Float32((float) p->value);
}

#to_float64Object



607
608
609
610
611
612
613
# File 'ext/primitive/primitive.c', line 607

static VALUE
r_Byte_to_float64(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Float64((double) p->value);
}

#to_iObject



614
615
616
617
618
619
620
# File 'ext/primitive/primitive.c', line 614

static VALUE
r_Byte_to_i(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __int32_to_i(p->value);
}

#to_intObject



614
615
616
617
618
619
620
# File 'ext/primitive/primitive.c', line 614

static VALUE
r_Byte_to_i(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __int32_to_i(p->value);
}

#to_int16Object



579
580
581
582
583
584
585
# File 'ext/primitive/primitive.c', line 579

static VALUE
r_Byte_to_int16(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int16((int16_t) p->value);
}

#to_int32Object



586
587
588
589
590
591
592
# File 'ext/primitive/primitive.c', line 586

static VALUE
r_Byte_to_int32(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int32((int32_t) p->value);
}

#to_int64Object



593
594
595
596
597
598
599
# File 'ext/primitive/primitive.c', line 593

static VALUE
r_Byte_to_int64(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int64((int64_t) p->value);
}

#to_sObject



560
561
562
563
564
565
566
# File 'ext/primitive/primitive.c', line 560

static VALUE
r_Byte_to_s(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __int32_to_s(p->value);
}

#toStringObject



546
547
548
549
550
551
552
# File 'ext/primitive/primitive.c', line 546

static VALUE
r_Byte_toString(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return rb_funcall(__int32_to_s(p->value), TO_J_ID, 0);
}

#ushr(o) ⇒ Object



765
766
767
768
769
770
771
772
773
# File 'ext/primitive/primitive.c', line 765

static VALUE
r_Byte_ushr(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	uint32_t u = (uint32_t) p->value;
	int32_t d = __accept_int32(o);
	return __allocate_Int32((int32_t) (u >> d));
}

#|(o) ⇒ Object



790
791
792
793
794
795
796
797
# File 'ext/primitive/primitive.c', line 790

static VALUE
r_Byte_or(VALUE self, VALUE o)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	int32_t v = __accept_int32(o);
	return __allocate_Int32(p->value | v);
}

#~Object



742
743
744
745
746
747
748
# File 'ext/primitive/primitive.c', line 742

static VALUE
r_Byte_inv(VALUE self)
{
	Byte *p;
	Data_Get_Struct(self, Byte, p);
	return __allocate_Int32(~p->value);
}