1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
11 # Encapsulates all primitive data types of nit
13 # Ensures that the use in the interpreter is independant of the
14 # underlying implementation and that the services are semantically correct.
15 module primitive_types
17 intrude import standard
::file
19 # Wrapper for `NativeFile`
20 class PrimitiveNativeFile
25 file
= new IFStream.from_fd
(0)
29 file
= new OFStream.from_fd
(1)
33 file
= new OFStream.from_fd
(2)
36 init io_open_read
(path
: String) do
37 file
= new IFStream.open
(path
.to_s
)
40 init io_open_write
(path
: String) do
41 file
= new OFStream.open
(path
.to_s
)
44 fun address_is_null
: Bool do return file
._file
.address_is_null
46 fun io_read
(buf
: NativeString, len
: Int): Int do return file
._file
.io_read
(buf
, len
)
48 fun io_write
(buf
: NativeString, len
: Int): Int do return file
._file
.io_write
(buf
, len
)
50 fun io_close
: Int do return file
._file
.io_close
52 fun fileno
: Int do return file
._file
.fileno
54 fun flush
: Int do return file
._file
.flush
56 fun set_buffering_type
(size
, mode
: Int): Int do
57 return file
._file
.set_buffering_type
(size
, mode
)