std.base

Provides the base library for use with extensions.

  • Author: Edward Jones
  • Date: 2021-09-17

Source file

close_var_scope

Closes the most recently-opened variable scope.

close_var_scope = -> ...

copy_loc

Copy a source-code location.

Returns: A copy of the current source code location

copy_loc = -> ...

em_loc

Get the current location in the source code.

Returns: A pointer to the current source location

em_loc = -> ...

eval_string

Evaluates a node pointer and extracts the text contained in and below it.

  • Param d: The userdata pointer to evaluate and extract from

Returns: A string which represents all text at and beneath d

eval_string = (d) -> ...

get_var

Gets the value of a given variable, if the variable name starts with n > 0 exclamation marks, then that many possible matches are skipped while searching from the innermost scope.

  • Param rn: The raw variable name as a string or core pointer
  • Param d: An optional default value to return if rn does not exist

Returns: The value of variable rn in the current scope otherwise d

get_var = (rn, d) -> ...

is_instance

Tests whether an object is an instance of a given class.

  • Param cls: The class to test, may be a class name or a class itself
  • Param obj: The object to test

Returns: true if obj is an instance of a sub-class of cls, otherwise false

is_instance = (cls, obj) -> ...

iter_num

Returns the number of the current iteration of the typesetting loop (starts at 1).

Returns: The number of times the typesetting loop has been started this run

iter_num = -> ...

node_string

Extracts the text beneath a given node.

  • Param n: The node to convert into a string, must be a table

Returns: The text stored at and under the given node

node_string = (n) -> ...

open_var_scope

Opens a new variable scope.

open_var_scope = -> ...

set_var

Set a variable to a given value, if the variable name starts with n > 0 exclamation marks, then a search is performed to set the n-th variable with the same name in found whilst searching parent scopes.

  • Param n: The name of the variable (string or code pointer)
  • Param v: The value to set (not changed by this operation)
  • Param surrounding_scope: If set to true, search is bumped up one scope (useful for the .set-var directive which would otherwise have the set value swallowed in its own scope)
set_var = (n, v, surrounding_scope=false, search=false) -> ...

set_var_string

Set a given variable to a given value as a string.

  • Param n: Variable name as for set_var
  • Param v: Value to evaluate then set to n
  • Param w: Scope widening paramerer as for set_var
set_var_string = (n, v, ...) -> ...

wrap_indices

Wrap the __get and __set methods into the __index and __newindex methods if available.

  • Param object: (table) to wrap

Returns: nil

wrap_indices = => ...