update all indirect references to native strings
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 8 Dec 2016 20:25:41 +0000 (15:25 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 13 Dec 2016 04:05:18 +0000 (23:05 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

12 files changed:
contrib/pep8analysis/www/index.html
contrib/pep8analysis/www/worker.js
lib/binary/serialization.nit
lib/mongodb/mongodb.nit
lib/mongodb/native_mongodb.nit
lib/sqlite3/sqlite3.nit
src/compiler/abstract_compiler.nit
src/interpreter/dynamic_loading_ffi/dynamic_loading_ffi.nit
src/interpreter/naive_interpreter.nit
src/model/model.nit
src/rapid_type_analysis.nit
src/semantize/typing.nit

index f3ec358..045087f 100644 (file)
@@ -91,7 +91,7 @@
                                _gaq.push(['_trackEvent', 'Bug', 'No Webworkers', $("#console").text()])
                                Module = Pep8Module
                                try {
-                                       run_analysis = Module.cwrap('pep8analysis_web___NativeString_run_analysis', null, ['string'])
+                                       run_analysis = Module.cwrap('pep8analysis_web___CString_run_analysis', null, ['string'])
                                        run_analysis(input)
 
                                        complete()
index 6b20007..1b7a7a9 100644 (file)
@@ -6,7 +6,7 @@ var Module = {
        'TOTAL_MEMORY': 512000000
 }
 importScripts("pep8analysis.js")
-run_analysis = Module.cwrap('pep8analysis_web___NativeString_run_analysis', null, ['string'])
+run_analysis = Module.cwrap('pep8analysis_web___CString_run_analysis', null, ['string'])
 
 function show_graph(data) {
        postMessage({'type':"show_graph", 'data': data})
index 34de766..be2b5ae 100644 (file)
@@ -53,7 +53,7 @@ private fun kind_bool: Byte do return 0x05u8
 private fun kind_char: Byte do return 0x06u8
 private fun kind_float: Byte do return 0x07u8
 private fun kind_string: Byte do return 0x08u8
-private fun kind_native_string: Byte do return 0x09u8
+private fun kind_c_string: Byte do return 0x09u8
 private fun kind_flat_array: Byte do return 0x0Au8
 
 private fun new_object_end: Byte do return 0x00u8
@@ -233,7 +233,7 @@ class BinaryDeserializer
                        return bf.to_s_with_length(ln)[0]
                end
                if kind == kind_string then return stream.read_block
-               if kind == kind_native_string then return stream.read_block.to_cstring
+               if kind == kind_c_string then return stream.read_block.to_cstring
 
                if kind == kind_flat_array then
                        # An array
@@ -406,7 +406,7 @@ end
 redef class CString
        redef fun serialize_to_binary(v)
        do
-               v.stream.write_byte kind_native_string
+               v.stream.write_byte kind_c_string
                v.stream.write_block to_s
        end
 end
index e7416f8..06b469e 100644 (file)
@@ -91,7 +91,7 @@ private class BSON
        end
 
        redef fun to_s do
-               var ns = native.to_native_string
+               var ns = native.to_c_string
                var res = ns.to_s_with_copy
                ns.free # manual free of gc allocated CString
                return res
index 692d08a..cf674f5 100644 (file)
@@ -64,7 +64,7 @@ extern class NativeBSON `{ bson_t * `}
        # The `bson_as_json()` function shall encode bson as a JSON encoded UTF-8 string.
        # The caller is responsible for freeing the resulting UTF-8 encoded string
        # by calling `bson_free()` with the result.
-       fun to_native_string: CString `{ return bson_as_json(self, NULL); `}
+       fun to_c_string: CString `{ return bson_as_json(self, NULL); `}
 
        # Wrapper for `bson_destroy()`.
        #
index ba45bc5..43af40d 100644 (file)
@@ -250,9 +250,9 @@ class StatementEntry
        do
                assert statement_closed: statement.is_open
 
-               var native_string = statement.native_statement.column_text(index)
-               if native_string.address_is_null then return ""
-               return native_string.to_s_with_copy
+               var c_string = statement.native_statement.column_text(index)
+               if c_string.address_is_null then return ""
+               return c_string.to_s_with_copy
        end
 
        # Get this entry as `Blob`
index 9602fa7..96ae7a3 100644 (file)
@@ -1685,8 +1685,8 @@ abstract class AbstractCompilerVisitor
        end
 
        # Generates a CString instance fully escaped in C-style \xHH fashion
-       fun native_string_instance(ns: CString, len: Int): RuntimeVariable do
-               var mtype = mmodule.native_string_type
+       fun c_string_instance(ns: CString, len: Int): RuntimeVariable do
+               var mtype = mmodule.c_string_type
                var nat = new_var(mtype)
                var byte_esc = new Buffer.with_cap(len * 4)
                for i in [0 .. len[ do
@@ -1706,7 +1706,7 @@ abstract class AbstractCompilerVisitor
                self.add("if (likely({name}!=NULL)) \{")
                self.add("{res} = {name};")
                self.add("\} else \{")
-               var native_mtype = mmodule.native_string_type
+               var native_mtype = mmodule.c_string_type
                var nat = self.new_var(native_mtype)
                self.add("{nat} = \"{string.escape_to_c}\";")
                var byte_length = self.int_instance(string.byte_length)
@@ -3726,7 +3726,7 @@ redef class AStringExpr
                var s = v.string_instance(value)
                if is_string then return s
                if is_bytestring then
-                       var ns = v.native_string_instance(bytes.items, bytes.length)
+                       var ns = v.c_string_instance(bytes.items, bytes.length)
                        var ln = v.int_instance(bytes.length)
                        var cs = to_bytes_with_copy
                        assert cs != null
@@ -3800,7 +3800,7 @@ redef class ASuperstringExpr
                        v.native_array_set(a, i, e)
                end
 
-               # Fast join the native string to get the result
+               # Fast join the C string to get the result
                var res = v.send(v.get_property("native_to_s", a.mtype), [a])
                assert res != null
 
index c748ad9..077ab37 100644 (file)
@@ -131,7 +131,7 @@ private extern class CallArg `{ nit_call_arg* `}
        fun instance=(value: Instance) is light_ffi `{ self->value_Pointer = value; `}
 
        # The `CString` held by this cell
-       fun native_string: CString `{ return (char*)self->value_Pointer; `}
+       fun c_string: CString `{ return (char*)self->value_Pointer; `}
 
        # Set the content of this cell according to `static_type`
        #
@@ -208,7 +208,7 @@ private extern class CallArg `{ nit_call_arg* `}
                else if name == "Float" then
                        return v.float_instance(self.float)
                else if name == "CString" then
-                       var instance = new PrimitiveInstance[CString](static_type, self.native_string)
+                       var instance = new PrimitiveInstance[CString](static_type, self.c_string)
                        v.init_instance_primitive instance
                        return instance
                else if static_type isa MClassType and static_type.mclass.kind == extern_kind then
index 5c9b27f..c4f7ac3 100644 (file)
@@ -317,10 +317,10 @@ class NaiveInterpreter
                end
        end
 
-       # Return a new native string initialized with `txt`
-       fun native_string_instance(txt: String): Instance
+       # Return a new C string initialized with `txt`
+       fun c_string_instance(txt: String): Instance
        do
-               var instance = native_string_instance_len(txt.byte_length+1)
+               var instance = c_string_instance_len(txt.byte_length+1)
                var val = instance.val
                val[txt.byte_length] = 0u8
                txt.to_cstring.copy_to(val, txt.byte_length, 0, 0)
@@ -328,22 +328,22 @@ class NaiveInterpreter
                return instance
        end
 
-       # Return a new native string initialized with `txt`
-       fun native_string_instance_from_ns(txt: CString, len: Int): Instance
+       # Return a new C string initialized with `txt`
+       fun c_string_instance_from_ns(txt: CString, len: Int): Instance
        do
-               var instance = native_string_instance_len(len)
+               var instance = c_string_instance_len(len)
                var val = instance.val
                txt.copy_to(val, len, 0, 0)
 
                return instance
        end
 
-       # Return a new native string initialized of `length`
-       fun native_string_instance_len(length: Int): PrimitiveInstance[CString]
+       # Return a new C string initialized of `length`
+       fun c_string_instance_len(length: Int): PrimitiveInstance[CString]
        do
                var val = new CString(length)
 
-               var t = mainmodule.native_string_type
+               var t = mainmodule.c_string_type
                var instance = new PrimitiveInstance[CString](t, val)
                init_instance_primitive(instance)
                return instance
@@ -352,7 +352,7 @@ class NaiveInterpreter
        # Return a new String instance for `txt`
        fun string_instance(txt: String): Instance
        do
-               var nat = native_string_instance(txt)
+               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)])
                assert res != null
                return res
@@ -941,7 +941,7 @@ redef class AMethPropdef
                else if pname == "native_class_name" then
                        var recv = args.first
                        var txt = recv.mtype.to_s
-                       return v.native_string_instance(txt)
+                       return v.c_string_instance(txt)
                else if pname == "==" then
                        # == is correctly redefined for instances
                        return v.bool_instance(args[0] == args[1])
@@ -952,7 +952,7 @@ redef class AMethPropdef
                else if pname == "is_same_instance" then
                        return v.bool_instance(args[0].eq_is(args[1]))
                else if pname == "class_inheritance_metamodel_json" then
-                       return v.native_string_instance(v.mainmodule.flatten_mclass_hierarchy.to_thin_json)
+                       return v.c_string_instance(v.mainmodule.flatten_mclass_hierarchy.to_thin_json)
                else if pname == "exit" then
                        exit(args[1].to_i)
                        abort
@@ -1150,7 +1150,7 @@ redef class AMethPropdef
                        end
                else if cname == "CString" then
                        if pname == "new" then
-                               return v.native_string_instance_len(args[1].to_i)
+                               return v.c_string_instance_len(args[1].to_i)
                        end
                        var recvval = args.first.val.as(CString)
                        if pname == "[]" then
@@ -1172,7 +1172,7 @@ redef class AMethPropdef
                                return v.int_instance(recvval.atoi)
                        else if pname == "fast_cstring" then
                                var ns = recvval.fast_cstring(args[1].to_i)
-                               return v.native_string_instance(ns.to_s)
+                               return v.c_string_instance(ns.to_s)
                        else if pname == "fetch_4_chars" then
                                return v.int_instance(args[0].val.as(CString).fetch_4_chars(args[1].to_i))
                        else if pname == "fetch_4_hchars" then
@@ -1468,7 +1468,7 @@ redef class AMethPropdef
                        return v.int_instance(v.arguments.length)
                else if pname == "native_argv" then
                        var txt = v.arguments[args[1].to_i]
-                       return v.native_string_instance(txt)
+                       return v.c_string_instance(txt)
                else if pname == "lexer_goto" then
                        return v.int_instance(lexer_goto(args[1].to_i, args[2].to_i))
                else if pname == "lexer_accept" then
@@ -2019,7 +2019,7 @@ redef class AStringExpr
                var s = v.string_instance(value)
                if is_string then return s
                if is_bytestring then
-                       var ns = v.native_string_instance_from_ns(bytes.items, bytes.length)
+                       var ns = v.c_string_instance_from_ns(bytes.items, bytes.length)
                        var ln = v.int_instance(bytes.length)
                        var prop = to_bytes_with_copy
                        assert prop != null
index 030cca9..2243a88 100644 (file)
@@ -253,7 +253,7 @@ redef class MModule
        var string_type: MClassType = self.get_primitive_class("String").mclass_type is lazy
 
        # The primitive type `CString`
-       var native_string_type: MClassType = self.get_primitive_class("CString").mclass_type is lazy
+       var c_string_type: MClassType = self.get_primitive_class("CString").mclass_type is lazy
 
        # A primitive type of `Array`
        fun array_type(elt_type: MType): MClassType do return array_class.get_mtype([elt_type])
index b59474f..99cf96c 100644 (file)
@@ -587,7 +587,7 @@ end
 redef class AStringFormExpr
        redef fun accept_rapid_type_visitor(v)
        do
-               var native = v.analysis.mainmodule.native_string_type
+               var native = v.analysis.mainmodule.c_string_type
                v.add_type(native)
                var prop = v.get_method(native, "to_s_full")
                v.add_monomorphic_send(native, prop)
index d586881..7b87faf 100644 (file)
@@ -1487,7 +1487,7 @@ redef class AugmentedStringFormExpr
                var mclass = v.get_mclass(self, "String")
                if mclass == null then return # Forward error
                if is_bytestring then
-                       to_bytes_with_copy = v.get_method(self, v.mmodule.native_string_type, "to_bytes_with_copy", false)
+                       to_bytes_with_copy = v.get_method(self, v.mmodule.c_string_type, "to_bytes_with_copy", false)
                        mclass = v.get_mclass(self, "Bytes")
                else if is_re then
                        to_re = v.get_method(self, mclass.mclass_type, "to_re", false)