[Gambas-devel] ncurses component

tobi tobias at ...692...
Sun Apr 1 21:28:20 CEST 2012


On Sun, 01 Apr 2012, Benoît Minisini wrote:
> Le 28/03/2012 23:21, tobi a écrit :
> >
> >
> > i'm already probing with that very Window class, but had a slightly different approach just because i
> > don't know of the old basic syntaxes (the funning thing i thought of was mirroring parts of the
> > gb.qt4/gb.gtk Windows to ncurses), i'll take a look on the basic syntaxes soon, it's kind of general
> > knowledge... maybe as soon as i'll create an account on sourceforge... (the most probably tomorrow, sorry)
> > i tried to figure out something like the inheritance of a Stream but i lacked knowledge of internal
> > stream behaviour, i.e. if i could overwrite whatever is used to process incoming data.
> >
> > regards,
> > tobi
> >
> 
> As an example of how to implement a stream class, you can look at the 
> Socket class in the gb.net sources ('CSocket.h' & 'CSocket.c' files).
> 
> In a few words:
> 
> 
> (1) You must declare your object structure that way:
> 
> typedef
>    struct {
>      GB_BASE ob;
>      GB_STREAM stream;
>      ...
>    }
>    MYCLASS;
> 
> 
> (2) You must declare a structure that represents all stream methods:
> 
> GB_STREAM_DESC MyClassStream =
> {
>    open: MyClassStream_open,
>    close: MyClassStream_close,
>    read: MyClassStream_read,
>    write: MyClassStream_write,
>    seek: MyClassStream_seek,
>    tell: MyClassStream_tell,
>    flush: MyClassStream_flush,
>    eof: MyClassStream_eof,
>    lof: MyClassStream_lof,
>    handle: MyClassStream_handle
> };
> 
> Each stream method must have a specific declaration, as specified in the 
> GB_STREAM_DESC declaration in 'gambas.h'
> 
> 
> (3) When you open the stream (in your case it should be as soon as the 
> object is created, inside the constructor), you must initialize your 
> object with the previous structure:
> 
> #define THIS ((MYCLASS *)_object)
> 
> BEGIN_METHOD_VOID(MyClass_new)
> 
>    ...
>    THIS->stream.desc = &MyClassStream;
> 
> END_METHOD
> 
> 
> I hope that things are clearer now.
> 
> Regards,
> 
> -- 
> Benoît Minisini
> 
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Gambas-devel mailing list
> Gambas-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-devel
> 

i learned almost entirely about the api until now from the CSocket class (virtual classes from
gb.pcre). it covers pretty much things. (btw: a comment on the GB_BASE structure should be added to
the howto page on c/c++ development, i wondered why my pointers were incremented after object
instanciation ;))
thanks for the introduction, it will save me a considerable amount of time.





More information about the Devel mailing list