1 | use crate::object::{PyObject, PyTypeObject, Py_TYPE}; |
2 | use std::os::raw::{c_char, c_int}; |
3 | use std::ptr::addr_of_mut; |
4 | |
5 | extern "C" { |
6 | pub static mut PyContext_Type: PyTypeObject; |
7 | // skipped non-limited opaque PyContext |
8 | pub static mut PyContextVar_Type: PyTypeObject; |
9 | // skipped non-limited opaque PyContextVar |
10 | pub static mut PyContextToken_Type: PyTypeObject; |
11 | // skipped non-limited opaque PyContextToken |
12 | } |
13 | |
14 | #[inline ] |
15 | pub unsafe fn PyContext_CheckExact(op: *mut PyObject) -> c_int { |
16 | (Py_TYPE(ob:op) == addr_of_mut!(PyContext_Type)) as c_int |
17 | } |
18 | |
19 | #[inline ] |
20 | pub unsafe fn PyContextVar_CheckExact(op: *mut PyObject) -> c_int { |
21 | (Py_TYPE(ob:op) == addr_of_mut!(PyContextVar_Type)) as c_int |
22 | } |
23 | |
24 | #[inline ] |
25 | pub unsafe fn PyContextToken_CheckExact(op: *mut PyObject) -> c_int { |
26 | (Py_TYPE(ob:op) == addr_of_mut!(PyContextToken_Type)) as c_int |
27 | } |
28 | |
29 | extern "C" { |
30 | pub fn PyContext_New() -> *mut PyObject; |
31 | pub fn PyContext_Copy(ctx: *mut PyObject) -> *mut PyObject; |
32 | pub fn PyContext_CopyCurrent() -> *mut PyObject; |
33 | |
34 | pub fn PyContext_Enter(ctx: *mut PyObject) -> c_int; |
35 | pub fn PyContext_Exit(ctx: *mut PyObject) -> c_int; |
36 | |
37 | pub fn PyContextVar_New(name: *const c_char, def: *mut PyObject) -> *mut PyObject; |
38 | pub fn PyContextVar_Get( |
39 | var: *mut PyObject, |
40 | default_value: *mut PyObject, |
41 | value: *mut *mut PyObject, |
42 | ) -> c_int; |
43 | pub fn PyContextVar_Set(var: *mut PyObject, value: *mut PyObject) -> *mut PyObject; |
44 | pub fn PyContextVar_Reset(var: *mut PyObject, token: *mut PyObject) -> c_int; |
45 | // skipped non-limited _PyContext_NewHamtForTests |
46 | } |
47 | |