mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Add AsyncIterator support to c-api (#8285)
This commit is contained in:
1 parent
ac28fff085
commit
96fde50f75
1 file changed
+14
@@ -9,6 +9,15 @@ pub unsafe extern "C" fn PyIter_Check(obj: *mut PyObject) -> c_int {
|
||||
with_vm(|_vm| Ok(PyIter::check(unsafe { &*obj })))
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn PyAIter_Check(obj: *mut PyObject) -> c_int {
|
||||
with_vm(|vm| {
|
||||
Ok(unsafe { &*obj }
|
||||
.class()
|
||||
.has_attr(rustpython_vm::identifier!(vm, __anext__)))
|
||||
})
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn PyObject_GetIter(obj: *mut PyObject) -> *mut PyObject {
|
||||
with_vm(|vm| {
|
||||
@@ -17,6 +26,11 @@ pub unsafe extern "C" fn PyObject_GetIter(obj: *mut PyObject) -> *mut PyObject {
|
||||
})
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn PyObject_GetAIter(obj: *mut PyObject) -> *mut PyObject {
|
||||
with_vm(|vm| unsafe { &*obj }.get_aiter(vm))
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn PyIter_NextItem(iter: *mut PyObject, item: *mut *mut PyObject) -> c_int {
|
||||
with_vm(|vm| {
|
||||
|
||||
Reference in new issue
Block a user