From bc02779c93d257cdfd627bbcffac7e10fccd7586 Mon Sep 17 00:00:00 2001
From: Jonah Beckford
- CHICKEN support was introduced to SWIG in version 1.3.18. SWIG relies
- on a recent addition to CHICKEN -- the C_TAGGED_POINTER -- which
- is only present in CVS versions of CHICKEN dated after February
- 11, 2003, and in releases of CHICKEN with version number
- greater than 0.1082.
+ CHICKEN support was introduced to SWIG in version 1.3.18. SWIG
+ relies on some recent additions to CHICKEN, which are only
+ present in releases of CHICKEN with version number
+ greater than or equal to 0.1099, or in CVS
+ versions of CHICKEN dated after March 11, 2003.
CHICKEN can be downloaded from http://www.call-with-current-continuation.org/chicken.html
You may want to look at any of the examples in Examples/chicken/
or Examples/GIFPlot/Chicken for the basic steps to run SWIG
- CHICKEN. We will generically refer to the wrapper as
- the generated files.
+ CHICKEN.
+
+ We will generically refer to the wrapper as the
+ generated files.
Please refer to CHICKEN - A practical and portable Scheme - system - User's manual for detailed help on how to - compile C code for use in a CHICKEN program. Briefly, to - compile C code, be sure to add `chicken-config -cflags` - to your compiler options. + system - User's manual for detailed help on how to compile + C code for use in a CHICKEN program. Briefly, to compile C + code, be sure to add `chicken-config -cflags` or + `chicken-config -shared -cflags` to your compiler + options. Use the -shared option if you want to create + a dynamically loadable module. You might also want to use the + much simpler csc or csc.bat.
All the following examples assume that the module is named
@@ -349,9 +359,10 @@ CHICKEN_HOME=/usr/local/share/chicken
- Two non-standard typemaps are supported: clos_in and
- clos_out. They are for converting TinyCLOS to and
- from low-level CHICKEN SWIG. Here is a quick example:
+ Two Chicken-specific typemaps are supported:
+ clos_in and clos_out. They are for
+ converting TinyCLOS to and from low-level CHICKEN SWIG. Here is
+ a quick example:
@@ -380,9 +391,101 @@ CHICKEN_HOME=/usr/local/share/chickento SWIG will have correct TinyCLOS representations based onSIMPLE_CLOS_OBJECT. SWIG "knows" the classes that are exposed in the SWIG interface file; it "fully knows" only - those classes that are not forward declarations. Have a look at - the Examples/chicken/vtk/example.i for more - information. + those classes that are not forward declarations. + +
+ + A real-world example of the "fully knows" problem is found in + the VTK visualization library. All VTK classes are derived from + vtkObject. + +++ ++ /* FILE: vtkObject.h */ + class vtkObject { + // ... + }; ++++ ++ /* FILE: vtkWindow.h */ + #include "vtkObject.h" + + class vtkWindow : public vtkObject { + // ... + }; ++++ ++ /* FILE: vtkViewport.h */ + #include "vtkViewport.h" + + class vtkViewport : public vtkObject { + // ... + }; ++++ ++ /* FILE: vtkRenderWindow.h */ + #include "vtkWindow.h" + + class vtkRenderer; + class vtkRenderWindow : public vtkWindow { + // ... + virtual void AddRenderer (vtkRenderer *rendererArg); + // ... + }; ++++ ++ /* FILE: vtkRenderer.h */ + #include "vtkViewport.h" + + class vtkRenderWindow; + class vtkRenderer : public vtkViewport { + // ... + void SetRenderWindow(vtkRenderWindow *); + // ... + }; ++++ + After SWIG processes+ /* FILE: vtk.i; SWIG interface file */ + %typemap(clos_in) vtkObject * = SIMPLE_CLOS_OBJECT *; + %typemap(clos_out) vtkObject * = SIMPLE_CLOS_OBJECT *; + %include "vtkObject.h" + %include "vtkWindow.h" + %include "vtkViewport.h" + %include "vtkRenderWindow.h" + %include "vtkRenderer.h" ++vtkObject.h(from the + %include "vtkObject.h" line), SWIG will have the complete + definition of thevtkObjectclass because +vtkObjectdoes not contain any references to any + other classes. As it readsvtkWindow.hand +vtkViewport.h, it will already have the definition of +vtkObject, so it will not need aclos_in+ orclos_outtypemap for thevtkWindowor +vtkViewportsubclasses ofvtkObject. + However, by the time SWIG gets to %include + "vtkRenderWindow.h", it will not have the definition for the +vtkRendererclass, even though it is used by +vtkRenderWindow. We therefore must + put inclos_in/clos_outtypemaps for +vtkRenderer.