Variables in Gnome
The core module gnome defines a few variables, which are not directly useful to the user. Their function is described here. All of them can, but must not be modified, at the risk of malfunctioning.
- A userdata with version information and a jump table. It is used by modules to access functionality of the core module.
- All Lua objects (struct object) proxying a C object have an environment to store arbitrary key/value pairs. To avoid having an empty table for each such object, they all initially are assigned the same, empty table. The first assignment then creates a private table. This shared table is stored here.
- For each fundamental type supported by the core library, like int, struct etc., one entry is created with the key=hash value, data=index into ffi_type_map, defined in the build directory gnome/fundamentals.c. This table is filled by the function src/gnome/data.c:lg_create_fundamental_map when the core module is loaded, and isn't modified afterwards.
- Each supported datatype has one entry in this table. Key is the hash value of the type name, while the data is a typespec_t, a 32 bit value described in include/common.h consisting of a module index and a type index, and a flag value. This table is initially empty, with more entries being added when a module is loaded.
- Each Lua proxy object has at least one entry here, but can have multiple. Key is an index (see the objects table), value is the proxy object. If an object is accessed as different types (typecasting, e.g. GtkEvent and GdkEventKey), more than one proxy object may be needed.
- One entry per metatable for objects; all objects of the same type share the same metatable.
- A lightuserdata pointing to NULL; can be used in certain situations instead of nil, which is ignored as last elements of tables etc.
- Maps a library object's address (via lightuserdata) to an index in the aliases table.