Module src/gnome/voidptr.c

Functions

lg_is_vwrapper (L, p) Determine whether the void* points to a value wrapper; it relies on a "magic" signature, which might give false positives in pathological cases.
lg_make_value_wrapper (L, index) A value should be passed to a Gtk function as void*.
lg_push_vwrapper_wrapper (L, wrp) Make a Lua wrapper for the C wrapper for the Lua value.
lg_userdata_to_ffi (ar, argtype, only_ptr) Try to convert a Userdata to a pointer.
lg_vwrapper_get (L, wrp) Push the Lua object wrapped by the given value_wrapper onto the stack.
lua2ffi_void_ptr (ar) The C function expects a void* pointer.
local wrapper_destroy (L) The :destroy method decreases the refcount by one, if it is > 1.
local wrapper_gc (L) Garbage collection of a Lua wrapper.
local wrapper_index (L) Access to a wrapper's fields - value or destroy().
local wrapper_len (L) Retrieve the length of the wrapped Lua value.
local wrapper_newindex (L) Call settable on the wrapped Lua value Lua stack: [void* wrapper] key value
local wrapper_tostring (L) Debug function: show the wrapper's address and content.


Functions

lg_is_vwrapper (L, p)
Determine whether the void* points to a value wrapper; it relies on a "magic" signature, which might give false positives in pathological cases.

Parameters

  • L:
  • p:
In file: src/gnome/voidptr.c line 81
lg_make_value_wrapper (L, index)
A value should be passed to a Gtk function as void*. This is most likely a "data" argument that will be given to a callback, or a value in a collection class like a tree etc. Allocate a C structure and put a reference to that value into it. Note: This wrapper is initialized with a refcount of 0. This function is either called by gtk.void_ptr(), which immediately creates a Lua wrapper for it, or by lua2ffi_void_ptr. In the latter case, refcount is set to 1 nevertheless, so the user must call the :destroy() method on it eventually.

Parameters

  • L:
  • index:
In file: src/gnome/voidptr.c line 331
lg_push_vwrapper_wrapper (L, wrp)
Make a Lua wrapper for the C wrapper for the Lua value.

Parameters

  • L:
  • wrp:
In file: src/gnome/voidptr.c line 380
lg_userdata_to_ffi (ar, argtype, only_ptr)
Try to convert a Userdata to a pointer.

Parameters

  • ar: Structure with L, index, output address
  • argtype: FFI type to use for the argument, most likely pointer.
  • only_ptr: Only accept a pointer type; otherwise, ENUM (integer) is OK
In file: src/gnome/voidptr.c line 111
lg_vwrapper_get (L, wrp)
Push the Lua object wrapped by the given value_wrapper onto the stack.

Parameters

  • L:
  • wrp:
In file: src/gnome/voidptr.c line 101
lua2ffi_void_ptr (ar)
The C function expects a void* pointer. Any datatype should be permissible; nil and lightuserdata are easy; userdata may be ENUM or contain an object. For other data types, a reference is created, which is then wrapped in a small memory block with a "magic" signature. This signature will then be recognized in ffi2lua_void_ptr. The problem is that it's unknown how long this value is required. The C function might store it somewhere (e.g. g_tree_insert key and value) or not (e.g. g_tree_foreach user_data), so it can't be freed automatically.

Parameters

  • ar:
In file: src/gnome/voidptr.c line 401
local wrapper_destroy (L)
The :destroy method decreases the refcount by one, if it is > 1. It must not be set to 0, because the userdata object will be garbage collected eventually, and then the refcount is decreased again.

Parameters

  • L:
In file: src/gnome/voidptr.c line 229
local wrapper_gc (L)
Garbage collection of a Lua wrapper. Free the referenced C wrapper if its refcount now drops to zero.

Parameters

  • L:
In file: src/gnome/voidptr.c line 188
local wrapper_index (L)
Access to a wrapper's fields - value or destroy(). __index in the metatable points to this function instead of itself, because in case of value, a function must be called.

Parameters

  • L:
In file: src/gnome/voidptr.c line 245
local wrapper_len (L)
Retrieve the length of the wrapped Lua value.

Parameters

  • L:
In file: src/gnome/voidptr.c line 291
local wrapper_newindex (L)
Call settable on the wrapped Lua value Lua stack: [void* wrapper] key value

Parameters

  • L:
In file: src/gnome/voidptr.c line 277
local wrapper_tostring (L)
Debug function: show the wrapper's address and content.

Parameters

  • L:
In file: src/gnome/voidptr.c line 303

Valid XHTML 1.0!