1 /* This file is part of NIT ( http://www.nitlanguage.org ).
3 * Copyright 2012 Alexis Laferrière <alexis.laf@xymus.net>
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
14 #include "extern_methods.nit.h"
19 C implementation of extern_methods::Int::fib
21 bigint
Int_fib___impl( bigint recv
) {
25 return Int_fib___impl( recv
-1 ) + Int_fib___impl( recv
-2 );
29 C implementation of extern_methods::Int::sleep
31 void Int_sleep___impl( bigint recv
) {
36 C implementation of extern_methods::Int::atan_with
38 float Int_atan_with___impl( bigint recv
, bigint x
) {
39 return atan2( recv
, x
);
43 C implementation of extern_methods::Int::foo
45 Imported methods signatures:
46 bigint Int_fib( bigint recv ) for extern_methods::Int::fib
47 bigint Int__plus( bigint recv, bigint i ) for kernel::Int::(kernel::Discrete::+)
48 String Int_to_s( bigint recv ) for string::Int::(string::Object::to_s)
49 char * String_to_cstring( String recv ) for string::String::to_cstring
51 void Int_foo___impl( bigint recv
) {
52 bigint recv_fib
= Int_fib( recv
);
53 bigint recv_plus_fib
= Int__plus( recv
, recv_fib
);
55 String nit_string
= Int_to_s( recv_plus_fib
);
56 char *c_string
= String_to_cstring( nit_string
);
58 printf( "from C: self + fib(self) = %s\n", c_string
);