[C++-sig] Pyste-generated extentsion Aborts Python

Jim Wilson wilson at afn.org
Fri Jul 4 02:10:40 CEST 2003


Nicodemus,

I got the CVS, and it seemed to fix the "overloaded bar(char**)"
problem I mentioned before.  My goal was to wrap (at least a portion
of) the Fast Light ToolKit (FLTK: http://www.fltk.org ).  Others are
attempting this with SWIG ( http://pyfltk.sourceforge.net/ ), but I
was hoping Pyste would simplify the job.

Alas, I'm not sure I can simplify the files I'm wrapping, but my wrapper
is quite lightweight.  Since I didn't want to figure out all those "needs-
a-policy" complaints, I wrote a small header which exposed only the routines
I needed from FLTK Version 1.1.4.  I'm not sure you want this, but here it
is:

fltk.h:

	class Fl {	// A class masquerading as a namespace,
	  public:	//   Fl is essentially a buch of static methods
   	  static int run();
	};
	#include <.../Fl_Window.H>	// This will be instanciated

fltk.pyste:

	Class("Fl", "fltk.h")
	w = Class("Fl_Window", "fltk.h")
	exclude(w.icon)		# Easier to exclude than use the
	exclude(w.child)	# trick I did with class Fl, since
	exclude(w.current)	# I may want to *do* something with
	exclude(w.array)	# my Fl_Window!
	exclude(w.resizable)
	exclude(w._ddfdesign_kludge)

(In fltk.h, <...> was the path prefix my the directory holding Fl_Window.h.)

I pysted, beat bjam into submission, and got a clean compile and link.  Now
came python:

	>>>from fltk import Fl, Fl_Window
	>>>w = Fl_Window(0,0, 600,400)
	>>>w.show()
	>>>Fl.run()
	Abort

The "w = ..." line, creates a window in the upper left corner (0,0) of size
600x400 pixels.  The next draws it on the screen, the last one fires up the
event loop.  The window is momentarily displayed before it immediately
vanishes and "Abort" appears (followed by the bash prompt).

The running python is half as big as the SWIG version though ;D.

I'd appreciate any advice.

Jim Wilson







More information about the Cplusplus-sig mailing list