-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrender_type.rs
More file actions
92 lines (86 loc) · 3.34 KB
/
render_type.rs
File metadata and controls
92 lines (86 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::{FromGil, PyDefault, flat};
use pyo3::prelude::*;
#[derive(pyo3::FromPyObject)]
pub enum RenderType {
Line3D(Py<super::Line3D>),
PolyLine3D(Py<super::PolyLine3D>),
String2D(Py<super::String2D>),
String3D(Py<super::String3D>),
Rect2D(Py<super::Rect2D>),
Rect3D(Py<super::Rect3D>),
}
impl RenderType {
pub fn py_default(py: Python) -> Py<PyAny> {
super::Line3D::py_default(py).into_any()
}
}
impl FromGil<&flat::RenderType> for RenderType {
fn from_gil(py: Python, flat_t: &flat::RenderType) -> Self {
match flat_t {
flat::RenderType::Line3D(item) => {
Self::Line3D(Py::new(py, super::Line3D::from_gil(py, &**item)).unwrap())
}
flat::RenderType::PolyLine3D(item) => {
Self::PolyLine3D(Py::new(py, super::PolyLine3D::from_gil(py, &**item)).unwrap())
}
flat::RenderType::String2D(item) => {
Self::String2D(Py::new(py, super::String2D::from_gil(py, &**item)).unwrap())
}
flat::RenderType::String3D(item) => {
Self::String3D(Py::new(py, super::String3D::from_gil(py, &**item)).unwrap())
}
flat::RenderType::Rect2D(item) => {
Self::Rect2D(Py::new(py, super::Rect2D::from_gil(py, &**item)).unwrap())
}
flat::RenderType::Rect3D(item) => {
Self::Rect3D(Py::new(py, super::Rect3D::from_gil(py, &**item)).unwrap())
}
}
}
}
impl FromGil<&RenderType> for flat::RenderType {
fn from_gil(py: Python, py_type: &RenderType) -> Self {
match py_type {
RenderType::Line3D(item) => {
flat::RenderType::Line3D(Box::new(crate::from_py_into(py, item)))
}
RenderType::PolyLine3D(item) => {
flat::RenderType::PolyLine3D(Box::new(crate::from_py_into(py, item)))
}
RenderType::String2D(item) => {
flat::RenderType::String2D(Box::new(crate::from_py_into(py, item)))
}
RenderType::String3D(item) => {
flat::RenderType::String3D(Box::new(crate::from_py_into(py, item)))
}
RenderType::Rect2D(item) => {
flat::RenderType::Rect2D(Box::new(crate::from_py_into(py, item)))
}
RenderType::Rect3D(item) => {
flat::RenderType::Rect3D(Box::new(crate::from_py_into(py, item)))
}
}
}
}
impl RenderType {
pub fn into_any(self) -> Py<PyAny> {
match self {
Self::Line3D(item) => item.into_any(),
Self::PolyLine3D(item) => item.into_any(),
Self::String2D(item) => item.into_any(),
Self::String3D(item) => item.into_any(),
Self::Rect2D(item) => item.into_any(),
Self::Rect3D(item) => item.into_any(),
}
}
pub fn __repr__(&self, py: Python) -> String {
match self {
Self::Line3D(item) => item.borrow(py).__repr__(py),
Self::PolyLine3D(item) => item.borrow(py).__repr__(py),
Self::String2D(item) => item.borrow(py).__repr__(py),
Self::String3D(item) => item.borrow(py).__repr__(py),
Self::Rect2D(item) => item.borrow(py).__repr__(py),
Self::Rect3D(item) => item.borrow(py).__repr__(py),
}
}
}