Crate yaslapi_sys

source ·
Expand description

§yaslapi-sys

yaslapi-sys is a Rust library that provides raw bindings to the Yet Another Scripting Language (YASL) API.

Then run cargo build to build your project.

§Usage

Here’s an example of how to use yaslapi-sys in your Rust code:

use yaslapi_sys::YASL_State;
use std::ffi::CString;

const SRC: &str = "let x = 5; echo x**x;";
let state: *mut YASL_State = unsafe { yaslapi_sys::YASL_newstate_bb(SRC.as_ptr().cast(), SRC.len()) };
assert!(!state.is_null());

Structs§

Constants§

Statics§

Functions§

  • Returns the nth position of the stack if it is a bool. Otherwise, causes a type error, along with a printed error message. @param S The YASL_State. @param name Name of the function in which this is called, used for error message. @param pos the position of the argument. @return the nth position of the stack if it’s a bool, otherwise no return.
  • Returns the nth position of the stack if it is a float. Otherwise, causes a type error, along with a printed error message. @param S The YASL_State. @param name Name of the function in which this is called, used for error message. @param pos the position of the argument. @return the nth position of the stack if it’s a float, otherwise no return.
  • Returns the nth position of the stack if it is an int. Otherwise, causes a type error, along with a printed error message. @param S The YASL_State. @param name Name of the function in which this is called, used for error message. @param pos the position of the argument. @return the nth position of the stack if it’s an int, otherwise no return.
  • Checks that the nth position of the stack if it is undef. Otherwise, causes a type error, along with a printed error message. @param S The YASL_State. @param name Name of the function in which this is called, used for error message. @param pos the position of the argument.
  • Returns the nth position of the stack if it is a userdata with a matching tag. Otherwise, causes a type error, along with a printed error message. @param S The YASL_State. @param tag The tag of the userdata. @param name Name of the function in which this is called, used for error message. @param pos the position of the argument, used only for the error message. @return the nth position of the stack if it’s a userdata, otherwise no return.
  • Loads all standard libraries into the appropriate state and declares them all with their default names. @param S The state onto which to load the libraries. @return YASL_SUCESS on success, else error code.
  • Declares a global and initializes it with the top value from the stack. @param S the YASL_State. @param name name of the global (nul-terminated). @return
  • Prints an error message @param S The YASL State. @param fn_name name of the function in which the error occured. @param position which arg had the wrong type. @param exp expected type of the arg. @param act actual type of the arg.
  • Inserts all functions in the array into a table on top of the stack. @param S The YASL_State @param functions array of function names, function pointers, and number of args.
  • [-0, +0] compiles the source for the given YASL_State, but doesn’t run it. @param S the YASL_State containing the YASL source code to be compiled. @return 0 on success, otherwise an error code.
  • [-0, +0] Declares a global for use in the given YASL_State. YASL does not handle the lifetime of the string; normally a literal is used. @param S the YASL_State in which to declare the global. @param name the name of the global (null-terminated string). @return YASL_SUCCESS on success, otherwise an error code.
  • deletes the given YASL_State. @param S YASL_State to be deleted. @return 0 on success, otherwise an error code.
  • [-0, +1] Duplicates the top of the stack. @param S the YASL_State. @return YASL_SUCCESS on success, otherwise an error code.
  • [-0, +0] Execute the bytecode for the given YASL_State. @param S the YASL_State to use to execute the bytecode. @return 0 on successful execution, else an error code.
  • [-0, +0] Execute the bytecode for the given YASL_State in REPL mode. The only difference between YASL_execute_REPL and YASL_execute is that YASL_execute_REPL will print the last statement passed to it if that statement is an expression. @param S the YASL_State to use to execute the bytecode. @return 0 on successful execution, else an error code.
  • [-(n+1), +r] Calls a function with n parameters. The function should be located below all n parameters it will be called with. The left-most parameter is placed directly above the function, the right-most paramter at the top of the stack. @param S the YASL_State @param n @return r, the number of return values of the called functions
  • [-0, +0] checks if the top of the stack is bool. @param S the YASL_State. @return true if the top of the stack is bool, else false.
  • [-0, +0] checks if the top of the stack is float. @param S the YASL_State. @return true if the top of the stack is float, else false.
  • [-0, +0] checks if the top of the stack is int. @param S the YASL_State. @return true if the top of the stack is int, else false.
  • [-0, +0] checks if the top of the stack is list. @param S the YASL_State. @return true if the top of the stack is list, else false.
  • [-0, +0] checks if the object at index n is bool. @param S the YASL_State. @return true if the object at index n is bool, else false.
  • [-0, +0] checks if the object at index n is float. @param S the YASL_State. @return true if the object at index n is float, else false.
  • [-0, +0] checks if the object at index n is int. @param S the YASL_State. @return true if the object at index n is int, else false.
  • [-0, +0] checks if the object at index n is list. @param S the YASL_State. @return true if the object at index n is list, else false.
  • [-0, +0] checks if the object at index n is str. @param S the YASL_State to which the stack belongs. @return true if the object at index n is str, else false.
  • [-0, +0] checks if the object at index n is table. @param S the YASL_State to which the stack belongs. @return true if the object at index n is table, else false.
  • [-0, +0] Checks if the object at index n is undef. @param S the YASL_State to which the stack belongs. @return true if the object at index n is undef, else false.
  • [-0, +0] checks if the object at index n is userdata. @param S the YASL_State. @return true if the object at index n is userdata, else false.
  • [-0, +0] checks if the object at index n is userpointer. @param S the YASL_State. @return true if the object at index n is userpointer, else false.
  • [-0, +0] checks if the top of the stack is str. @param S the YASL_State. @return true if the top of the stack is str, else false.
  • [-0, +0] checks if the top of the stack is table. @param S the YASL_State. @return true if the top of the stack is table, else false.
  • [-0, +0] Checks if the top of the stack is undef. @param S the YASL_State. @return true if the top of the stack is undef, else false.
  • [-0, +0] checks if the top of the stack is userdata. @param S the YASL_State. @return true if the top of the stack is userdata, else false.
  • [-0, +0] checks if the top of the stack is userpointer. @param S the YASL_State. @return true if the top of the stack is userpointer, else false.
  • [+1, -1] Pops the top of the stack, the evalutes len x, where x is the popped value. The result is pushed on top of the stack. @param S the YASL_State.
  • [+1, -0] Indexes the list on top of the stack and pushes the result on top of the stack. @param S the YASL_State. @param n the index to use on the list. @return YASL_SUCCESS on
  • [-1, +0] Pops the top of the stack and appends it to a list (which should be located directly below the top of the stack). @param S the YASL_State. @return YASL_SUCCESS on sucess, else an error code.
  • [-0, +1] Loads a global and puts it on top of the stack. @param S the YASL_State. @param name nul-terminated name of the global. @return YASL_SUCCESS on success, otherwise an error code.
  • [-0, +1] Loads a metatable by name. @param S the YASL_State. @param name name of the metatable. @return YASL_SUCCESS on success, else an error code.
  • Initialises a new YASL_State for usage. @param filename the name of the file used to initialize the state. @return the new YASL_State, or NULL on failure.
  • initialises a new YASL_State for usage, or NULL on failure. @param buf buffer containing the source code used to initialize the state. @param len the length of the buffer. @return the new YASL_State
  • [-0, +0] Returns the bool value of the top of the stack, if it is a boolean. Otherwise returns false. Does not modify the stack. @param S the YASL_State. @return
  • [-0, +0] Returns a copy of the str value of the top of the stack, if the top of the stack is a str. Otherwise returns 0. Does not modify the stack. @param S the YASL_State. @return the value of the str on top of the stack, or NULL if it’s not a str.
  • [-0, +0] Returns the float value of the top of the stack, if the top of the stack is a float. Otherwise returns 0.0. Does not modify the stack. @param S the YASL_State. @return
  • [-0, +0] Returns the int value of the top of the stack, if the top of the stack is an int. Otherwise returns 0. Does not modify the stack. @param S the YASL_State. @return the value of the int on top of the stack, or 0 if it’s not an int.
  • [-0, +0] Returns the bool value at index n, if it is a boolean. Otherwise returns false. Does not modify the stack. @param S @return
  • [-0, +0] Returns the float value at index n, if it is a float. Otherwise returns 0.0. Does not modify the stack. @param S @return
  • [-0, +0] Returns the int value at index n, if it is an int. Otherwise returns 0. Does not modify the stack. @param S the YASL_State. @return the value of the int at index n, or 0 if it’s not an int.
  • [-0, +0] returns the type of object at index n. @param S the YASL_State. @return the type on top of the stack.
  • [-0, +0] returns the type of index n as a string. @param S the YASL_State. @return the string representation of the type of index n.
  • [-0, +0] Returns the userdata value at index n, if it is a userdata. Otherwise returns NULL. Does not modify the stack. @param S the YASL_State. @return the userdata value at index n, or NULL if it’s not a userdata.
  • [-0, +0] returns the type of the top of the stack. @param S the YASL_State. @return the type on top of the stack.
  • [-0, +0] returns the type of the top of the stack as a string. @param S the YASL_State to which the stack belongs. @return the string representation of the type on top of the stack.
  • [-0, +0] Returns the userdata value of the top of the stack, if the top of the stack is a userdata. Otherwise returns NULL. Does not modify the stack. @param S the YASL_State. @return the userdata value on top of the stack, or NULL if it’s not a userdata.
  • [-0, +0] Returns the userptr value of the top of the stack, if the top of the stack is a userptr. Otherwise returns NULL. Does not modify the stack. @param S the YASL_State. @return the value of the userptr on top of the stack, or NULL if it’s not a userptr.
  • [-1, +0] Removes the top of the stack. @param S the YASL_State the stack belongs to.
  • [-1, +0] Returns the bool value of the top of the stack, if the top of the stack is a boolean. Otherwise returns false. Removes the top element of the stack. @param S the YASL_State. @return the bool value of the top of the stack.
  • [-1, +0] Returns the str value (nul-terminated) of the top of the stack, if the top of the stack is a str. Otherwise returns NULL. @param S the YASL_State. @return the value of the str on top of the stack, or NULL if it’s not a str.
  • [-1, +0] Returns the float value of the top of the stack, if the top of the stack is a float. Otherwise returns 0.0. Removes the top of the stack. @param S the YASL_State. @return the float value on top of the stack.
  • [-1, +0] Returns the int value of the top of the stack, if the top of the stack is an int. Otherwise returns 0. Removes the top of the stack. @param S the YASL_State. @return the int value of the top of the stack.
  • [-0, +0] Prints a runtime error. @param S the YASL_State in which the error occurred. @param fmt a format string, taking the same parameters as printf. @param … var args for the above format strings.
  • [-0, +1] Pushes a boolean value onto the stack. @param S the YASL_State onto which to push the boolean. @param value boolean to be pushed onto the stack.
  • [-0, +1] Pushes a function pointer onto the stack @param S the YASL_State onto which to push the string. @param value the function pointer to be pushed onto the stack.
  • [-0, +1] Pushes a double value onto the stack. @param S the YASL_State onto which to push the double. @param value the float to push onto the stack.
  • [-0, +1] Pushes an integer value onto the stack. @param S the YASL_State onto which to push the integer. @param integer to be pushed onto the stack.
  • [-0, +1] Pushes an empty list onto the stack. @param S the YASL_State onto which to push the list.
  • [-0, +1] Pushes a nul-terminated string onto the stack. This memory will not be managed by YASL, and must outlive S. @param S the YASL_State. @param value nul-terminated string to be pushed onto the stack.
  • [-0, +1] Pushes a string with length len onto the stack. YASL makes a copy of the given string, and manages the memory for it. The string may have embedded 0s. @param S the YASL_State. @param value the string to be pushed onto the stack. @param len the length of value.
  • [-0, +1] Pushes an empty table onto the stack. @param S the YASL_State onto which to push the table.
  • [-0, +1] Pushes an undef value onto the stack. @param S the YASL_State onto which to push the undef.
  • [-0, +1] Pushes a user-pointer onto the stack @param S the YASL_State onto which to push the user-pointer. @param userpointer the user-pointer to push onto the stack.
  • [-0, +1] Pushes a user-pointer onto the stack @param S the YASL_State onto which to push the user-pointer. @param userpointer the user-pointer to push onto the stack.
  • Pushes a nul-terminated string onto the stack. YASL makes a copy of the given string, and manages the memory for it. The string may not have embedded 0s; it is assumed to end at the first 0. @param S the YASL_State. @param value the string to be pushed onto the stack (nul-terminated).
  • [-0, +0] Registers a metatable with name name. After this returns, the metatable can be referred to by name in other functions dealing with metatables, e.g. YASL_setmt or YASL_loadmt. @param S the YASL_State. @param name the name of the metatable. @return YASL_SUCCESS.
  • resets S to the same state it would be in if newly created using YASL_newstate. @param S the YASL_State @param filename the name of the file used to initialize S @return YASL_SUCCESS if successful, otherwise an error.
  • resets S to the same state it would be in if newly created using YASL_newstate_bb. @param S the YASL_State. @param buf the buffer used to initialize S. @param len the length of buf. @return YASL_SUCCESS on success, else an error code.
  • [-1, +0] Pops the top of the YASL stack and stores it in the given global. @param S the YASL_State in which to store the global. @param name the name of the global. @return YASL_SUCCESS on success, otherwise an error code.
  • [-1, +2] Iterates over a table. The topmost item of the stack should be the previous index in the table, followed by the table itself. The index is popped, and then if there are more elements in the table, the next index and value are pushed. No values are pushed if we are already at the end of the table. @param S the YASL_State. @return true if there was a next element, otherwise false.
  • [-2, +0] inserts a key-value pair into the table. The topmost items is value, then key, then table. The key and value are popped from the stack. @param S the YASL_State which has the 3 items on top of the stack. @return 0 on success, else error code
  • [-0, +0] Causes a fatal error. @param S the YASL_State in which the error occured. @param error the error code.
  • a64l
  • abs
  • atof
  • atoi
  • atol
  • div
  • ecvt
  • exit
  • fcvt
  • free
  • gcvt
  • l64a
  • labs
  • ldiv
  • rand

Type Aliases§

Unions§