tests: adds native interface tests
[nit.git] / tests / test_ni_operators.nit.c
1 /* This file is part of NIT ( http://www.nitlanguage.org ).
2 *
3 * Copyright 2011 Alexis Laferrière <alexis.laf@xymus.net>
4 *
5 * This file is free software, which comes along with NIT. This software is
6 * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8 * PARTICULAR PURPOSE. You can modify it is you want, provided this header
9 * is kept unaltered, and a notification of the changes is added.
10 * You are allowed to redistribute it and sell it, alone or is a part of
11 * another product.
12 */
13
14 #include "test_ni_operators.nit.h"
15
16 /*
17 C implementation of test_ni_operators::A::+
18
19 Imported methods signatures:
20 bigint A_value( A recv ) for test_ni_operators::A::value
21 A new_A( bigint value ) for test_ni_operators::A::init
22 */
23 A A__plus___impl( A recv, A other )
24 {
25
26 int s = A_value( recv );
27 int o = A_value( other );
28
29 return new_A( s + o );
30
31 }
32
33 /*
34 C implementation of test_ni_operators::A::-
35
36 Imported methods signatures:
37 bigint A_value( A recv ) for test_ni_operators::A::value
38 A new_A( bigint value ) for test_ni_operators::A::init
39 */
40 A A__minus___impl( A recv, A other )
41 {
42
43 int s = A_value( recv );
44 int o = A_value( other );
45
46 return new_A( s - o );
47
48 }
49
50 /*
51 C implementation of test_ni_operators::A::*
52
53 Imported methods signatures:
54 bigint A_value( A recv ) for test_ni_operators::A::value
55 A new_A( bigint value ) for test_ni_operators::A::init
56 */
57 A A__star___impl( A recv, bigint by )
58 {
59
60 int s = A_value( recv );
61
62 return new_A( s * by );
63
64 }
65
66 /*
67 C implementation of test_ni_operators::A::/
68
69 Imported methods signatures:
70 bigint A_value( A recv ) for test_ni_operators::A::value
71 A new_A( bigint value ) for test_ni_operators::A::init
72 */
73 A A__slash___impl( A recv, bigint by )
74 {
75
76 int s = A_value( recv );
77
78 return new_A( s / by );
79
80 }
81
82 /*
83 C implementation of test_ni_operators::A::(kernel::Object::==)
84
85 Imported methods signatures:
86 bigint A_value( A recv ) for test_ni_operators::A::value
87 int nullable_Object_is_a_A( nullable_Object value ) to check if a nullable Object is a A
88 A nullable_Object_as_A( nullable_Object value ) to cast from nullable Object to A
89 */
90 int A__equal___impl( A recv, nullable_Object other )
91 {
92
93 if ( nullable_Object_is_a_A( other ) &&
94 A_value( nullable_Object_as_A(other) ) == A_value( recv ) )
95 return 1;
96 else
97 return 0;
98
99 }
100
101 /*
102 C implementation of test_ni_operators::A::%
103
104 Imported methods signatures:
105 bigint A_value( A recv ) for test_ni_operators::A::value
106 A new_A( bigint value ) for test_ni_operators::A::init
107 */
108 A A__percent___impl( A recv, A other )
109 {
110
111 return new_A( A_value( recv ) % A_value( other ) );
112
113 }
114
115 /*
116 C implementation of test_ni_operators::A::<=>
117
118 Imported methods signatures:
119 bigint A_value( A recv ) for test_ni_operators::A::value
120 A new_A( bigint value ) for test_ni_operators::A::init
121 */
122 A A__starship___impl( A recv, A other )
123 {
124
125 return new_A( A_value( recv )* 1024 );
126
127 }
128
129 /*
130 C implementation of test_ni_operators::A::>
131
132 Imported methods signatures:
133 bigint A_value( A recv ) for test_ni_operators::A::value
134 */
135 int A__greater___impl( A recv, A other )
136 {
137
138 return A_value( recv ) > A_value( other );
139
140 }
141
142 /*
143 C implementation of test_ni_operators::A::<
144
145 Imported methods signatures:
146 bigint A_value( A recv ) for test_ni_operators::A::value
147 */
148 int A__less___impl( A recv, A other )
149 {
150
151 return A_value( recv ) < A_value( other );
152
153 }
154
155 /*
156 C implementation of test_ni_operators::A::>=
157
158 Imported methods signatures:
159 bigint A_value( A recv ) for test_ni_operators::A::value
160 */
161 int A__ge___impl( A recv, A other )
162 {
163
164 return A_value( recv ) >= A_value( other );
165
166 }
167
168 /*
169 C implementation of test_ni_operators::A::<=
170
171 Imported methods signatures:
172 bigint A_value( A recv ) for test_ni_operators::A::value
173 */
174 int A__less_or_equal___impl( A recv, A other )
175 {
176
177 return A_value( recv ) <= A_value( other );
178
179 }
180
181 /*
182 C implementation of test_ni_operators::A::>>
183
184 Imported methods signatures:
185 bigint A_value( A recv ) for test_ni_operators::A::value
186 void A_value__assign( A recv, bigint value ) for test_ni_operators::A::value=
187 A new_A( bigint value ) for test_ni_operators::A::init
188 */
189 void A__right___impl( A recv, A other )
190 {
191
192 int new_val = A_value( recv ) >> A_value( other );
193 A_value__assign( recv, new_val );
194
195 }
196
197 /*
198 C implementation of test_ni_operators::A::<<
199
200 Imported methods signatures:
201 bigint A_value( A recv ) for test_ni_operators::A::value
202 A new_A( bigint value ) for test_ni_operators::A::init
203 */
204 void A__left___impl( A recv, A other )
205 {
206
207 int new_val = A_value( recv ) << A_value( other );
208 A_value__assign( recv, new_val );
209
210 }
211
212 /*
213 C implementation of test_ni_operators::A::[]
214
215 Imported methods signatures:
216 A new_A( bigint value ) for test_ni_operators::A::init
217 */
218 A A__index___impl( A recv, bigint index )
219 {
220
221 return new_A( index );
222
223 }
224
225 /*
226 C implementation of test_ni_operators::A::[]=
227
228 Imported methods signatures:
229 A new_A( bigint value ) for test_ni_operators::A::init
230 */
231 A A__index_assign___impl( A recv, bigint index, A value )
232 {
233
234 return new_A( index + A_value( value ) );
235
236 }