mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
feat: add asyncio
type decls
This commit is contained in:
parent
4cd79cbb1a
commit
c6882fee53
11 changed files with 78 additions and 3 deletions
19
crates/erg_compiler/lib/pystd/asyncio.d/__init__.d.er
Normal file
19
crates/erg_compiler/lib/pystd/asyncio.d/__init__.d.er
Normal file
|
@ -0,0 +1,19 @@
|
|||
{.BaseEventLoop!; .Server!} = import "base_events"
|
||||
{.iscoroutine;. iscoroutinefunction;} = pyimport "coroutines"
|
||||
{
|
||||
.AbstractEventLoop!;
|
||||
.AbstractEventLoopPolicy!;
|
||||
.AbstractServer!;
|
||||
.Handle!;
|
||||
.TimerHandle!;
|
||||
} = pyimport "events"
|
||||
{
|
||||
.LifoQueue!;
|
||||
.PriorityQueue!;
|
||||
.Queue!;
|
||||
.QueueEmpty;
|
||||
.QueueFull;
|
||||
} = pyimport "queues"
|
||||
{.Runner!; .run!;} = pyimport "runners"
|
||||
{.Task!; .current_task!; .gather!; .sleep!;} = pyimport "tasks"
|
||||
{.to_thread!;} = pyimport "threads"
|
3
crates/erg_compiler/lib/pystd/asyncio.d/base_events.d.er
Normal file
3
crates/erg_compiler/lib/pystd/asyncio.d/base_events.d.er
Normal file
|
@ -0,0 +1,3 @@
|
|||
.BaseEventLoop!: ClassType
|
||||
|
||||
.Server!: ClassType
|
2
crates/erg_compiler/lib/pystd/asyncio.d/coroutines.d.er
Normal file
2
crates/erg_compiler/lib/pystd/asyncio.d/coroutines.d.er
Normal file
|
@ -0,0 +1,2 @@
|
|||
.iscoroutinefunction: (obj: Obj) -> Bool
|
||||
.iscoroutine: (obj: Obj) -> Bool
|
8
crates/erg_compiler/lib/pystd/asyncio.d/events.d.er
Normal file
8
crates/erg_compiler/lib/pystd/asyncio.d/events.d.er
Normal file
|
@ -0,0 +1,8 @@
|
|||
.Handle!: ClassType
|
||||
|
||||
.TimerHandle!: ClassType
|
||||
.TimerHandle! <: Handle!
|
||||
|
||||
.AbstractServer!: ClassType
|
||||
.AbstractEventLoop!: ClassType
|
||||
.AbstractEventLoopPolicy!: ClassType
|
11
crates/erg_compiler/lib/pystd/asyncio.d/futures.d.er
Normal file
11
crates/erg_compiler/lib/pystd/asyncio.d/futures.d.er
Normal file
|
@ -0,0 +1,11 @@
|
|||
.Future!: ClassType
|
||||
.Future!.
|
||||
result: (self: Ref Future!) -> Obj
|
||||
exception: (self: Ref Future!) -> Exception
|
||||
done: (self: Ref Future!) -> Bool
|
||||
cancelled: (self: Ref Future!) -> Bool
|
||||
set_result!: (self: RefMut Future!, result: Obj) => NoneType
|
||||
set_exception!: (self: RefMut Future!, exception: Exception) => NoneType
|
||||
cancel!: (self: RefMut Future!, msg := Str) => Bool
|
||||
|
||||
.isfuture: (obj: Obj) -> Bool
|
13
crates/erg_compiler/lib/pystd/asyncio.d/queues.d.er
Normal file
13
crates/erg_compiler/lib/pystd/asyncio.d/queues.d.er
Normal file
|
@ -0,0 +1,13 @@
|
|||
.QueueEmpty: ClassType
|
||||
.QueueEmpty <: BaseException
|
||||
|
||||
.QueueFull: ClassType
|
||||
.QueueFull <: BaseException
|
||||
|
||||
.Queue!: ClassType
|
||||
|
||||
.PriorityQueue!: ClassType
|
||||
.PriorityQueue! <: Queue!
|
||||
|
||||
.LifoQueue!: ClassType
|
||||
.LifoQueue! <: Queue!
|
8
crates/erg_compiler/lib/pystd/asyncio.d/runners.d.er
Normal file
8
crates/erg_compiler/lib/pystd/asyncio.d/runners.d.er
Normal file
|
@ -0,0 +1,8 @@
|
|||
.Runner!: ClassType
|
||||
.Runner!.
|
||||
run!: (self: Runner!, coro: GenericCallable, debug := Bool) => NoneType
|
||||
close!: (self: Runner!) => NoneType
|
||||
get_loop!: (self: Runner!) => NoneType
|
||||
|
||||
# TODO: return value
|
||||
.run!: (coro: GenericCallable, debug := Bool) => NoneType
|
|
@ -1,4 +1,5 @@
|
|||
# TODO: return value
|
||||
.run!: (coro: GenericCallable, debug := Bool) => NoneType
|
||||
.sleep!: (delay: Float) => NoneType
|
||||
.Task!: ClassType
|
||||
|
||||
.current_task!: (loop := Obj) => Task!
|
||||
.gather!: (*coros: GenericCallable) => NoneType
|
||||
.sleep!: (delay: Float) => NoneType
|
1
crates/erg_compiler/lib/pystd/asyncio.d/threads.d.er
Normal file
1
crates/erg_compiler/lib/pystd/asyncio.d/threads.d.er
Normal file
|
@ -0,0 +1 @@
|
|||
.to_thread!: (func: GenericCallable) => Obj
|
Loading…
Add table
Add a link
Reference in a new issue