lib: prepare for new constructors
authorJean Privat <jean@pryen.org>
Fri, 15 Aug 2014 10:21:22 +0000 (06:21 -0400)
committerJean Privat <jean@pryen.org>
Fri, 15 Aug 2014 10:21:22 +0000 (06:21 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/android/audio.nit
lib/bucketed_game.nit
lib/curl/curl.nit
lib/nitcc_runtime.nit
lib/nitcorn/http_request.nit
lib/nitcorn/sessions.nit
lib/perfect_hashing.nit
lib/realtime.nit
lib/socket/socket.nit
lib/standard/collection/array.nit
lib/standard/ropes.nit

index 3fce628..480238f 100644 (file)
@@ -135,7 +135,7 @@ end
 
 # Used to play sound, best suited for sounds effects in apps or games
 class SoundPool
-       private var nsoundpool: NativeSoundPool
+       private var nsoundpool: NativeSoundPool is noinit
        # The maximum number of simultaneous streams for this SoundPool
        var max_streams writable = 10
 
index b326d29..cdedc32 100644 (file)
@@ -38,7 +38,7 @@ class Buckets[G: Game]
        super Turnable[G]
        type BUCKET: HashSet[Bucketable[G]]
 
-       private var buckets: Array[BUCKET]
+       private var buckets: Array[BUCKET] is noinit
 
        private var next_bucket: nullable BUCKET = null
        private var current_bucket_key: Int = -1
index 33b56a9..fd6e359 100644 (file)
@@ -21,11 +21,10 @@ import curl_c
 
 # Top level of Curl
 class Curl
-       protected var prim_curl: CCurl
+       protected var prim_curl = new CCurl.easy_init
 
        init
        do
-               self.prim_curl = new CCurl.easy_init
                assert curlInstance:self.prim_curl.is_init else
                        print "Curl must be instancied to be used"
                end
index 9d455c8..c71ea6b 100644 (file)
@@ -99,7 +99,7 @@ abstract class Parser
 
        # The current state
        # Used by generated parsers
-       var state: LRState
+       var state: LRState is noinit
 
        init
        do
index 85aef12..1a49e0c 100644 (file)
@@ -61,7 +61,7 @@ end
 # The main method is `parse_http_request`.
 class HttpRequestParser
        # The current `HttpRequest` under construction
-       private var http_request: HttpRequest
+       private var http_request: HttpRequest is noinit
 
        # Untreated body
        private var body = ""
index 9ed5f53..8ae26ac 100644 (file)
@@ -31,7 +31,7 @@ import http_response
 class Session
 
        # Hashed id used both client and server side to identify this `Session`
-       var id_hash: String
+       var id_hash: String is noinit
 
        init
        do
index a4b8417..1a74641 100644 (file)
@@ -24,19 +24,17 @@ class Perfecthashing
        # Union of interval for implementing perfect numbering
        # Represents the interval of free identifiers
        # A null value represents the upper bound of identifier
-       private var interval: List[Couple[nullable Int, nullable Int]]
+       private var interval = new List[Couple[nullable Int, nullable Int]]
 
        # An array used as a temporary Hashtable for 
        # checking there is no collision between identifiers
-       private var tempht: Array[nullable Int]
+       private var tempht = new Array[nullable Int]
 
        # Initialize the structure of free identifiers
        init
        do
                # By default, all identifiers are available
-               interval = new List[Couple[nullable Int, nullable Int]]
                interval.push(new Couple[nullable Int, nullable Int](1, null))
-               tempht = new Array[nullable Int]
        end
        
        # Returns a mask composed by discriminants bits
index 38a601c..68b7834 100644 (file)
@@ -71,16 +71,10 @@ end
 # Keeps track of real time
 class Clock
        # Time at instanciation
-       protected var time_at_beginning : Timespec
+       protected var time_at_beginning = new Timespec.monotonic_now
 
        # Time at last time a lapse method was called
-       protected var time_at_last_lapse : Timespec
-
-       init
-       do
-               time_at_beginning = new Timespec.monotonic_now
-               time_at_last_lapse = new Timespec.monotonic_now
-       end
+       protected var time_at_last_lapse = new Timespec.monotonic_now
 
        # Smallest time frame reported by clock
        fun resolution : Timespec `{
index 8c96d17..d82e1e5 100644 (file)
@@ -211,8 +211,7 @@ class Socket
 end
 
 class SocketSet
-       var sset: FFSocketSet
-       init do sset = new FFSocketSet end
+       var sset = new FFSocketSet
        fun set(s: Socket) do sset.set(s.socket) end
        fun is_set(s: Socket): Bool do return sset.is_set(s.socket) end
        fun zero do sset.zero end
index e98ddea..4848257 100644 (file)
@@ -518,7 +518,7 @@ class ArrayMap[K: Object, E]
        end
 
        # Internal storage.
-       var _items: Array[Couple[K,E]]
+       var _items = new Array[Couple[K,E]]
 
        # fast remove the ith element of the array
        private fun remove_at_index(i: Int)
@@ -547,12 +547,6 @@ class ArrayMap[K: Object, E]
                end
                return -1
        end
-
-       # A new empty map.
-       init
-       do
-               _items = new Array[Couple[K,E]]
-       end
 end
 
 private class ArrayMapKeys[K: Object, E]
index ebc3377..843096f 100644 (file)
@@ -122,7 +122,7 @@ abstract class Rope
        private var leaf_cache: nullable LeafCache = null
 
        # Empty Rope
-       init do from("")
+       init do root = new StringLeaf("".as(FlatString))
 
        # Creates a new Rope with `s` as root
        init from(s: String) do