From 5d23d6640f3dba6169bd5ef8af13994b36ff9c28 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sat, 24 Dec 2016 11:03:55 -0500 Subject: [PATCH] *: update all clients of the `CString::to_s` services MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- .../strings/array_to_s_vars/array_to_s_flatstr.nit | 2 +- .../strings/array_to_s_vars/array_to_s_manual.nit | 2 +- lib/binary/serialization.nit | 2 +- lib/cocoa/foundation.nit | 4 +-- lib/core/bytes.nit | 2 +- lib/core/codecs/utf8.nit | 4 +-- lib/core/file.nit | 6 ++-- lib/core/fixed_ints.nit | 10 +++--- lib/core/re.nit | 8 ++--- lib/core/text/abstract_text.nit | 8 ++--- lib/core/text/flat.nit | 2 +- lib/core/time.nit | 10 +++--- lib/curl/native_curl.nit | 8 ++--- lib/gtk/v3_4/gtk_assistant.nit | 4 +-- lib/gtk/v3_4/gtk_core.nit | 28 +++++++-------- lib/gtk/v3_4/gtk_dialogs.nit | 36 ++++++++++---------- lib/gtk/v3_4/gtk_widgets_ext.nit | 4 +-- lib/mongodb/mongodb.nit | 8 ++--- lib/mongodb/native_mongodb.nit | 4 +-- lib/socket/socket.nit | 4 +-- lib/sqlite3/sqlite3.nit | 2 +- src/compiler/abstract_compiler.nit | 2 +- src/interpreter/naive_interpreter.nit | 2 +- src/interpreter/primitive_types.nit | 2 +- src/rapid_type_analysis.nit | 2 +- tests/sav/error_needed_method_alt3.res | 2 +- tests/sav/niti/error_needed_method_alt4.res | 2 +- tests/sav/nitpretty_args21.res | 4 +-- tests/sav/nitpretty_args52.res | 4 +-- tests/sav/nitserial_args1.res | 2 +- tests/string_ffi_ref_test.nit | 4 +-- tests/test_copy_to_native.nit | 2 +- tests/test_nativestring_fill_from.nit | 2 +- tests/test_pretty/test_extern1.nit | 4 +-- 34 files changed, 96 insertions(+), 96 deletions(-) diff --git a/benchmarks/strings/array_to_s_vars/array_to_s_flatstr.nit b/benchmarks/strings/array_to_s_vars/array_to_s_flatstr.nit index 60f4196..95f8c39 100644 --- a/benchmarks/strings/array_to_s_vars/array_to_s_flatstr.nit +++ b/benchmarks/strings/array_to_s_vars/array_to_s_flatstr.nit @@ -30,7 +30,7 @@ redef class FlatString pos += 1 end end - return nns.to_s_with_length(mlen) + return nns.to_s_unsafe(mlen, copy=false) end end diff --git a/benchmarks/strings/array_to_s_vars/array_to_s_manual.nit b/benchmarks/strings/array_to_s_vars/array_to_s_manual.nit index ba1e084..0a79d35 100644 --- a/benchmarks/strings/array_to_s_vars/array_to_s_manual.nit +++ b/benchmarks/strings/array_to_s_vars/array_to_s_manual.nit @@ -52,6 +52,6 @@ redef class Array[E] end i += 1 end - return ns.to_s_with_length(sl) + return ns.to_s_unsafe(sl, copy=false) end end diff --git a/lib/binary/serialization.nit b/lib/binary/serialization.nit index be2b5ae..c99572e 100644 --- a/lib/binary/serialization.nit +++ b/lib/binary/serialization.nit @@ -230,7 +230,7 @@ class BinaryDeserializer if b == null then return '�' bf[i] = b end - return bf.to_s_with_length(ln)[0] + return bf.to_s_unsafe(ln, copy=false)[0] end if kind == kind_string then return stream.read_block if kind == kind_c_string then return stream.read_block.to_cstring diff --git a/lib/cocoa/foundation.nit b/lib/cocoa/foundation.nit index 2e50e39..3ea7b5e 100644 --- a/lib/cocoa/foundation.nit +++ b/lib/cocoa/foundation.nit @@ -37,7 +37,7 @@ extern class NSString in "ObjC" `{ NSString * `} # Get an UTF8 encoded `char*` copy of `self` fun utf8_string: CString in "ObjC" `{ return (char *)[self UTF8String]; `} - redef fun to_s do return utf8_string.to_s_with_copy + redef fun to_s do return utf8_string.to_s end redef class CString @@ -63,7 +63,7 @@ extern class NSData in "ObjC" `{ NSData * `} # Number of bytes containted in `self` fun length: Int in "ObjC" `{ return self.length; `} - redef fun to_s do return bytes.to_s_with_copy_and_length(length) + redef fun to_s do return bytes.to_s_with_length(length) end # Error condition diff --git a/lib/core/bytes.nit b/lib/core/bytes.nit index fed8173..c4f4415 100644 --- a/lib/core/bytes.nit +++ b/lib/core/bytes.nit @@ -474,7 +474,7 @@ class Bytes redef fun to_s do persisted = true var b = self - var r = b.items.to_s_with_length(length) + var r = b.items.to_s_unsafe(length, copy=false) if r != items then persisted = false return r end diff --git a/lib/core/codecs/utf8.nit b/lib/core/codecs/utf8.nit index debb3f5..43f6235 100644 --- a/lib/core/codecs/utf8.nit +++ b/lib/core/codecs/utf8.nit @@ -68,12 +68,12 @@ private class UTF8Codec end redef fun decode_string(ns, len) do - var ret = ns.to_s_with_length(len) + var ret = ns.to_s_unsafe(len, copy=false) var rit = ret.as(FlatString).items if rit == ns then var nns = new CString(len) rit.copy_to(nns, len, 0, 0) - return nns.to_s_full(ret.byte_length, ret.length) + return nns.to_s_unsafe(ret.byte_length, ret.length, copy=false) end return ret end diff --git a/lib/core/file.nit b/lib/core/file.nit index bfbd8c3..c78f6d4 100644 --- a/lib/core/file.nit +++ b/lib/core/file.nit @@ -683,7 +683,7 @@ class Path # readdir cannot fail, so null means end of list break end - var name = de.to_s_with_copy + var name = de.to_s if name == "." or name == ".." then continue res.add self / name end @@ -1024,7 +1024,7 @@ redef class String fun realpath: String do var cs = to_cstring.file_realpath assert file_exists - var res = cs.to_s_with_copy + var res = cs.to_s cs.free return res end @@ -1324,7 +1324,7 @@ redef class String loop var de = d.readdir if de.address_is_null then break - var name = de.to_s_with_copy + var name = de.to_s if name == "." or name == ".." then continue res.add name end diff --git a/lib/core/fixed_ints.nit b/lib/core/fixed_ints.nit index 3fb7468..843381c 100644 --- a/lib/core/fixed_ints.nit +++ b/lib/core/fixed_ints.nit @@ -240,7 +240,7 @@ universal Int8 var ns = new CString(nslen + 1) ns[nslen] = 0u8 native_to_s(ns, nslen + 1) - return ns.to_s_with_length(nslen) + return ns.to_s_unsafe(nslen, copy=false) end end @@ -386,7 +386,7 @@ universal Int16 var ns = new CString(nslen + 1) ns[nslen] = 0u8 native_to_s(ns, nslen + 1) - return ns.to_s_with_length(nslen) + return ns.to_s_unsafe(nslen, copy=false) end end @@ -532,7 +532,7 @@ universal UInt16 var ns = new CString(nslen + 1) ns[nslen] = 0u8 native_to_s(ns, nslen + 1) - return ns.to_s_with_length(nslen) + return ns.to_s_unsafe(nslen, copy=false) end end @@ -679,7 +679,7 @@ universal Int32 var ns = new CString(nslen + 1) ns[nslen] = 0u8 native_to_s(ns, nslen + 1) - return ns.to_s_with_length(nslen) + return ns.to_s_unsafe(nslen, copy=false) end end @@ -825,7 +825,7 @@ universal UInt32 var ns = new CString(nslen + 1) ns[nslen] = 0u8 native_to_s(ns, nslen + 1) - return ns.to_s_with_length(nslen) + return ns.to_s_unsafe(nslen, copy=false) end end diff --git a/lib/core/re.nit b/lib/core/re.nit index 3a3d196..048eed3 100644 --- a/lib/core/re.nit +++ b/lib/core/re.nit @@ -239,7 +239,7 @@ class Regex var error_cstr = native.regerror(res) # We leave it to the lib to decide how to allocate the string that we keep - var error_str = error_cstr.to_s_with_copy + var error_str = error_cstr.to_s error_cstr.free return new Error(error_str) @@ -279,7 +279,7 @@ class Regex var error_cstr = native.regerror(errcode) # We leave it to the lib to decide how to allocate the string that we keep - var error_str = error_cstr.to_s_with_copy + var error_str = error_cstr.to_s error_cstr.free return error_str @@ -368,7 +368,7 @@ class Regex # Actually execute var cstr = text.to_cstring - var rets = cstr.to_s_with_length(text.byte_length) + var rets = cstr.to_s_unsafe(text.byte_length, copy=false) var bytefrom = cstr.char_to_byte_index_cached(charfrom, 0, 0) var subcstr = cstr.fast_cstring(bytefrom) var eflags = gather_eflags @@ -428,7 +428,7 @@ class Regex # Actually execute var cstr = text.to_cstring var subcstr = cstr - var rets = cstr.to_s_with_length(text.byte_length) + var rets = cstr.to_s_unsafe(text.byte_length, copy=false) var eflags = gather_eflags var eflags_or_notbol = eflags | flag_notbol var native_match = self.native_match diff --git a/lib/core/text/abstract_text.nit b/lib/core/text/abstract_text.nit index 43d017e..9078918 100644 --- a/lib/core/text/abstract_text.nit +++ b/lib/core/text/abstract_text.nit @@ -894,7 +894,7 @@ abstract class Text l += 1 end - return buf.to_s_unsafe(l) + return buf.to_s_unsafe(l, copy=false) end # Escape the characters `<`, `>`, `&`, `"`, `'` and `/` as HTML/XML entity references. @@ -1114,7 +1114,7 @@ abstract class Text # # var ns = new CString(8) # "Text is String".copy_to_native(ns, 8, 2, 0) - # assert ns.to_s_unsafe(8) == "xt is St" + # assert ns.to_s_with_length(8) == "xt is St" # fun copy_to_native(dest: CString, n, src_offset, dest_offset: Int) do var mypos = src_offset @@ -1798,7 +1798,7 @@ redef class Byte var ns = new CString(nslen + 1) ns[nslen] = 0u8 native_byte_to_s(ns, nslen + 1) - return ns.to_s_unsafe(nslen) + return ns.to_s_unsafe(nslen, copy=false, clean=false) end end @@ -1987,7 +1987,7 @@ redef class Char var ln = u8char_len var ns = new CString(ln + 1) u8char_tos(ns, ln) - return ns.to_s_unsafe(ln) + return ns.to_s_unsafe(ln, copy=false, clean=false) end # Returns `self` escaped to UTF-16 diff --git a/lib/core/text/flat.nit b/lib/core/text/flat.nit index ac006db..a28a264 100644 --- a/lib/core/text/flat.nit +++ b/lib/core/text/flat.nit @@ -329,7 +329,7 @@ redef class FlatText end pos += 1 end - return nns.to_s_unsafe(nlen) + return nns.to_s_unsafe(nlen, copy=false, clean=false) end redef fun [](index) do diff --git a/lib/core/time.nit b/lib/core/time.nit index 606ccd8..74c9818 100644 --- a/lib/core/time.nit +++ b/lib/core/time.nit @@ -55,8 +55,8 @@ extern class TimeT `{time_t`} fun update `{ time(&self); `} # Convert `self` to a human readable String. - fun ctime: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy( ctime(&self) ); + fun ctime: String import CString.to_s `{ + return CString_to_s( ctime(&self) ); `} # Difference in secondes from start (self if the end time) @@ -136,19 +136,19 @@ extern class Tm `{struct tm *`} # Convert `self` to a human readable String corresponding to `format`. # TODO document allowed format. - fun strftime(format: String): String import String.to_cstring, CString.to_s_with_copy `{ + fun strftime(format: String): String import String.to_cstring, CString.to_s `{ char* buf, *c_format; buf = (char*)malloc(100); c_format = String_to_cstring(format); strftime(buf, 100, c_format, self); - String s = CString_to_s_with_copy(buf); + String s = CString_to_s(buf); free(buf); return s; `} - redef fun to_s do return asctime.to_s_with_copy.replace("\n", "") + redef fun to_s do return asctime.to_s.replace("\n", "") end # Date using the international format defined by ISO 8601. diff --git a/lib/curl/native_curl.nit b/lib/curl/native_curl.nit index f802e75..d611dbf 100644 --- a/lib/curl/native_curl.nit +++ b/lib/curl/native_curl.nit @@ -250,11 +250,11 @@ extern class NativeCurl `{ CURL * `} `} # Convert given string to URL encoded string - fun escape(url: String): String import String.to_cstring, CString.to_s_with_copy `{ + fun escape(url: String): String import String.to_cstring, CString.to_s `{ char *orig_url, *encoded_url = NULL; orig_url = String_to_cstring(url); encoded_url = curl_easy_escape( self, orig_url, strlen(orig_url)); - String b_url = CString_to_s_with_copy(encoded_url); + String b_url = CString_to_s(encoded_url); curl_free(encoded_url); return b_url; `} @@ -279,9 +279,9 @@ extern class CURLCode `{ CURLcode `} fun is_valid_protocol: Bool `{ return self == CURLE_UNSUPPORTED_PROTOCOL; `} fun is_valid_init: Bool `{ return self == CURLE_FAILED_INIT; `} fun to_i: Int do return code end - redef fun to_s import CString.to_s_with_copy `{ + redef fun to_s import CString.to_s `{ char *c = (char*)curl_easy_strerror(self); - return CString_to_s_with_copy(c); + return CString_to_s(c); `} end diff --git a/lib/gtk/v3_4/gtk_assistant.nit b/lib/gtk/v3_4/gtk_assistant.nit index 5838e5c..09140cb 100644 --- a/lib/gtk/v3_4/gtk_assistant.nit +++ b/lib/gtk/v3_4/gtk_assistant.nit @@ -72,8 +72,8 @@ extern class GtkAssistant `{GtkAssistant *`} gtk_assistant_set_page_type(self, page, t); `} - fun get_page_title(page: GtkWidget): String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_assistant_get_page_title(self, page)); + fun get_page_title(page: GtkWidget): String import CString.to_s `{ + return CString_to_s((char *)gtk_assistant_get_page_title(self, page)); `} fun set_page_title(page: GtkWidget, title: String) import String.to_cstring `{ diff --git a/lib/gtk/v3_4/gtk_core.nit b/lib/gtk/v3_4/gtk_core.nit index c3617f1..225d4ce 100644 --- a/lib/gtk/v3_4/gtk_core.nit +++ b/lib/gtk/v3_4/gtk_core.nit @@ -331,8 +331,8 @@ extern class GtkFrame `{GtkFrame *`} return (GtkFrame *)gtk_frame_new(String_to_cstring(lbl)); `} - fun frame_label: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_frame_get_label(self)); + fun frame_label: String import CString.to_s `{ + return CString_to_s((char *)gtk_frame_get_label(self)); `} fun frame_label=(lbl: String) import String.to_cstring `{ @@ -475,8 +475,8 @@ extern class GtkEntry `{GtkEntry *`} return (GtkEntry *)gtk_entry_new(); `} - fun text: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_entry_get_text(self)); + fun text: String import CString.to_s `{ + return CString_to_s((char *)gtk_entry_get_text(self)); `} fun text=(value: String) import String.to_cstring `{ @@ -682,8 +682,8 @@ extern class GtkLabel `{GtkLabel *`} `} # Returns the text of the label - fun text: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char*)gtk_label_get_text(self)); + fun text: String import CString.to_s `{ + return CString_to_s((char*)gtk_label_get_text(self)); `} # Sets the angle of rotation for the label. @@ -803,8 +803,8 @@ extern class GtkButton `{GtkButton *`} return (GtkButton *)gtk_button_new_from_stock(String_to_cstring(stock_id)); `} - fun text: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_button_get_label(self)); + fun text: String import CString.to_s `{ + return CString_to_s((char *)gtk_button_get_label(self)); `} fun text=(value: String) import String.to_cstring `{ @@ -876,8 +876,8 @@ extern class GtkExpander `{GtkExpander *`} gtk_expander_set_spacing(self, pixels); `} - fun label_text: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_expander_get_label(self)); + fun label_text: String import CString.to_s `{ + return CString_to_s((char *)gtk_expander_get_label(self)); `} fun label_text=(lbl: String) import String.to_cstring `{ @@ -995,8 +995,8 @@ extern class GtkComboBox `{GtkComboBox *`} gtk_combo_box_set_id_column(self, id_column); `} - fun active_id: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_combo_box_get_active_id(self)); + fun active_id: String import CString.to_s `{ + return CString_to_s((char *)gtk_combo_box_get_active_id(self)); `} fun active_id=(id_active: String) import String.to_cstring `{ @@ -1019,8 +1019,8 @@ extern class GtkComboBox `{GtkComboBox *`} gtk_combo_box_popdown(self); `} - fun title: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_combo_box_get_title(self)); + fun title: String import CString.to_s `{ + return CString_to_s((char *)gtk_combo_box_get_title(self)); `} fun title=(t: String) import String.to_cstring `{ diff --git a/lib/gtk/v3_4/gtk_dialogs.nit b/lib/gtk/v3_4/gtk_dialogs.nit index ade1741..8184d9f 100644 --- a/lib/gtk/v3_4/gtk_dialogs.nit +++ b/lib/gtk/v3_4/gtk_dialogs.nit @@ -52,40 +52,40 @@ extern class GtkAboutDialog `{GtkAboutDialog *`} return (GtkAboutDialog *)gtk_about_dialog_new(); `} - fun program_name: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_about_dialog_get_program_name(self)); + fun program_name: String import CString.to_s `{ + return CString_to_s((char *)gtk_about_dialog_get_program_name(self)); `} fun program_name=(name: String) import String.to_cstring `{ gtk_about_dialog_set_program_name(self, String_to_cstring(name)); `} - fun version: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_about_dialog_get_version(self)); + fun version: String import CString.to_s `{ + return CString_to_s((char *)gtk_about_dialog_get_version(self)); `} fun version=(v: String) import String.to_cstring `{ gtk_about_dialog_set_version(self, String_to_cstring(v)); `} - fun copyright: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_about_dialog_get_copyright(self)); + fun copyright: String import CString.to_s `{ + return CString_to_s((char *)gtk_about_dialog_get_copyright(self)); `} fun copyright=(c: String) import String.to_cstring `{ gtk_about_dialog_set_copyright(self, String_to_cstring(c)); `} - fun comments: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_about_dialog_get_comments(self)); + fun comments: String import CString.to_s `{ + return CString_to_s((char *)gtk_about_dialog_get_comments(self)); `} fun comments=(com: String) import String.to_cstring `{ gtk_about_dialog_set_comments(self, String_to_cstring(com)); `} - fun license: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_about_dialog_get_license(self)); + fun license: String import CString.to_s `{ + return CString_to_s((char *)gtk_about_dialog_get_license(self)); `} fun license=(li: String) import String.to_cstring `{ @@ -94,16 +94,16 @@ extern class GtkAboutDialog `{GtkAboutDialog *`} # license_type - fun website: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_about_dialog_get_website(self)); + fun website: String import CString.to_s `{ + return CString_to_s((char *)gtk_about_dialog_get_website(self)); `} fun website=(link: String) import String.to_cstring `{ gtk_about_dialog_set_website(self, String_to_cstring(link)); `} - fun website_label: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *) gtk_about_dialog_get_website_label(self)); + fun website_label: String import CString.to_s `{ + return CString_to_s((char *) gtk_about_dialog_get_website_label(self)); `} fun website_label=(link_label: String) import String.to_cstring `{ @@ -111,8 +111,8 @@ extern class GtkAboutDialog `{GtkAboutDialog *`} `} # TODO - # fun authors: String import CString.to_s_with_copy `{ - # return CString_to_s_with_copy(gtk_about_dialog_get_authors(self)); + # fun authors: String import CString.to_s `{ + # return CString_to_s(gtk_about_dialog_get_authors(self)); # `} # TODO @@ -144,8 +144,8 @@ extern class GtkAppChooserDialog `{GtkAppChooserDialog *`} fun widget: GtkWidget `{ return gtk_app_chooser_dialog_get_widget(self); `} - fun heading: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_app_chooser_dialog_get_heading(self)); + fun heading: String import CString.to_s `{ + return CString_to_s((char *)gtk_app_chooser_dialog_get_heading(self)); `} fun heading=(text: String) import String.to_cstring `{ diff --git a/lib/gtk/v3_4/gtk_widgets_ext.nit b/lib/gtk/v3_4/gtk_widgets_ext.nit index 63cdb1e..323c14e 100644 --- a/lib/gtk/v3_4/gtk_widgets_ext.nit +++ b/lib/gtk/v3_4/gtk_widgets_ext.nit @@ -131,8 +131,8 @@ extern class GtkProgressBar `{GtkProgressBar *`} gtk_progress_bar_set_show_text(self, show); `} - fun text: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy((char *)gtk_progress_bar_get_text(self)); + fun text: String import CString.to_s `{ + return CString_to_s((char *)gtk_progress_bar_get_text(self)); `} fun text=(value: String) import String.to_cstring `{ diff --git a/lib/mongodb/mongodb.nit b/lib/mongodb/mongodb.nit index 06b469e..fdc03b6 100644 --- a/lib/mongodb/mongodb.nit +++ b/lib/mongodb/mongodb.nit @@ -92,7 +92,7 @@ private class BSON redef fun to_s do var ns = native.to_c_string - var res = ns.to_s_with_copy + var res = ns.to_s ns.free # manual free of gc allocated CString return res end @@ -147,7 +147,7 @@ class MongoError # Human readable error message. fun message: String do var ns = native.message - var res = ns.to_s_with_copy + var res = ns.to_s ns.free return res end @@ -237,7 +237,7 @@ class MongoClient var i = 0 var name = nas[i] while not name.address_is_null do - res.add name.to_s_with_copy + res.add name.to_s name.free i += 1 name = nas[i] @@ -323,7 +323,7 @@ class MongoDb var i = 0 var name = nas[i] while not name.address_is_null do - res.add name.to_s_with_copy + res.add name.to_s name.free i += 1 name = nas[i] diff --git a/lib/mongodb/native_mongodb.nit b/lib/mongodb/native_mongodb.nit index cf674f5..05f2d19 100644 --- a/lib/mongodb/native_mongodb.nit +++ b/lib/mongodb/native_mongodb.nit @@ -123,10 +123,10 @@ extern class BSONObjectId `{ bson_oid_t * `} `} # Object id. - fun id: String import CString.to_s_with_copy `{ + fun id: String import CString.to_s `{ char str[25]; bson_oid_to_string(self, str); - return CString_to_s_with_copy(str); + return CString_to_s(str); `} # Destroy `self`. diff --git a/lib/socket/socket.nit b/lib/socket/socket.nit index 2d17656..96944f1 100644 --- a/lib/socket/socket.nit +++ b/lib/socket/socket.nit @@ -407,7 +407,7 @@ class UDPSocket error = new IOError.from_errno return "" end - return buf.to_s_with_length(len) + return buf.to_s_unsafe(len, copy=false) end # Receive `length` bytes of data from any sender and store the sender info in `sender.item` @@ -426,7 +426,7 @@ class UDPSocket end sender.item = new SocketAddress(src) - return buf.to_s_with_length(len) + return buf.to_s_unsafe(len, copy=false) end # Send `data` to `dest_address` on `port` diff --git a/lib/sqlite3/sqlite3.nit b/lib/sqlite3/sqlite3.nit index 43af40d..daa980b 100644 --- a/lib/sqlite3/sqlite3.nit +++ b/lib/sqlite3/sqlite3.nit @@ -252,7 +252,7 @@ class StatementEntry var c_string = statement.native_statement.column_text(index) if c_string.address_is_null then return "" - return c_string.to_s_with_copy + return c_string.to_s end # Get this entry as `Blob` diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 96ae7a3..47f813d 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -1711,7 +1711,7 @@ abstract class AbstractCompilerVisitor self.add("{nat} = \"{string.escape_to_c}\";") var byte_length = self.int_instance(string.byte_length) var unilen = self.int_instance(string.length) - self.add("{res} = {self.send(self.get_property("to_s_full", native_mtype), [nat, byte_length, unilen]).as(not null)};") + self.add("{res} = {self.send(self.get_property("to_s_unsafe", native_mtype), [nat, byte_length, unilen, value_instance(false), value_instance(false)]).as(not null)};") self.add("{name} = {res};") self.add("\}") return res diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index c4f7ac3..34530b7 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -353,7 +353,7 @@ class NaiveInterpreter fun string_instance(txt: String): Instance do var nat = c_string_instance(txt) - var res = self.send(self.force_get_primitive_method("to_s_full", nat.mtype), [nat, self.int_instance(txt.byte_length), self.int_instance(txt.length)]) + var res = self.send(self.force_get_primitive_method("to_s_unsafe", nat.mtype), [nat, self.int_instance(txt.byte_length), self.int_instance(txt.length), self.false_instance, self.false_instance]) assert res != null return res end diff --git a/src/interpreter/primitive_types.nit b/src/interpreter/primitive_types.nit index 129d0c6..ba058c1 100644 --- a/src/interpreter/primitive_types.nit +++ b/src/interpreter/primitive_types.nit @@ -56,7 +56,7 @@ class PrimitiveNativeFile fun io_write(buf: CString, from, len: Int): Int do if file isa FileStream then return file.as(FileStream)._file.io_write(buf, from, len) - file.as(Writer).write(buf.to_s_with_length(len).substring_from(from)) + file.as(Writer).write(buf.to_s_unsafe(len, copy=false).substring_from(from)) return len end diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 99cf96c..0c08063 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -589,7 +589,7 @@ redef class AStringFormExpr do var native = v.analysis.mainmodule.c_string_type v.add_type(native) - var prop = v.get_method(native, "to_s_full") + var prop = v.get_method(native, "to_s_unsafe") v.add_monomorphic_send(native, prop) v.add_callsite(to_re) v.add_callsite(ignore_case) diff --git a/tests/sav/error_needed_method_alt3.res b/tests/sav/error_needed_method_alt3.res index 60df1cb..0f58952 100644 --- a/tests/sav/error_needed_method_alt3.res +++ b/tests/sav/error_needed_method_alt3.res @@ -1 +1 @@ -alt/error_needed_method_alt3.nit:48,9--13: Fatal Error: `CString` 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_unsafe`. diff --git a/tests/sav/niti/error_needed_method_alt4.res b/tests/sav/niti/error_needed_method_alt4.res index b1bbd91..01f1b47 100644 --- a/tests/sav/niti/error_needed_method_alt4.res +++ b/tests/sav/niti/error_needed_method_alt4.res @@ -1 +1 @@ -alt/error_needed_method_alt4.nit:49,10--14: Fatal Error: `CString` 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_unsafe`. diff --git a/tests/sav/nitpretty_args21.res b/tests/sav/nitpretty_args21.res index 3182a71..7fca201 100644 --- a/tests/sav/nitpretty_args21.res +++ b/tests/sav/nitpretty_args21.res @@ -70,8 +70,8 @@ extern class TimeT `{time_t`} new from_i(i: Int) `{ return i; `} fun update `{ time(&self); `} - fun ctime: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy( ctime(&self) ); + fun ctime: String import CString.to_s `{ + return CString_to_s( ctime(&self) ); `} # Difference in secondes from start (self if the end time) diff --git a/tests/sav/nitpretty_args52.res b/tests/sav/nitpretty_args52.res index 94f2a3a..85f8367 100644 --- a/tests/sav/nitpretty_args52.res +++ b/tests/sav/nitpretty_args52.res @@ -71,8 +71,8 @@ extern class TimeT `{time_t`} fun update `{ time(&self); `} - fun ctime: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy( ctime(&self) ); + fun ctime: String import CString.to_s `{ + return CString_to_s( ctime(&self) ); `} # Difference in secondes from start (self if the end time) diff --git a/tests/sav/nitserial_args1.res b/tests/sav/nitserial_args1.res index 4cdda33..f82f50e 100644 --- a/tests/sav/nitserial_args1.res +++ b/tests/sav/nitserial_args1.res @@ -16,12 +16,12 @@ redef class Deserializer if name == "Array[String]" then return new Array[String].from_deserializer(self) if name == "Array[Error]" then return new Array[Error].from_deserializer(self) if name == "POSet[String]" then return new POSet[String].from_deserializer(self) + if name == "Array[Int]" then return new Array[Int].from_deserializer(self) if name == "Array[nullable Object]" then return new Array[nullable Object].from_deserializer(self) if name == "HashSet[String]" then return new HashSet[String].from_deserializer(self) if name == "Array[nullable FlatString]" then return new Array[nullable FlatString].from_deserializer(self) if name == "Array[FlatString]" then return new Array[FlatString].from_deserializer(self) if name == "Array[nullable Int]" then return new Array[nullable Int].from_deserializer(self) - if name == "Array[Int]" then return new Array[Int].from_deserializer(self) if name == "Array[nullable Float]" then return new Array[nullable Float].from_deserializer(self) if name == "Array[Float]" then return new Array[Float].from_deserializer(self) if name == "Array[Object]" then return new Array[Object].from_deserializer(self) diff --git a/tests/string_ffi_ref_test.nit b/tests/string_ffi_ref_test.nit index 18b98b7..56461e1 100644 --- a/tests/string_ffi_ref_test.nit +++ b/tests/string_ffi_ref_test.nit @@ -25,13 +25,13 @@ class StringTest var referenced_str: nullable String = null - fun get_c_string import FlatString.items, CString.to_s, CString.to_s_with_copy, StringTest.ref_test, StringTest.copy_test `{ + fun get_c_string import FlatString.items, CString.to_s, CString.to_s, StringTest.ref_test, StringTest.copy_test `{ char* string = "This is a test string"; FlatString ref_string = CString_to_s(string); StringTest_ref_test(self, ref_string); - FlatString copy_string = CString_to_s_with_copy(string); + FlatString copy_string = CString_to_s(string); StringTest_copy_test(self, copy_string); int same_refs = FlatString_items(copy_string) == FlatString_items(ref_string); diff --git a/tests/test_copy_to_native.nit b/tests/test_copy_to_native.nit index f7ab36f..d52d920 100644 --- a/tests/test_copy_to_native.nit +++ b/tests/test_copy_to_native.nit @@ -25,4 +25,4 @@ var str: String = base_str var copy_len = (str.byte_length - 4).min(9) str.copy_to_native(ons, copy_len, 4, 0) -print ons.to_s_with_length(copy_len) +print ons.to_s_unsafe(copy_len, copy=false) diff --git a/tests/test_nativestring_fill_from.nit b/tests/test_nativestring_fill_from.nit index 51d917b..91aa315 100644 --- a/tests/test_nativestring_fill_from.nit +++ b/tests/test_nativestring_fill_from.nit @@ -24,4 +24,4 @@ var cpstr: Text = src_s var ns = new CString(cpstr.byte_length) ns.fill_from(cpstr) -print ns.to_s_with_length(cpstr.byte_length) +print ns.to_s_unsafe(cpstr.byte_length, copy=false) diff --git a/tests/test_pretty/test_extern1.nit b/tests/test_pretty/test_extern1.nit index 40f9579..a7b3b0d 100644 --- a/tests/test_pretty/test_extern1.nit +++ b/tests/test_pretty/test_extern1.nit @@ -70,8 +70,8 @@ extern class TimeT `{time_t`} fun update `{ time(&self); `} - fun ctime: String import CString.to_s_with_copy `{ - return CString_to_s_with_copy( ctime(&self) ); + fun ctime: String import CString.to_s `{ + return CString_to_s( ctime(&self) ); `} # Difference in secondes from start (self if the end time) -- 1.7.9.5