# See the License for the specific language governing permissions and
# limitations under the License.
-# Utilities and performant structure for the FFI with C
+# Structures and services for compatibility with the C language
module c
-import standard
-intrude import standard::collection::array
+
+import core
+intrude import core::collection::array
# A thin wrapper around a `NativeCArray` adding length information
abstract class CArray[E]
# Wrapper around an array of `unsigned char` in C (`unsigned char*`) with length and destroy state
class CByteArray
- super CArray[Int]
+ super CArray[Byte]
redef type NATIVE: NativeCByteArray
# Allocate a new array of `size`
super size
end
- # Build from an `Array[Int]`
- new from(array: Array[Int])
+ # Build from a `SequenceRead[Byte]`
+ new from(array: SequenceRead[Byte])
do
var carray = new CByteArray(array.length)
for i in array.length.times do
# An array of `unsigned char` in C (`unsigned char*`)
extern class NativeCByteArray `{ unsigned char* `}
super NativeCArray
- redef type E: Int
+ redef type E: Byte
# Allocate a new array of `size`
new(size: Int) `{ return calloc(size, sizeof(unsigned char)); `}