lib: some update towards more use of new constructors
authorJean Privat <privat@pryen.org>
Sat, 27 Sep 2014 02:48:03 +0000 (22:48 -0400)
committerJean Privat <privat@pryen.org>
Sat, 27 Sep 2014 09:38:14 +0000 (05:38 -0400)
Signed-off-by: Jean Privat <privat@pryen.org>

contrib/pep8analysis/src/cfg/cfg_base.nit
lib/android/audio.nit
lib/neo4j/neo4j.nit
lib/socket/socket.nit
lib/standard/collection/array.nit
lib/standard/collection/list.nit
lib/standard/exec.nit
lib/standard/ropes.nit
lib/standard/stream.nit
lib/standard/string.nit

index c4de901..d42a4b3 100644 (file)
@@ -376,7 +376,7 @@ class CFG
 end
 
 class BasicBlock
-       var name : String
+       var name: String is noinit
        var lines = new Array[ANonEmptyLine]
        var successors = new Array[BasicBlock]
        var predecessors = new Array[BasicBlock]
index 8d3264f..e640621 100644 (file)
@@ -232,10 +232,10 @@ end
 # The Android MediaPlayer has a complex state diagram that you'll need to
 # respect if you want your MediaPlayer to work fine, see the android doc
 class MediaPlayer
-       private var nmedia_player: NativeMediaPlayer
+       private var nmedia_player: NativeMediaPlayer is noinit
 
        # The sound associated with this mediaplayer
-       var sound: nullable Sound
+       var sound: nullable Sound = null
 
        # Create a new MediaPlayer, but no sound is attached, you'll need
        # to use `load_sound` before using it
index 41fc26b..385b966 100644 (file)
@@ -384,14 +384,12 @@ end
 # For more details, see: http://docs.neo4j.org/chunked/milestone/rest-api-cypher.html
 class CypherQuery
        # Query string to perform
-       private var query: String
+       private var query: String = ""
 
        # `params` to embed in the query like in prepared statements
        var params = new JsonObject
 
-       init do
-               self.query = ""
-       end
+       init do end
 
        # init the query from a query string
        init from_string(query: String) do
@@ -488,10 +486,10 @@ end
 #     assert node["name"] == "Andres"  # loaded lazily from base
 abstract class NeoEntity
        # Neo4j client connector
-       private var neo: Neo4jClient
+       private var neo: Neo4jClient is noinit
 
        # Entity unique URL in Neo4j REST API
-       var url: nullable String
+       var url: nullable String = null
 
        # Temp id used in batch mode to update the entity
        private var batch_id: nullable Int = null
index 7dee2ef..aad6449 100644 (file)
@@ -28,20 +28,20 @@ class Socket
 
        # IPv4 address the socket is connected to
        # Formatted as xxx.xxx.xxx.xxx
-       var address: String
+       var address: String is noinit
 
        # Hostname of the socket connected to self
        # In C : The real canonical host name (e.g. example.org)
-       var host: nullable String
+       var host: nullable String = null
 
        # Port open for the socket
-       var port: Int
+       var port: Int is noinit
 
        # Underlying C socket
-       private var socket: FFSocket
+       private var socket: FFSocket is noinit
 
        # Underlying C socket
-       private var addrin: FFSocketAddrIn
+       private var addrin: FFSocketAddrIn is noinit
 
        redef var end_reached = false
 
index 61e8700..f106b25 100644 (file)
@@ -416,7 +416,7 @@ class ArraySet[E: Object]
        super Set[E]
 
        # The stored elements.
-       private var array: Array[E]
+       private var array: Array[E] is noinit
 
        redef fun has(e) do return _array.has(e)
 
index 08a8459..4487ec3 100644 (file)
@@ -210,10 +210,10 @@ class List[E]
        init from(coll: Collection[E]) do append(coll)
 
        # The first node of the list
-       private var head: nullable ListNode[E]
+       private var head: nullable ListNode[E] = null
 
        # The last node of the list
-       private var tail: nullable ListNode[E]
+       private var tail: nullable ListNode[E] = null
 
        # Get the `i`th node. get `null` otherwise.
        private fun get_node(i: Int): nullable ListNode[E]
index 347e123..150ed48 100644 (file)
@@ -92,7 +92,7 @@ end
 class IProcess
        super Process
        super IStream
-       var stream_in: FDIStream
+       var stream_in: FDIStream is noinit
 
        redef fun close do stream_in.close
 
@@ -102,8 +102,6 @@ class IProcess
 
        redef fun pipeflags do return 2
 
-       redef init(command: String, arguments: String...) do super
-
        redef fun execute
        do
                super
@@ -115,7 +113,7 @@ end
 class OProcess
        super Process
        super OStream
-       var stream_out: OStream
+       var stream_out: OStream is noinit
 
        redef fun close do stream_out.close
 
@@ -125,8 +123,6 @@ class OProcess
 
        redef fun pipeflags do return 1
 
-       redef init(command: String, arguments: String...) do super
-
        redef fun execute
        do
                super
@@ -148,8 +144,6 @@ class IOProcess
 
        redef fun pipeflags do return 3
 
-       redef init(command: String, arguments: String...) do super
-
        redef fun execute
        do
                super
index 843096f..ad97500 100644 (file)
@@ -114,7 +114,7 @@ abstract class Rope
        super Text
 
        # Root node, entry point of a Rope.
-       private var root: RopeNode
+       private var root: RopeNode is noinit
 
        # Cached version of self as a flat String
        private var str_representation: nullable NativeString = null
index 5932daa..6b70e21 100644 (file)
@@ -288,8 +288,6 @@ abstract class FDStream
        private fun native_read(i: Int, buf: NativeString, len: Int): Int is extern "stream_FDStream_FDStream_native_read_3"
        private fun native_write(i: Int, buf: NativeString, len: Int): Int is extern "stream_FDStream_FDStream_native_write_3"
        private fun native_write_char(i: Int, c: Char): Int is extern "stream_FDStream_FDStream_native_write_char_2"
-
-       init(fd: Int) do self.fd = fd
 end
 
 class FDIStream
@@ -303,36 +301,24 @@ class FDIStream
                if nb == -1 then eof = true
                return nb
        end
-
-       init(fd: Int) do end 
 end
 
 class FDOStream
        super FDStream
        super OStream
-       redef var is_writable: Bool
+       redef var is_writable = true
 
        redef fun write(s)
        do
                var nb = native_write(fd, s.to_cstring, s.length)
                if nb < s.length then is_writable = false
        end
-
-       init(fd: Int)
-       do
-               is_writable = true
-       end
 end
 
 class FDIOStream
        super FDIStream
        super FDOStream
        super IOStream
-       init(fd: Int)
-       do
-               self.fd = fd
-               is_writable = true
-       end
 end
 
 redef interface Object
index a81bdd6..3eede86 100644 (file)
@@ -663,7 +663,7 @@ abstract class FlatText
        #
        # Warning : Might be void in some subclasses, be sure to check
        # if set before using it.
-       private var items: NativeString
+       private var items: NativeString is noinit
 
        # Real items, used as cache for to_cstring is called
        private var real_items: nullable NativeString = null
@@ -887,10 +887,10 @@ class FlatString
        super String
 
        # Index in _items of the start of the string
-       private var index_from: Int
+       private var index_from: Int is noinit
 
        # Indes in _items of the last item of the string
-       private var index_to: Int
+       private var index_to: Int is noinit
 
        redef var chars: SequenceRead[Char] = new FlatStringCharView(self)