[Gambas-user] Calling external function by pointer

Bruno Félix Rezende Ribeiro oitofelix at ...181...
Thu May 8 16:14:58 CEST 2014


Em Wed, 07 May 2014 21:36:04 +0200
Benoît Minisini <gambas at ...1...> escreveu:

> Le 07/05/2014 20:43, Bruno Félix Rezende Ribeiro a écrit :
> > Em Wed, 07 May 2014 19:32:46 +0200
> > Benoît Minisini <gambas at ...1...> escreveu:
> >
> >> I'm afraid this is not possible, because the FFI library used by
> >> Gambas must know the signature of the function before calling it.
> >
> > What about providing a way to declare the function signature for a
> > pointer variable?
> >
> 
> Why do you need that?

For example, the Xlib function 'XSetErrorHandler' accepts the new error
handler as an argument and returns the old one.  I have a class called
'X11Error' which interfaces with the Xlib's error facilities.  Inside
its '_new' method it registers within Xlib its private method
'ErrorHandler' as the error handler and stores the returned pointer to
the default Xlib's error handler inside a private variable.  Then, to
define a new error handler the user has to create a new object of class
'X11Error' and then catch the event 'Error' which will be raised by
'ErrorHandler'.  However, if there is no observer for such object the
Xlib's default error handler is called instead.  Therefore I need the
ability to call an anonymous function whose signature is known.  Do you
know any other way?  Even if there is a specific way to solve this
very problem within Xlib, I think Gambas module programmers would
benefit of such improvement.

-- 
 ,= ,-_-. =.  Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF]
((_/)o o(\_)) There is no system but GNU;
 `-'(. .)`-'  GNU Linux-Libre is one of its official kernels;
     \_/      All software must be free as in freedom;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20140508/01caf814/attachment.sig>


More information about the User mailing list