Solution for passing a function pointer as an argument (was: Re: [C++-sig] Parsing complex C++)

Niall Douglas s_sourceforge at nedprod.com
Mon Dec 15 20:11:26 CET 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 15 Dec 2003 at 13:23, Nicodemus wrote:

> I was about to send an email to the list about that. I have been very
> busy lately, without any time for Pyste at all (and my games, an my
> books... 8( ), but that doesn't mean that I abandoned it. As soon as I
> have time (I will be in vacation shortly) I plan to integrate some
> patches that have been sitting in my todo list for some time now.

v0.5 of TnFOX will be out before Christmas and it provides full 
"embed TnFOX into Python" and "embed Python into TnFOX" 
functionality. There shouldn't be any more outstanding issues with 
python in TnFOX except that pyste still doesn't have AllFromHeader() 
working and thus not everything is represented yet.

BTW, I have a solution to the "installing a python function as a C-
style callback" problem with no alterations required to the original 
C++ library. Basically I've written a generic class which generates X 
static functions taking any arbitrary set of parameters & return 
(specified by a policy) and stores the function pointers into an 
array during construction. Now you can pass one of those strawman 
function addresses to the C++ code which when called indexes the 
array, gets the corresponding python function and calls it with the 
relevent parameters. The solves the FAQ problem "How can I wrap a 
function which takes a function pointer as an argument?".

Unfortunately this solution is based upon TnFOX's compile-time 
library but should provide a very good start for anyone with a 
similar problem. I should warn you that I do a lot of template 
classes inheriting off their template parameters so the logic gets 
quite convoluted.

How about updating the FAQ? Ralf shall I send a diff to you?

Cheers,
Niall





-----BEGIN PGP SIGNATURE-----
Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2

iQA/AwUBP94HX8EcvDLFGKbPEQIv+QCfTEWsUU039VBPSLIr9TPfzfZX0BAAoIm7
CanC6PYwfwdEntT8lnnttkjy
=EY3+
-----END PGP SIGNATURE-----




More information about the Cplusplus-sig mailing list