Module src/gnome/object.c

Functions

local _alias_unlink (L, w) A Lua object is to be garbage collected, but it is not the only entry for this memory location.
local _determine_object_type (L, p) Determine the type of the object
local _get_object_check (L, object, ts) A object for a given object (identified by its address) has been found.
local _get_object_meta (L, ts) Given the type, retrieve or create the metaclass for this type of object.
local _get_object_meta_parent (L, type_nr) A meta table for a class has been created on the stack.
local _get_object_ref (L, p) Get the ref_nr for the object at the address "p".
local _is_on_stack (p) Determine whether p points to something on the stack.
local _make_object (L, p, ts, flags) Push a new object (struct object) onto the stack.
local _reuse_object (L, p, ts, flags) A object has been found for the given address.
local _set_object_pointer (L, p, ref, old_ref) Update/remove the entry in objects, which maps the library object's address to a reference.
local l_object_compare (L) Test two objects for equality.
local l_object_gc (L) When a Lua object is garbage collected, decrease the reference count of the associated library object, too.
local l_object_get_type (L) Return the object's type name.
lg_check_object (L, index) The Lua stack should contain a proxy object at the given stack position, verify this.
lg_get_object (L, p, ts, flags) Create or find a Lua proxy object for the object or structure at the given address for later usage in Lua scripts.
lg_invalidate_object (L, o) A object has been freed and must not be accessed anymore.


Functions

local _alias_unlink (L, w)
A Lua object is to be garbage collected, but it is not the only entry for this memory location. Remove this one from the circular list.

Parameters

  • L:
  • w: The object to release w2: object being looked at w3: the one before w2
In file: src/gnome/object.c line 120
local _determine_object_type (L, p)
Determine the type of the object

Parameters

  • L:
  • p: Pointer to the object

Return value:

A typespec_t which is zero on error. In file: src/gnome/object.c line 644
local _get_object_check (L, object, ts)
A object for a given object (identified by its address) has been found. Check the address, and the type. Returns: 0 ... success 1 ... error (NIL on top of stack, return that) 2 ... type mismatch; need to create new Lua object Lua stack: gtk.objects gtk.objects_aliases w w may be replaced with another object (alias), but otherwise the Lua stack remains unchanged.

Parameters

  • L:
  • object:
  • ts:
In file: src/gnome/object.c line 421
local _get_object_meta (L, ts)
Given the type, retrieve or create the metaclass for this type of object. If the given object type has a base class, recurse to make that, too. Stack input: nothing Returns: 0 on error, or 1 on success. Stack output: on success: the metaclass; otherwise, nothing.

Parameters

  • L:
  • ts:
In file: src/gnome/object.c line 365
local _get_object_meta_parent (L, type_nr)
A meta table for a class has been created on the stack. Now try to find the base class and call _get_object_meta for it, too.

Parameters

  • L: Lua State
  • type_nr: The GType of the class to find the parent for Input stack: metaclass Output stack: metaclass

Return value:

1 on success, 0 otherwise In file: src/gnome/object.c line 258
local _get_object_ref (L, p)
Get the ref_nr for the object at the address "p".

Parameters

  • L:
  • p:

Return value:

the reference_nr, or -1 if not found. In file: src/gnome/object.c line 99
local _is_on_stack (p)
Determine whether p points to something on the stack. I don't want to create reusable Lua proxy objects for library objects on the stack. Such objects are usually given to callbacks (e.g. a GdkEvent), don't have refcounting, and will go away when returning from the callback. The user must still take care not to keep the Lua proxy object around. Accessing the same address again (with lg_get_object) will return a new Lua object.

Parameters

  • p: Pointer to a memory location

Return value:

true if p is on the stack In file: src/gnome/object.c line 489
local _make_object (L, p, ts, flags)
Push a new object (struct object) onto the stack.

Parameters

  • L:
  • p: pointer to the object to make the Lua object for; must not be NULL.
  • ts: what the pointer type is; 0 for auto detect
  • flags: see lg_get_object

Return value:

-1 on error (nothing pushed), 0 (stack object) or >0 (normal, ref to an entry in gtk.object_aliases) Lua stack: unless -1 is returned, a new object is pushed. In file: src/gnome/object.c line 696
local _reuse_object (L, p, ts, flags)
A object has been found for the given address. It is on the Lua stack; check that it matches the requested type. If not, make a new alias. Lua stack: [-3]objects [-2]object_aliases [-1]w

Parameters

  • L: Lua State
  • p: Pointer to the object
  • ts: Requested type; if 0, use whatever type it has
  • flags: Extra flags, see FLAG_NOT_NEW_OBJECT etc.
In file: src/gnome/object.c line 513
local _set_object_pointer (L, p, ref, old_ref)
Update/remove the entry in objects, which maps the library object's address to a reference.

Parameters

  • L: Lua State
  • p: Pointer to the object
  • ref: The reference that p should be associated with. May be 0 to remove an entry.
  • old_ref: The expected current reference of p.
In file: src/gnome/object.c line 58
local l_object_compare (L)
Test two objects for equality. As just a single proxy object should exist for a given object, this shouldn't be required; but in certain situations this could happen, so here it is.

Parameters

  • L:
In file: src/gnome/object.c line 330
local l_object_gc (L)
When a Lua object is garbage collected, decrease the reference count of the associated library object, too. This may cause the library object to be freed. Note that for a given library object, multiple Lua objects can exist, having different types (which should be related to each other, of course). Each such Lua proxy object can have multiple Lua references, but holds only one reference to the underlying library object.

Parameters

  • L:
In file: src/gnome/object.c line 160
local l_object_get_type (L)
Return the object's type name.

Parameters

  • L:
In file: src/gnome/object.c line 342
lg_check_object (L, index)
The Lua stack should contain a proxy object at the given stack position, verify this.

Parameters

  • L: Lua state
  • index: Stack position

Return value:

Pointer to the object, or NULL on error. In file: src/gnome/object.c line 19
lg_get_object (L, p, ts, flags)
Create or find a Lua proxy object for the object or structure at the given address for later usage in Lua scripts. If this object was already registered with a different typespec, create a new alias.

Parameters

  • L: Lua state
  • p: Pointer to the object or structure
  • ts: Type of the object at *p, or 0 for auto detection.
  • flags: FLAG_NEW_OBJECT if this is a newly allocated/created object; FLAG_ALLOCATED if this object was created by g_slice_alloc and doesn't have refcounting. FLAG_ARRAY if this was allocated by g_malloc and contains more than one structure. FLAG_NOINCREF means that this is a new object, but lg_inc_refcount should not be called. If we already have a Lua object for this object, do NOT increase the refcount of the object. Only the Lua object has a new reference. You can call this function from C code to make existing library objects available to Lua code: lg_get_object(L, object_ptr, 0, 0);
In file: src/gnome/object.c line 562
lg_invalidate_object (L, o)
A object has been freed and must not be accessed anymore. Invalidate the object proxy and all aliases. It should have an entry in objects, which will be removed too. XXX seems not to be correct. if multiple aliases exist, remove just this from the circular list and set the pointer in "objects" to one of the others.

Parameters

  • L:
  • o:
In file: src/gnome/object.c line 221

Valid XHTML 1.0!