tests: adds native interface tests
[nit.git] / tests / test_ni_cast_extra.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_cast_extra.nit.h"
15
16 /*
17 C implementation of test_ni_cast_extra::A::isa_b
18
19 Imported methods signatures:
20 int A_is_a_B( A value ) to check if a A is a B
21 B A_as_B( A value ) to cast from A to B
22 */
23 int A_isa_b___impl( A recv )
24 {
25 return A_is_a_B( recv );
26 }
27
28 /*
29 C implementation of test_ni_cast_extra::A::as_b
30
31 Imported methods signatures:
32 int A_is_a_B( A value ) to check if a A is a B
33 B A_as_B( A value ) to cast from A to B
34 int A_is_a_nullable_B( A value ) to check if a A is a nullable B
35 nullable_B A_as_nullable_B( A value ) to cast from A to nullable B
36 */
37 nullable_B A_as_b___impl( A recv )
38 {
39 if ( A_is_a_nullable_B( recv ) )
40 return A_as_nullable_B( recv );
41 else
42 return null_B();
43 }
44
45 /*
46 C implementation of test_ni_cast_extra::C::isa_a
47
48 Imported methods signatures:
49 int C_is_a_A( C value ) to check if a C is a A
50 A C_as_A( C value ) to cast from C to A
51 */
52 int C_isa_a___impl( C recv )
53 {
54 return C_is_a_A( recv );
55 }
56
57 /*
58 C implementation of test_ni_cast_extra::D::as_a
59
60 Imported methods signatures:
61 int D_is_a_A( D value ) to check if a D is a A
62 A D_as_A( D value ) to cast from D to A
63 */
64 A D_as_a___impl( D recv )
65 {
66 return D_as_A( recv );
67 }