Am Mittwoch, den 14.07.2010, 18:16 +0200 schrieb Benoît Minisini: > > Benoît Minisini ha scritto: > > >>>> Nice thing. But now I have a further question: is it possible to > > >>>> implement generic callbacks in Gambas? > > >>>> I mean - many libraries have functions where you specify a callback to > > >>>> be called, like the glib function g_signal_connect(); it would be nice > > >>>> to implement them, even partly, without resorting to write a gambas > > >>>> component. May be that by using libffi it is possible to implement > > >>>> them fully, but even a simple event could do. My problem now is that > > >>>> using ALSA, I must poll continuously to see if some event is coming > > >>>> in, wasting a lot of CPU and losing precision. With a callback if > > >>>> would be much simpler... > > >>>> > > >>>> I hope I have been clear enough. > > >>>> > > >>>> Regards, > > >>>> Doriano > > >>> > > >>> It is possible, I will trying to do that. There is a lot of magic > > >>> involved behind that, hopefully handled by the libffi library. > > >>> > > >>> Alas, that library is not very well documented, so it will take a > > >>> little time, and I'm not 100% sure it will work as expected. > > >>> > > >>> Regards, > > >> > > >> You should be happy with revision #3040. > > >> > > >> Regards, > > > > > > Some little information about callbacks: > > > > > > If you want to use a Gambas function as a callback for an extern > > > function, you just have to: > > > > > > 1) Declare the extern function argument that will receive the function > > > address as "Pointer". > > > > > > 2) Use the Gambas function name when calling the extern function. > > > > > > Note that you can use any private or public Gambas function. You can even > > > use non-static methods: but beware that the object the method applies on > > > is captured by the callback, and released at the end of the program > > > only. > > > > So if I have: > > > > int setcallback(callback_t yourfunc, int tag); > > > > I must declare: > > > > EXTERN setcallback(afunc as pointer, tag as integer) as integer > > > > private sub mycallback(tag as integer) > > ... > > END > > ... > > setcallback(mycallback, 25) > > > > Is it right? > > Yes. > > > > > > Waiting for your returns! > > > > I must download this last revision of gambas, and compile it. I never > > tried to do it. How do I download it? Possibly without SVN? Can it work > > without QT4? I would prefer not to mess up my machine... (fanatic of > > "stable" repositories...). > > Can you advice? > > > > Thanks, > > Doriano > > > > Read the top of the "dowload" page on the web site to know how to get the > latest trunk. > > Sorry, but you have to install svn, qt4, and all the development tools and > package. This is explained on the wiki at the "compilation & installation" > page. Logically, unless you have a very old distribution, all "stable" > packages will be sufficient, and there is no reason you mess up your machine. > > I can't say more without knowing your distribution. > > Regards, >
Salut, for svn, you can also go to "gambas homepage", click on "Browse Source code" or direct to http://gambas.svn.sourceforge.net/viewvc/gambas/?view=tar and there go to trunk and use "Download GNU tarball" -- Amicalement Charlie ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user