thox startup API

Startup standard APIs

Todo

Should we put into place a complete cross-version environment, or instead setup the appropriate environment for the current Lua version?

The following utilities are available as described in the Lua 5.3 manual:

_G
_VERSION

assert
error
getmetatable
ipairs
load
next
pairs
pcall
rawequal
rawget
rawlen
rawset
select
setmetatable
tonumber
tostring
type
xpcall

coroutine.create
coroutine.resume
coroutine.running
coroutine.status
coroutine.wrap
coroutine.yield

math.abs
math.acos
math.asin
math.atan
math.ceil
math.cos
math.deg
math.exp
math.floor
math.fmod
math.huge
math.log
math.max
math.min
math.modf
math.pi
math.rad
math.random
math.randomseed
math.sin
math.sqrt
math.tan

os.clock
os.date
os.difftime
os.time

string.byte
string.char
string.dump
string.find
string.format
string.gmatch
string.gsub
string.len
string.lower
string.match
string.rep
string.reverse
string.sub
string.upper

table.concat
table.insert
table.pack
table.remove
table.sort
table.unpack

On certain conditions, the debug utilities might be available:

debug.gethook
debug.getinfo
debug.getlocal
debug.getmetatable
debug.getupvalue
debug.getuservalue
debug.sethook
debug.setlocal
debug.setmetatable
debug.setupvalue
debug.setuservalue
debug.traceback
debug.upvalueid
debug.upvaluejoin

On Lua 5.3 if available, the following utilities are also available:

coroutine.isyieldable

string.pack
string.unpack
string.packsize

table.move

math.maxinteger
math.mininteger
math.tointeger
math.type
math.ult

utf8.char
utf8.charpattern
utf8.codes
utf8.codepoint
utf8.len
utf8.offset

Todo

Check if we have access to debug, in what circumstances, and so on.

Startup components API

Tha main abstract bus is available through the bus global variable, which corresponds to the core bus. Every component, including the core bus, is of the following type:

class startup.Component

A component representation.

parent: Component

The reference to the parent bus as a component. The main abstract bus sets this to nil.

address: string or number

The address of the component on the parent bus, which format depends on the bus type.

type: string

The string representing the device type, e.g. core-bus.thox.madefor.cc or modem.tweaked.cc.

available: boolean

A boolean indicating if the component is still available for calling. When attached, this attribute is set to true. If the component gets disconnected, this attribute is set to false and does not evolve from here; references to this component object should be lost, as a new object will be created if the component is reattached.

interfaces: table<string>

The name of the interfaces a given device implements, in order to recognize devices through their functions (and therefore the methods we can use on them) rather than by their name.

methods: ComponentMethods

The methods of the given object. The content of this table can be guaranteed by the interfaces provided above.

class startup.ComponentMethods: table, string, function

A set of component methods. This class is to be overloaded for every interface that a component implements.

class startup.BusComponentMethods

Methods for when a component implements the "bus" interface.

listComponents()

Get the list of all components on this bus.

Returns

a list of all components on this bus.

Return type

table<Component>

getComponent(address)

Get the reference to a component.

Parameters

address (string or number) – the address of the component to get a reference of

Returns

the reference to the component object or nil

Return type

Component