update c_src (now with ffi)
[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 int orig_return;
36 val_t trans_return;
37 orig_return = string_NativeString_NativeString_file_exists_0( UNBOX_NativeString(recv) );
38 trans_return = TAG_Bool(orig_return);
39 nitni_local_ref_clean( );
40 return trans_return;
41 }
42 /* out/indirect function for file::NativeString::file_stat */
43 val_t NativeString_file_stat___out( val_t recv )
44 {
45 void* orig_return;
46 val_t trans_return;
47 orig_return = string_NativeString_NativeString_file_stat_0( UNBOX_NativeString(recv) );
48 trans_return = BOX_FileStat(orig_return);
49 nitni_local_ref_clean( );
50 return trans_return;
51 }
52 /* out/indirect function for file::NativeString::file_mkdir */
53 val_t NativeString_file_mkdir___out( val_t recv )
54 {
55 int orig_return;
56 val_t trans_return;
57 orig_return = string_NativeString_NativeString_file_mkdir_0( UNBOX_NativeString(recv) );
58 trans_return = TAG_Bool(orig_return);
59 nitni_local_ref_clean( );
60 return trans_return;
61 }
62 /* out/indirect function for file::NativeString::file_delete */
63 val_t NativeString_file_delete___out( val_t recv )
64 {
65 int orig_return;
66 val_t trans_return;
67 orig_return = string_NativeString_NativeString_file_delete_0( UNBOX_NativeString(recv) );
68 trans_return = TAG_Bool(orig_return);
69 nitni_local_ref_clean( );
70 return trans_return;
71 }
72 /* out/indirect function for file::FileStat::mode */
73 val_t FileStat_mode___out( val_t recv )
74 {
75 bigint orig_return;
76 val_t trans_return;
77 orig_return = file_FileStat_FileStat_mode_0( UNBOX_FileStat(recv) );
78 trans_return = TAG_Int(orig_return);
79 nitni_local_ref_clean( );
80 return trans_return;
81 }
82 /* out/indirect function for file::FileStat::atime */
83 val_t FileStat_atime___out( val_t recv )
84 {
85 bigint orig_return;
86 val_t trans_return;
87 orig_return = file_FileStat_FileStat_atime_0( UNBOX_FileStat(recv) );
88 trans_return = TAG_Int(orig_return);
89 nitni_local_ref_clean( );
90 return trans_return;
91 }
92 /* out/indirect function for file::FileStat::ctime */
93 val_t FileStat_ctime___out( val_t recv )
94 {
95 bigint orig_return;
96 val_t trans_return;
97 orig_return = file_FileStat_FileStat_ctime_0( UNBOX_FileStat(recv) );
98 trans_return = TAG_Int(orig_return);
99 nitni_local_ref_clean( );
100 return trans_return;
101 }
102 /* out/indirect function for file::FileStat::mtime */
103 val_t FileStat_mtime___out( val_t recv )
104 {
105 bigint orig_return;
106 val_t trans_return;
107 orig_return = file_FileStat_FileStat_mtime_0( UNBOX_FileStat(recv) );
108 trans_return = TAG_Int(orig_return);
109 nitni_local_ref_clean( );
110 return trans_return;
111 }
112 /* out/indirect function for file::FileStat::size */
113 val_t FileStat_size___out( val_t recv )
114 {
115 bigint orig_return;
116 val_t trans_return;
117 orig_return = file_FileStat_FileStat_size_0( UNBOX_FileStat(recv) );
118 trans_return = TAG_Int(orig_return);
119 nitni_local_ref_clean( );
120 return trans_return;
121 }
122 /* out/indirect function for file::NativeFile::io_read */
123 val_t NativeFile_io_read___out( val_t recv, val_t buf, val_t len )
124 {
125 bigint trans___len;
126 bigint orig_return;
127 val_t trans_return;
128 trans___len = UNTAG_Int(len);
129 orig_return = file_NativeFile_NativeFile_io_read_2( UNBOX_NativeFile(recv), UNBOX_NativeString(buf), trans___len );
130 trans_return = TAG_Int(orig_return);
131 nitni_local_ref_clean( );
132 return trans_return;
133 }
134 /* out/indirect function for file::NativeFile::io_write */
135 val_t NativeFile_io_write___out( val_t recv, val_t buf, val_t len )
136 {
137 bigint trans___len;
138 bigint orig_return;
139 val_t trans_return;
140 trans___len = UNTAG_Int(len);
141 orig_return = file_NativeFile_NativeFile_io_write_2( UNBOX_NativeFile(recv), UNBOX_NativeString(buf), trans___len );
142 trans_return = TAG_Int(orig_return);
143 nitni_local_ref_clean( );
144 return trans_return;
145 }
146 /* out/indirect function for file::NativeFile::io_close */
147 val_t NativeFile_io_close___out( val_t recv )
148 {
149 bigint orig_return;
150 val_t trans_return;
151 orig_return = file_NativeFile_NativeFile_io_close_0( UNBOX_NativeFile(recv) );
152 trans_return = TAG_Int(orig_return);
153 nitni_local_ref_clean( );
154 return trans_return;
155 }
156 /* out/indirect function for file::NativeFile::file_stat */
157 val_t NativeFile_file_stat___out( val_t recv )
158 {
159 void* orig_return;
160 val_t trans_return;
161 orig_return = file_NativeFile_NativeFile_file_stat_0( UNBOX_NativeFile(recv) );
162 trans_return = BOX_FileStat(orig_return);
163 nitni_local_ref_clean( );
164 return trans_return;
165 }
166 /* out/indirect function for file::NativeFile::io_open_read */
167 val_t NEW_NativeFile_standard___file___NativeFile___io_open_read( val_t path )
168 {
169 void* orig_return;
170 val_t trans_return;
171 orig_return = file_NativeFileCapable_NativeFileCapable_io_open_read_1( UNBOX_NativeString(path) );
172 trans_return = BOX_NativeFile(orig_return);
173 nitni_local_ref_clean( );
174 return trans_return;
175 }
176 /* out/indirect function for file::NativeFile::io_open_write */
177 val_t NEW_NativeFile_standard___file___NativeFile___io_open_write( val_t path )
178 {
179 void* orig_return;
180 val_t trans_return;
181 orig_return = file_NativeFileCapable_NativeFileCapable_io_open_write_1( UNBOX_NativeString(path) );
182 trans_return = BOX_NativeFile(orig_return);
183 nitni_local_ref_clean( );
184 return trans_return;
185 }
186 /* out/indirect function for file::NativeFile::native_stdin */
187 val_t NEW_NativeFile_standard___file___NativeFile___native_stdin( )
188 {
189 void* orig_return;
190 val_t trans_return;
191 orig_return = file_NativeFileCapable_NativeFileCapable_native_stdin_0( );
192 trans_return = BOX_NativeFile(orig_return);
193 nitni_local_ref_clean( );
194 return trans_return;
195 }
196 /* out/indirect function for file::NativeFile::native_stdout */
197 val_t NEW_NativeFile_standard___file___NativeFile___native_stdout( )
198 {
199 void* orig_return;
200 val_t trans_return;
201 orig_return = file_NativeFileCapable_NativeFileCapable_native_stdout_0( );
202 trans_return = BOX_NativeFile(orig_return);
203 nitni_local_ref_clean( );
204 return trans_return;
205 }
206 /* out/indirect function for file::NativeFile::native_stderr */
207 val_t NEW_NativeFile_standard___file___NativeFile___native_stderr( )
208 {
209 void* orig_return;
210 val_t trans_return;
211 orig_return = file_NativeFileCapable_NativeFileCapable_native_stderr_0( );
212 trans_return = BOX_NativeFile(orig_return);
213 nitni_local_ref_clean( );
214 return trans_return;
215 }
216 /* friendly for hash_collection::HashSet::init */
217 HashSet file_new_HashSet( )
218 {
219 val_t orig_return;
220 HashSet trans_return;
221 trans_return = malloc( sizeof( struct s_HashSet ) );
222 trans_return->ref.val = NIT_NULL;
223 trans_return->ref.count = 0;
224 nitni_local_ref_add( (struct nitni_ref *)trans_return );
225 orig_return = NEW_HashSet_standard___collection___hash_collection___HashSet___init( );
226 trans_return->ref.val = orig_return;
227 return trans_return;
228 }
229 /* friendly for hash_collection::HashSet::(abstract_collection::SimpleCollection::add) */
230 void file_HashSet_add( HashSet recv, Object item )
231 {
232 val_t trans_recv;
233 val_t trans___item;
234 trans_recv = recv->ref.val;
235 trans___item = item->ref.val;
236 CALL_standard___collection___abstract_collection___SimpleCollection___add( trans_recv )( trans_recv, trans___item );
237 }
238 /* friendly for string::String::from_cstring */
239 String file_new_String_from_cstring( char * str )
240 {
241 val_t orig_return;
242 String trans_return;
243 trans_return = malloc( sizeof( struct s_String ) );
244 trans_return->ref.val = NIT_NULL;
245 trans_return->ref.count = 0;
246 nitni_local_ref_add( (struct nitni_ref *)trans_return );
247 orig_return = NEW_String_standard___string___String___from_cstring( BOX_NativeString(str) );
248 trans_return->ref.val = orig_return;
249 return trans_return;
250 }
251 /* friendly for string::String::to_cstring */
252 char * file_String_to_cstring( String recv )
253 {
254 val_t trans_recv;
255 val_t orig_return;
256 char * trans_return;
257 trans_recv = recv->ref.val;
258 orig_return = CALL_standard___string___String___to_cstring( trans_recv )( trans_recv );
259 trans_return = UNBOX_NativeString(orig_return);
260 return trans_return;
261 }
262 int file_HashSet_is_a_Set( HashSet value )
263 {
264 val_t temp;
265 temp = value->ref.val;
266 if ( ! ( ISOBJ( temp ) ? OBJISA( temp, standard___collection___abstract_collection___Set ): VALISA( temp, standard___collection___abstract_collection___Set ) ) ) return 0;
267 return 1;
268 }
269 Set file_HashSet_as_Set( HashSet value )
270 {
271 val_t temp;
272 Set out;
273 out = malloc( sizeof( struct s_Set ) );
274 out->ref.val = NIT_NULL;
275 out->ref.count = 0;
276 nitni_local_ref_add( (struct nitni_ref *)out );
277 temp = value->ref.val;
278 if ( ISNULL(temp) ){ fprintf( stderr, "Casting from HashSet[String] to Set[String] failed because value is null." );
279 abort();
280 }if ( ! ( ISOBJ( temp ) ? OBJISA( temp, standard___collection___abstract_collection___Set ): VALISA( temp, standard___collection___abstract_collection___Set ) ) ){
281 fprintf( stderr, "Casting to Set[String] failed because value is not a Set[String]." );
282 abort();
283 }
284 out->ref.val = temp;
285 return out;
286 }
287 int file_String_is_a_Object( String value )
288 {
289 val_t temp;
290 temp = value->ref.val;
291 if ( ! ( ISOBJ( temp ) ? OBJISA( temp, standard___kernel___Object ): VALISA( temp, standard___kernel___Object ) ) ) return 0;
292 return 1;
293 }
294 Object file_String_as_Object( String value )
295 {
296 val_t temp;
297 Object out;
298 out = malloc( sizeof( struct s_Object ) );
299 out->ref.val = NIT_NULL;
300 out->ref.count = 0;
301 nitni_local_ref_add( (struct nitni_ref *)out );
302 temp = value->ref.val;
303 if ( ISNULL(temp) ){ fprintf( stderr, "Casting from String to Object failed because value is null." );
304 abort();
305 }if ( ! ( ISOBJ( temp ) ? OBJISA( temp, standard___kernel___Object ): VALISA( temp, standard___kernel___Object ) ) ){
306 fprintf( stderr, "Casting to Object failed because value is not a Object." );
307 abort();
308 }
309 out->ref.val = temp;
310 return out;
311 }