lib/standard/array: new NativeArray/NativeString are now usable everywhere.
authorLucas Bajolet <r4pass@hotmail.com>
Tue, 26 Aug 2014 18:32:46 +0000 (14:32 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 26 Aug 2014 18:40:16 +0000 (14:40 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/collection/array.nit
lib/standard/string.nit
tests/test_new_native.nit

index 4848257..a819d54 100644 (file)
@@ -732,6 +732,8 @@ end
 # Access are unchecked and it has a fixed size
 # Not for public use: may become private.
 universal NativeArray[E]
+       # Creates a new NativeArray of capacity `length`
+       new(length: Int) is intern
        # The length of the array
        fun length: Int is intern
        # Use `self` to initialize a standard Nit Array.
index 5a0c039..3e330f3 100644 (file)
@@ -1877,7 +1877,8 @@ end
 # Native strings are simple C char *
 extern class NativeString `{ char* `}
        super StringCapable
-
+       # Creates a new NativeString with a capacity of `length`
+       new(length: Int) is intern
        fun [](index: Int): Char is intern
        fun []=(index: Int, item: Char) is intern
        fun copy_to(dest: NativeString, length: Int, from: Int, to: Int) is intern
index d2c35fc..49ab177 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-redef class NativeArray[E]
-       new(length: Int) is intern
-end
-
-redef class NativeString
-       new(length: Int) is intern
-end
-
 var s = new NativeString(4)
 s[0] = 'N'
 s[2] = 't'