tests: adds native interface tests
[nit.git] / tests / test_ni_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_pointer.nit.h"
15
16 /*
17 C implementation of test_ni_pointer::A::init
18 */
19 A new_A___impl( )
20 {
21 int* v = (int*)malloc( sizeof(int) );
22 (*v) = 123;
23 return (A)v;
24 }
25
26 /*
27 C implementation of test_ni_pointer::A::(string::Object::to_s)
28
29 Imported methods signatures:
30 String new_String_from_cstring( char * str ) for string::String::from_cstring
31 */
32 String A_to_s___impl( A recv )
33 {
34 char* s = calloc( 256, sizeof(char) );
35 sprintf( s, "%d", *((int*)recv) );
36 return new_String_from_cstring( s );
37 }