[Gambas-user] Extern howto/tutorial
Benoît Minisini
gambas at ...1...
Mon Aug 23 21:47:57 CEST 2010
> Hi,
>
> I finally wrote the tutorial about using external declarations.
Great!
>
> It is a long text and perhaps difficult, but I didn't find any other way
> to put it in a simpler form: the problem of interfacing gambas to
> external libraries, from the perspective of a gambas user, is not simple.
>
> I wrote it using zim, a nice wiki editor. I attach what I exported from
> the document, in both html and "Txt2Tags" (?) format.
This is not HTML, but plain text. If you can make an HTML version of your
document, with formatted text, I will be able to add it to the wiki.
>
> Feel free to modify it as needed, to include it in the wiki, or
> whatever. I attach two projects related to the explanation, one short
> and simple and one much more complex, but more funny.
>
> This document regards Gambas2. When it will be corrected/approved, I
> will port projects and documentation to Gambas3.
>
> Now some technical question.
>
> In the Drum Machine project, after having verified that it works
> correctly using pointers for read/write, I tried to create a new class
> which should be a gambas representation for an alsa event (which is a C
> struct). It does not work, and I don't know how to debug it (well, I
> could, using gdb or similar, but I was looking for a more direct way).
Give me the C declaration, and your class declaration, and I will be able to
see if they correctly match.
> My idea was to point a pointer to the instance of the class CEvent, and
> then dump a few bytes to see them. But gambas does not let me to assign
> a pointer to a class instance ("wanted integer, found object").
>
> Moreover, in the gambas 3 documentation there is nothing that makes me
> think that "write #pointer, ..." is no more supported. Either gambas3
> supports it (but it does not seems to me), or the documentation is wrong.
It is explicitely said that "WRITE #Pointer" is not supported anymore in
Gambas 3, in the WRITE documentation page. And so on for the READ instruction.
>
> Another thing is that if I declare a constant as a byte, and then try to
> "write #pointer, my_byte_constant", 4 bytes are written instead of just
> one. I had to mention it in the document.
Mmm. it could be a bug in Gambas 2. A workaround would be using CByte()
explicitely.
>
> I am really curious to give a try to gambas3 structures, but I want
> firstly terminate with gambas2.
>
> Best regards,
> Doriano Blengino
The Gambas 3 structures were implemented for the use of extern C structures.
Moreover, in Gambas 3, you can now use Gambas functions as C function pointer
(as known as "callbacks") almost transparently.
Regards,
--
Benoît Minisini
More information about the User
mailing list