Module src/gnome/data.c

Functions

local _decode_constant_v2 (L, ts, res, datalen, result) A constant has been found.
local _find_constant (L, ts, key, keylen, result) Find a constant by name in the given module.
local _find_my_handle (L, dyn) Find out what the handle is for the module shared object.
local _find_symbol (dyn, name) Find the symbol in the shared library.
local _map_fundamental_names (L, mi) Each module lists fundamental names' hash values which are used here to build a mapping for fundamental types.
local _update_typemap_hash (L, mi) Add all native types of this module to the global hash list of types.
find_attribute (ts, attr_name) Look for an attribute of the given class.
lg_create_fundamental_map (L) Create and fill gnome.fundamental_map containing hash values of all fundamental types supported by this core module.
lg_dl_init (L, dyn) Load the dynamic libraries.
lg_find_constant (L, ts, key, keylen, result) Search for the string in the constants table.
lg_find_func (L, mi, func_name, fi) Look for the function in the dynamic library.
lg_find_global (L, mi, name) Look for a global variable, and return its current value if found.
lg_find_struct (L, type_name, indirections) Look for a structure (class) of the given name in the specified module, or in all modules if module_idx isn't set.
lg_get_module (L, module_name) Determine the module_idx for the given module_name.
lg_get_type_indirections (ts) Return the number of indirections the underlying fundamental type has.
lg_get_type_name_full (L, ts, buf) Writes the type's name into the given buffer.
lg_gtype_from_name (L, mi, s) Determine the type number for the given class.
lg_make_func_name (mi, buf, buf_size, class_name, attr_name) Given a class name in the form "GtkVBox" and a method name like "pack_start", construct a function name like "gtk_vbox_pack_start".
lg_object_arg (L, index, name) Get a object from the Lua stack, checking its type (class).
lg_optional_func (L, mi, name, min_version) If a function is not always available in Gtk, retrieve it with this helper; it throws an error if the function is not available.
lg_register_module (module_name) Add a module to the module list.
lg_type_equal (L, ts1, ts2) Determine whether two typespecs are equal, disregarding the flags that may be set.
lg_type_modify (L, ts, ind_delta) Given a type, change the level of indirections by "ind_delta", so for example ("char**", -1) turns into "char*".
lg_type_normalize (L, ts) If a typespec refers to a "non-native" type, use the hash value stored there to look up the type in the table gnome.typemap.
local unavailable_function () Functions that can't be found during dynamic loading of the libraries are replaced by this.


Functions

local _decode_constant_v2 (L, ts, res, datalen, result)
A constant has been found. The data is encoded in a certain binary format, which this function decodes. Various encoding formats have been tried, and this is the best one so far. Even better ones might come along. The top 2 bits of the first byte: 00=no type, 01=8 bit type, 10=16 bit type, 11=string. If the (16 bit) type has the top bit set, this means a negative number. The other 6 bits of the first byte are used as high bits of the value, unless it is a string. Following that is the string, or as many bytes of the value as are required from high to low byte.

Parameters

  • L: Lua State
  • ts: (output) to store the data type, if the constant has one
  • res: (input) Pointer to the binary encoding of the value
  • datalen: Length of this value
  • result: (output) Store the value at this location.

Return value:

1=typed value, 2=untyped, 3=string (on Lua stack). In file: src/gnome/data.c line 402
local _find_constant (L, ts, key, keylen, result)
Find a constant by name in the given module.

Parameters

  • L: Lua State
  • ts: The typespec with its module_idx set; its type_idx field may be set as output.
  • key: Name of the constant to look up
  • keylen: Length of the name; -1 means zero terminated string
  • result: (output) Location where to store the resulting value

Return value:

0=not found, else see _decode_constant_v2(). In file: src/gnome/data.c line 470
local _find_my_handle (L, dyn)
Find out what the handle is for the module shared object. This is important because _find_symbol needs this handle for DLLOOKUP to find the symbols in the linked library. Unfortunately, Lua stores this handle in an almost inaccessible location: in the registry with a key that is a string derived from the full path name of the dynamic library. If the handle can be found, it is stored in dyn->dl_self_handle.

Parameters

  • L:
  • dyn:
In file: src/gnome/data.c line 997
local _find_symbol (dyn, name)
Find the symbol in the shared library. It most likely is a function, but might also be a global variable.

Parameters

  • dyn:
  • name:
In file: src/gnome/data.c line 872
local _map_fundamental_names (L, mi)
Each module lists fundamental names' hash values which are used here to build a mapping for fundamental types.

Parameters

  • L:
  • mi:
In file: src/gnome/data.c line 592
local _update_typemap_hash (L, mi)
Add all native types of this module to the global hash list of types.

Parameters

  • L:
  • mi:
In file: src/gnome/data.c line 662
find_attribute (ts, attr_name)
Look for an attribute of the given class. The attributes are ordered by their offset within the structure, but not strictly - unions have their attributes at the same offset.

Parameters

  • ts: Type of the structure to look in
  • attr_name: Name of the attribute being looked for

Return value:

A struct_elem or NULL In file: src/gnome/data.c line 531
lg_create_fundamental_map (L)
Create and fill gnome.fundamental_map containing hash values of all fundamental types supported by this core module. Non-core modules just have hashes of the names of fundamental types, which is shorter and easier to look up than the full names.

Parameters

  • L:
In file: src/gnome/data.c line 561
lg_dl_init (L, dyn)
Load the dynamic libraries. Returns 0 on error. On Linux with automatic linking, nothing has to be done; the dynamic linker already has loaded libgtk+2.0 and its dependencies. Note: do _not_ use any functions that are runtime linked, e.g. g_malloc.

Parameters

  • L:
  • dyn:
In file: src/gnome/data.c line 1028
lg_find_constant (L, ts, key, keylen, result)
Search for the string in the constants table. The result might be an enum (typed integer), flags (typed integer, can be ORed together), a regular integer, or a string.

Parameters

  • L: Lua State
  • ts: (in/out) Type Spec - module_idx can be set, but can be zero.
  • key: The name of the constant to look for
  • keylen: Length of key. If -1, key must be zero terminated.
  • result: (output) value of the constant (if ENUM, FLAGS or integer)

Return value:

0=error, 1=ENUM found (type in *ts), 2=int found (in *result), 3=string found (on Lua stack) In file: src/gnome/data.c line 500
lg_find_func (L, mi, func_name, fi)
Look for the function in the dynamic library. If it is not found, this is not an error, because many tries for different object types may be necessary to find one method. Returns 0 if the function hasn't been found, 1 otherwise.

Parameters

  • L:
  • mi:
  • func_name:
  • fi:
In file: src/gnome/data.c line 1091
lg_find_global (L, mi, name)
Look for a global variable, and return its current value if found. NOTE: This doesn't support assignment.

Parameters

  • L: Lua State
  • mi: Module Info of the module that contains the global variable
  • name: Name of the global

Return value:

non-zero if a global was found and pushed on the Lua stack. In file: src/gnome/data.c line 899
lg_find_struct (L, type_name, indirections)
Look for a structure (class) of the given name in the specified module, or in all modules if module_idx isn't set.

Parameters

  • L: Lua State
  • type_name: Name of the type to look for
  • indirections: The number of "*" after the type name.
In file: src/gnome/data.c line 804
lg_get_module (L, module_name)
Determine the module_idx for the given module_name.

Parameters

  • L:
  • module_name:

Return value:

The module_idx, or 0 when it wasn't found. In file: src/gnome/data.c line 853
lg_get_type_indirections (ts)
Return the number of indirections the underlying fundamental type has. This may be more than what type_info.indirections specifies.

Parameters

  • ts:
In file: src/gnome/data.c line 277
lg_get_type_name_full (L, ts, buf)
Writes the type's name into the given buffer. Its length should be LG_TYPE_NAME_LENGTH bytes long.

Parameters

  • L: Lua state
  • ts: Typespec
  • buf: Output buffer (must be at least LG_TYPE_NAME_LENGTH bytes long)
In file: src/gnome/data.c line 229
lg_gtype_from_name (L, mi, s)
Determine the type number for the given class. After using the class for the first time, g_type_from_name returns the ID; otherwise is is required to call the get_type function for this class.

Parameters

  • L:
  • mi: Module this type should be in (NULL if not known)
  • s: Name of the type

Return value:

0 if not found, else the GType (an integer) In file: src/gnome/data.c line 119
lg_make_func_name (mi, buf, buf_size, class_name, attr_name)
Given a class name in the form "GtkVBox" and a method name like "pack_start", construct a function name like "gtk_vbox_pack_start". All letters are converted to lowercase, but before initially uppercase letters, an underscore is inserted, unless a single letter would then be surrounded by underscores (as is the case for GtkVBox, which turns into gtk_vbox, and not gtk_v_box). Returns 0 on success, else 1. The only possible error is that the buffer is not big enough.

Parameters

  • mi:
  • buf:
  • buf_size:
  • class_name:
  • attr_name:
In file: src/gnome/data.c line 56
lg_object_arg (L, index, name)
Get a object from the Lua stack, checking its type (class). It should at least be some kind of object, not an unrelated userdata - might crash otherwise. Note: a more thorough implementation could get the metatable and check that it has a _typespec attribute etc.

Parameters

  • L:
  • index:
  • name:
In file: src/gnome/data.c line 1159
lg_optional_func (L, mi, name, min_version)
If a function is not always available in Gtk, retrieve it with this helper; it throws an error if the function is not available. This ensures compatibility with older Gtk versions.

Parameters

  • L:
  • mi:
  • name:
  • min_version:
In file: src/gnome/data.c line 1142
lg_register_module (module_name)
Add a module to the module list. This also creates a global table for that module: { new, new_array, _modinfo }

Parameters

  • module_name:
In file: src/gnome/data.c line 727
lg_type_equal (L, ts1, ts2)
Determine whether two typespecs are equal, disregarding the flags that may be set.

Parameters

  • L:
  • ts1:
  • ts2:
In file: src/gnome/data.c line 334
lg_type_modify (L, ts, ind_delta)
Given a type, change the level of indirections by "ind_delta", so for example ("char**", -1) turns into "char*". This is needed when a function argument is an output argument.

Parameters

  • L:
  • ts:
  • ind_delta:
In file: src/gnome/data.c line 294
lg_type_normalize (L, ts)
If a typespec refers to a "non-native" type, use the hash value stored there to look up the type in the table gnome.typemap.

Parameters

  • L:
  • ts:
In file: src/gnome/data.c line 345
local unavailable_function ()
Functions that can't be found during dynamic loading of the libraries are replaced by this. Until they are called, we can continue. A pity that it's not known which function isn't available. This could be solved by using closures, but then it probably doesn't help much. In file: src/gnome/data.c line 967

Valid XHTML 1.0!