The Objective Lua API

Introduction

The Objective Lua API provides the functionality for translating Objective Lua programs into classic Lua.

Note that this does not include functionality for creating classes, calling methods, etc. The Objective Lua runtime is cleanly separated from the translator; translated code access only the publically available methods on the classes referenced and does not call directly into the runtime. The standard runtime is part of the olua.lib.Object class. See the API documentation for more details.

(Note that it is possible to have multiple, distinct class hierarchies, each with a different runtime, operating side by side.)

b = olua.isobject(object)

Tests to see whether object can have methods called on it.

mangled = olua.mangle(selector)

Mangles a selector in the form "foo:bar:" into the form used internally when calling methods (currently, "foo_bar_").

unmangled = olua.unmangle(selector)

Unmangles a selector from internal form into printed form.

result, e = olua.translate(intext, filename)

Performs the low-level translation of an Objective Lua chunk into a classic Lua chunk.

intext is the input source. filename is the filename used for reporting errors.

The function returns the translated source in result, or nil on error; e is nil on success, or an error string on error.

result, e = olua.loadstring(intext, filename)

Equivalent to the standard Lua loadstring() function, but for Objective Lua programs.

chunk = olua.loadstring(fp, filename)

Reads an Objective Lua program from the stream fp, and returns a compiled chunk.

Errors are thrown; filename is used to report them.

The compiled chunk contains an exception catching veneer that will convert Objective Lua exceptions into strings and rethrow them.

olua.run(filename, ...)

Runs an Objective Lua program from filename. Any remaining arguments are passed in; the function returns whatever the program does.