[lazarus] Wrapping glib with objects

John Margaglione jmargaglione at hotmail.com
Mon Jun 14 10:47:34 EDT 1999

Hi all,
I'm looking at wrapping up the glib functions in object 
wrappers.  Let me explain why:
1.  There is WAY too much useful functionality in there 
to pass up.  The FCL needs most of that functionality available, but 
programmers should not have to revert to C programming constructs to use 
2.  By wrapping up the functions in objects, we open up 
the possibility of converting the object implementations to pure pascal in the 
future, with minimal impact to application code (including our implementation of 
the gtk libraries).
class TLinkedList = class(TObject)
    _list: TGList;
    constructor Create;
    destructor Destroy; 
    procedure Insert( obj: TObject 
    procedure Remove( obj: TObject 
The public interface is now clear of glib 
constructs/variables, and the application programmer doesn't need to know/care 
about glib.
There are a few issues I would like some comments upon, 
1.  glib likes to pass around gpointers.  I like to 
pass around TObjects.  There are merits in doing both.  By passing 
around TObjects we wave the application programmer from constantly doing this: 
pointer( thing ).  But, by restricting the user to TObjects, they can't 
store records.  The obvious solution is to overload the Inser function so 
that it accepts both pointers and TObjects.  Any other 
2.  glib provides OS-independed threading/thread 
synchronization control.  How should this be wrapped?  Should it be a 
class, TThread, like Delphi 3 does it?  Or should we integrate threading 
into TObject, like Java does it?  I love the Java constructs, but that is a 
LOT more work on our part!  Any suggestions?
I'm sure there's more, but I can't remember them 
John Margaglione
href="mailto:jmargaglione at hotmail.com">jmargaglione at hotmail.com

More information about the Lazarus mailing list