c_src: update to have intern args
[nit.git] / c_src / stream._nitni.c
1 #include "stream._nitni.h"
2 #include "stream_nit.h"
3 /* out/indirect function for stream::FDStream::native_close */
4 val_t FDStream_native_close___out( val_t recv, val_t i )
5 {
6 bigint orig_return;
7 val_t trans_return;
8 orig_return = stream_FDStream_FDStream_native_close_1( NULL, UNTAG_Int(i) );
9 trans_return = TAG_Int(orig_return);
10 nitni_local_ref_clean( );
11 return trans_return;
12 }
13 /* out/indirect function for stream::FDStream::native_read_char */
14 val_t FDStream_native_read_char___out( val_t recv, val_t i )
15 {
16 bigint orig_return;
17 val_t trans_return;
18 orig_return = stream_FDStream_FDStream_native_read_char_1( NULL, UNTAG_Int(i) );
19 trans_return = TAG_Int(orig_return);
20 nitni_local_ref_clean( );
21 return trans_return;
22 }
23 /* out/indirect function for stream::FDStream::native_read */
24 val_t FDStream_native_read___out( val_t recv, val_t i, val_t buf, val_t len )
25 {
26 char * trans___buf;
27 bigint orig_return;
28 val_t trans_return;
29 trans___buf = UNBOX_NativeString(buf);
30 orig_return = stream_FDStream_FDStream_native_read_3( NULL, UNTAG_Int(i), trans___buf, UNTAG_Int(len) );
31 trans_return = TAG_Int(orig_return);
32 nitni_local_ref_clean( );
33 return trans_return;
34 }
35 /* out/indirect function for stream::FDStream::native_write */
36 val_t FDStream_native_write___out( val_t recv, val_t i, val_t buf, val_t len )
37 {
38 char * trans___buf;
39 bigint orig_return;
40 val_t trans_return;
41 trans___buf = UNBOX_NativeString(buf);
42 orig_return = stream_FDStream_FDStream_native_write_3( NULL, UNTAG_Int(i), trans___buf, UNTAG_Int(len) );
43 trans_return = TAG_Int(orig_return);
44 nitni_local_ref_clean( );
45 return trans_return;
46 }
47 /* out/indirect function for stream::FDStream::native_write_char */
48 val_t FDStream_native_write_char___out( val_t recv, val_t i, val_t c )
49 {
50 bigint orig_return;
51 val_t trans_return;
52 orig_return = stream_FDStream_FDStream_native_write_char_2( NULL, UNTAG_Int(i), UNTAG_Char(c) );
53 trans_return = TAG_Int(orig_return);
54 nitni_local_ref_clean( );
55 return trans_return;
56 }
57 /* out/indirect function for stream::Object::intern_poll */
58 val_t Object_intern_poll___out( val_t recv, val_t in_fds, val_t out_fds )
59 {
60 Object trans_recv;
61 Array trans___in_fds;
62 Array trans___out_fds;
63 nullable_Int orig_return;
64 val_t trans_return;
65 trans_recv = malloc( sizeof( struct s_Object ) );
66 trans_recv->ref.val = NIT_NULL;
67 trans_recv->ref.count = 0;
68 nitni_local_ref_add( (struct nitni_ref *)trans_recv );
69 trans_recv->ref.val = recv;
70 trans___in_fds = malloc( sizeof( struct s_Array ) );
71 trans___in_fds->ref.val = NIT_NULL;
72 trans___in_fds->ref.count = 0;
73 nitni_local_ref_add( (struct nitni_ref *)trans___in_fds );
74 trans___in_fds->ref.val = in_fds;
75 trans___out_fds = malloc( sizeof( struct s_Array ) );
76 trans___out_fds->ref.val = NIT_NULL;
77 trans___out_fds->ref.count = 0;
78 nitni_local_ref_add( (struct nitni_ref *)trans___out_fds );
79 trans___out_fds->ref.val = out_fds;
80 orig_return = malloc( sizeof( struct s_nullable_Int ) );
81 orig_return->ref.val = NIT_NULL;
82 orig_return->ref.count = 0;
83 orig_return = Object_intern_poll___impl( trans_recv, trans___in_fds, trans___out_fds );
84 trans_return = orig_return->ref.val;
85 nitni_local_ref_clean( );
86 return trans_return;
87 }
88 nullable_Int stream_null_Int()
89 {
90 nullable_Int n;
91 n = malloc( sizeof( struct s_nullable_Int ) );
92 n->ref.val = NIT_NULL;
93 n->ref.count = 0;
94 nitni_local_ref_add( (struct nitni_ref *)n );
95 return n;
96 }
97 nullable_Object stream_null_Object()
98 {
99 nullable_Object n;
100 n = malloc( sizeof( struct s_nullable_Object ) );
101 n->ref.val = NIT_NULL;
102 n->ref.count = 0;
103 nitni_local_ref_add( (struct nitni_ref *)n );
104 return n;
105 }
106 /* friendly for array::AbstractArrayRead::(abstract_collection::Collection::length) */
107 bigint stream_Array_length( Array recv )
108 {
109 val_t trans_recv;
110 val_t orig_return;
111 bigint trans_return;
112 trans_recv = recv->ref.val;
113 orig_return = CALL_standard___collection___abstract_collection___Collection___length( trans_recv )( trans_recv );
114 trans_return = UNTAG_Int(orig_return);
115 return trans_return;
116 }
117 /* friendly for array::Array::(abstract_collection::SequenceRead::[]) */
118 nullable_Object stream_Array__index( Array recv, bigint index )
119 {
120 val_t trans_recv;
121 val_t orig_return;
122 nullable_Object trans_return;
123 trans_recv = recv->ref.val;
124 trans_return = malloc( sizeof( struct s_nullable_Object ) );
125 trans_return->ref.val = NIT_NULL;
126 trans_return->ref.count = 0;
127 nitni_local_ref_add( (struct nitni_ref *)trans_return );
128 orig_return = CALL_standard___collection___abstract_collection___SequenceRead_____bra( trans_recv )( trans_recv, TAG_Int(index) );
129 trans_return->ref.val = orig_return;
130 return trans_return;
131 }
132 int stream_nullable_Object_is_a_Int( nullable_Object value )
133 {
134 val_t temp;
135 temp = value->ref.val;
136 if ( ISNULL(temp) ) return 0;
137 if ( ! ( ISOBJ( temp ) ? ISNULL( temp ) || OBJISA( temp, standard___kernel___Int ): VALISA( temp, standard___kernel___Int ) ) ) return 0;
138 return 1;
139 }
140 bigint stream_nullable_Object_as_Int( nullable_Object value )
141 {
142 val_t temp;
143 bigint out;
144 temp = value->ref.val;
145 if ( ISNULL(temp) ){ fprintf( stderr, "Casting from nullable Object to Int failed because value is null." );
146 abort();
147 }if ( ! ( ISOBJ( temp ) ? ISNULL( temp ) || OBJISA( temp, standard___kernel___Int ): VALISA( temp, standard___kernel___Int ) ) ){
148 fprintf( stderr, "Casting to Int failed because value is not a Int." );
149 abort();
150 }
151 out = UNTAG_Int(temp);
152 return out;
153 }
154 nullable_Int stream_Int_as_nullable( bigint value )
155 {
156 val_t temp;
157 nullable_Int out;
158 out = malloc( sizeof( struct s_nullable_Int ) );
159 out->ref.val = NIT_NULL;
160 out->ref.count = 0;
161 nitni_local_ref_add( (struct nitni_ref *)out );
162 temp = TAG_Int(value);
163 out->ref.val = temp;
164 return out;
165 }