Skip to content

Commit

Permalink
refactor(py, imports): create preludes (#14)
Browse files Browse the repository at this point in the history
* testing new pyo3 feat with a DAT

* refactor(py, imports): create preludes

* remove test dat
  • Loading branch information
rosofo authored Dec 8, 2024
1 parent 7553635 commit bdb7a00
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 16 deletions.
5 changes: 4 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions plugins/chop/python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#![feature(min_specialization)]

use pyo3::impl_::pyclass::{PyClassImpl, PyMethods};
use pyo3::prelude::PyAnyMethods;
use pyo3::{pyclass, pymethods, Bound, PyAny, PyResult, Python};
use std::pin::Pin;
use td_rs_chop::cxx::AsPlugin;
use td_rs_chop::*;
use td_rs_chop::prelude::*;
use td_rs_derive::*;
use td_rs_derive_py::PyOp;

Expand Down
8 changes: 4 additions & 4 deletions plugins/sop/generator-sop/src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ pub const THE_CUBE_TEXTURE: [TexCoord; THE_CUBE_NUM_PTS] = [
// front
TexCoord::new(2.0 / 3.0, 0.0, 0.0),
TexCoord::new(2.0 / 3.0, 0.5, 0.0),
TexCoord::new(3.0 / 3.0, 0.0, 0.0),
TexCoord::new(3.0 / 3.0, 0.5, 0.0),
TexCoord::new(1.0, 0.0, 0.0),
TexCoord::new(1.0, 0.5, 0.0),
// back
TexCoord::new(0.0 / 3.0, 0.5, 0.0),
TexCoord::new(0.0 / 3.0, 0.0, 0.0),
TexCoord::new(1.0 / 3.0, 0.5, 0.0),
TexCoord::new(1.0 / 3.0, 0.0, 0.0),
// top
TexCoord::new(2.0 / 3.0, 1.0, 0.0),
TexCoord::new(3.0 / 3.0, 1.0, 0.0),
TexCoord::new(1.0, 1.0, 0.0),
TexCoord::new(2.0 / 3.0, 0.5, 0.0),
TexCoord::new(3.0 / 3.0, 0.5, 0.0),
TexCoord::new(1.0, 0.5, 0.0),
// bottom
TexCoord::new(1.0 / 3.0, 0.5, 0.0),
TexCoord::new(2.0 / 3.0, 0.5, 0.0),
Expand Down
3 changes: 2 additions & 1 deletion td-rs-chop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cxx = "1.0.78"
td-rs-base = { path = "../td-rs-base" }
tracing-base = { package = "tracing", version = "0.1", optional = true }
tracing-subscriber = { version = "0.2", optional = true }
pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true }

[build-dependencies]
td-rs-autocxx-build = { path = "../td-rs-autocxx-build" }
Expand All @@ -21,6 +22,6 @@ miette = { version="5", features = [ "fancy" ] }

[features]
default = []
python = ["td-rs-base/python"]
python = ["td-rs-base/python", "dep:pyo3"]
tracing = ["td-rs-base/tracing", "tracing-base", "tracing-subscriber"]
tokio = ["td-rs-base/tokio"]
1 change: 1 addition & 0 deletions td-rs-chop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub use td_rs_base::chop::*;
pub use td_rs_base::*;

pub mod cxx;
pub mod prelude;

#[derive(Debug, Default)]
pub struct ChopOutputInfo {
Expand Down
9 changes: 9 additions & 0 deletions td-rs-chop/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub use crate::cxx::AsPlugin;
pub use crate::*;

#[cfg(feature = "python")]
pub use pyo3::impl_::pyclass::{PyClassImpl, PyMethods};
#[cfg(feature = "python")]
pub use pyo3::prelude::*;
#[cfg(feature = "python")]
pub use std::pin::Pin;
3 changes: 2 additions & 1 deletion td-rs-dat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ref-cast = "1.0"
sparsevec = "0.2.0"
tracing-base = { package = "tracing", version = "0.1", optional = true }
tracing-subscriber = { version = "0.2", optional = true }
pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true }

[build-dependencies]
td-rs-autocxx-build = { path = "../td-rs-autocxx-build" }
Expand All @@ -23,6 +24,6 @@ miette = { version="5", features = [ "fancy" ] }

[features]
default = []
python = ["td-rs-base/python"]
python = ["td-rs-base/python", "dep:pyo3"]
tracing = ["td-rs-base/tracing", "tracing-base", "tracing-subscriber"]
tokio = ["td-rs-base/tokio"]
1 change: 1 addition & 0 deletions td-rs-dat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub use td_rs_base::param::OperatorParams;
pub use td_rs_base::*;

pub mod cxx;
pub mod prelude;

#[derive(Debug, Default)]
pub struct DatGeneralInfo {
Expand Down
9 changes: 9 additions & 0 deletions td-rs-dat/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub use crate::cxx::AsPlugin;
pub use crate::*;

#[cfg(feature = "python")]
pub use pyo3::impl_::pyclass::{PyClassImpl, PyMethods};
#[cfg(feature = "python")]
pub use pyo3::prelude::*;
#[cfg(feature = "python")]
pub use std::pin::Pin;
3 changes: 2 additions & 1 deletion td-rs-sop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ td-rs-base = { path = "../td-rs-base" }
ref-cast = "1.0"
tracing-base = { package = "tracing", version = "0.1", optional = true }
tracing-subscriber = { version = "0.2", optional = true }
pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true }

[build-dependencies]
td-rs-autocxx-build = { path = "../td-rs-autocxx-build" }
Expand All @@ -22,6 +23,6 @@ miette = { version="5", features = [ "fancy" ] }

[features]
default = []
python = ["td-rs-base/python"]
python = ["td-rs-base/python", "dep:pyo3"]
tracing = ["td-rs-base/tracing", "tracing-base", "tracing-subscriber"]
tokio = ["td-rs-base/tokio"]
8 changes: 7 additions & 1 deletion td-rs-sop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub use td_rs_base::sop::*;
pub use td_rs_base::*;

pub mod cxx;
pub mod prelude;

#[derive(Debug, Default)]
pub struct SopGeneralInfo {
Expand Down Expand Up @@ -140,7 +141,12 @@ impl<'cook> SopOutput<'cook> {
self.output.as_mut().getNumTexCoordLayers() as usize
}

pub fn set_custom_attribute(&mut self, info: CustomAttributeInfo, data: CustomAttributeData, num_pts: usize) {
pub fn set_custom_attribute(
&mut self,
info: CustomAttributeInfo,
data: CustomAttributeData,
num_pts: usize,
) {
unsafe {
let name = std::ffi::CString::new(info.name).unwrap();
let info = cxx::SOP_CustomAttribInfo {
Expand Down
9 changes: 9 additions & 0 deletions td-rs-sop/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub use crate::cxx::AsPlugin;
pub use crate::*;

#[cfg(feature = "python")]
pub use pyo3::impl_::pyclass::{PyClassImpl, PyMethods};
#[cfg(feature = "python")]
pub use pyo3::prelude::*;
#[cfg(feature = "python")]
pub use std::pin::Pin;
3 changes: 2 additions & 1 deletion td-rs-top/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ td-rs-base = { path = "../td-rs-base" }
ref-cast = "1.0"
tracing-base = { package = "tracing", version = "0.1", optional = true }
tracing-subscriber = { version = "0.2", optional = true }
pyo3 = { git = "https://github.com/tychedelia/pyo3", branch = "td-rs", features = ["abi3-py311"], optional = true }

[build-dependencies]
td-rs-autocxx-build = { path = "../td-rs-autocxx-build" }
Expand All @@ -22,6 +23,6 @@ miette = { version="5", features = [ "fancy" ] }

[features]
default = []
python = ["td-rs-base/python"]
python = ["td-rs-base/python", "dep:pyo3"]
tracing = ["td-rs-base/tracing", "tracing-base", "tracing-subscriber"]
tokio = ["td-rs-base/tokio"]
2 changes: 2 additions & 0 deletions td-rs-top/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::pin::Pin;
pub use td_rs_base::top::*;
pub use td_rs_base::*;

pub mod prelude;

pub struct TopOutput<'cook> {
output: Pin<&'cook mut cxx::TOP_Output>,
}
Expand Down
9 changes: 9 additions & 0 deletions td-rs-top/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub use crate::cxx::AsPlugin;
pub use crate::*;

#[cfg(feature = "python")]
pub use pyo3::impl_::pyclass::{PyClassImpl, PyMethods};
#[cfg(feature = "python")]
pub use pyo3::prelude::*;
#[cfg(feature = "python")]
pub use std::pin::Pin;

0 comments on commit bdb7a00

Please sign in to comment.