som_passport_t

Struct som_passport_t 

Source
#[repr(C)]
pub struct som_passport_t { pub flags: u64, pub name: som_atom_t, pub properties: *const som_property_def_t, pub n_properties: usize, pub methods: *const som_method_def_t, pub n_methods: usize, pub item_getter: Option<extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &mut VALUE) -> BOOL>, pub item_setter: Option<extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &VALUE) -> BOOL>, pub item_next: Option<extern "C" fn(thing: *mut som_asset_t, p_idx: &mut VALUE, p_value: &mut VALUE) -> BOOL>, pub prop_getter: Option<extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &mut VALUE) -> BOOL>, pub prop_setter: Option<extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &VALUE) -> BOOL>, }
Expand description

Defines properties and methods of an asset.

Fields§

§flags: u64

Flags of an asset, see som_passport_flags.

§name: som_atom_t

The name of the class (asset type).

§properties: *const som_property_def_t

Properties: asset.prop.

Must be a pointer to an array of structures:

let mut pst = Box::new(som_passport_t::default());

type ObjectProps = [som_property_def_t; 2];
let mut props = Box::new(ObjectProps::default());

let mut prop1 = &mut props[0];
prop1.name = atom("age");

let mut prop2 = &mut props[1];
prop2.name = atom("name");

pst.n_properties = 2;
pst.properties = Box::into_raw(props) as *const _;
§n_properties: usize

Properties count.

§methods: *const som_method_def_t

Methods: asset.func()

Must be a pointer to an array of structures, see properties for an example.

§n_methods: usize

Methods count.

§item_getter: Option<extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &mut VALUE) -> BOOL>

Index access: var item = asset[key].

§item_setter: Option<extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &VALUE) -> BOOL>

Index access: asset[key] = item.

§item_next: Option<extern "C" fn(thing: *mut som_asset_t, p_idx: &mut VALUE, p_value: &mut VALUE) -> BOOL>

Enumeration: for(var item in asset).

§prop_getter: Option<extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &mut VALUE) -> BOOL>

Property access interceptor: var val = asset.prop.

§prop_setter: Option<extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &VALUE) -> BOOL>

Property set interceptor: asset.prop = val.

Trait Implementations§

Source§

impl Default for som_passport_t

Empty passport.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, 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.