| 1 | package SPVM::Long; | ||
| 2 | |||
| 3 | 1; | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | SPVM::Long - A long value as An Object | ||
| 8 | |||
| 9 | =head1 Description | ||
| 10 | |||
| 11 | Long class in L<SPVM> represents a long value as an object. | ||
| 12 | |||
| 13 | =head1 Usage | ||
| 14 | |||
| 15 | my $long_object = Long->new(5L); | ||
| 16 | my $long_value = $long_object->value; | ||
| 17 | $long_object->set_value(10L); | ||
| 18 | |||
| 19 | # New unsigned object | ||
| 20 | my $unsigned_long = Long->new_unsigned(0xFFFFFFFFFFFFFFFFL); # 18446744073709551615 | ||
| 21 | |||
| 22 | =head1 Details | ||
| 23 | |||
| 24 | This class is automatically loaded. | ||
| 25 | |||
| 26 | =head1 Interfaces | ||
| 27 | |||
| 28 | =over 2 | ||
| 29 | |||
| 30 | =item * L<Stringable|SPVM::Stringable> | ||
| 31 | =item * L<Cloneable|SPVM::Cloneable> | ||
| 32 | |||
| 33 | =back | ||
| 34 | |||
| 35 | =head1 Fields | ||
| 36 | |||
| 37 | =head2 value | ||
| 38 | |||
| 39 | C<has value : rw long;> | ||
| 40 | |||
| 41 | The value. | ||
| 42 | |||
| 43 | If the L</"unsigned"> field is 1, the value is treated as an unsigned 64-bit integer (0 to 18446744073709551615). | ||
| 44 | |||
| 45 | If the L</"is_read_only"> field is 1, a compilation error or a runtime error occurs when setting the value. | ||
| 46 | |||
| 47 | =head2 is_read_only | ||
| 48 | |||
| 49 | C<has is_read_only : ro byte;> | ||
| 50 | |||
| 51 | If this value is 1, the L</"value"> field is read-only. | ||
| 52 | |||
| 53 | =head2 unsigned | ||
| 54 | |||
| 55 | C<has unsigned : rw byte;> | ||
| 56 | |||
| 57 | If this value is 1, the value is treated as an unsigned 64-bit integer. | ||
| 58 | |||
| 59 | =head1 Class Methods | ||
| 60 | |||
| 61 | =head2 new | ||
| 62 | |||
| 63 | C<static method new : L<Long|SPVM::Long> ($value : long);> | ||
| 64 | |||
| 65 | Creates a new L<Long|SPVM::Long> object with a C<long> $value. The L</"unsigned"> field is initialized to 0. | ||
| 66 | |||
| 67 | =head2 new_unsigned | ||
| 68 | |||
| 69 | C<static method new_unsigned : L<Long|SPVM::Long> ($value : long);> | ||
| 70 | |||
| 71 | Creates a new L<Long|SPVM::Long> object with a C<long> $value. The L</"unsigned"> field is initialized to 1. | ||
| 72 | |||
| 73 | =head1 Instance Methods | ||
| 74 | |||
| 75 | =head2 make_read_only | ||
| 76 | |||
| 77 | C<method make_read_only : void ();> | ||
| 78 | |||
| 79 | Sets L</"is_read_only"> field to 1. | ||
| 80 | |||
| 81 | =head2 clone | ||
| 82 | |||
| 83 | C<method clone : L<Long|SPVM::Long> ();> | ||
| 84 | |||
| 85 | Creates a new L<Long|SPVM::Long> object that clones this object. | ||
| 86 | |||
| 87 | The L</"unsigned"> field is copied to the new object. | ||
| 88 | |||
| 89 | The value of L</"is_read_only"> field in the new object is 0. | ||
| 90 | |||
| 91 | =head2 to_string | ||
| 92 | |||
| 93 | C<method to_string : string ();> | ||
| 94 | |||
| 95 | Casts the value to string type and returns it. | ||
| 96 | |||
| 97 | If L</"unsigned"> field is 1, the value is converted to a string as an unsigned 64-bit integer. | ||
| 98 | |||
| 99 | =head1 Copyright & License | ||
| 100 | |||
| 101 | Copyright (c) 2023 Yuki Kimoto | ||
| 102 | |||
| 103 | MIT License |