Skip to main content

pxs_Module

Struct pxs_Module 

Source
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: String

Name 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

Source

pub fn new(name: String) -> Self

Create a new module.

Source

pub fn add_callback(&mut self, name: &str, full_name: &str, idx: i32)

Add a callback to current module.

Source

pub fn add_variable(&mut self, name: &str, var: *mut pxs_Var)

Add a variable to current module.

Source

pub fn add_module(&mut self, child: Arc<pxs_Module>)

Add a internal module.

Source

pub fn get_name(&self) -> String

Get name without package

Source

pub fn get_pkg(&self) -> String

Get package name

Trait Implementations§

Source§

impl Clone for pxs_Module

Source§

fn clone(&self) -> pxs_Module

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for pxs_Module

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PtrMagic for pxs_Module

Source§

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§

fn from_raw(ptr: *mut Self) -> Self

Safety: Only call this on a pointer created via into_raw.
Source§

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
Source§

impl Send for pxs_Module

Source§

impl Sync for pxs_Module

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> MaybeSend for T
where T: Send,