1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#[macro_export]
macro_rules! number_def {
($name:ident, $def:ty) => {
pub struct $name {
value: $def,
}
castable_to!($name => [sync] IObject, Number);
impl $name {
pub fn new(value: $def) -> Object {
Object::new(Some(Arc::new($name {value})))
}
}
impl IObject for $name {
fn getClass<'a>(&self) -> &'a SClass {
todo!()
}
fn hashCode(&self) -> usize {
todo!()
}
fn equals(&self, other: &Object) -> bool {
todo!()
}
fn toString(&self) -> String {
todo!()
}
}
impl Number for $name {
fn big_integer_value_o(&self) -> Object {
BigInteger::new(self.big_integer_value())
}
fn long_value_o(&self) -> Object {
Long::new(self.long_value())
}
fn int_value_o(&self) -> Object {
Integer::new(self.int_value())
}
fn short_value_o(&self) -> Object {
Short::new(self.short_value())
}
fn byte_value_o(&self) -> Object {
Byte::new(self.byte_value())
}
fn double_value_o(&self) -> Object {
Double::new(self.double_value())
}
fn float_value_o(&self) -> Object {
Float::new(self.float_value())
}
fn usize_value_o(&self) -> Object {
Usize::new(self.usize_value())
}
fn big_integer_value(&self) -> i128 {
self.value as i128
}
fn long_value(&self) -> i64 {
self.value as i64
}
fn int_value(&self) -> i32 {
self.value as i32
}
fn short_value(&self) -> i16 {
self.value as i16
}
fn byte_value(&self) -> i8 {
self.value as i8
}
fn double_value(&self) -> f64 {
self.value as f64
}
fn float_value(&self) -> f32 {
self.value as f32
}
fn usize_value(&self) -> usize {
self.value as usize
}
}
impl Default for $name {
fn default() -> Self {
$name {
value: <$def>::default(),
}
}
}
};
}