From: Jean Privat Date: Thu, 17 Apr 2014 02:17:06 +0000 (-0400) Subject: lib: add `NativeArray::length` X-Git-Tag: v0.6.6~109^2~3 X-Git-Url: http://nitlanguage.org lib: add `NativeArray::length` Engines should be able to store the allocated size. Unlike `NativeString` that is a char*, `NativeArray` is a special Nit opaque structure. Signed-off-by: Jean Privat --- diff --git a/lib/standard/collection/array.nit b/lib/standard/collection/array.nit index d40a220..6ae145d 100644 --- a/lib/standard/collection/array.nit +++ b/lib/standard/collection/array.nit @@ -650,8 +650,14 @@ interface ArrayCapable[E] protected fun calloc_array(size: Int): NativeArray[E] is intern end -# Native C array (void ...). +# Native Nit array +# Access are unchecked and it has a fixed size +# Not for public use: may become private. universal NativeArray[E] + # The length of the array + fun length: Int is intern + # Use `self` to initialize a standard Nit Array. + fun to_a: Array[E] do return new Array[E].with_native(self, length) fun [](index: Int): E is intern fun []=(index: Int, item: E) is intern fun copy_to(dest: NativeArray[E], length: Int) is intern