pub struct pxs_Module {
pub name: String,
pub callbacks: Vec<ModuleCallback>,
pub variables: Vec<ModuleVariable>,
pub modules: Vec<Arc<pxs_Module>>,
}Expand description
A Module is a C representation of data that needs to be (imported,required, etc)
The process is you add callbacks, variables, etc.
And THEN add the module.
So you first need to call
pixelmods_create_module() Which will create a new module struct with a name.
Here is a simple example.
Module* m = pixelmods_new_module("math");
pixelmods_module_add_callback(m, ...);
pixelmods_module_add_variable(m, ...);
pixelmods_add_module(m);You never free the module pointer because the runtime takes ownership.
Callbacks within modules use the same FUNCTION_LOOKUP global static variable.
Fields§
§name: StringName of the module.
callbacks: Vec<ModuleCallback>Callbacks that need to be added.
variables: Vec<ModuleVariable>Variables that need to be added.
modules: Vec<Arc<pxs_Module>>Internal modules
Implementations§
Source§impl pxs_Module
impl pxs_Module
Sourcepub fn add_callback(&mut self, name: &str, full_name: &str, idx: i32)
pub fn add_callback(&mut self, name: &str, full_name: &str, idx: i32)
Add a callback to current module.
Sourcepub fn add_variable(&mut self, name: &str, var: *mut pxs_Var)
pub fn add_variable(&mut self, name: &str, var: *mut pxs_Var)
Add a variable to current module.
Sourcepub fn add_module(&mut self, child: Arc<pxs_Module>)
pub fn add_module(&mut self, child: Arc<pxs_Module>)
Add a internal module.
Trait Implementations§
Source§impl Clone for pxs_Module
impl Clone for pxs_Module
Source§fn clone(&self) -> pxs_Module
fn clone(&self) -> pxs_Module
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Drop for pxs_Module
impl Drop for pxs_Module
Source§impl PtrMagic for pxs_Module
impl PtrMagic for pxs_Module
Source§fn into_raw(self) -> *mut Self
fn into_raw(self) -> *mut Self
Moves the object to the heap and returns a raw pointer.
Caller owns this memory but don’t worry about freeing it. The library frees it somewhere.
Source§unsafe fn from_borrow<'a>(ptr: *mut Self) -> &'a mut Self
unsafe fn from_borrow<'a>(ptr: *mut Self) -> &'a mut Self
Build from a Ptr but only get a reference, this means that the caller will still own the memory
impl Send for pxs_Module
impl Sync for pxs_Module
Auto Trait Implementations§
impl Freeze for pxs_Module
impl !RefUnwindSafe for pxs_Module
impl Unpin for pxs_Module
impl UnsafeUnpin for pxs_Module
impl !UnwindSafe for pxs_Module
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more