Basic Concepts

At its core, deai is an object system, not dissimilar to GLib’s GObject system, albeit with a very different design.

Objects

Rather than being the “object” in Object Oriented Programming, an object in deai is closer to a Python or Javascript object, or a Lua table. This design choice was made to simplify interfacing with scripting languages.

In other words, an object is just a dictionary mapping string keys to its members. There is some caveats, but from a users perspective that’s mostly it.

Using Lua as an example, say you get a deai object:

obj = di.xorg -- get the xorg module

Then you can use it like this:

a = obj.some_attribute -- read a member of the object
obj.some_attribute = a + 1 -- write to a member of the object
obj:connect() -- connect to the X server

Iterators

Iterators are special types of objects that can be used to iterate over a number of elements.

For an object to be an iterator, it must have a member function named “next”. When “next” is first called, it should set a member named “front”, to be the current element. Every subsequent call to “next” should advance the iterator, and set “front” to the next element.

“next” should return true if “front” is set, or false if the iterator is exhausted. In that case, “front” should remain unchanged.

Signals

Signals are how events are delivered in deai. Signals are emitted from objects, and can carry arguments with them.

Again using Lua as an example, say you have an object obj:

obj:on("some-signal", function(data)
  -- do something with data
end)

This register a listener on the event "some-signal". This signal carries an argument data, which will be passed on to the callback function.

Language support

Scripting language supports in deai are implemented as plugins. Currently there is only the Lua plugin, but I will use plural anyways.

These plugins implement the ability to load a script, and they also exposes deai objects in the languages’ native form.

For more information on, for example, how Lua scripting support works, see lua.

Compiled language support is implemented as bindings. C is supported by core deai, there is also C++ binding available.