mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
feat: enhance array
, io
, os
, struct
type decls
This commit is contained in:
parent
b17b802223
commit
d46f84564b
4 changed files with 81 additions and 14 deletions
|
@ -1,23 +1,25 @@
|
|||
.typecodes: Str
|
||||
|
||||
.Array! = 'array': ClassType
|
||||
.Array!.
|
||||
__call__: (typecode: Str, initializer := [Obj; _] or Iterable(Obj)) -> .Array!
|
||||
typecode: Str
|
||||
itemsize: Nat
|
||||
append: (self: RefMut(.Array!), x: Obj) => NoneType
|
||||
append!: (self: RefMut(.Array!), x: Obj) => NoneType
|
||||
buffer_info: (self: Ref(.Array!)) -> (Nat, Nat)
|
||||
byteswap: (self: RefMut(.Array!)) => NoneType
|
||||
byteswap!: (self: RefMut(.Array!)) => NoneType
|
||||
count: (self: Ref(.Array!), x: Obj) -> Nat
|
||||
extend: (self: RefMut(.Array!), iterable: Iterable(Obj)) => NoneType
|
||||
frombytes: (self: RefMut(.Array!), bytes: Bytes) => NoneType
|
||||
fromfile: (self: RefMut(.Array!), f: File!, n: Nat) => NoneType
|
||||
fromlist: (self: RefMut(.Array!), list: [Obj; _]) => NoneType
|
||||
fromunicode: (self: RefMut(.Array!), s: Str) => NoneType
|
||||
extend!: (self: RefMut(.Array!), iterable: Iterable(Obj)) => NoneType
|
||||
frombytes!: (self: RefMut(.Array!), bytes: Bytes) => NoneType
|
||||
fromfile!: (self: RefMut(.Array!), f: File!, n: Nat) => NoneType
|
||||
fromlist!: (self: RefMut(.Array!), list: [Obj; _]) => NoneType
|
||||
fromunicode!: (self: RefMut(.Array!), s: Str) => NoneType
|
||||
index: (self: Ref(.Array!), x: Obj) -> Nat
|
||||
insert: (self: RefMut(.Array!), i: Nat, x: Obj) => NoneType
|
||||
pop: (self: RefMut(.Array!), i := Nat) -> Obj
|
||||
remove: (self: RefMut(.Array!), x: Obj) => NoneType
|
||||
reverse: (self: RefMut(.Array!)) => NoneType
|
||||
insert!: (self: RefMut(.Array!), i: Nat, x: Obj) => NoneType
|
||||
pop!: (self: RefMut(.Array!), i := Nat) -> Obj
|
||||
remove!: (self: RefMut(.Array!), x: Obj) => NoneType
|
||||
reverse!: (self: RefMut(.Array!)) => NoneType
|
||||
tobytes: (self: Ref(.Array!)) -> Bytes
|
||||
tofile: (self: Ref(.Array!), f: File!) => NoneType
|
||||
tofile!: (self: Ref(.Array!), f: File!) => NoneType
|
||||
tolist: (self: Ref(.Array!)) -> [Obj; _]
|
||||
tounicode: (self: Ref(.Array!)) -> Str
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
.DEFAULT_BUFFER_SIZE: {8192}
|
||||
|
||||
.BlockingIOError = BlockingIOError
|
||||
.UnsupportedOperation: ClassType
|
||||
.UnsupportedOperation <: OSError
|
||||
.UnsupportedOperation <: ValueError
|
||||
|
||||
.IOBase!: ClassType
|
||||
.IOBase! <: FileLike!
|
||||
.IOBase!.
|
||||
|
@ -101,3 +106,4 @@
|
|||
|
||||
.open!: (file: PathLike, mode := Str, buffering := Nat, encoding := Str or NoneType) -> File!
|
||||
.open_code!: (path: PathLike) -> File!
|
||||
.text_encoding: (encoding: Str or NoneType, stacklevel := Nat) -> Str
|
||||
|
|
|
@ -130,11 +130,27 @@ The name of the operating system dependent module imported. The following names
|
|||
.SF_NODISKIO: Nat
|
||||
.SF_SYNC: Nat
|
||||
|
||||
.access!: (
|
||||
path: PathLike,
|
||||
mode: Nat,
|
||||
dir_fd := Nat or FileDescriptor,
|
||||
effective_ids := Bool,
|
||||
follow_symlinks := Bool,
|
||||
) => Bool
|
||||
.close!: (fd: Nat or FileDescriptor) => NoneType
|
||||
.closerange!: (fd_low: Nat, fd_high: Nat) => NoneType
|
||||
.ctermid!: () => Str
|
||||
.chdir!: (path: PathLike, ) => NoneType
|
||||
.chflags!: (path: PathLike, flags: Nat, follow_symlinks := Bool) => NoneType
|
||||
.chmod!: (path: PathLike, mode: Nat) => NoneType
|
||||
.chown!: (
|
||||
path: PathLike,
|
||||
uid: Nat,
|
||||
gid: Nat,
|
||||
dir_fd := Nat or FileDescriptor,
|
||||
follow_symlinks := Bool,
|
||||
) => NoneType
|
||||
.chroot!: (path: PathLike) => NoneType
|
||||
.copy_file_range!: (src: Nat or FileDescriptor, dst: Nat or FileDescriptor, count: Nat, offset_src := Nat, offset_dst := Nat) => Nat
|
||||
.device_encoding: (fd: Nat or FileDescriptor) -> Str or NoneType
|
||||
.dup!: (fd: Nat or FileDescriptor) => Nat
|
||||
|
@ -161,6 +177,12 @@ The name of the operating system dependent module imported. The following names
|
|||
) => Iterator [Str, [Str; _], [Str; _], Nat]
|
||||
.get_blocking!: (fd: Nat or FileDescriptor) => Bool
|
||||
.get_exec_path!: (env := {Str: Str}) => [Str; _]
|
||||
.get_inheritable!: (fd: Nat or FileDescriptor) => Bool
|
||||
.get_handle_inheritable!: (handle: Nat) => Bool
|
||||
.get_terminal_size!: (fd := Nat or FileDescriptor) => NamedTuple {
|
||||
.columns = Nat;
|
||||
.lines = Nat;
|
||||
}
|
||||
.getcwd!: () => Str
|
||||
.getcwdb!: () => Bytes
|
||||
.getegid!: () => Nat
|
||||
|
@ -183,14 +205,33 @@ The name of the operating system dependent module imported. The following names
|
|||
.getuid!: () => Nat
|
||||
.initgroups!: (username: Str, gid: Nat) => NoneType
|
||||
.isatty!: (fd: Nat or FileDescriptor) => Bool
|
||||
.lchmod!: (path: PathLike, mode: Nat) => NoneType
|
||||
.lchown!: (path: PathLike, uid: Nat, gid: Nat) => NoneType
|
||||
.link!: (
|
||||
src: PathLike,
|
||||
dst: PathLike,
|
||||
src_dir_fd := Nat or FileDescriptor,
|
||||
dst_dir_fd := Nat or FileDescriptor,
|
||||
follow_symlinks := Bool,
|
||||
) => NoneType
|
||||
.listdir!: (path := PathLike,) => [Str; _]
|
||||
.listdrives!: () => [Str; _]
|
||||
.listmounts!: (volume: PathLike) => [Str; _]
|
||||
.listvolumes!: () => [Str; _]
|
||||
.lockf!: (fd: Nat or FileDescriptor, cmd: Nat, len := Nat) => NoneType
|
||||
.login_tty!: (fd: Nat or FileDescriptor) => NoneType
|
||||
.lseek!: (fd: Nat or FileDescriptor, pos: Nat, whence: Nat) => Nat
|
||||
.mkdir!: (path: PathLike, mode := Nat) => NoneType
|
||||
.lstat!: (path: PathLike, dir_fd := Nat or FileDescriptor) => .StatResult
|
||||
.mkdir!: (path: PathLike, mode := Nat, dir_fd := Nat or FileDescriptor) => NoneType
|
||||
.makedev!: (major: Nat, minor: Nat) => Nat
|
||||
.makedirs!: (path: PathLike, mode := Nat, exist_ok := Bool) => NoneType
|
||||
.makefifo!: (path: PathLike, mode := Nat, dir_fd := Nat or FileDescriptor) => NoneType
|
||||
.major!: (device: Nat) => Nat
|
||||
.minor!: (device: Nat) => Nat
|
||||
.mknod!: (path: PathLike, mode: Nat, device := Nat, dir_fd := Nat or FileDescriptor) => NoneType
|
||||
.open!: (path: PathLike, flags: Nat, mode := Nat, dir_fd := Nat or FileDescriptor) => Nat
|
||||
.openpty!: () => (Nat, Nat)
|
||||
.pathconf!: (path: PathLike, name: Str or Nat) => Nat
|
||||
.pipe!: () => (Nat, Nat)
|
||||
.pipe2!: (flags: Nat) => (Nat, Nat)
|
||||
# TODO: only on linux
|
||||
|
@ -203,6 +244,7 @@ The name of the operating system dependent module imported. The following names
|
|||
.pwritev!: (fd: Nat or FileDescriptor, buffers: Ref(ByteArray!), offset: Nat, flags := Nat) => Nat
|
||||
.read!: (fd: Nat or FileDescriptor, n: Nat) => Bytes
|
||||
.readlink!: (path: PathLike, dir_fd := Nat or FileDescriptor) => Str
|
||||
.readv!: (fd: Nat or FileDescriptor, buffers: RefMut(ByteArray!)) => Nat
|
||||
.remove!: (path: PathLike,) => NoneType
|
||||
.removedirs!: (path: PathLike,) => NoneType
|
||||
.rename!: (src: PathLike, dst: PathLike) => NoneType
|
||||
|
@ -212,6 +254,8 @@ The name of the operating system dependent module imported. The following names
|
|||
.scandir!: (path := PathLike,) => Iterator DirEntry
|
||||
.sendfile!: (out_fd: Nat or FileDescriptor, in_fd: Nat or FileDescriptor, offset := Nat, count := Nat) => Nat
|
||||
.set_blocking!: (fd: Nat or FileDescriptor, blocking: Bool) => NoneType
|
||||
.set_inheritable!: (fd: Nat or FileDescriptor, inheritable: Bool) => NoneType
|
||||
.set_handle_inheritable!: (handle: Nat, inheritable: Bool) => NoneType
|
||||
.setegid!: (egid: Nat) => NoneType
|
||||
.seteuid!: (euid: Nat) => NoneType
|
||||
.setgid!: (gid: Nat) => NoneType
|
||||
|
@ -226,6 +270,7 @@ The name of the operating system dependent module imported. The following names
|
|||
.setreuid!: (ruid: Nat, euid: Nat) => NoneType
|
||||
.setsid!: () => Nat
|
||||
.setuid!: (uid: Nat) => NoneType
|
||||
.splice!: (src: Nat or FileDescriptor, dst: Nat or FileDescriptor, count: Nat, offset_src := Nat, offset_dst := Nat) => NoneType
|
||||
.statvfs!: (path: PathLike) => NamedTuple {
|
||||
.f_bsize = Nat;
|
||||
.f_frsize = Nat;
|
||||
|
@ -242,6 +287,9 @@ The name of the operating system dependent module imported. The following names
|
|||
.strerror: (code: Nat) -> Str
|
||||
.symlink!: (src: PathLike, dst: PathLike, target_is_directory := Bool, dir_fd := Nat or FileDescriptor) => NoneType
|
||||
.sync!: () => NoneType
|
||||
.tcgetpgrp!: (fd: Nat or FileDescriptor) => Nat
|
||||
.tcsetpgrp!: (fd: Nat or FileDescriptor, pgrp: Nat) => NoneType
|
||||
.ttyname!: (fd: Nat or FileDescriptor) => Str
|
||||
|
||||
.umask!: (mask: Nat) => Nat
|
||||
# posix = pyimport "posix"
|
||||
|
@ -265,3 +313,5 @@ The name of the operating system dependent module imported. The following names
|
|||
onerror := Subroutine,
|
||||
followlinks := Bool
|
||||
) => Iterator [Str, [Str; _], [Str; _]]
|
||||
.write!: (fd: Nat or FileDescriptor, str: Bytes) => Nat
|
||||
.writev!: (fd: Nat or FileDescriptor, buffers: Ref(ByteArray!)) => Nat
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
.Error = 'error': ClassType
|
||||
.Error <: Exception
|
||||
|
||||
.Struct: ClassType
|
||||
.Struct.
|
||||
__call__: (format: Str) -> .Struct
|
||||
format: Str
|
||||
size: Nat
|
||||
pack: (self: .Struct, *values: Obj) -> Bytes
|
||||
unpack: (self: .Struct, bytes: Bytes) -> Obj
|
||||
pack_into!: (self: .Struct, buffer: RefMut(ByteArray!), offset: Nat, *values: Obj) => NoneType
|
||||
unpack: (self: .Struct, buffer: Bytes) -> Obj
|
||||
unpack_from: (self: .Struct, buffer: Bytes, offset := Nat) -> [Obj; _]
|
||||
iter_unpack: (self: .Struct, buffer: Bytes) -> Iterator [Obj; _]
|
||||
|
||||
.pack: (format: Str, *values: Obj) -> Bytes
|
||||
.pack_into!: (format: Str, buffer: RefMut(ByteArray!), offset: Nat, *values: Obj) => NoneType
|
||||
.unpack: (format: Str, bytes: Bytes) -> Obj
|
||||
.unpack_from: (format: Str, buffer: Bytes, offset := Nat) -> [Obj; _]
|
||||
.iter_unpack: (format: Str, buffer: Bytes) -> Iterator [Obj; _]
|
||||
.calcsize: (format: Str) -> Nat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue