devUtils Reference
Module defined in `lua/common/devUtils.lua`. Development utilities for sandboxed Lua execution, module local variable introspection, global state snapshots, and table recursion detection.
Module defined in lua/common/devUtils.lua. Development utilities for sandboxed Lua execution, module local variable introspection, global state snapshots, and table recursion detection.
Exports
All exports are global functions (no module table).
Functions
executeLuaSandboxed(cmd, source)
Executes a Lua string in a sandboxed environment with stdout capture.
- Parameters:
cmd- string - Lua code to executesource- string|nil - Source name for error reporting (default: "executeLuaSandboxed")
- Returns: any, table|nil - Result of execution (or error string), and captured stdout lines
getModuleLocals(moduleTbl)
Returns all upvalue locals used by functions in a module table. Useful for introspection and serialization.
- Parameters:
moduleTbl- table - The module table to inspect
- Returns: table - Map of local variable names to their values
createGlobalSnapshot(filename)
Serializes the entire global Lua state to a JSON file for debugging. Captures all global tables, their locals, extension state, and variables.
- Parameters:
filename- string - Output JSON filename
tableFindRecursion(tbl)
Detects tables that appear at multiple paths within a table hierarchy (shared references).
- Parameters:
tbl- table - Root table to inspect
- Returns: number, table - Count of duplicate table references, and a map of table pointers to their paths
Internal Notes
executeLuaSandboxedis NOT truly safe - it can access hidden objects through the environment- The sandbox captures
print()output and redirects it to a table createGlobalSnapshotskips functions, extension modules, and the global table itself- Internal helpers:
_findUpValuesFromFunction,_recFindUpvalues,_cleanupCloneTbl,_createGraphviz
dequeue Reference
Module defined in `lua/common/dequeue.lua`. Double-ended queue (deque) implementation supporting push/pop from both ends, rotation, removal, and iteration. Based on Pierre Chapuis's library.
Event Reference
Module defined in `lua/common/event.lua`. Implements a simple event/delegate class for publish-subscribe patterns. Subscribers register functions that get called when the event fires.