char* string = "This is a test string";
FlatString ref_string = NativeString_to_s(string);
- StringTest_ref_test(recv, ref_string);
+ StringTest_ref_test(self, ref_string);
FlatString copy_string = NativeString_to_s_with_copy(string);
- StringTest_copy_test(recv, copy_string);
+ StringTest_copy_test(self, copy_string);
int same_refs = FlatString_items(copy_string) == FlatString_items(ref_string);
info = curl.easy_getinfo_long(new CURLInfoLong.rtsp_server_cseq)
assert infoResp:info != null
-info = curl.easy_getinfo_long(new CURLInfoLong.rtsp_cseq_recv)
+info = curl.easy_getinfo_long(new CURLInfoLong.rtsp_cseq_self)
assert infoResp:info != null
# Double
fun print_all import String.to_cstring, r, rw `{
printf( "%s %s\n",
- String_to_cstring( A_r( recv ) ),
- String_to_cstring( A_rw( recv ) ) );
+ String_to_cstring( A_r( self ) ),
+ String_to_cstring( A_rw( self ) ) );
`}
fun modify import NativeString.to_s, w=, rw= `{
- A_w__assign( recv, NativeString_to_s( "w set from native" ) );
- A_rw__assign( recv, NativeString_to_s( "rw set from native" ) );
+ A_w__assign( self, NativeString_to_s( "w set from native" ) );
+ A_rw__assign( self, NativeString_to_s( "rw set from native" ) );
`}
end
int i;
for(i = 0; i < 2000; ++i) {
printf("%d\n", i);
- Test_foo(recv, NativeString_to_s("asdf"));
+ Test_foo(self, NativeString_to_s("asdf"));
}
`}
fun foo do print "foo"
fun call_a_fun import foo `{
- Sys_foo(recv);
+ Sys_foo(self);
`}
fun call_a_constructor import A, A.bar `{
if ( n == 1 )
return 1;
else
- return FibonacciEngine_fibonacci( recv, n-1 ) + FibonacciEngine_fibonacci( recv, n-2 );
+ return FibonacciEngine_fibonacci( self, n-1 ) + FibonacciEngine_fibonacci( self, n-2 );
`}
end
redef class Int
fun fibonacci : Int import fibonacci `{
- if ( recv == 0 )
+ if ( self == 0 )
return 0;
- else if ( recv == 1 )
+ else if ( self == 1 )
return 1;
else
- return Int_fibonacci( recv-1 ) + Int_fibonacci( recv-2 );
+ return Int_fibonacci( self-1 ) + Int_fibonacci( self-2 );
`}
end
`}
fun []=(i: Int, v: A) `{
- recv[i] = v;
+ self[i] = v;
A_incr_ref(v);
`}
fun [](i: Int): A `{
- return recv[i];
+ return self[i];
`}
end
`}
fun p : Int import m `{
- return A_m( recv ) + 5;
+ return A_m( self ) + 5;
`}
fun in_language : Int is extern in "C" `{
fun out(i: Int, f: Float): Int import in1, in2, A, A.alt, A.to_i `{
printf("From C, beginning out: %ld\n", i);
- Sys_in1(recv, i);
+ Sys_in1(self, i);
A a = new_A();
A b = new_A_alt(10);
printf("From C, a=%ld\n", A_to_i(a));
fun a do print "a"
fun p `{
- printf( "allo from %i\n", *recv );
+ printf( "allo from %i\n", *self );
`}
fun d : A import d, A `{
return new_A();
`}
redef fun to_s import NativeString, NativeString.to_s `{
- int len = snprintf(NULL, 0, "%d", *recv) + 1;
+ int len = snprintf(NULL, 0, "%d", *self) + 1;
char *c = new_NativeString(len);
- sprintf(c, "%d", *recv);
+ sprintf(c, "%d", *self);
return NativeString_to_s(c);
`}
end
init(value: Int) do self.value = value
fun +(other: A): A import value, A `{
- int s = A_value( recv );
+ int s = A_value( self );
int o = A_value( other );
return new_A( s + o );
`}
fun +: A import value, A `{
- int s = A_value(recv);
+ int s = A_value(self);
return new_A(+s);
`}
fun -(other: A): A import value, A `{
- int s = A_value( recv );
+ int s = A_value( self );
int o = A_value( other );
return new_A( s - o );
`}
fun -: A import value, A `{
- int s = A_value(recv);
+ int s = A_value(self);
return new_A(-s);
`}
fun *(by: Int): A import value, A `{
- int s = A_value( recv );
+ int s = A_value( self );
return new_A( s * by );
`}
fun /(by: Int): A import value, A `{
- int s = A_value( recv );
+ int s = A_value( self );
return new_A( s / by );
`}
redef fun ==(other) import value, nullable Object.as(A) `{
if ( nullable_Object_is_a_A( other ) &&
- A_value( nullable_Object_as_A(other) ) == A_value( recv ) )
+ A_value( nullable_Object_as_A(other) ) == A_value( self ) )
return 1;
else
return 0;
`}
fun %(other: A): A import value, A `{
- return new_A( A_value( recv ) % A_value( other ) );
+ return new_A( A_value( self ) % A_value( other ) );
`}
fun <=>(other: A): A import value, A `{
- return new_A( A_value( recv )* 1024 );
+ return new_A( A_value( self )* 1024 );
`}
fun >(other: A): Bool import value `{
- return A_value( recv ) > A_value( other );
+ return A_value( self ) > A_value( other );
`}
fun <(other: A): Bool import value `{
- return A_value( recv ) < A_value( other );
+ return A_value( self ) < A_value( other );
`}
fun >=(other: A): Bool import value `{
- return A_value( recv ) >= A_value( other );
+ return A_value( self ) >= A_value( other );
`}
fun <=(other: A): Bool import value `{
- return A_value( recv ) <= A_value( other );
+ return A_value( self ) <= A_value( other );
`}
fun >>(other: A): A import value, value=, A `{
- int new_val = A_value( recv ) >> A_value( other );
+ int new_val = A_value( self ) >> A_value( other );
return new_A(new_val);
`}
fun <<(other: A): A import value, A `{
- int new_val = A_value( recv ) << A_value( other );
+ int new_val = A_value( self ) << A_value( other );
return new_A(new_val);
`}
fun |(other: A): A import value, A `{
- int new_val = A_value( recv ) | A_value( other );
+ int new_val = A_value( self ) | A_value( other );
return new_A(new_val);
`}
fun ^(other: A): A import value, A `{
- int new_val = A_value( recv ) ^ A_value( other );
+ int new_val = A_value( self ) ^ A_value( other );
return new_A(new_val);
`}
fun ~: A import value, A `{
- int new_val = ~A_value( recv );
+ int new_val = ~A_value( self );
return new_A(new_val);
`}
fun &(other: A): A import value, A `{
- int new_val = A_value( recv ) & A_value( other );
+ int new_val = A_value( self ) & A_value( other );
return new_A(new_val);
`}
redef fun id : String import super, NativeString.to_s, String.to_cstring `{
char *new_name;
char *prefix = "B special ";
- char *super_name = String_to_cstring( B_id___super( recv ) );
+ char *super_name = String_to_cstring( B_id___super( self ) );
new_name = calloc( strlen( prefix )+strlen( super_name )+1, sizeof(char) );
strcpy( new_name, prefix );
return v;
`}
fun p `{
- printf( "A< %d %d >\n", recv->x, recv->y );
+ printf( "A< %d %d >\n", self->x, self->y );
`}
end
`}
redef fun p import super `{
printf( "B< " );
- B_p___super(recv);
- printf( " %d %d >\n", recv->w, recv->h );
+ B_p___super(self);
+ printf( " %d %d >\n", self->w, self->h );
`}
end
return v;
`}
redef fun p `{
- printf( "C< %d %d >\n", recv->x, recv->y );
+ printf( "C< %d %d >\n", self->x, self->y );
`}
end
# Adds an element to the end of the vector
fun push(v: Int) in "C++" `{
- recv->push_back(v);
+ self->push_back(v);
`}
# Pops an element from the end of the vector
fun pop: Int in "C++" `{
- long val = recv->back();
- recv->pop_back();
+ long val = self->back();
+ self->pop_back();
return val;
`}
fun safe_pop_with_default(default_return: Int): Int import report_error in "C++" `{
- if (recv->empty()) {
- CppVector_report_error(recv);
+ if (self->empty()) {
+ CppVector_report_error(self);
return default_return;
} else {
- long val = recv->back();
- recv->pop_back();
+ long val = self->back();
+ self->pop_back();
return val;
}
`}
# Adds an element to the end of the vector
fun push(v: Int) in "C++" `{
- recv->push_back(v);
+ self->push_back(v);
`}
# Pops an element from the end of the vector
fun pop: Int in "C++" `{
- long val = recv->back();
- recv->pop_back();
+ long val = self->back();
+ self->pop_back();
return val;
`}
# Uses a callback to report when receiver is empty
fun safe_pop_with_default(default_return: Int): Int import report_error in "C++" `{
- if (recv->empty()) {
- CppVector_report_error(recv);
+ if (self->empty()) {
+ CppVector_report_error(self);
return default_return;
} else {
- long val = recv->back();
- recv->pop_back();
+ long val = self->back();
+ self->pop_back();
return val;
}
`}
# Prints the given string when receiver is empty
fun safe_pop_with_custom_error(default_return: Int, error_msg: String): Int import String.to_cpp_string in "C++" `{
- if (recv->empty()) {
+ if (self->empty()) {
string *cpp_error_msg = String_to_cpp_string(error_msg);
cout << *cpp_error_msg << "\n";
return default_return;
} else {
- long val = recv->back();
- recv->pop_back();
+ long val = self->back();
+ self->pop_back();
return val;
}
`}
# Adds an element to the end of the vector
fun push(v: Int) in "C++" `{
- recv->push_back(v);
+ self->push_back(v);
`}
# Pops an element from the end of the vector
fun pop: Int in "C++" `{
- long val = recv->back();
- recv->pop_back();
+ long val = self->back();
+ self->pop_back();
return val;
`}
end
fun i: Int do return 777
fun foo import bar, i in "Java" `{
- A_bar(recv);
- long i = A_i(recv);
+ A_bar(self);
+ long i = A_i(self);
System.out.println(i);
`}
return new LinkedBlockingQueue<String>();
`}
- fun offer(o: JavaString) in "Java" `{ recv.offer(o); `}
+ fun offer(o: JavaString) in "Java" `{ self.offer(o); `}
- fun remove: JavaString in "Java" `{ return recv.remove(); `}
+ fun remove: JavaString in "Java" `{ return self.remove(); `}
redef fun output in "Java" `{
- for (String s: recv) {
+ for (String s: self) {
System.out.println(s);
}
`}
System.out.println(input);
// Callback Nit with string
- String str = A_bar(recv, "Created in Java");
+ String str = A_bar(self, "Created in Java");
System.out.println(str);
// Send back a string
return new ArrayList();
`}
- fun add(o: JavaString) in "Java" `{ recv.add(o); `}
+ fun add(o: JavaString) in "Java" `{ self.add(o); `}
redef fun output in "Java" `{
- for (Object i: recv) {
+ for (Object i: self) {
System.out.println((String)i);
}
`}
fun sort in "Java" `{
- Collections.sort(recv);
+ Collections.sort(self);
`}
end
printf("From Objective-C: %ld %f %s\n", ii, f, cstr);
- Sys_bar(recv, ii, f, s);
+ Sys_bar(self, ii, f, s);
`}
fun bar(i: Int, f: Float, s: String)
printf( "received msg: %s, of length = %d\n", c_msg, msg_len );
/* A_my_attr is a callback to the getter of self.my_attr */
- printf( "old attr %d\n", A_my_attr(recv) );
+ printf( "old attr %d\n", A_my_attr(self) );
if(chose)
truc;
chose;
/* A_my_attr is a callback to the setter of self.my_attr= */
- A_my_attr__assign( recv, msg_len );
+ A_my_attr__assign( self, msg_len );
`}
end
new `{ return time(NULL); `}
new from_i(i: Int) `{ return i; `}
- fun update `{ time(&recv); `}
+ fun update `{ time(&self); `}
fun ctime: String import NativeString.to_s_with_copy `{
- return NativeString_to_s_with_copy( ctime(&recv) );
+ return NativeString_to_s_with_copy( ctime(&self) );
`}
# Difference in secondes from start (self if the end time)
- fun difftime(start: TimeT): Float `{ return difftime(recv, start); `}
+ fun difftime(start: TimeT): Float `{ return difftime(self, start); `}
private fun intern_poll(in_fds: Array[Int], out_fds: Array[Int]) : nullable Int is extern import Array[Int].length, Array[Int].[], Int.as(nullable Int) `{`}
end
fun address_is_null: Bool is extern "address_is_null"
-fun free `{ free(recv); `}
+fun free `{ free(self); `}