The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1180 changed files with 125431 additions and 43485 deletions
1
SWIG/Examples/GIFPlot/.cvsignore
Normal file
1
SWIG/Examples/GIFPlot/.cvsignore
Normal file
|
|
@ -0,0 +1 @@
|
|||
Makefile
|
||||
BIN
SWIG/Examples/GIFPlot/Common-Lisp/full/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Common-Lisp/full/cmap
Normal file
Binary file not shown.
21
SWIG/Examples/GIFPlot/Common-Lisp/full/gifplot.i
Normal file
21
SWIG/Examples/GIFPlot/Common-Lisp/full/gifplot.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* Oh what the heck, let's just grab the whole darn header file
|
||||
and see what happens. */
|
||||
|
||||
%module gifplot
|
||||
%{
|
||||
|
||||
/* Note: You still need this part because the %include directive
|
||||
merely causes SWIG to interpret the contents of a file. It doesn't
|
||||
include the right include headers for the resulting C code */
|
||||
|
||||
#include "gifplot.h"
|
||||
|
||||
%}
|
||||
|
||||
/* Pixel is typedef'd to unsigned char, and SWIG will translate this
|
||||
type into Scheme characters. We would like to translate Pixels to
|
||||
Scheme integers instead, so: */
|
||||
|
||||
SIMPLE_MAP(Pixel, gh_scm2int, gh_int2scm, integer);
|
||||
|
||||
%include gifplot.h
|
||||
59
SWIG/Examples/GIFPlot/Common-Lisp/full/runme.lisp
Normal file
59
SWIG/Examples/GIFPlot/Common-Lisp/full/runme.lisp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
;;; Plot a 3D function
|
||||
|
||||
;; Here is the function to plot
|
||||
(defun func (x y)
|
||||
(* 5
|
||||
(cos (* 2 (sqrt (+ (* x x) (* y y)))))
|
||||
(exp (* -0.3 (sqrt (+ (* x x) (* y y)))))))
|
||||
|
||||
;; Here are some plotting parameters
|
||||
(defvar xmin -5D0)
|
||||
(defvar xmax 5D0)
|
||||
(defvar ymin -5D0)
|
||||
(defvar ymax 5D0)
|
||||
(defvar zmin -5D0)
|
||||
(defvar zmax 5D0)
|
||||
|
||||
;; Grid resolution
|
||||
(defvar nxpoints 60)
|
||||
(defvar nypoints 60)
|
||||
|
||||
(defun drawsolid (p3)
|
||||
(Plot3D-clear p3 0)
|
||||
(Plot3D-start p3)
|
||||
(let ((dx (/ (- xmax xmin) nxpoints))
|
||||
(dy (/ (- ymax ymin) nypoints))
|
||||
(cscale (/ 240 (- zmax zmin))))
|
||||
(loop for x from xmin by dx
|
||||
repeat nxpoints
|
||||
do (loop for y from ymin by dy
|
||||
repeat nypoints
|
||||
do (let* ((z1 (func x y))
|
||||
(z2 (func (+ x dx) y))
|
||||
(z3 (func (+ x dx) (+ y dy)))
|
||||
(z4 (func x (+ y dy)))
|
||||
(c1 (* cscale (- z1 zmin)))
|
||||
(c2 (* cscale (- z2 zmin)))
|
||||
(c3 (* cscale (- z3 zmin)))
|
||||
(c4 (* cscale (- z4 zmin)))
|
||||
(cc (/ (+ c1 c2 c3 c4) 4))
|
||||
(c (round (max (min cc 239) 0))))
|
||||
(Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy)
|
||||
z3 x (+ y dy) z4 (+ c 16)))))))
|
||||
|
||||
(defun action (cmap-filename)
|
||||
(let ((cmap (new-ColorMap cmap-filename))
|
||||
(frame (new-FrameBuffer 500 500)))
|
||||
(format t "Making a nice 3D plot...~%")
|
||||
(FrameBuffer-clear frame 0)
|
||||
(let ((p3 (new-Plot3D frame xmin ymin zmin xmax ymax zmax)))
|
||||
(Plot3D-lookat p3 (* 2 (- zmax zmin)))
|
||||
(Plot3D-autoperspective p3 40D0)
|
||||
(Plot3D-rotu p3 60D0)
|
||||
(Plot3D-rotr p3 30D0)
|
||||
(Plot3D-rotd p3 10D0)
|
||||
(drawsolid p3))
|
||||
(FrameBuffer-writeGIF frame cmap "/tmp/image.gif")
|
||||
(format t "Wrote image.gif~%")))
|
||||
|
||||
|
||||
3
SWIG/Examples/GIFPlot/Guile/check.list
Normal file
3
SWIG/Examples/GIFPlot/Guile/check.list
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
simple
|
||||
3
SWIG/Examples/GIFPlot/Guile/full/.cvsignore
Normal file
3
SWIG/Examples/GIFPlot/Guile/full/.cvsignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
gifplot-guile
|
||||
gifplot_wrap.c
|
||||
image.gif
|
||||
|
|
@ -5,23 +5,24 @@ SRCS =
|
|||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot -lm
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all:: static
|
||||
|
||||
dynamic::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so gifguile .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
4
SWIG/Examples/GIFPlot/Guile/simple/.cvsignore
Normal file
4
SWIG/Examples/GIFPlot/Guile/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
gifguile
|
||||
image.gif
|
||||
simple-guile
|
||||
simple_wrap.c
|
||||
|
|
@ -5,23 +5,24 @@ SRCS =
|
|||
TARGET = simple
|
||||
INTERFACE = simple.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDE = -I../../Include
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all:: static
|
||||
|
||||
dynamic::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
|
||||
SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so gifguile .~* core *.gif
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
#ifndef GIFPLOT_H
|
||||
|
||||
#ifdef SWIG
|
||||
%pragma no_default
|
||||
#endif
|
||||
|
||||
/* Pixel is 8-bits */
|
||||
|
||||
typedef unsigned char Pixel;
|
||||
|
|
@ -125,9 +129,9 @@ extern void delete_PixMap(PixMap *pm);
|
|||
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
|
||||
extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor);
|
||||
|
||||
#define TRANSPARENT 0
|
||||
#define FOREGROUND 1
|
||||
#define BACKGROUND 2
|
||||
#define GIFPLOT_TRANSPARENT 0
|
||||
#define GIFPLOT_FOREGROUND 1
|
||||
#define GIFPLOT_BACKGROUND 2
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
Plot2D
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
typedef unsigned char Pixel;
|
||||
typedef float Zvalue;
|
||||
|
||||
%disabledoc
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
ColorMap
|
||||
|
||||
|
|
@ -23,14 +21,14 @@ typedef struct ColorMap {
|
|||
char *name;
|
||||
|
||||
//
|
||||
// %addmethods adds some C methods to this structure to make it
|
||||
// %extend adds some C methods to this structure to make it
|
||||
// look like a C++ class in Python.
|
||||
// These are really named things like ColorMap_default, ColorMap_assign, etc...
|
||||
|
||||
%addmethods {
|
||||
%extend {
|
||||
ColorMap(char *filename);
|
||||
~ColorMap();
|
||||
#ifdef SWIGJAVA
|
||||
#if defined(SWIGJAVA ) || defined(SWIGPHP4)
|
||||
%name(make_default) void default();
|
||||
#else
|
||||
void default();
|
||||
|
|
@ -44,16 +42,6 @@ typedef struct ColorMap {
|
|||
|
||||
/* Some default colors */
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
const Pixel BLACK = 0;
|
||||
const Pixel WHITE = 1;
|
||||
const Pixel RED = 2;
|
||||
const Pixel GREEN = 3;
|
||||
const Pixel BLUE = 4;
|
||||
const Pixel YELLOW = 5;
|
||||
const Pixel CYAN = 6;
|
||||
const Pixel MAGENTA = 7;
|
||||
#else
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define RED 2
|
||||
|
|
@ -62,7 +50,6 @@ const Pixel MAGENTA = 7;
|
|||
#define YELLOW 5
|
||||
#define CYAN 6
|
||||
#define MAGENTA 7
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
FrameBuffer
|
||||
|
|
@ -77,7 +64,7 @@ typedef struct FrameBuffer {
|
|||
int ymin;
|
||||
int xmax;
|
||||
int ymax;
|
||||
%addmethods {
|
||||
%extend {
|
||||
FrameBuffer(unsigned int width, unsigned int height);
|
||||
~FrameBuffer();
|
||||
void resize(int width, int height);
|
||||
|
|
@ -119,9 +106,9 @@ extern PixMap *new_PixMap(int width, int height, int centerx, int centery);
|
|||
extern void delete_PixMap(PixMap *pm);
|
||||
extern void PixMap_set(PixMap *pm, int x, int y, int pix);
|
||||
|
||||
#define TRANSPARENT 0
|
||||
#define FOREGROUND 1
|
||||
#define BACKGROUND 2
|
||||
#define GIFPLOT_TRANSPARENT 0
|
||||
#define GIFPLOT_FOREGROUND 1
|
||||
#define GIFPLOT_BACKGROUND 2
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
Plot2D
|
||||
|
|
@ -141,7 +128,7 @@ typedef struct Plot2D {
|
|||
double ymax;
|
||||
int xscale; /* Type of scaling (LINEAR, LOG, etc..) */
|
||||
int yscale;
|
||||
%addmethods {
|
||||
%extend {
|
||||
Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax);
|
||||
~Plot2D();
|
||||
Plot2D *copy();
|
||||
|
|
@ -203,7 +190,7 @@ typedef struct Plot3D {
|
|||
double lookatz; /* Where is the z-lookat point */
|
||||
double xshift; /* Used for translation and stuff */
|
||||
double yshift;
|
||||
%addmethods {
|
||||
%extend {
|
||||
Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax);
|
||||
~Plot3D();
|
||||
Plot3D *copy();
|
||||
|
|
@ -264,13 +251,11 @@ typedef struct Plot3D {
|
|||
/* These directives create constants of a specific type. They
|
||||
do not correspond to any C variable or declared constant in the
|
||||
header file */
|
||||
%constant(PixMap *) SQUARE = &PixMap_SQUARE;
|
||||
%constant(PixMap *) TRIANGLE = &PixMap_TRIANGLE;
|
||||
%constant(PixMap *) CROSS = &PixMap_CROSS;
|
||||
%constant PixMap * SQUARE = &PixMap_SQUARE;
|
||||
%constant PixMap * TRIANGLE = &PixMap_TRIANGLE;
|
||||
%constant PixMap * CROSS = &PixMap_CROSS;
|
||||
#endif
|
||||
|
||||
%enabledoc
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig -shadow
|
||||
SWIGOPT = -I../Include
|
||||
SRCS =
|
||||
TARGET = libjgifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L.. -lgifplot -lm
|
||||
INCLUDE = -I../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDE='$(INCLUDE)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
|
||||
|
||||
clean::
|
||||
rm -f *_wrap* *.o *~ *.so .~* core *.gif *.class ColorMap.java FrameBuffer.java Plot2D.java Plot3D.java gifplot.java
|
||||
|
||||
check: all
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
The gifplot example does not work straight out of the box,
|
||||
I had to change ../Interface/gifplot.i slightly for java.
|
||||
|
||||
a)
|
||||
The colors (e.g. BLACK) where defined as:
|
||||
|
||||
#define BLACK 0
|
||||
|
||||
and the functions expect 'Pixel color' where Pixel is a unsigned char.
|
||||
#define constants contain no type information and are translated to integer
|
||||
constants. Because of that, you have to cast every Pixel to a byte in java.
|
||||
|
||||
Changing the definition to:
|
||||
const Pixel BLACK = 0;
|
||||
fixes this.
|
||||
|
||||
b)
|
||||
The definitions:
|
||||
|
||||
const PixMap *SQUARE = &PixMap_SQUARE;
|
||||
const PixMap *TRIANGLE = &PixMap_TRIANGLE;
|
||||
const PixMap *CROSS = &PixMap_CROSS;
|
||||
|
||||
don't work.
|
||||
The wrapper code expects actual variables SQUARE, etc. and they are not
|
||||
defined in gifplot.h.
|
||||
|
||||
c)
|
||||
In shadow mode the method ColorMap::default() clashes with the reserved name
|
||||
default.
|
||||
4
SWIG/Examples/GIFPlot/Java/check.list
Normal file
4
SWIG/Examples/GIFPlot/Java/check.list
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
full
|
||||
shadow
|
||||
simple
|
||||
Binary file not shown.
7
SWIG/Examples/GIFPlot/Java/full/.cvsignore
Normal file
7
SWIG/Examples/GIFPlot/Java/full/.cvsignore
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
*.class
|
||||
*.java
|
||||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*.so
|
||||
*.dll
|
||||
*.gif
|
||||
20
SWIG/Examples/GIFPlot/Java/full/Makefile
Normal file
20
SWIG/Examples/GIFPlot/Java/full/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIGOPT = -I../../Include -noproxy
|
||||
SRCS =
|
||||
TARGET = gifplot
|
||||
INTERFACE = gifplot.i
|
||||
LIBS = -L../.. -lgifplot
|
||||
INCLUDES = -I../../Include
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
|
||||
javac *.java
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile java_clean
|
||||
rm -f *.gif
|
||||
|
||||
check: all
|
||||
8
SWIG/Examples/GIFPlot/Java/full/README
Normal file
8
SWIG/Examples/GIFPlot/Java/full/README
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
This example runs the entire gifplot.h header file through SWIG without
|
||||
any changes. The program 'main.java' does something a little more
|
||||
interesting. After doing a make, run it using 'java main'. You'll have to go
|
||||
look at the header file to get a complete listing of the functions.
|
||||
|
||||
Note the differences in the main.java files between this example and the
|
||||
'full' example. This example does not use shadow classes.
|
||||
|
||||
BIN
SWIG/Examples/GIFPlot/Java/full/cmap
Normal file
BIN
SWIG/Examples/GIFPlot/Java/full/cmap
Normal file
Binary file not shown.
15
SWIG/Examples/GIFPlot/Java/full/gifplot.i
Normal file
15
SWIG/Examples/GIFPlot/Java/full/gifplot.i
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Oh what the heck, let's just grab the whole darn header file
|
||||
and see what happens. */
|
||||
|
||||
%module gifplot
|
||||
%{
|
||||
|
||||
/* Note: You still need this part because the %include directive
|
||||
merely causes SWIG to interpret the contents of a file. It doesn't
|
||||
include the right include headers for the resulting C code */
|
||||
|
||||
#include "gifplot.h"
|
||||
|
||||
%}
|
||||
|
||||
%include gifplot.h
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue