tests: fix test errors for engine nitc
[nit.git] / c_src / file._nitni.c
1 #include "file._nitni.h"
2 #include "file_nit.h"
3 /* out/indirect function for file::Stdin::poll_in */
4 val_t Stdin_poll_in___out( val_t recv )
5 {
6 int orig_return;
7 val_t trans_return;
8 orig_return = file_stdin_poll_in( NULL );
9 trans_return = TAG_Bool(orig_return);
10 nitni_local_ref_clean( );
11 return trans_return;
12 }
13 /* out/indirect function for file::String::files */
14 val_t String_files___out( val_t recv )
15 {
16 String trans_recv;
17 Set orig_return;
18 val_t trans_return;
19 trans_recv = malloc( sizeof( struct s_String ) );
20 trans_recv->ref.val = NIT_NULL;
21 trans_recv->ref.count = 0;
22 nitni_local_ref_add( (struct nitni_ref *)trans_recv );
23 trans_recv->ref.val = recv;
24 orig_return = malloc( sizeof( struct s_Set ) );
25 orig_return->ref.val = NIT_NULL;
26 orig_return->ref.count = 0;
27 orig_return = String_files___impl( trans_recv );
28 trans_return = orig_return->ref.val;
29 nitni_local_ref_clean( );
30 return trans_return;
31 }
32 /* out/indirect function for file::NativeString::file_exists */
33 val_t NativeString_file_exists___out( val_t recv )
34 {
35 char * trans_recv;
36 int orig_return;
37 val_t trans_return;
38 trans_recv = UNBOX_NativeString(recv);
39 orig_return = string_NativeString_NativeString_file_exists_0( trans_recv );
40 trans_return = TAG_Bool(orig_return);
41 nitni_local_ref_clean( );
42 return trans_return;
43 }
44 /* out/indirect function for file::NativeString::file_stat */
45 val_t NativeString_file_stat___out( val_t recv )
46 {
47 char * trans_recv;
48 struct stat * orig_return;
49 val_t trans_return;
50 trans_recv = UNBOX_NativeString(recv);
51 orig_return = string_NativeString_NativeString_file_stat_0( trans_recv );
52 trans_return = BOX_FileStat(orig_return);
53 nitni_local_ref_clean( );
54 return trans_return;
55 }
56 /* out/indirect function for file::NativeString::file_lstat */
57 val_t NativeString_file_lstat___out( val_t recv )
58 {
59 char * trans_recv;
60 struct stat * orig_return;
61 val_t trans_return;
62 trans_recv = UNBOX_NativeString(recv);
63 orig_return = NativeString_file_lstat___impl( trans_recv );
64 trans_return = BOX_FileStat(orig_return);
65 nitni_local_ref_clean( );
66 return trans_return;
67 }
68 /* out/indirect function for file::NativeString::file_mkdir */
69 val_t NativeString_file_mkdir___out( val_t recv )
70 {
71 char * trans_recv;
72 int orig_return;
73 val_t trans_return;
74 trans_recv = UNBOX_NativeString(recv);
75 orig_return = string_NativeString_NativeString_file_mkdir_0( trans_recv );
76 trans_return = TAG_Bool(orig_return);
77 nitni_local_ref_clean( );
78 return trans_return;
79 }
80 /* out/indirect function for file::NativeString::file_delete */
81 val_t NativeString_file_delete___out( val_t recv )
82 {
83 char * trans_recv;
84 int orig_return;
85 val_t trans_return;
86 trans_recv = UNBOX_NativeString(recv);
87 orig_return = string_NativeString_NativeString_file_delete_0( trans_recv );
88 trans_return = TAG_Bool(orig_return);
89 nitni_local_ref_clean( );
90 return trans_return;
91 }
92 /* out/indirect function for file::FileStat::mode */
93 val_t FileStat_mode___out( val_t recv )
94 {
95 struct stat * trans_recv;
96 bigint orig_return;
97 val_t trans_return;
98 trans_recv = UNBOX_FileStat(recv);
99 orig_return = file_FileStat_FileStat_mode_0( trans_recv );
100 trans_return = TAG_Int(orig_return);
101 nitni_local_ref_clean( );
102 return trans_return;
103 }
104 /* out/indirect function for file::FileStat::atime */
105 val_t FileStat_atime___out( val_t recv )
106 {
107 struct stat * trans_recv;
108 bigint orig_return;
109 val_t trans_return;
110 trans_recv = UNBOX_FileStat(recv);
111 orig_return = file_FileStat_FileStat_atime_0( trans_recv );
112 trans_return = TAG_Int(orig_return);
113 nitni_local_ref_clean( );
114 return trans_return;
115 }
116 /* out/indirect function for file::FileStat::ctime */
117 val_t FileStat_ctime___out( val_t recv )
118 {
119 struct stat * trans_recv;
120 bigint orig_return;
121 val_t trans_return;
122 trans_recv = UNBOX_FileStat(recv);
123 orig_return = file_FileStat_FileStat_ctime_0( trans_recv );
124 trans_return = TAG_Int(orig_return);
125 nitni_local_ref_clean( );
126 return trans_return;
127 }
128 /* out/indirect function for file::FileStat::mtime */
129 val_t FileStat_mtime___out( val_t recv )
130 {
131 struct stat * trans_recv;
132 bigint orig_return;
133 val_t trans_return;
134 trans_recv = UNBOX_FileStat(recv);
135 orig_return = file_FileStat_FileStat_mtime_0( trans_recv );
136 trans_return = TAG_Int(orig_return);
137 nitni_local_ref_clean( );
138 return trans_return;
139 }
140 /* out/indirect function for file::FileStat::size */
141 val_t FileStat_size___out( val_t recv )
142 {
143 struct stat * trans_recv;
144 bigint orig_return;
145 val_t trans_return;
146 trans_recv = UNBOX_FileStat(recv);
147 orig_return = file_FileStat_FileStat_size_0( trans_recv );
148 trans_return = TAG_Int(orig_return);
149 nitni_local_ref_clean( );
150 return trans_return;
151 }
152 /* out/indirect function for file::FileStat::is_reg */
153 val_t FileStat_is_reg___out( val_t recv )
154 {
155 struct stat * trans_recv;
156 int orig_return;
157 val_t trans_return;
158 trans_recv = UNBOX_FileStat(recv);
159 orig_return = FileStat_is_reg___impl( trans_recv );
160 trans_return = TAG_Bool(orig_return);
161 nitni_local_ref_clean( );
162 return trans_return;
163 }
164 /* out/indirect function for file::FileStat::is_dir */
165 val_t FileStat_is_dir___out( val_t recv )
166 {
167 struct stat * trans_recv;
168 int orig_return;
169 val_t trans_return;
170 trans_recv = UNBOX_FileStat(recv);
171 orig_return = FileStat_is_dir___impl( trans_recv );
172 trans_return = TAG_Bool(orig_return);
173 nitni_local_ref_clean( );
174 return trans_return;
175 }
176 /* out/indirect function for file::FileStat::is_chr */
177 val_t FileStat_is_chr___out( val_t recv )
178 {
179 struct stat * trans_recv;
180 int orig_return;
181 val_t trans_return;
182 trans_recv = UNBOX_FileStat(recv);
183 orig_return = FileStat_is_chr___impl( trans_recv );
184 trans_return = TAG_Bool(orig_return);
185 nitni_local_ref_clean( );
186 return trans_return;
187 }
188 /* out/indirect function for file::FileStat::is_blk */
189 val_t FileStat_is_blk___out( val_t recv )
190 {
191 struct stat * trans_recv;
192 int orig_return;
193 val_t trans_return;
194 trans_recv = UNBOX_FileStat(recv);
195 orig_return = FileStat_is_blk___impl( trans_recv );
196 trans_return = TAG_Bool(orig_return);
197 nitni_local_ref_clean( );
198 return trans_return;
199 }
200 /* out/indirect function for file::FileStat::is_fifo */
201 val_t FileStat_is_fifo___out( val_t recv )
202 {
203 struct stat * trans_recv;
204 int orig_return;
205 val_t trans_return;
206 trans_recv = UNBOX_FileStat(recv);
207 orig_return = FileStat_is_fifo___impl( trans_recv );
208 trans_return = TAG_Bool(orig_return);
209 nitni_local_ref_clean( );
210 return trans_return;
211 }
212 /* out/indirect function for file::FileStat::is_lnk */
213 val_t FileStat_is_lnk___out( val_t recv )
214 {
215 struct stat * trans_recv;
216 int orig_return;
217 val_t trans_return;
218 trans_recv = UNBOX_FileStat(recv);
219 orig_return = FileStat_is_lnk___impl( trans_recv );
220 trans_return = TAG_Bool(orig_return);
221 nitni_local_ref_clean( );
222 return trans_return;
223 }
224 /* out/indirect function for file::FileStat::is_sock */
225 val_t FileStat_is_sock___out( val_t recv )
226 {
227 struct stat * trans_recv;
228 int orig_return;
229 val_t trans_return;
230 trans_recv = UNBOX_FileStat(recv);
231 orig_return = FileStat_is_sock___impl( trans_recv );
232 trans_return = TAG_Bool(orig_return);
233 nitni_local_ref_clean( );
234 return trans_return;
235 }
236 /* out/indirect function for file::NativeFile::io_read */
237 val_t NativeFile_io_read___out( val_t recv, val_t buf, val_t len )
238 {
239 void* trans_recv;
240 char * trans___buf;
241 bigint orig_return;
242 val_t trans_return;
243 trans_recv = UNBOX_NativeFile(recv);
244 trans___buf = UNBOX_NativeString(buf);
245 orig_return = file_NativeFile_NativeFile_io_read_2( trans_recv, trans___buf, UNTAG_Int(len) );
246 trans_return = TAG_Int(orig_return);
247 nitni_local_ref_clean( );
248 return trans_return;
249 }
250 /* out/indirect function for file::NativeFile::io_write */
251 val_t NativeFile_io_write___out( val_t recv, val_t buf, val_t len )
252 {
253 void* trans_recv;
254 char * trans___buf;
255 bigint orig_return;
256 val_t trans_return;
257 trans_recv = UNBOX_NativeFile(recv);
258 trans___buf = UNBOX_NativeString(buf);
259 orig_return = file_NativeFile_NativeFile_io_write_2( trans_recv, trans___buf, UNTAG_Int(len) );
260 trans_return = TAG_Int(orig_return);
261 nitni_local_ref_clean( );
262 return trans_return;
263 }
264 /* out/indirect function for file::NativeFile::io_close */
265 val_t NativeFile_io_close___out( val_t recv )
266 {
267 void* trans_recv;
268 bigint orig_return;
269 val_t trans_return;
270 trans_recv = UNBOX_NativeFile(recv);
271 orig_return = file_NativeFile_NativeFile_io_close_0( trans_recv );
272 trans_return = TAG_Int(orig_return);
273 nitni_local_ref_clean( );
274 return trans_return;
275 }
276 /* out/indirect function for file::NativeFile::file_stat */
277 val_t NativeFile_file_stat___out( val_t recv )
278 {
279 void* trans_recv;
280 struct stat * orig_return;
281 val_t trans_return;
282 trans_recv = UNBOX_NativeFile(recv);
283 orig_return = file_NativeFile_NativeFile_file_stat_0( trans_recv );
284 trans_return = BOX_FileStat(orig_return);
285 nitni_local_ref_clean( );
286 return trans_return;
287 }
288 /* out/indirect function for file::NativeFile::io_open_read */
289 val_t NEW_NativeFile_standard___file___NativeFile___io_open_read( val_t path )
290 {
291 char * trans___path;
292 void* orig_return;
293 val_t trans_return;
294 trans___path = UNBOX_NativeString(path);
295 orig_return = file_NativeFileCapable_NativeFileCapable_io_open_read_1( trans___path );
296 trans_return = BOX_NativeFile(orig_return);
297 nitni_local_ref_clean( );
298 return trans_return;
299 }
300 /* out/indirect function for file::NativeFile::io_open_write */
301 val_t NEW_NativeFile_standard___file___NativeFile___io_open_write( val_t path )
302 {
303 char * trans___path;
304 void* orig_return;
305 val_t trans_return;
306 trans___path = UNBOX_NativeString(path);
307 orig_return = file_NativeFileCapable_NativeFileCapable_io_open_write_1( trans___path );
308 trans_return = BOX_NativeFile(orig_return);
309 nitni_local_ref_clean( );
310 return trans_return;
311 }
312 /* out/indirect function for file::NativeFile::native_stdin */
313 val_t NEW_NativeFile_standard___file___NativeFile___native_stdin( )
314 {
315 void* orig_return;
316 val_t trans_return;
317 orig_return = file_NativeFileCapable_NativeFileCapable_native_stdin_0( );
318 trans_return = BOX_NativeFile(orig_return);
319 nitni_local_ref_clean( );
320 return trans_return;
321 }
322 /* out/indirect function for file::NativeFile::native_stdout */
323 val_t NEW_NativeFile_standard___file___NativeFile___native_stdout( )
324 {
325 void* orig_return;
326 val_t trans_return;
327 orig_return = file_NativeFileCapable_NativeFileCapable_native_stdout_0( );
328 trans_return = BOX_NativeFile(orig_return);
329 nitni_local_ref_clean( );
330 return trans_return;
331 }
332 /* out/indirect function for file::NativeFile::native_stderr */
333 val_t NEW_NativeFile_standard___file___NativeFile___native_stderr( )
334 {
335 void* orig_return;
336 val_t trans_return;
337 orig_return = file_NativeFileCapable_NativeFileCapable_native_stderr_0( );
338 trans_return = BOX_NativeFile(orig_return);
339 nitni_local_ref_clean( );
340 return trans_return;
341 }
342 /* friendly for hash_collection::HashSet::init */
343 HashSet file_new_HashSet( )
344 {
345 val_t orig_return;
346 HashSet trans_return;
347 trans_return = malloc( sizeof( struct s_HashSet ) );
348 trans_return->ref.val = NIT_NULL;
349 trans_return->ref.count = 0;
350 nitni_local_ref_add( (struct nitni_ref *)trans_return );
351 orig_return = NEW_HashSet_standard___collection___hash_collection___HashSet___init( );
352 trans_return->ref.val = orig_return;
353 return trans_return;
354 }
355 /* friendly for hash_collection::HashSet::(abstract_collection::SimpleCollection::add) */
356 void file_HashSet_add( HashSet recv, Object item )
357 {
358 val_t trans_recv;
359 val_t trans___item;
360 trans_recv = recv->ref.val;
361 trans___item = item->ref.val;
362 CALL_standard___collection___abstract_collection___SimpleCollection___add( trans_recv )( trans_recv, trans___item );
363 }
364 /* friendly for string::NativeString::(string::Object::to_s) */
365 String file_NativeString_to_s( char * recv )
366 {
367 val_t trans_recv;
368 val_t orig_return;
369 String trans_return;
370 trans_recv = BOX_NativeString(recv);
371 trans_return = malloc( sizeof( struct s_String ) );
372 trans_return->ref.val = NIT_NULL;
373 trans_return->ref.count = 0;
374 nitni_local_ref_add( (struct nitni_ref *)trans_return );
375 orig_return = CALL_standard___string___Object___to_s( trans_recv )( trans_recv );
376 trans_return->ref.val = orig_return;
377 return trans_return;
378 }
379 /* friendly for string::String::to_cstring */
380 char * file_String_to_cstring( String recv )
381 {
382 val_t trans_recv;
383 val_t orig_return;
384 char * trans_return;
385 trans_recv = recv->ref.val;
386 orig_return = CALL_standard___string___String___to_cstring( trans_recv )( trans_recv );
387 trans_return = UNBOX_NativeString(orig_return);
388 return trans_return;
389 }
390 int file_HashSet_is_a_Set( HashSet value )
391 {
392 val_t temp;
393 temp = value->ref.val;
394 if ( ! ( ISOBJ( temp ) ? ISNULL( temp ) || OBJISA( temp, standard___collection___abstract_collection___Set ): VALISA( temp, standard___collection___abstract_collection___Set ) ) ) return 0;
395 return 1;
396 }
397 Set file_HashSet_as_Set( HashSet value )
398 {
399 val_t temp;
400 Set out;
401 out = malloc( sizeof( struct s_Set ) );
402 out->ref.val = NIT_NULL;
403 out->ref.count = 0;
404 nitni_local_ref_add( (struct nitni_ref *)out );
405 temp = value->ref.val;
406 if ( ISNULL(temp) ){ fprintf( stderr, "Casting from HashSet[String] to Set[String] failed because value is null." );
407 abort();
408 }if ( ! ( ISOBJ( temp ) ? ISNULL( temp ) || OBJISA( temp, standard___collection___abstract_collection___Set ): VALISA( temp, standard___collection___abstract_collection___Set ) ) ){
409 fprintf( stderr, "Casting to Set[String] failed because value is not a Set[String]." );
410 abort();
411 }
412 out->ref.val = temp;
413 return out;
414 }
415 int file_String_is_a_Object( String value )
416 {
417 val_t temp;
418 temp = value->ref.val;
419 if ( ! ( ISOBJ( temp ) ? ISNULL( temp ) || OBJISA( temp, standard___kernel___Object ): VALISA( temp, standard___kernel___Object ) ) ) return 0;
420 return 1;
421 }
422 Object file_String_as_Object( String value )
423 {
424 val_t temp;
425 Object out;
426 out = malloc( sizeof( struct s_Object ) );
427 out->ref.val = NIT_NULL;
428 out->ref.count = 0;
429 nitni_local_ref_add( (struct nitni_ref *)out );
430 temp = value->ref.val;
431 if ( ISNULL(temp) ){ fprintf( stderr, "Casting from String to Object failed because value is null." );
432 abort();
433 }if ( ! ( ISOBJ( temp ) ? ISNULL( temp ) || OBJISA( temp, standard___kernel___Object ): VALISA( temp, standard___kernel___Object ) ) ){
434 fprintf( stderr, "Casting to Object failed because value is not a Object." );
435 abort();
436 }
437 out->ref.val = temp;
438 return out;
439 }