Index  |  Classes  |  Functions

ClassDynLib

class DynLib

Dynamic Loader support. more...


Member list

Constructor
init Creates a reference to a dynamic library.
Methods
get Gets a dynamic symbol in this library.
query Gets a dynamic symbol in this library.
unload Unloads a dynamic library from memory.

Detailed description

This class allows to load functions from dynamic link library or shared objects.


Class methods

init()

Creates a reference to a dynamic library.

DynLib.init( )
Raises:
DynLibError

on load failed.

On error, a more specific error description is returned in the extra parameter of the raised error.

get()

Gets a dynamic symbol in this library.

DynLib.get( symbol, [rettype], [pmask] )
symbol

The symbol to be retreived.

rettype

Function return type (see below).

pmask

Function parameter mask (see below).

Returns:

On success an instance of DynFunction class.

Raises:
DynLibError

if this instance is not valid (i.e. if used after an unload).

DynLibError

if the sybmol parameter cannot be resolved in the library.

ParamError

in case of invalid parameter mask or return type.

On success, the returned DynFunction instance has all the needed informations to perform calls directed to the foreign library.

As the call method of DynFunction is performing the actual call, if the other informations are not needed, it is possible to get a callable symbol by accessing directly the call property:

       allocate = mylib.get( "allocate" ).call
       use = mylib.get( "use" ).call
       dispose = mylib.get( "dispose" ).call
 
       // create an item
       item = allocate()
 
       // use it
       use( item )
 
       // and free it
       dispose( item )

See the main page of this document for more details on safety.

query()

Gets a dynamic symbol in this library.

DynLib.query( symbol, [rettype], [pmask] )
symbol

The symbol to be retreived.

rettype

Function return type (see below).

pmask

Function parameter mask (see below).

Returns:

On success an instance of DynFunction class; nil if the symbol can't be found.

Raises:
DynLibError

if this instance is not valid (i.e. if used after an unload).

ParamError

in case of invalid parameter mask or return type.

This function is equivalent to DynLib.get, except for the fact that it returns nil instead of raising an error if the given function is not found. Some program logic may prefer a raise when the desired function is not there (as it is supposed to be there), other may prefer just to peek at the library for optional content.

unload()

Unloads a dynamic library from memory.

DynLib.unload( )
Raises:
DynLibError

on failure.

Using any of the functions retreived from this library after this call may cause immediate crash of the host application.


Index  |  Classes  |  Functions
Made with Faldoc 1.0.0