2021-10-02 18:44:32 +00:00
|
|
|
#![no_implicit_prelude]
|
|
|
|
#![allow(unused_variables)]
|
|
|
|
|
|
|
|
#[::pyo3::pyclass]
|
|
|
|
pub struct Dummy;
|
|
|
|
|
|
|
|
#[::pyo3::pyclass]
|
|
|
|
pub struct DummyIter;
|
|
|
|
|
|
|
|
#[::pyo3::pymethods]
|
|
|
|
impl Dummy {
|
|
|
|
//////////////////////
|
|
|
|
// Basic customization
|
|
|
|
//////////////////////
|
|
|
|
fn __repr__(&self) -> &'static str {
|
|
|
|
"Dummy"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __str__(&self) -> &'static str {
|
|
|
|
"Dummy"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __bytes__<'py>(&self, py: ::pyo3::Python<'py>) -> &'py ::pyo3::types::PyBytes {
|
|
|
|
::pyo3::types::PyBytes::new(py, &[0])
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __format__(&self, format_spec: ::std::string::String) -> ::std::string::String {
|
|
|
|
::std::panic!("unimplemented isn't hygienic before 1.50")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __lt__(&self, other: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __le__(&self, other: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
fn __eq__(&self, other: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
fn __ne__(&self, other: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
fn __gt__(&self, other: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
fn __ge__(&self, other: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __hash__(&self) -> u64 {
|
|
|
|
42
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __bool__(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// Customizing attribute access
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __getattr__(&self, name: ::std::string::String) -> &::pyo3::PyAny {
|
|
|
|
::std::panic!("unimplemented isn't hygienic before 1.50")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __getattribute__(&self, name: ::std::string::String) -> &::pyo3::PyAny {
|
|
|
|
::std::panic!("unimplemented isn't hygienic before 1.50")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __setattr__(&mut self, name: ::std::string::String, value: ::std::string::String) {}
|
|
|
|
|
|
|
|
fn __delattr__(&mut self, name: ::std::string::String) {}
|
|
|
|
|
|
|
|
fn __dir__<'py>(&self, py: ::pyo3::Python<'py>) -> &'py ::pyo3::types::PyList {
|
2021-10-03 00:09:53 +00:00
|
|
|
::pyo3::types::PyList::new(py, vec![0])
|
2021-10-02 18:44:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// Implementing Descriptors
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __get__(
|
|
|
|
&self,
|
|
|
|
instance: &::pyo3::PyAny,
|
|
|
|
owner: &::pyo3::PyAny,
|
|
|
|
) -> ::pyo3::PyResult<&::pyo3::PyAny> {
|
|
|
|
::std::panic!("unimplemented isn't hygienic before 1.50")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __set__(&self, instance: &::pyo3::PyAny, owner: &::pyo3::PyAny) {}
|
|
|
|
|
|
|
|
fn __delete__(&self, instance: &::pyo3::PyAny) {}
|
|
|
|
|
|
|
|
fn __set_name__(&self, owner: &::pyo3::PyAny, name: &::pyo3::PyAny) {}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// Implementing Descriptors
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __len__(&self) -> usize {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __getitem__(&self, key: u32) -> ::pyo3::PyResult<u32> {
|
|
|
|
::std::result::Result::Err(::pyo3::exceptions::PyKeyError::new_err("boo"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __setitem__(&self, key: u32, value: u32) {}
|
|
|
|
|
|
|
|
fn __delitem__(&self, key: u32) {}
|
|
|
|
|
|
|
|
fn __iter__(_: ::pyo3::pycell::PyRef<Self>, py: ::pyo3::Python) -> ::pyo3::Py<DummyIter> {
|
|
|
|
::pyo3::Py::new(py, DummyIter {}).unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __next__(&mut self) -> ::std::option::Option<()> {
|
|
|
|
::std::option::Option::None
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __reversed__(slf: ::pyo3::pycell::PyRef<Self>, py: ::pyo3::Python) -> ::pyo3::Py<DummyIter> {
|
|
|
|
::pyo3::Py::new(py, DummyIter {}).unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __contains__(&self, item: u32) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// Emulating numeric types
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __add__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __sub__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __mul__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __truediv__(&self, _other: &Self) -> ::pyo3::PyResult<()> {
|
|
|
|
::std::result::Result::Err(::pyo3::exceptions::PyZeroDivisionError::new_err("boo"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __floordiv__(&self, _other: &Self) -> ::pyo3::PyResult<()> {
|
|
|
|
::std::result::Result::Err(::pyo3::exceptions::PyZeroDivisionError::new_err("boo"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __mod__(&self, _other: &Self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __divmod__(&self, _other: &Self) -> (u32, u32) {
|
|
|
|
(0, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __pow__(&self, _other: &Self, modulo: ::std::option::Option<i32>) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __lshift__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rshift__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __and__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __xor__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __or__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __radd__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rrsub__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rmul__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rtruediv__(&self, _other: &Self) -> ::pyo3::PyResult<()> {
|
|
|
|
::std::result::Result::Err(::pyo3::exceptions::PyZeroDivisionError::new_err("boo"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rfloordiv__(&self, _other: &Self) -> ::pyo3::PyResult<()> {
|
|
|
|
::std::result::Result::Err(::pyo3::exceptions::PyZeroDivisionError::new_err("boo"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rmod__(&self, _other: &Self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rdivmod__(&self, _other: &Self) -> (u32, u32) {
|
|
|
|
(0, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rpow__(&self, _other: &Self, modulo: ::std::option::Option<i32>) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rlshift__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rrshift__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rand__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __rxor__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __ror__(&self, other: &Self) -> Dummy {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __iadd__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __irsub__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __imul__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __itruediv__(&mut self, _other: &Self) {}
|
|
|
|
|
|
|
|
fn __ifloordiv__(&mut self, _other: &Self) {}
|
|
|
|
|
|
|
|
fn __imod__(&mut self, _other: &Self) {}
|
|
|
|
|
|
|
|
fn __ipow__(&mut self, _other: &Self, modulo: ::std::option::Option<i32>) {}
|
|
|
|
|
|
|
|
fn __ilshift__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __irshift__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __iand__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __ixor__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __ior__(&mut self, other: &Self) {}
|
|
|
|
|
|
|
|
fn __neg__(slf: ::pyo3::pycell::PyRef<Self>) -> ::pyo3::pycell::PyRef<Self> {
|
|
|
|
slf
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __pos__(slf: ::pyo3::pycell::PyRef<Self>) -> ::pyo3::pycell::PyRef<Self> {
|
|
|
|
slf
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __abs__(slf: ::pyo3::pycell::PyRef<Self>) -> ::pyo3::pycell::PyRef<Self> {
|
|
|
|
slf
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __invert__(slf: ::pyo3::pycell::PyRef<Self>) -> ::pyo3::pycell::PyRef<Self> {
|
|
|
|
slf
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __complex__<'py>(&self, py: ::pyo3::Python<'py>) -> &'py ::pyo3::types::PyComplex {
|
|
|
|
::pyo3::types::PyComplex::from_doubles(py, 0.0, 0.0)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __int__(&self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __float__(&self) -> f64 {
|
|
|
|
0.0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __index__(&self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __round__(&self, ndigits: ::std::option::Option<u32>) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __trunc__(&self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __floor__(&self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __ceil__(&self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// With Statement Context Managers
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __enter__(&mut self) {}
|
|
|
|
|
|
|
|
fn __exit__(
|
|
|
|
&mut self,
|
|
|
|
exc_type: &::pyo3::PyAny,
|
|
|
|
exc_value: &::pyo3::PyAny,
|
|
|
|
traceback: &::pyo3::PyAny,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// Awaitable Objects
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __await__(slf: ::pyo3::pycell::PyRef<Self>) -> ::pyo3::pycell::PyRef<Self> {
|
|
|
|
slf
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
// Asynchronous Iterators
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __aiter__(slf: ::pyo3::pycell::PyRef<Self>, py: ::pyo3::Python) -> ::pyo3::Py<DummyIter> {
|
|
|
|
::pyo3::Py::new(py, DummyIter {}).unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn __anext__(&mut self) -> ::std::option::Option<()> {
|
|
|
|
::std::option::Option::None
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
// Asynchronous Context Managers
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
fn __aenter__(&mut self) {}
|
|
|
|
|
|
|
|
fn __aexit__(
|
|
|
|
&mut self,
|
|
|
|
exc_type: &::pyo3::PyAny,
|
|
|
|
exc_value: &::pyo3::PyAny,
|
|
|
|
traceback: &::pyo3::PyAny,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Things with attributes
|
|
|
|
|
|
|
|
#[args(x = "1", "*", _z = "2")]
|
|
|
|
fn test(&self, _y: &Dummy, _z: i32) {}
|
|
|
|
#[staticmethod]
|
|
|
|
fn staticmethod() {}
|
|
|
|
#[classmethod]
|
|
|
|
fn clsmethod(_: &::pyo3::types::PyType) {}
|
|
|
|
#[call]
|
|
|
|
#[args(args = "*", kwds = "**")]
|
|
|
|
fn __call__(
|
|
|
|
&self,
|
|
|
|
_args: &::pyo3::types::PyTuple,
|
|
|
|
_kwds: ::std::option::Option<&::pyo3::types::PyDict>,
|
|
|
|
) -> ::pyo3::PyResult<i32> {
|
|
|
|
::std::panic!("unimplemented isn't hygienic before 1.50")
|
|
|
|
}
|
|
|
|
#[new]
|
|
|
|
fn new(a: u8) -> Self {
|
|
|
|
Dummy {}
|
|
|
|
}
|
|
|
|
#[getter]
|
|
|
|
fn get(&self) -> i32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
#[setter]
|
|
|
|
fn set(&mut self, _v: i32) {}
|
|
|
|
#[classattr]
|
|
|
|
fn class_attr() -> i32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dunder methods invented for protocols
|
|
|
|
|
|
|
|
fn __richcmp__(
|
|
|
|
&self,
|
|
|
|
other: &Self,
|
|
|
|
op: ::pyo3::class::basic::CompareOp,
|
|
|
|
) -> ::pyo3::PyResult<bool> {
|
|
|
|
::std::result::Result::Ok(false)
|
|
|
|
}
|
|
|
|
// PyGcProtocol
|
|
|
|
// Buffer protocol?
|
|
|
|
}
|