# Check Float.object_id
assert 1.0.object_id.to_s.is_numeric
-# Check NativeString.object_id
+# Check CString.object_id
assert "Test".as(FlatString).items.object_id.to_s.is_numeric
class String
end
-enum NativeString
+enum CString
end
class Array[E]
-alt/error_needed_method_alt3.nit:48,9--13: Fatal Error: `NativeString` must have a property named `to_s_full`.
+alt/error_needed_method_alt3.nit:48,9--13: Fatal Error: `CString` must have a property named `to_s_full`.
-NativeString
+CString
0x4e
Nit
NativeArray
-NativeString
+CString
0x4e
Nit
NativeArray
-alt/error_needed_method_alt4.nit:49,10--14: Fatal Error: `NativeString` must have a property named `to_s_full`.
+alt/error_needed_method_alt4.nit:49,10--14: Fatal Error: `CString` must have a property named `to_s_full`.
-NativeString
+CString
N
Nit
NativeArray
-NativeString
+CString
N
Nit
NativeArray
new from_i(i: Int) `{ return i; `}
fun update `{ time(&self); `}
- fun ctime: String import NativeString.to_s_with_copy `{
- return NativeString_to_s_with_copy( ctime(&self) );
+ fun ctime: String import CString.to_s_with_copy `{
+ return CString_to_s_with_copy( ctime(&self) );
`}
# Difference in secondes from start (self if the end time)
fun update `{ time(&self); `}
- fun ctime: String import NativeString.to_s_with_copy `{
- return NativeString_to_s_with_copy( ctime(&self) );
+ fun ctime: String import CString.to_s_with_copy `{
+ return CString_to_s_with_copy( ctime(&self) );
`}
# Difference in secondes from start (self if the end time)
This is a test string
This is a test string
-Do the strings have the same NativeString reference ? False
+Do the strings have the same CString reference ? False
-NativeString
+CString
0x4e
Nit
NativeArray[Int]
Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/core/collection/array.nit:991)
-NativeString
+CString
0x4e
Nit
do
var count = 0
var b_arrsz = ((n - 1).to_f / 8.0).ceil.to_i
- var bitarr = new Bitarray(new Bytes(new NativeString(b_arrsz), b_arrsz, b_arrsz))
+ var bitarr = new Bitarray(new Bytes(new CString(b_arrsz), b_arrsz, b_arrsz))
for i in [2 .. n[ do
# If self is already false, then no need to check for multiples
if not bitarr[i] then continue
var referenced_str: nullable String = null
- fun get_c_string import FlatString.items, NativeString.to_s, NativeString.to_s_with_copy, StringTest.ref_test, StringTest.copy_test `{
+ fun get_c_string import FlatString.items, CString.to_s, CString.to_s_with_copy, StringTest.ref_test, StringTest.copy_test `{
char* string = "This is a test string";
- FlatString ref_string = NativeString_to_s(string);
+ FlatString ref_string = CString_to_s(string);
StringTest_ref_test(self, ref_string);
- FlatString copy_string = NativeString_to_s_with_copy(string);
+ FlatString copy_string = CString_to_s_with_copy(string);
StringTest_copy_test(self, copy_string);
int same_refs = FlatString_items(copy_string) == FlatString_items(ref_string);
- printf("Do the strings have the same NativeString reference ? ");
+ printf("Do the strings have the same CString reference ? ");
if(same_refs){
printf("True\n");
#alt1 intrude import core::text::ropes
#alt2 intrude import core::text::ropes
-var ons = new NativeString(9)
+var ons = new CString(9)
var base_str = "%Dégâštr"
var str: String = base_str
String_to_cstring( A_r( self ) ),
String_to_cstring( A_rw( self ) ) );
`}
- fun modify import NativeString.to_s, w=, rw= `{
- A_w__assign( self, NativeString_to_s( "w set from native" ) );
- A_rw__assign( self, NativeString_to_s( "rw set from native" ) );
+ fun modify import CString.to_s, w=, rw= `{
+ A_w__assign( self, CString_to_s( "w set from native" ) );
+ A_rw__assign( self, CString_to_s( "rw set from native" ) );
`}
end
class B
- fun print_and_modify( a : A ) import A.rw, A.rw=, String.to_cstring, NativeString.to_s `{
+ fun print_and_modify( a : A ) import A.rw, A.rw=, String.to_cstring, CString.to_s `{
printf( "%s\n", String_to_cstring( A_rw( a ) ) );
- A_rw__assign( a, NativeString_to_s( "set from native" ) );
+ A_rw__assign( a, CString_to_s( "set from native" ) );
printf( "%s\n", String_to_cstring( A_rw( a ) ) );
`}
end
return foobar;
`}
- fun test_me is extern import Test.foo, NativeString.to_s `{
+ fun test_me is extern import Test.foo, CString.to_s `{
int i;
for(i = 0; i < 2000; ++i) {
printf("%d\n", i);
- Test_foo(self, NativeString_to_s("asdf"));
+ Test_foo(self, CString_to_s("asdf"));
}
`}
fun m : Int is extern `{ return 10; `}
- fun n : String is extern import NativeString.to_s `{
- return NativeString_to_s( "allo" );
+ fun n : String is extern import CString.to_s `{
+ return CString_to_s( "allo" );
`}
fun o ( str : String ) is extern import String.to_cstring `{
return r;
`}
- redef fun to_s import NativeString, NativeString.to_s `{
+ redef fun to_s import CString, CString.to_s `{
int len = snprintf(NULL, 0, "%d", *self) + 1;
- char *c = new_NativeString(len);
+ char *c = new_CString(len);
sprintf(c, "%d", *self);
- return NativeString_to_s(c);
+ return CString_to_s(c);
`}
end
return v + 0x10;
`}
-fun print_ns(s: NativeString) `{
+fun print_ns(s: CString) `{
printf("%s\n", s);
`}
# See the License for the specific language governing permissions and
# limitations under the License.
-fun print_cstring(cstr: NativeString) `{
+fun print_cstring(cstr: CString) `{
printf("cstr-> %s\n", cstr);
`}
-fun get_cstring: NativeString `{
+fun get_cstring: CString `{
return "char* from C";
`}
printf("str-> %s\n", String_to_cstring(str) );
`}
-fun get_string: String import NativeString.to_s, String.output `{
- String str = NativeString_to_s("Nit string from C");
+fun get_string: String import CString.to_s, String.output `{
+ String str = CString_to_s("Nit string from C");
String_output(str);
printf("\n");
return str;
class B
super A
- redef fun id : String import super, NativeString.to_s, String.to_cstring `{
+ redef fun id : String import super, CString.to_s, String.to_cstring `{
char *new_name;
char *prefix = "B special ";
char *super_name = String_to_cstring( B_id___super( self ) );
strcpy( new_name+strlen( prefix ), super_name );
new_name[ strlen( prefix )+strlen( super_name ) ] = '\0';
- return NativeString_to_s( new_name );
+ return CString_to_s( new_name );
`}
end
# See the License for the specific language governing permissions and
# limitations under the License.
-var x = "string__NativeString__to_s_with_length"
+var x = "string__CString__to_s_with_length"
-var y = "string" + "__" + "NativeString" + "__" + "to_s_with_length"
+var y = "string" + "__" + "CString" + "__" + "to_s_with_length"
var z = new FlatBuffer.from("string")
z.append("__")
-z.append("NativeString")
+z.append("CString")
z.append("__")
z.append("to_s_with_length")
-var a = ["string", "NativeString", "to_s_with_length"].join("__")
+var a = ["string", "CString", "to_s_with_length"].join("__")
print x.hash == y.hash
print y.hash == z.hash
#alt2 cpstr = new FlatBuffer.from(src_s)
#alt3 cpstr = cpstr.substring(1, 5)
-var ns = new NativeString(cpstr.byte_length)
+var ns = new CString(cpstr.byte_length)
ns.fill_from(cpstr)
print ns.to_s_with_length(cpstr.byte_length)
# See the License for the specific language governing permissions and
# limitations under the License.
-var s = new NativeString(4)
+var s = new CString(4)
s[0] = 0x4Eu8
s[2] = 0x74u8
s[1] = 0x69u8
fun update `{ time(&self); `}
- fun ctime: String import NativeString.to_s_with_copy `{
- return NativeString_to_s_with_copy( ctime(&self) );
+ fun ctime: String import CString.to_s_with_copy `{
+ return CString_to_s_with_copy( ctime(&self) );
`}
# Difference in secondes from start (self if the end time)