|
Mach Modules Documentation
Lua Module API Documentation
|
Go to the source code of this file.
Functions | |
| bridge | IgnoreErrors (opts) |
| Check whether the ignore_errors option is set in an options table. | |
| bridge | HandleError (opts, fmt,...) |
| Handle a Bridge module error in a uniform way. | |
| bridge | ParseLuaData (blob, opts) |
| Parse a Lua data blob string and return the resulting Lua value. | |
| bridge | ResolveRegisterPath (path, opts) |
| Resolve a register path string to a Mach4 register handle. | |
| bridge | ResolveIOPath (path, opts) |
| Resolve an I/O path string to a Mach4 I/O handle. | |
| bridge | GlobalCommand (command, opts) |
| Execute a global Bridge command and return the parsed result. | |
| bridge | GetRemoteServerNames (opts) |
| Retrieve the list of configured remote Bridge server names. | |
| bridge BridgeInterface | new (opts) |
| Construct a new BridgeInterface object connected to a named remote Bridge server. | |
| bridge BridgeInterface | GetOpt_MachAPIRaiseErrors () |
| Check whether the MachAPI_raise_errors option is enabled for this interface. | |
| bridge BridgeInterface | HandleError (...) |
| Delegate error handling to the global bridge.HandleError using this object's options. | |
| bridge BridgeInterface GetOpt_MachAPIRaiseErrors | ( | ) |
Check whether the MachAPI_raise_errors option is enabled for this interface.
Inspects the instance's opts table for the MachAPI_raise_errors flag. If the opts table is nil or the flag is not set, returns false. When enabled, API calls that return non-zero MachAPI error codes will raise an error rather than silently continuing.
| bridge GetRemoteServerNames | ( | opts | ) |
Retrieve the list of configured remote Bridge server names.
Sends the 'GetRemoteServerNames' global command via bridge.GlobalCommand() and returns the resulting array of server nickname strings. This list is used during BridgeInterface construction to validate that the requested remote server is available.
| opts | (table|nil) Optional options table with keys:
|
| bridge GlobalCommand | ( | command | , |
| opts | ) |
Execute a global Bridge command and return the parsed result.
Sends a command string to the Bridge plugin's global command register (BridgeRemoteServers/global.lua) using mc.mcRegSendCommand(). The register handle is cached after the first successful resolution to avoid repeated lookups. The raw response string is parsed as Lua data via bridge.ParseLuaData() before being returned.
If the register cannot be resolved or the command fails, the error is handled via bridge.HandleError() and nil is returned.
| command | (string) The global command name to send (e.g. 'GetRemoteServerNames') |
| opts | (table|nil) Optional options table with keys:
|
| bridge BridgeInterface HandleError | ( | ... | ) |
Delegate error handling to the global bridge.HandleError using this object's options.
Calls the module-level bridge.HandleError function using the instance's stored options (self._opts). This method provides a consistent way to report errors within a BridgeInterface object without needing to pass the options table explicitly at each call site.
| fmt | (string) Format string for the error message (printf-style) |
| ... | (any) Variable arguments to format into the message string |
| bridge HandleError | ( | opts | , |
| fmt | , | ||
| ... ) |
Handle a Bridge module error in a uniform way.
Formats the provided message using string.format() (with safe fallback if formatting fails), logs it via w.Log(), and then raises an error via w.Error() unless the ignore_errors option is set in the opts table. This function is the central error handler for the entire BridgeInterface module.
If formatting the message itself causes an error, a fallback representation of the format string and arguments is used to avoid introducing new errors during error handling.
| opts | (table|nil) Options table controlling error behavior:
|
| fmt | (string) Printf-style format string for the error message |
| ... | (any) Variable arguments to substitute into the format string |
| bridge IgnoreErrors | ( | opts | ) |
Check whether the ignore_errors option is set in an options table.
Inspects the provided opts table for the ignore_errors key. Returns false if opts is nil, not a table, or if opts.ignore_errors is not explicitly true. This function is used by bridge.HandleError() to decide whether to suppress errors or raise them.
| opts | (table|nil) The options table to inspect. May be nil or any non-table type. |
| bridge BridgeInterface new | ( | opts | ) |
Construct a new BridgeInterface object connected to a named remote Bridge server.
Creates and initializes a BridgeInterface instance for the given remote server nickname. The constructor performs the following steps:
If any step fails and ignore_errors is not set, an error is raised and nil is returned.
| client_nickname | (string) The name of the remote Bridge server to connect to (e.g. 'head') |
| opts | (table|nil) Optional configuration table with keys:
|
| bridge ParseLuaData | ( | blob | , |
| opts | ) |
Parse a Lua data blob string and return the resulting Lua value.
Accepts a string containing Lua data (e.g. a serialized table or scalar value) and evaluates it, returning the result. The function handles two special prefix cases before standard parsing:
' - Treated as a remote error; HandleError is called and nil is returned.
For standard blobs, the string is wrapped as 'return <blob>' and loaded with load(), then executed via w.pcall(). Any parse or execution error is reported via HandleError.
| blob | (string) The raw Lua data string to parse, optionally prefixed with a special directive |
| opts | (table|nil) Optional options table with keys:
|
| bridge ResolveIOPath | ( | path | , |
| opts | ) |
Resolve an I/O path string to a Mach4 I/O handle.
Calls mc.mcIoGetHandle() with the given path string. If the call succeeds (rc == mc.MERROR_NOERROR), the I/O handle is returned. Otherwise the error is reported via bridge.HandleError() and nil is returned. Paths follow the Mach4 I/O naming convention (e.g. 'BridgeRemoteServers/head.active').
| path | (string) The I/O path to resolve (e.g. 'BridgeRemoteServers/head.active') |
| opts | (table|nil) Optional options table with keys:
|
| bridge ResolveRegisterPath | ( | path | , |
| opts | ) |
Resolve a register path string to a Mach4 register handle.
Calls mc.mcRegGetHandle() with the given path string. If the call succeeds (rc == mc.MERROR_NOERROR), the register handle is returned. Otherwise the error is reported via bridge.HandleError() and nil is returned. Paths follow the Mach4 register naming convention (e.g. 'BridgeRemoteServers/global.lua').
| path | (string) The register path to resolve (e.g. 'BridgeRemoteServers/head.api.lua') |
| opts | (table|nil) Optional options table with keys:
|