|
1 | 1 | #[cfg(not(PyPy))]
|
2 | 2 | use crate::Py_hash_t;
|
3 | 3 | use crate::{PyObject, Py_UCS1, Py_UCS2, Py_UCS4, Py_ssize_t};
|
4 |
| -use libc::wchar_t; |
5 |
| -use std::os::raw::{c_char, c_int, c_uint, c_void}; |
| 4 | +use libc::{c_ushort, wchar_t}; |
6 | 5 | #[cfg(Py_3_14)]
|
7 | 6 | use std::os::raw::c_ushort;
|
| 7 | +use std::os::raw::{c_char, c_int, c_uint, c_void}; |
8 | 8 |
|
9 | 9 | // skipped Py_UNICODE_ISSPACE()
|
10 | 10 | // skipped Py_UNICODE_ISLOWER()
|
@@ -587,6 +587,46 @@ impl PyASCIIObject {
|
587 | 587 | state.set_ready(val);
|
588 | 588 | self.state = u32::from(state);
|
589 | 589 | }
|
| 590 | + |
| 591 | + /// Get the `statically_allocated` field of the [`PyASCIIObject`] state bitfield. |
| 592 | + /// |
| 593 | + /// Returns either `0` or `1`. |
| 594 | + #[inline] |
| 595 | + #[cfg(all(Py_3_12), not(Py_3_14))] |
| 596 | + pub unsafe fn statically_allocated(&self) -> c_uint { |
| 597 | + PyASCIIObjectState::from(self.state).statically_allocated() |
| 598 | + } |
| 599 | + |
| 600 | + /// Set the `statically_allocated` flag of the [`PyASCIIObject`] state bitfield. |
| 601 | + /// |
| 602 | + /// Calling this function with an argument that is neither `0` nor `1` is invalid. |
| 603 | + #[inline] |
| 604 | + #[cfg(all(Py_3_12), not(Py_3_14))] |
| 605 | + pub unsafe fn set_statically_allocated(&mut self, val: c_uint) { |
| 606 | + let mut state = PyASCIIObjectState::from(self.state); |
| 607 | + state.set_statically_allocated(val); |
| 608 | + self.state = u32::from(state); |
| 609 | + } |
| 610 | + |
| 611 | + /// Get the `statically_allocated` field of the [`PyASCIIObject`] state bitfield. |
| 612 | + /// |
| 613 | + /// Returns either `0` or `1`. |
| 614 | + #[inline] |
| 615 | + #[cfg(Py_3_14)] |
| 616 | + pub unsafe fn statically_allocated(&self) -> c_ushort { |
| 617 | + PyASCIIObjectState::from(self.state).statically_allocated() |
| 618 | + } |
| 619 | + |
| 620 | + /// Set the `statically_allocated` flag of the [`PyASCIIObject`] state bitfield. |
| 621 | + /// |
| 622 | + /// Calling this function with an argument that is neither `0` nor `1` is invalid. |
| 623 | + #[inline] |
| 624 | + #[cfg(Py_3_14)] |
| 625 | + pub unsafe fn set_statically_allocated(&mut self, val: c_ushort) { |
| 626 | + let mut state = PyASCIIObjectState::from(self.state); |
| 627 | + state.set_statically_allocated(val); |
| 628 | + self.state = u32::from(state); |
| 629 | + } |
590 | 630 | }
|
591 | 631 |
|
592 | 632 | #[repr(C)]
|
|
0 commit comments