tests: adds native interface tests
[nit.git] / tests / test_ni_special_pointer.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_special_pointer.nit.h"
15
16 /*
17 C implementation of test_ni_special_pointer::ExternInt::as_0
18 */
19 ExternInt new_ExternInt_as_0___impl( )
20 {
21 ExternInt i0 = (int*)malloc( sizeof(int) );
22 (*i0) = 0;
23 return i0;
24 }
25
26 /*
27 C implementation of test_ni_special_pointer::ExternInt::as_1
28 */
29 ExternInt new_ExternInt_as_1___impl( )
30 {
31 ExternInt i0 = (int*)malloc( sizeof(int) );
32 (*i0) = 1;
33 return i0;
34 }
35
36 /*
37 C implementation of test_ni_special_pointer::ExternInt::as_2
38 */
39 ExternInt new_ExternInt_as_2___impl( )
40 {
41 ExternInt i0 = (int*)malloc( sizeof(int) );
42 (*i0) = 2;
43 return i0;
44 }
45
46 /*
47 C implementation of test_ni_special_pointer::ExternInt::(string::Object::to_s)
48
49 Imported methods signatures:
50 String new_String_from_cstring( char * str ) for string::String::from_cstring
51 */
52 String ExternInt_to_s___impl( ExternInt recv )
53 {
54 int v = *recv;
55 char *vs = (char*)calloc( 256, sizeof(char) );
56
57 sprintf( vs, "%i", v );
58 return new_String_from_cstring( vs );
59 }
60
61 /*
62 C implementation of test_ni_special_pointer::ExternInt::to_i
63 */
64 bigint ExternInt_to_i___impl( ExternInt recv )
65 {
66 return *recv;
67 }
68
69 /*
70 C implementation of test_ni_special_pointer::Int::to_extern_int
71 */
72 ExternInt Int_to_extern_int___impl( bigint recv )
73 {
74 ExternInt i = malloc( sizeof(int) );
75 (*i) = recv;
76 return i;
77 }