Struct playdate_lua

Source
#[repr(C)]
pub struct playdate_lua {
Show 32 fields pub addFunction: Option<unsafe extern "C" fn(f: lua_CFunction, name: *const c_char, outErr: *mut *const c_char) -> c_int>, pub registerClass: Option<unsafe extern "C" fn(name: *const c_char, reg: *const lua_reg, vals: *const lua_val, isstatic: c_int, outErr: *mut *const c_char) -> c_int>, pub pushFunction: Option<unsafe extern "C" fn(f: lua_CFunction)>, pub indexMetatable: Option<unsafe extern "C" fn() -> c_int>, pub stop: Option<unsafe extern "C" fn()>, pub start: Option<unsafe extern "C" fn()>, pub getArgCount: Option<unsafe extern "C" fn() -> c_int>, pub getArgType: Option<unsafe extern "C" fn(pos: c_int, outClass: *mut *const c_char) -> LuaType>, pub argIsNil: Option<unsafe extern "C" fn(pos: c_int) -> c_int>, pub getArgBool: Option<unsafe extern "C" fn(pos: c_int) -> c_int>, pub getArgInt: Option<unsafe extern "C" fn(pos: c_int) -> c_int>, pub getArgFloat: Option<unsafe extern "C" fn(pos: c_int) -> c_float>, pub getArgString: Option<unsafe extern "C" fn(pos: c_int) -> *const c_char>, pub getArgBytes: Option<unsafe extern "C" fn(pos: c_int, outlen: *mut usize) -> *const c_char>, pub getArgObject: Option<unsafe extern "C" fn(pos: c_int, type_: *mut c_char, outud: *mut *mut LuaUDObject) -> *mut c_void>, pub getBitmap: Option<unsafe extern "C" fn(pos: c_int) -> *mut LCDBitmap>, pub getSprite: Option<unsafe extern "C" fn(pos: c_int) -> *mut LCDSprite>, pub pushNil: Option<unsafe extern "C" fn()>, pub pushBool: Option<unsafe extern "C" fn(val: c_int)>, pub pushInt: Option<unsafe extern "C" fn(val: c_int)>, pub pushFloat: Option<unsafe extern "C" fn(val: c_float)>, pub pushString: Option<unsafe extern "C" fn(str_: *const c_char)>, pub pushBytes: Option<unsafe extern "C" fn(str_: *const c_char, len: usize)>, pub pushBitmap: Option<unsafe extern "C" fn(bitmap: *mut LCDBitmap)>, pub pushSprite: Option<unsafe extern "C" fn(sprite: *mut LCDSprite)>, pub pushObject: Option<unsafe extern "C" fn(obj: *mut c_void, type_: *mut c_char, nValues: c_int) -> *mut LuaUDObject>, pub retainObject: Option<unsafe extern "C" fn(obj: *mut LuaUDObject) -> *mut LuaUDObject>, pub releaseObject: Option<unsafe extern "C" fn(obj: *mut LuaUDObject)>, pub setUserValue: Option<unsafe extern "C" fn(obj: *mut LuaUDObject, slot: c_uint)>, pub getUserValue: Option<unsafe extern "C" fn(obj: *mut LuaUDObject, slot: c_uint) -> c_int>, pub callFunction_deprecated: Option<unsafe extern "C" fn(name: *const c_char, nargs: c_int)>, pub callFunction: Option<unsafe extern "C" fn(name: *const c_char, nargs: c_int, outerr: *mut *const c_char) -> c_int>,
}

Fields§

§addFunction: Option<unsafe extern "C" fn(f: lua_CFunction, name: *const c_char, outErr: *mut *const c_char) -> c_int>

int playdate->lua->addFunction(lua_CFunction f, const char* name, const char** outErr);

Adds the Lua function f to the Lua runtime, with name name. (name can be a table path using dots, e.g. if name = “mycode.myDrawingFunction” adds the function “myDrawingFunction” to the global table “myCode”.) Returns 1 on success or 0 with an error message in outErr.

§registerClass: Option<unsafe extern "C" fn(name: *const c_char, reg: *const lua_reg, vals: *const lua_val, isstatic: c_int, outErr: *mut *const c_char) -> c_int>

int playdate->lua->registerClass(const char* name, const lua_reg* reg, const lua_val* vals, int isstatic, const char** outErr);

Creates a new “class” (i.e., a Lua metatable containing functions) with the given name and adds the given functions and constants to it. If the table is simply a list of functions that won’t be used as a metatable, isstatic should be set to 1 to create a plain table instead of a metatable. Please see C_API/Examples/Array for an example of how to use registerClass to create a Lua table-like object from C.

§pushFunction: Option<unsafe extern "C" fn(f: lua_CFunction)>

void playdate->lua->pushFunction(lua_CFunction f);

Pushes a lua_CFunction onto the stack.

§indexMetatable: Option<unsafe extern "C" fn() -> c_int>

int playdate->lua->indexMetatable(void);

If a class includes an __index function, it should call this first to check if the indexed variable exists in the metatable. If the indexMetatable() call returns 1, it has located the variable and put it on the stack, and the __index function should return 1 to indicate a value was found. If indexMetatable() doesn’t find a value, the __index function can then do its custom getter magic.

§stop: Option<unsafe extern "C" fn()>

void playdate->lua->stop(void);

Stops the run loop.

§start: Option<unsafe extern "C" fn()>

void playdate->lua->start(void);

Starts the run loop back up.

§getArgCount: Option<unsafe extern "C" fn() -> c_int>

int playdate->lua->getArgCount(void);

Returns the number of arguments passed to the function.

§getArgType: Option<unsafe extern "C" fn(pos: c_int, outClass: *mut *const c_char) -> LuaType>

enum LuaType playdate->lua->getArgType(int pos, const char** outClass);

Returns the type of the variable at stack position pos. If the type is kTypeObject and outClass is non-NULL, it returns the name of the object’s metatable.

§argIsNil: Option<unsafe extern "C" fn(pos: c_int) -> c_int>

int playdate->lua->argIsNil(int pos);

Returns 1 if the argument at the given position pos is nil.

§getArgBool: Option<unsafe extern "C" fn(pos: c_int) -> c_int>

int playdate->lua->getArgBool(int pos);

Returns one if the argument at position pos is true, zero if not.

§getArgInt: Option<unsafe extern "C" fn(pos: c_int) -> c_int>

int playdate->lua->getArgInt(int pos);

Returns the argument at position pos as an int.

§getArgFloat: Option<unsafe extern "C" fn(pos: c_int) -> c_float>

float playdate->lua->getArgFloat(int pos);

Returns the argument at position pos as a float.

§getArgString: Option<unsafe extern "C" fn(pos: c_int) -> *const c_char>

const char* playdate->lua->getArgString(int pos);

Returns the argument at position pos as a string.

§getArgBytes: Option<unsafe extern "C" fn(pos: c_int, outlen: *mut usize) -> *const c_char>

const char* playdate->lua->getArgBytes(int pos, size_t* outlen);

Returns the argument at position pos as a string and sets outlen to its length.

§getArgObject: Option<unsafe extern "C" fn(pos: c_int, type_: *mut c_char, outud: *mut *mut LuaUDObject) -> *mut c_void>

void* playdate->lua->getArgObject(int pos, char* type, LuaUDObject** outud);

Checks the object type of the argument at position pos and returns a pointer to it if it’s the correct type. Optionally sets outud to a pointer to the opaque LuaUDObject for the given stack.

§getBitmap: Option<unsafe extern "C" fn(pos: c_int) -> *mut LCDBitmap>

LCDBitmap* playdate->lua->getBitmap(int pos);

Returns the argument at position pos as an LCDBitmap.

§getSprite: Option<unsafe extern "C" fn(pos: c_int) -> *mut LCDSprite>

LCDSprite* playdate->lua->getSprite(int pos);

Returns the argument at position pos as an LCDSprite.

§pushNil: Option<unsafe extern "C" fn()>

void playdate->lua->pushNil(void);

Pushes nil onto the stack.

§pushBool: Option<unsafe extern "C" fn(val: c_int)>

void playdate->lua->pushBool(int val);

Pushes the int val onto the stack.

§pushInt: Option<unsafe extern "C" fn(val: c_int)>

void playdate->lua->pushInt(int val);

Pushes the int val onto the stack.

§pushFloat: Option<unsafe extern "C" fn(val: c_float)>

void playdate->lua->pushFloat(float val);

Pushes the float val onto the stack.

§pushString: Option<unsafe extern "C" fn(str_: *const c_char)>

void playdate->lua->pushString(char* str);

Pushes the string str onto the stack.

§pushBytes: Option<unsafe extern "C" fn(str_: *const c_char, len: usize)>

void playdate->lua->pushBytes(char* str, size_t len);

Like pushString(), but pushes an arbitrary byte array to the stack, ignoring \0 characters.

§pushBitmap: Option<unsafe extern "C" fn(bitmap: *mut LCDBitmap)>

void playdate->lua->pushBitmap(LCDBitmap* bitmap);

Pushes the LCDBitmap bitmap onto the stack.

§pushSprite: Option<unsafe extern "C" fn(sprite: *mut LCDSprite)>

void playdate->lua->pushSprite(LCDSprite* sprite);

Pushes the LCDSprite sprite onto the stack.

§pushObject: Option<unsafe extern "C" fn(obj: *mut c_void, type_: *mut c_char, nValues: c_int) -> *mut LuaUDObject>

LuaUDObject* playdate->lua->pushObject(void* obj, char* type, int nValues);

Pushes the given custom object obj onto the stack and returns a pointer to the opaque LuaUDObject. type must match the class name used in playdate->lua->registerClass(). nValues is the number of slots to allocate for Lua values (see set/getObjectValue()).

§retainObject: Option<unsafe extern "C" fn(obj: *mut LuaUDObject) -> *mut LuaUDObject>

LuaUDObject* playdate->lua->retainObject(LuaUDObject* obj);

Retains the opaque LuaUDObject obj and returns same.

§releaseObject: Option<unsafe extern "C" fn(obj: *mut LuaUDObject)>

void playdate->lua->releaseObject(LuaUDObject* obj);

Releases the opaque LuaUDObject obj.

§setUserValue: Option<unsafe extern "C" fn(obj: *mut LuaUDObject, slot: c_uint)>

void playdate->lua->setUserValue(LuaUDObject* obj, int slot);

Sets the value of object obj’s uservalue slot number slot (starting at 1, not zero) to the value at the top of the stack.

§getUserValue: Option<unsafe extern "C" fn(obj: *mut LuaUDObject, slot: c_uint) -> c_int>

int playdate->lua->getUserValue(LuaUDObject* obj, int slot);

Copies the value at obj’s given uservalue slot to the top of the stack and returns its stack position.

§callFunction_deprecated: Option<unsafe extern "C" fn(name: *const c_char, nargs: c_int)>§callFunction: Option<unsafe extern "C" fn(name: *const c_char, nargs: c_int, outerr: *mut *const c_char) -> c_int>

int playdate->lua->callFunction(const char* name, int nargs, const char** outerr);

Calls the Lua function name and and indicates that nargs number of arguments have already been pushed to the stack for the function to use. name can be a table path using dots, e.g. “playdate.apiVersion”. Returns 1 on success; on failure, returns 0 and puts an error message into the outerr pointer, if it’s set. Calling Lua from C is slow, so use sparingly.

Trait Implementations§

Source§

impl Clone for playdate_lua

Source§

fn clone(&self) -> playdate_lua

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for playdate_lua

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for playdate_lua

Source§

fn default() -> playdate_lua

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

impl Hash for playdate_lua

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
Source§

impl Ord for playdate_lua

Source§

fn cmp(&self, other: &playdate_lua) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for playdate_lua

Source§

fn eq(&self, other: &playdate_lua) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for playdate_lua

Source§

fn partial_cmp(&self, other: &playdate_lua) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for playdate_lua

Source§

impl Eq for playdate_lua

Source§

impl StructuralPartialEq for playdate_lua

Auto Trait Implementations§

§

impl Freeze for playdate_lua

§

impl RefUnwindSafe for playdate_lua

§

impl Send for playdate_lua

§

impl Sync for playdate_lua

§

impl Unpin for playdate_lua

§

impl UnwindSafe for playdate_lua

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 128 bytes