tests: add nit.nit
[nit.git] / tests / test_ni_global_ref.nit.c
1 /* This file is part of NIT ( http://www.nitlanguage.org ).
2 *
3 * Copyright 2012 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_global_ref.nit.h"
15
16 ToBePreserved global_tbp = NULL;
17
18 /*
19 C implementation of test_ni_references::A::save_as_global
20
21 Imported methods signatures:
22 void ToBePreserved_output( ToBePreserved recv ) for test_ni_references::ToBePreserved::(kernel::Object::output)
23 */
24 void A_save_as_global___impl( A recv, ToBePreserved tbp ) {
25 if ( global_tbp != NULL ) {
26 ToBePreserved_decr_ref( global_tbp );
27 }
28
29 global_tbp = tbp;
30 ToBePreserved_incr_ref( global_tbp );
31 }
32
33 /*
34 C implementation of test_ni_references::A::recover_unsafe
35 */
36 ToBePreserved A_recover_unsafe___impl( A recv ) {
37 return global_tbp;
38 }
39
40 /*
41 C implementation of test_ni_references::A::recover
42
43 Imported methods signatures:
44 nullable_ToBePreserved ToBePreserved_as_nullable( ToBePreserved value ) to cast from ToBePreserved to nullable ToBePreserved
45 */
46 nullable_ToBePreserved A_recover___impl( A recv ) {
47 if ( global_tbp != NULL ) {
48 return ToBePreserved_as_nullable( global_tbp );
49 } else {
50 return null_ToBePreserved();
51 }
52 }
53