diff --git a/td-rs-dat/src/RustDatPlugin.h b/td-rs-dat/src/RustDatPlugin.h index 0ccf383..fefdaee 100644 --- a/td-rs-dat/src/RustDatPlugin.h +++ b/td-rs-dat/src/RustDatPlugin.h @@ -95,6 +95,10 @@ class RustDatPlugin : public DatPlugin { public: virtual ~RustDatPlugin(){}; + virtual void* inner() const = 0; + + virtual void* innerMut() = 0; + virtual void getGeneralInfo(DAT_GeneralInfo &info, const OP_Inputs &inputs) = 0; diff --git a/td-rs-dat/src/cxx.rs b/td-rs-dat/src/cxx.rs index c3b6f3f..6465b90 100644 --- a/td-rs-dat/src/cxx.rs +++ b/td-rs-dat/src/cxx.rs @@ -75,6 +75,14 @@ extern "C" fn dat_new(info: &'static OP_NodeInfo) -> *mut RustDatPluginImplCpp { } impl RustDatPlugin_methods for RustDatPluginImpl { + fn inner(&self) -> *mut c_void { + self.inner.as_ref() as *const dyn Dat as *mut c_void + } + + fn innerMut(&mut self) -> *mut c_void { + self.inner.as_mut() as *mut dyn Dat as *mut c_void + } + fn getGeneralInfo(&mut self, mut info: Pin<&mut DAT_GeneralInfo>, inputs: &OP_Inputs) { let input = OperatorInputs::new(inputs); if let Some(params) = self.inner.params_mut() { diff --git a/td-rs-derive-py/src/lib.rs b/td-rs-derive-py/src/lib.rs index fdfef31..b524ea6 100644 --- a/td-rs-derive-py/src/lib.rs +++ b/td-rs-derive-py/src/lib.rs @@ -128,8 +128,8 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { return std::ptr::null_mut(); } let py_chop = { - // let me = cxx::plugin_cast(me); - // let me = me.as_plugin_mut().inner(); + let me = cxx::plugin_cast(me); + let me = me.as_plugin().inner(); &mut *(me as *mut #struct_name) }; py::ToPyObj::to_py_obj(py_chop.#field_name) @@ -176,7 +176,7 @@ fn impl_py_op(input: &DeriveInput) -> TokenStream { } let py_chop = { let me = cxx::plugin_cast(me); - let me = me.as_plugin_mut().inner(); + let me = me.as_plugin_mut().innerMut(); &mut *(me as *mut #struct_name) }; @@ -331,7 +331,7 @@ pub fn py_op_methods(_attr: TokenStream, item: TokenStream) -> TokenStream { } let py_chop = { let me = cxx::plugin_cast(me); - let me = me.as_plugin_mut().inner(); + let me = me.as_plugin_mut().innerMut(); &mut *(me as *mut #struct_name) }; let res = py_chop.#fn_name(args, nargs as usize); diff --git a/td-rs-sop/src/RustSopPlugin.h b/td-rs-sop/src/RustSopPlugin.h index 2def693..d291e65 100644 --- a/td-rs-sop/src/RustSopPlugin.h +++ b/td-rs-sop/src/RustSopPlugin.h @@ -106,6 +106,10 @@ class RustSopPlugin : public SopPlugin { public: virtual ~RustSopPlugin() {}; + virtual void* inner() const = 0; + + virtual void* innerMut() = 0; + virtual void getGeneralInfo(SOP_GeneralInfo &info, const OP_Inputs &inputs) = 0; virtual void execute(SOP_Output &outputs, const OP_Inputs &inputs) = 0; diff --git a/td-rs-sop/src/cxx.rs b/td-rs-sop/src/cxx.rs index c787ea6..c5b64f9 100644 --- a/td-rs-sop/src/cxx.rs +++ b/td-rs-sop/src/cxx.rs @@ -86,6 +86,14 @@ extern "C" fn sop_new(info: &'static OP_NodeInfo) -> *mut RustSopPluginImplCpp { } impl RustSopPlugin_methods for RustSopPluginImpl { + fn inner(&self) -> *mut c_void { + self.inner.as_ref() as *const dyn Sop as *mut c_void + } + + fn innerMut(&mut self) -> *mut c_void { + self.inner.as_mut() as *mut dyn Sop as *mut c_void + } + fn getGeneralInfo(&mut self, mut info: Pin<&mut SOP_GeneralInfo>, inputs: &OP_Inputs) { let input = OperatorInputs::new(inputs); if let Some(params) = self.inner.params_mut() { diff --git a/td-rs-top/src/RustTopPlugin.h b/td-rs-top/src/RustTopPlugin.h index 2693df8..c1979c4 100644 --- a/td-rs-top/src/RustTopPlugin.h +++ b/td-rs-top/src/RustTopPlugin.h @@ -115,6 +115,10 @@ class RustTopPlugin : public TopPlugin { public: virtual ~RustTopPlugin() {}; + virtual void* inner() const = 0; + + virtual void* innerMut() = 0; + virtual void getGeneralInfo(TOP_GeneralInfo &info, const OP_Inputs &inputs) = 0; diff --git a/td-rs-top/src/cxx.rs b/td-rs-top/src/cxx.rs index e0417dd..293391c 100644 --- a/td-rs-top/src/cxx.rs +++ b/td-rs-top/src/cxx.rs @@ -97,6 +97,14 @@ extern "C" fn top_new( } impl RustTopPlugin_methods for RustTopPluginImpl { + fn inner(&self) -> *mut c_void { + self.inner.as_ref() as *const dyn Top as *mut c_void + } + + fn innerMut(&mut self) -> *mut c_void { + self.inner.as_mut() as *mut dyn Top as *mut c_void + } + fn getGeneralInfo(&mut self, mut info: Pin<&mut TOP_GeneralInfo>, inputs: &OP_Inputs) { let input = OperatorInputs::new(inputs); if let Some(params) = self.inner.params_mut() {