Skip to main content

Lua

Struct Lua 

Source
pub struct Lua;
Expand description

The Lua backend.

Trait Implementations§

Source§

impl Clone for Lua

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CodecTarget for Lua

Source§

fn scalar(kind: Scalar) -> Self::Type

The tag and nothing else: Lua declares no types. boolean is the one tag Self::cast acts on.

Source§

fn handle(_kind: Handle) -> Self::Type

Every runtime handle is a plain table.

Source§

fn code_point(value: Self::Expr, _narrow: bool) -> Self::Expr

The member holds the code point already, so there is nothing to convert in either direction.

Source§

fn constant(which: Constant) -> Self::Expr

The runtime’s policy values, in the spelling runtime/lua matches — the same strings runtime/python takes, because both spell WstringLengthPolicy::as_str and its siblings. One arm per constant and no catch-all, so a policy this column has not implemented is a compile error here rather than a plausible value.

Source§

fn unsigned_holder(_bits: u16) -> Self::Type

A Lua integer, at every bit bound: 64 bits hold every @bit_bound a set can declare.

Source§

fn unsigned_less(octets: u8, left: Self::Expr, right: Self::Expr) -> Self::Expr

Whether left is less than right as unsigned integers.

At eight octets the held value is the two’s-complement bit pattern and Lua’s < is signed, so the answer is math.ult — Lua’s own unsigned comparison. Narrower widths hold the value itself, non-negative, and the default < is right.

Source§

fn bool_less(left: Self::Expr, right: Self::Expr) -> Self::Expr

false before true. Lua’s < refuses two booleans outright — “attempt to compare two boolean values” — so the order is spelled as not (left) and (right), which is false-before-true exactly.

Source§

fn map_entry_name(_ast: &Ast, _id: Id<TypeNode>) -> String

A map entry is a plain { key = …, value = … } table; the name is a marker Self::storage matches on and nothing declares.

Source§

fn module_prefix(_ast: &Ast, _id: Id<TypeNode>) -> String

Nothing: the declared paths this backend writes go through Self::enumerator_constant and the defaulters, both rooted at M, and a prefix would be a second answer to the same question.

Source§

fn escape(name: &str) -> String

The identifier, unchanged. Lua renames nothing: a keyword member keeps its name and only the syntax it is reached by changes — t["end"] instead of t.end — which lua::Place::field and lua::table_key decide at the use.

Source§

fn wide_int(value: i128) -> Self::Expr

An integer literal that survives its own width. A Lua decimal numeral above 2^63 − 1 denotes a float (reference §3.1) and a hexadecimal one wraps to the exact bit pattern, so a union label like 16045690984833335998 is written 0xDEADBEEFCAFEBABE-style — the same reading the member itself holds. The same care covers −2^63 itself: -9223372036854775808 is unary minus over a numeral that is already a float by the time the minus applies, so the minimum goes out as its own hex pattern too.

Source§

fn wide_unsigned(value: u64) -> Self::Expr

As Self::wide_int, from the unsigned side.

Source§

fn unsigned_int(value: i128) -> Self::Expr

The number, with no suffix: 2u is not a Lua numeral.

Source§

fn literal(value: Literal) -> Self::Expr

A literal, with the two raw tokens the walk escapes through Literal::Int read back as the booleans they are. Lua spells them the same way C does, so this is for the tree’s sake rather than the renderer’s: a Literal::Bool cannot be mistaken for a number by anything that walks the statements later.

Source§

fn call(callee: &str, args: Vec<Self::Expr>) -> Self::Expr

A call to a generated codec — or, for the one C name the walk hands here, to the runtime’s byte-wise strcmp: Lua’s own < on strings goes through strcoll and the process’s locale, and a map’s entry order must not.

Source§

fn runtime(receiver: &str, method: &str, args: Vec<Self::Expr>) -> Self::Expr

zdw.write_u32(w, x) — the runtime is a table of functions taking the writer or reader first, so the receiver becomes the first argument.

Source§

fn runtime_static(method: &str, args: Vec<Self::Expr>) -> Self::Expr

A free function of the runtime — the same table, because the runtime is one table: zdw.no_dheader(), zdw.pid_is_user_member(zd_p), zdw.utf8_octets(v).

Source§

fn carries_hdds_axes() -> bool

runtime/lua carries the three HDDS axes: begin_packed_element / finish_packed_element on the writer and reader_begin_packed_element / reader_finish_packed_element on the reader, the DHEADER pair for a sequence element’s own length, and write_wstring_utf8_octets / read_wstring_utf8_octets.

Source§

fn member(base: &str, field: &str) -> Self::Expr

A field name with dots is a path through the members that hold a base (parent.x, XTypes 1.3 §7.5.1.4.1.3): one field step per segment.

Source§

fn inherited_path(depth: usize) -> Option<String>

The base is the first member parent (XTypes 1.3 §7.5.1.4.1.3).

Source§

fn index(value: Self::Expr, at: Self::Expr) -> Self::Expr

t[(i) + 1] — the one place the 0-based walk meets Lua’s 1-based tables. Every counter stays 0-based (see Self::count_up), so every subscript adds one, here and nowhere else.

Source§

fn count_of(base: &str, fixed: Option<u64>) -> Self::Expr

#v, or the bound where the materialiser fixed one. The length operator counts the array part’s border, which for the contiguous tables this column builds is the element count.

Source§

fn cast(type_: Self::Type, value: Self::Expr) -> Self::Expr

The identity on every integer — Lua’s integer holds every IDL width’s pattern and runtime/lua range-checks at the octet — and a rewrite on two things that are not integers:

  • a boolean discriminator holds true/false, and v._d == 1 is never true against a boolean, so an integer label becomes the literal;
  • signed char, C’s reading of a map’s char key, which this column computes as ((cp + 128) % 256) - 128 — Lua’s % is floored, so the two’s-complement wrap is exact.

A char label needs nothing: the member holds the code point as an integer already.

Source§

fn handoff(value: Self::Expr, _form: Handoff) -> Self::Expr

The value, unchanged: Lua passes every table by reference and takes no address.

Source§

fn declare( _type_: Self::Type, name: &str, value: Option<Self::Expr>, ) -> Self::Stmt

local name = value, or local name. The type is a tag Lua has no syntax for and is dropped.

Source§

fn perform(value: Self::Expr) -> Self::Stmt

An assignment where the walk built one, the call statement everywhere else — the only expression Lua’s grammar takes as a statement, and the only other thing the walk performs.

Source§

fn give_back(value: Option<Self::Expr>) -> Self::Stmt

return v: this column’s decoders answer with the sample — there is no out-parameter to fill — so the walk’s bare give_back(None) returns the local the body built.

Source§

fn count_up(counter: &str, bound: Self::Expr, body: Self::Block) -> Self::Stmt

for counter = 0, bound - 1 do … end. The counter stays 0-based — Self::index carries the whole 1-based convention — and Lua’s inclusive upper bound takes the minus one.

Source§

fn drop_value(value: Self::Expr) -> Self::Stmt

The call, alone: Lua warns about nothing and (nil) call is not a statement.

Source§

fn mark_used(_name: &str) -> Vec<Self::Stmt>

Nothing: an unread parameter is not a diagnostic Lua has, and a bare name is not a statement.

Source§

fn read_call( callee: &str, place: Self::Expr, _form: Handoff, behaviour: Self::Expr, ) -> Self::Stmt

place = ZD.zd_dec_T(r, zd_tc): decoders answer with the value and the destination is the assignment’s left-hand side.

Source§

fn read_forward(callee: &str) -> Self::Stmt

v = ZD.zd_dec_T(r, zd_tc) — a typedef, handed straight on.

Source§

fn make_room( base: &str, _element: Self::Type, count: Self::Expr, assigned_whole: bool, fill: Vec<Self::Stmt>, ) -> Vec<Self::Stmt>

Room for count values: a fresh table, and — for a map, whose entries are written half at a time — one {} per slot ahead of the fill, because v[i].key = … needs the slot table to exist. A sequence’s element decoder assigns the slot outright and needs only the outer table; Lua tables grow as they are written.

Source§

fn keep_first(base: &str, count: Self::Expr) -> Vec<Self::Stmt>

Drop everything past count: shorten from the border, one element at a time — t[#t] = nil moves the border down — until the bound holds. §7.3.1.2.1.12.3’s TRIM.

Source§

fn sequence_element( base: &str, index: Self::Expr, _element: Self::Type, ) -> (Vec<Self::Stmt>, Self::Expr, Vec<Self::Stmt>)

The subscript, with nothing before or after it: a Lua table element is an ordinary place at every element type.

Source§

fn present(base: &str, field: &str) -> Self::Expr

v.field ~= nil — in Lua the absence of a value is the absence of the key, so presence is the key being there.

Source§

fn set_present(base: &str, field: &str, present: bool) -> Vec<Self::Stmt>

Nothing on the way in — writing the member is what makes it present — and v.field = nil on the way out, which removes the key.

Source§

fn clear_union_cases(base: &str, fields: &[String]) -> Vec<Self::Stmt>

v.field = nil for every case: a union’s branches are keys beside _d on one table, and a branch the discriminator does not select is a key that is not there. The same statement as an absent @optional member, Self::set_present with false.

Source§

fn optional_destination( base: &str, field: &str, ) -> (Vec<Self::Stmt>, Self::Expr)

The member, with nothing to do first: there is no wrapper to engage before a table key can be written.

Source§

fn optional_value( _ast: &Ast, _id: Id<TypeNode>, base: &str, field: &str, ) -> Self::Expr

The member itself: the key holds the value or is absent.

Source§

fn case_member(base: &str, field: &str) -> Self::Expr

v.field — a union’s branches sit beside _d on one table.

Source§

fn entry_half(entry: Self::Expr, key: bool) -> Self::Expr

entry.key and entry.value — a map entry is a table with the two keys adapter/lua.rs names.

Source§

fn materialised(_value: Self::Expr) -> Option<Self::Expr>

Nothing: a Lua string owns its storage and a read that ran out of memory raised long before this question.

Source§

fn storage(type_: Self::Type, name: &str) -> Self::Stmt

A local the body writes into: for the one type this is asked for — the map entry marker — a fresh table, so zd_scratch.key has somewhere to land.

Source§

fn routine(spec: Routine<Self>) -> Option<Self::Decl>

function ZD.zd_enc_T(w, v) … end, or the reading form that opens from Table 9 and returns the sample. A forward declaration is answered with nothing: ZD.<name> resolves at the call, so a recursive or mutually recursive type needs none.

Source§

fn default_into( ast: &Ast, id: Id<TypeNode>, place: Self::Expr, ) -> Result<Self::Stmt, EncodeError>

§Errors

Never; the signature matches the emitters around it.

Source§

fn member_default( ast: &Ast, node: &MemberNode, type_: Id<TypeNode>, place: Self::Expr, ) -> Result<Vec<Self::Stmt>, EncodeError>

§Errors

As crate::default_lua::member_default: a @default this column cannot spell as a Lua expression is refused rather than silently replaced by Table 9’s zero.

Source§

fn enumerator_constant( ast: &Ast, id: Id<TypeNode>, enumerator: &str, ) -> Self::Expr

M.a.b.Colour.values.RED — the declared value out of the descriptor the materialiser wrote, through its own path derivation, so the codec cannot part from it over a spelling. An enumeration member is an integer here, so the constant compares directly against what the member holds.

Source§

type Expr = Expr

An expression.
Source§

type Stmt = Stat

A statement.
Source§

type Block = Vec<Stat>

A sequence of statements.
Source§

type Type = LuaType

A type, as written in a declaration.
Source§

type Decl = Stat

A top-level declaration — in C a function, in Java a method.
Source§

fn named(name: &str) -> Self::Type

A type named by the materialiser.
Source§

fn nothing() -> Self::Type

What a codec function returns when it returns nothing.
Source§

fn value_type(ast: &Ast, id: Id<TypeNode>) -> Self::Type

How this target spells the type of id where a codec holds it. Read more
Source§

fn type_name(ast: &Ast, id: Id<TypeNode>) -> String

The name this target gives the type of id. Read more
Source§

fn name(text: &str) -> Self::Expr

A bare name.
Source§

fn int(value: i128) -> Self::Expr

An integer literal.
Source§

fn wide_signed(value: i128) -> Self::Expr

A signed 64-bit constant, as CodecTarget::wide_unsigned.
Source§

fn whole(base: &str) -> Self::Expr

The whole value the codec was handed, rather than one member. Read more
Source§

fn field_of(value: Self::Expr, field: &str) -> Self::Expr

A member of an expression.
Source§

fn elements(base: &str) -> Self::Expr

Where a sequence keeps the elements themselves. Read more
Source§

fn binary(op: &'static str, lhs: Self::Expr, rhs: Self::Expr) -> Self::Expr

a op b, written as given.
Source§

fn unary(op: &'static str, value: Self::Expr) -> Self::Expr

op a, written as given.
Source§

fn paren(value: Self::Expr) -> Self::Expr

Parentheses written on purpose. Read more
Source§

fn when( condition: Self::Expr, then: Self::Block, otherwise: Option<Self::Block>, ) -> Self::Stmt

if (cond) { .. } else { .. }
Source§

fn until(condition: Self::Expr, body: Self::Block) -> Self::Stmt

A loop with no counter. Read more
Source§

fn leave() -> Self::Stmt

Leave the enclosing loop.
Source§

fn note(doc: Doc) -> Self::Stmt

A comment on its own line.
Source§

fn block(statements: Vec<Self::Stmt>) -> Self::Block

Statements gathered into a body.
Source§

fn into_statements(block: Self::Block) -> Vec<Self::Stmt>

A body taken apart again. Read more
Source§

fn absent() -> Self::Expr

The value that says a target holds nothing. Read more
Source§

fn bit_pattern(source: BitPatternSource, value: Self::Expr) -> Self::Expr

The value’s storage bits, zero-extended into the runtime’s 64-bit pattern argument. See BitPatternSource; consumed by the runtime’s write_union_overlay, which writes the low octets of the pattern as one integer of that width in wire endianness — the Cyclone union overlay. Read more
Source§

fn bulk_octets_write(base: &str, count: Self::Expr) -> Option<Self::Stmt>

All of count octet elements of base at once, in place of the element loop of a sequence<octet> or a one-dimensional octet[N] (and the same over uint8); None, the default, keeps the loop. The octets are the loop’s: an octet has alignment 1 and no byte order (XTypes 1.3 §7.4.3.4.1), so a run of them is the same bytes however it is copied. What a target gains is the per-element call — measured in the C++ column: sequence<octet, 8192> element by element cost ~100 µs per roundtrip of four codec passes.
Source§

fn bulk_octets_read(base: &str, count: Self::Expr) -> Option<Self::Stmt>

The read side of Self::bulk_octets_write: count octets into base, which already holds room for them.
Source§

fn make_room_of( _ast: &Ast, _element_id: Id<TypeNode>, base: &str, element: Self::Type, count: Self::Expr, assigned_whole: bool, fill: Vec<Self::Stmt>, ) -> Vec<Self::Stmt>

CodecTarget::make_room for a sequence whose element is element_id. A target that cannot spell a slot’s start value from element alone overrides it: Kotlin’s Array(n) { T() } has no constructor to call where T is a typealias of Int.
Source§

fn store(place: Self::Expr, type_: Self::Type, value: Self::Expr) -> Self::Stmt

One scalar, as it comes off the runtime, into a place of type_. Read more
Source§

fn header_field(value: Self::Expr, field: &str) -> Self::Expr

One field of a header the runtime handed back. Read more
Source§

fn open_array(base: &str, lengths: &[i128]) -> Vec<Self::Stmt>

Statements that make an array’s Table 9 default writable, before its elements are read into it; lengths are its dimensions, outermost first. Read more
Source§

fn close_array(base: &str, lengths: &[i128]) -> Vec<Self::Stmt>

Statements that give a read array the type its member declares, after its last element is read. Nothing by default; see CodecTarget::open_array.
Source§

fn discriminant(base: &str) -> Self::Expr

A union’s discriminant. Read more
Source§

fn enumerator_ordinal( ast: &Ast, id: Id<TypeNode>, value: Self::Expr, ) -> Self::Expr

The integer an enumeration’s value carries, given the value. Read more
Source§

fn case_label(ast: &Ast, discriminator: Id<TypeNode>, value: i128) -> Self::Expr

The value a union case label is compared against, in this target’s spelling of the discriminator’s type. Read more
Source§

fn behind_indirection( ast: &Ast, id: Id<TypeNode>, place: Self::Expr, ) -> Self::Expr

The place a member is reached at, given that the column could not put the member’s value inside its own aggregate. Read more
Source§

fn make_indirection( ast: &Ast, id: Id<TypeNode>, place: Self::Expr, ) -> (Vec<Self::Stmt>, Self::Expr)

The reading counterpart of CodecTarget::behind_indirection: the same place, and what has to happen before a reader can write through it. Read more
Source§

fn holds_by_reference( ast: &Ast, aggregate: Id<TypeNode>, member_type: Id<TypeNode>, optional: bool, external: bool, ) -> bool

Whether this column holds an @optional or @external member of aggregate, of type member_type, behind a reference of its own — where the shared walk would reach it through CodecTarget::present, CodecTarget::optional_value and their external_ counterparts. A member this answers for goes through CodecTarget::reference_present, CodecTarget::reference_value, CodecTarget::reference_destination and CodecTarget::reference_absent instead. Read more
Source§

fn reference_present(base: &str, field: &str) -> Self::Expr

Whether a member CodecTarget::holds_by_reference answers for is present. Reached only where that answered true.
Source§

fn reference_value( ast: &Ast, id: Id<TypeNode>, base: &str, field: &str, ) -> Self::Expr

The value behind such a member, given that it is present.
Source§

fn reference_destination( ast: &Ast, id: Id<TypeNode>, base: &str, field: &str, ) -> (Vec<Self::Stmt>, Self::Expr)

Where a reader puts such a member’s value, and what it takes to have somewhere to put it; id is the member’s type.
Source§

fn reference_absent(base: &str, field: &str) -> Vec<Self::Stmt>

The statements that leave such a member absent.
Source§

fn holds_a_cycle_externally() -> bool

Whether this column keeps a member that closes a type cycle the way it keeps an @external one — through the external_ seams below, whether or not the member carries the annotation. Read more
Source§

fn externals_are_pointers() -> bool

Whether this column holds an @external member behind a pointer of its own, where the member’s value is not a pointer already. Read more
Source§

fn optionals_are_pointers() -> bool

Whether this column holds an @optional member behind a pointer of its own, where the member’s value is not a pointer already. Read more
Source§

fn value_is_pointer(ast: &Ast, id: Id<TypeNode>) -> bool

Whether the column’s value of id is a pointer already, so that an @external or @optional member of that type needs no pointer of its own. C’s string, wstring and fixed are const char * (XTypes 1.3 §7.5.1.2.3.1); a C++ std::string is a value.
Source§

fn refuse_unset_external(present: Self::Expr) -> Vec<Self::Stmt>

Statements that stop a writer from going on when an @external member that is not @optional has no value at the time of the write. Read more
Source§

fn external_value( ast: &Ast, id: Id<TypeNode>, base: &str, field: &str, optional: bool, ) -> Self::Expr

The value of an @external member, as the member’s codec takes it. Read more
Source§

fn external_destination( base: &str, field: &str, optional: bool, ) -> (Vec<Self::Stmt>, Self::Expr)

Where a reader puts an @external member’s value, and what it takes to have somewhere to put it. The reading counterpart of CodecTarget::external_value, shaped like CodecTarget::optional_destination and for the same reason: a column whose member is an indirection has to make storage before there is a value to write into. The default is the walk’s old answer for both combinations.
Source§

fn external_present(base: &str, field: &str) -> Self::Expr

Whether an @optional @external member is present. Read more
Source§

fn external_set_present( base: &str, field: &str, present: bool, ) -> Vec<Self::Stmt>

Say that an @optional @external member is present, or is not. The counterpart of CodecTarget::set_present, split for the reason CodecTarget::external_present gives.
Source§

fn external_case_value( ast: &Ast, id: Id<TypeNode>, base: &str, field: &str, ) -> Self::Expr

The value of an @external union branch, as the branch’s codec takes it. The union counterpart of CodecTarget::external_value, reached through CodecTarget::case_member because that is the accessor a branch has; there is no optional parameter because no union member is @optional (DDS-XTypes 1.3 §7.2.2.4.4.4.7). The default is the accessor itself — the columns that keep the value inline — and a column that keeps an indirection answers with the dereference, exactly as it does for a structure member.
Source§

fn external_case_destination( base: &str, field: &str, ) -> (Vec<Self::Stmt>, Self::Expr)

Where a reader puts an @external union branch’s value, and what it takes to have somewhere to put it. The union counterpart of CodecTarget::external_destination, shaped the same way and defaulted the same way.
Source§

fn published_name(name: String) -> String

One generated name, in the spelling this target publishes it under. Read more
Source§

fn initialized_reader( _spec: Routine<Self>, _initializer: Self::Stmt, ) -> Option<Self::Decl>

A new reader entry with an explicit, target-derived initializer. Targets that cannot preserve this contract refuse the new entry only; existing data routines and their initialization remain unchanged.
Source§

fn bitmask_value(ast: &Ast, id: Id<TypeNode>, value: Self::Expr) -> Self::Expr

The 64-bit pattern a bitmask arrives as, in the bitmask’s own declared type. Read more
Source§

fn map_entry_type(ast: &Ast, id: Id<TypeNode>) -> Self::Type

The type a map’s entry is declared with — the reader’s scratch entry and make_room’s element. Read more
Source§

impl Copy for Lua

Source§

impl Debug for Lua

Source§

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

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

impl Eq for Lua

Source§

impl PartialEq for Lua

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Lua

Auto Trait Implementations§

§

impl Freeze for Lua

§

impl RefUnwindSafe for Lua

§

impl Send for Lua

§

impl Sync for Lua

§

impl Unpin for Lua

§

impl UnsafeUnpin for Lua

§

impl UnwindSafe for Lua

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.