Skip to main content

LuaHost

Trait LuaHost 

Source
pub trait LuaHost {
Show 18 methods // Required method fn run( &self, engine: &mut Engine, name: &str, code: &[u8], ) -> Result<(), String>; // Provided methods fn call_function( &self, _engine: &mut Engine, _n: i32, ) -> Option<Result<(), String>> { ... } fn intarray_set(&self, _gset: i32, _writes: &[(i64, i64, &[i64])]) -> bool { ... } fn dump(&self, _engine: &mut Engine) -> Vec<u8> ⓘ { ... } fn undump(&self, _engine: &mut Engine, _data: &[u8]) -> Result<(), String> { ... } fn call_simple( &self, _engine: &mut Engine, _name: &str, ) -> Result<(), String> { ... } fn call_with_string( &self, _engine: &mut Engine, _name: &str, _arg: &str, ) -> Result<(), String> { ... } fn has_callback(&self, _name: &str) -> bool { ... } fn define_font( &self, _engine: &mut Engine, _name: &[u8], _size: i32, ) -> Option<u32> { ... } fn list_filter( &self, _engine: &mut Engine, _callback: &str, head: NodeRef, _group: &str, ) -> ListFilter { ... } fn pack_quality( &self, _engine: &mut Engine, _cb: &str, _incident: &str, _detail: i32, _b: NodeRef, _first: i32, _last: i32, ) -> NodeRef { ... } fn node_pass(&self, _engine: &mut Engine, _cb: &str, _head: NodeRef) -> bool { ... } fn linebreak_filter( &self, _engine: &mut Engine, _head: NodeRef, _display: bool, ) -> Option<NodeRef> { ... } fn mlist_to_hlist( &self, _engine: &mut Engine, _head: NodeRef, _style: i32, _penalties: bool, ) -> Option<NodeRef> { ... } fn pipe_read(&self, _engine: &mut Engine, _cmd: &[u8]) -> Option<Vec<u8>> { ... } fn input_level_string( &self, _engine: &mut Engine, _n: i64, ) -> Option<Vec<u8>> { ... } fn glyph_info(&self, _engine: &mut Engine, _p: NodeRef) -> Option<Vec<u8>> { ... } fn call_reference( &self, _engine: &mut Engine, _reference: i32, _args: ReferenceArgs, ) -> Result<(), String> { ... }
}
Expand description

Callbacks from the engine into an embedded Lua interpreter.

The engine does not depend on Lua. \directlua and related primitives call this trait, which retex-lua implements. The host is shared (Rc), so nested calls (Lua → TeX → Lua) reach it too.

Required Methods§

Source

fn run( &self, engine: &mut Engine, name: &str, code: &[u8], ) -> Result<(), String>

Runs a chunk of Lua code for \directlua (or \latelua, etc.). name is the chunk name. Text printed with tex.print must be pushed back into the engine’s input by the host.

Provided Methods§

Source

fn call_function( &self, _engine: &mut Engine, _n: i32, ) -> Option<Result<(), String>>

Calls the registered Lua function n (\luafunction n) with its number, like run runs a chunk; None if there is no such function.

Source

fn intarray_set(&self, _gset: i32, _writes: &[(i64, i64, &[i64])]) -> bool

Sets entries of expl3’s intarrays (l3intarray under LuaTeX keeps them in Lua tables), as \__intarray_gset:w does: for each (array, first, values), entry first + k of the array numbered array (\__intarray:w <array>) gets values[k]. gset is the \luafunction number of \__intarray_gset:w, through which the arrays are found. false, with nothing changed, when the arrays are not reachable natively.

Source

fn dump(&self, _engine: &mut Engine) -> Vec<u8> ⓘ

Data to store in the format file (e.g. lua.bytecode).

Source

fn undump(&self, _engine: &mut Engine, _data: &[u8]) -> Result<(), String>

Restores data stored by dump.

Source

fn call_simple(&self, _engine: &mut Engine, _name: &str) -> Result<(), String>

Calls callback name without arguments, ignoring its results (pre_dump, stop_run, …). Does nothing if none is registered.

Source

fn call_with_string( &self, _engine: &mut Engine, _name: &str, _arg: &str, ) -> Result<(), String>

Calls callback name with one string argument, ignoring its results (buildpage_filter, contribute_filter).

Source

fn has_callback(&self, _name: &str) -> bool

Whether a Lua function is registered for callback name.

Source

fn define_font( &self, _engine: &mut Engine, _name: &[u8], _size: i32, ) -> Option<u32>

Calls the define_font callback. Returns the id of the font it defined, or None if the font could not be loaded.

Source

fn list_filter( &self, _engine: &mut Engine, _callback: &str, head: NodeRef, _group: &str, ) -> ListFilter

Calls a node-list filter callback (pre_linebreak_filter, hpack_filter, post_linebreak_filter, …) on the list starting at head. Returns the new head; ListFilter::Flush means the list must be discarded.

Source

fn pack_quality( &self, _engine: &mut Engine, _cb: &str, _incident: &str, _detail: i32, _b: NodeRef, _first: i32, _last: i32, ) -> NodeRef

Calls the hpack_quality or vpack_quality callback cb for box b with incident (overfull, underfull, loose, tight) and its detail; returns the node the callback gave (null if none).

Source

fn node_pass(&self, _engine: &mut Engine, _cb: &str, _head: NodeRef) -> bool

Runs the hyphenate, ligaturing or kerning callback cb on the list after head (a temporary node), with its last node: true if a function or false is registered, which replaces the built-in pass.

Source

fn linebreak_filter( &self, _engine: &mut Engine, _head: NodeRef, _display: bool, ) -> Option<NodeRef>

Calls the linebreak_filter callback on paragraph head (display: a display follows): Some(list) if it returned a node list, which replaces line breaking; None otherwise.

Source

fn mlist_to_hlist( &self, _engine: &mut Engine, _head: NodeRef, _style: i32, _penalties: bool, ) -> Option<NodeRef>

Calls the mlist_to_hlist callback on math list head in style style (0–7); None if the callback failed or none is set.

Source

fn pipe_read(&self, _engine: &mut Engine, _cmd: &[u8]) -> Option<Vec<u8>>

Runs shell command cmd under the shell escape rules (as Lua’s io.popen does) and returns its output; None if it may not run.

Source

fn input_level_string(&self, _engine: &mut Engine, _n: i64) -> Option<Vec<u8>>

Calls the input_level_string callback with input-stack depth n; None if it returned no string.

Source

fn glyph_info(&self, _engine: &mut Engine, _p: NodeRef) -> Option<Vec<u8>>

Calls the glyph_info callback for glyph node p: Some(text) is what to print, None means the callback returned no string.

Source

fn call_reference( &self, _engine: &mut Engine, _reference: i32, _args: ReferenceArgs, ) -> Result<(), String>

Runs the Lua value kept under reference number reference (see nodes::LuaRefs) at shipout: a function is called with args, a string is run as Lua code. For the lua commands of virtual characters and \latelua functions.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§