merge revisions 11872:11876 from trunk to gsoc2009-sploving branch - license changes

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11906 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-03-06 01:19:37 +00:00
commit f2b542d8f4
150 changed files with 1386 additions and 12575 deletions

View file

@ -1,3 +0,0 @@
# see top-level Makefile.in
full
simple

View file

@ -1,28 +0,0 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
INTERFACE = gifplot.i
SRCS =
CXXSRCS =
TARGET = gifplot
INCLUDE = -I. -I../../Include
SWIGOPT = -I../../Include
CFLAGS =
VARIANT =
LIBS = -L../.. -lgifplot -lm
# comment the following two lines to build a dynamic so file
CHICKEN_MAIN = test-gifplot.scm
VARIANT = _static
all:: $(TARGET)
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f gifplot.scm image.gif
rm -f $(TARGET)

View file

@ -1,6 +0,0 @@
This example runs the entire gifplot.h header file through SWIG without
any changes. The Scheme program 'test-gifplot.scm' does something a
little more interesting. You'll have to go look at the header file to
get a complete listing of the functions.
`make' will build a static binary. Run ./gifplot to test it.

Binary file not shown.

View file

@ -1,26 +0,0 @@
/* 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_TYPEMAP(Pixel, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
%{
static Pixel int_to_Pixel (int v) { return (Pixel) v; }
%}
extern Pixel int_to_Pixel (int v);
%include gifplot.h

View file

@ -1,66 +0,0 @@
;;; Plot a 3D function
(declare (uses gifplot))
;; Here is the function to plot
(define (func x y)
(* 5
(cos (* 2 (sqrt (+ (* x x) (* y y)))))
(exp (* -0.3 (sqrt (+ (* x x) (* y y)))))))
;; Here are some plotting parameters
(define xmin -5.0)
(define xmax 5.0)
(define ymin -5.0)
(define ymax 5.0)
(define zmin -5.0)
(define zmax 5.0)
;; Grid resolution
(define nxpoints 60)
(define nypoints 60)
(define cmap (gifplot:new-ColorMap "cmap"))
(define frame (gifplot:new-FrameBuffer 500 500))
(gifplot:FrameBuffer-clear frame (gifplot:BLACK))
(define p3 (gifplot:new-Plot3D frame xmin ymin zmin xmax ymax zmax))
(gifplot:Plot3D-lookat p3 (* 2 (- zmax zmin)))
(gifplot:Plot3D-autoperspective p3 40.0)
(gifplot:Plot3D-rotu p3 60.0)
(gifplot:Plot3D-rotr p3 30.0)
(gifplot:Plot3D-rotd p3 10.0)
(define (drawsolid)
(gifplot:Plot3D-clear p3 (gifplot:BLACK))
(gifplot:Plot3D-start p3)
(let ((dx (/ (- xmax xmin) nxpoints))
(dy (/ (- ymax ymin) nypoints))
(cscale (/ 240 (- zmax zmin))))
(let x-loop ((x xmin) (i 0))
(cond
((< i nxpoints)
(let y-loop ((y ymin) (j 0))
(cond
((< j nypoints)
(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 (inexact->exact (round (max (min cc 239) 0)))))
(gifplot:Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy)
z3 x (+ y dy) z4
(gifplot:int->Pixel (+ c 16))))
(y-loop (+ y dy) (+ j 1)))))
(x-loop (+ x dx) (+ i 1)))))))
(display "Making a nice 3D plot...\n")
(drawsolid)
(gifplot:FrameBuffer-writeGIF frame cmap "image.gif")
(display "Wrote image.gif\n")

View file

@ -1,28 +0,0 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
INTERFACE = simple.i
SRCS =
CXXSRCS =
TARGET = simple
INCLUDE = -I. -I../../Include
SWIGOPT = -I../../Include
CFLAGS =
VARIANT =
LIBS = -L../.. -lgifplot -lm
# comment the following two lines to build a dynamic so file
CHICKEN_MAIN = test-simple.scm
VARIANT = _static
all:: $(TARGET)
$(TARGET): $(INTERFACE) $(SRCS)
$(MAKE) -f $(TOP)/Makefile \
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f simple.scm image.gif
rm -f $(TARGET)

View file

@ -1,5 +0,0 @@
This is a very minimalistic example in which just a few functions
and constants from library are wrapped and used to draw some simple
shapes.
`make' will build an exe. Run ./simple to test it.

View file

@ -1,34 +0,0 @@
/* This example shows a very simple interface wrapping a few
primitive declarations */
%module simple
%{
#include "gifplot.h"
%}
typedef unsigned int Pixel;
/* Here are a few useful functions */
ColorMap *new_ColorMap(char *filename = 0);
void delete_ColorMap(ColorMap *cmap);
FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height);
void delete_FrameBuffer(FrameBuffer *frame);
void FrameBuffer_clear(FrameBuffer *frame, Pixel color);
void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color);
void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color);
int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename);
/* And some useful constants, which we redefine (from gifplot.h) so
that SWIG sees them */
#define BLACK 0
#define WHITE 1
#define RED 2
#define GREEN 3
#define BLUE 4
#define YELLOW 5
#define CYAN 6
#define MAGENTA 7

View file

@ -1,29 +0,0 @@
;;; Draw some simple shapes
(declare (uses simple))
(display "Drawing some basic shapes\n")
(define cmap (simple:new-ColorMap #f))
(define f (simple:new-FrameBuffer 400 400))
;; Clear the picture
(simple:FrameBuffer-clear f (simple:BLACK))
;; Make a red box
(simple:FrameBuffer-box f 40 40 200 200 (simple:RED))
;; Make a blue circle
(simple:FrameBuffer-circle f 200 200 40 (simple:BLUE))
;; Make green line
(simple:FrameBuffer-line f 10 390 390 200 (simple:GREEN))
;; Write an image out to disk
(simple:FrameBuffer-writeGIF f cmap "image.gif")
(display "Wrote image.gif\n")
(simple:delete-FrameBuffer f)
(simple:delete-ColorMap cmap)

View file

@ -1,21 +0,0 @@
/* 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

View file

@ -1,59 +0,0 @@
;;; 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~%")))

View file

@ -1,3 +0,0 @@
# see top-level Makefile.in
full
simple

View file

@ -1,28 +0,0 @@
TOP = ../../..
SWIG = $(TOP)/../swig
SWIGOPT = -I../../Include
SRCS =
TARGET = gifplot
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot -lm
INCLUDES = -I../../Include
all:: static
dynamic::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
static::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
clean::
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
rm -f *.gif
check: all

View file

@ -1,8 +0,0 @@
This example runs the entire gifplot.h header file through SWIG without
any changes. The Scheme program 'runme.scm' does something a little more
interesting. You'll have to go look at the header file to get a complete
listing of the functions.

Binary file not shown.

View file

@ -1,21 +0,0 @@
/* 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

View file

@ -1,66 +0,0 @@
;;; Plot a 3D function
;; Use the wrapped GIFPlot library
(use-modules (gifplot))
;; Here is the function to plot
(define (func x y)
(* 5
(cos (* 2 (sqrt (+ (* x x) (* y y)))))
(exp (* -0.3 (sqrt (+ (* x x) (* y y)))))))
;; Here are some plotting parameters
(define xmin -5.0)
(define xmax 5.0)
(define ymin -5.0)
(define ymax 5.0)
(define zmin -5.0)
(define zmax 5.0)
;; Grid resolution
(define nxpoints 60)
(define nypoints 60)
(define cmap (new-ColorMap "cmap"))
(define frame (new-FrameBuffer 500 500))
(FrameBuffer-clear frame (BLACK))
(define p3 (new-Plot3D frame xmin ymin zmin xmax ymax zmax))
(Plot3D-lookat p3 (* 2 (- zmax zmin)))
(Plot3D-autoperspective p3 40)
(Plot3D-rotu p3 60)
(Plot3D-rotr p3 30)
(Plot3D-rotd p3 10)
(define (drawsolid)
(Plot3D-clear p3 (BLACK))
(Plot3D-start p3)
(let ((dx (/ (- xmax xmin) nxpoints))
(dy (/ (- ymax ymin) nypoints))
(cscale (/ 240 (- zmax zmin))))
(let x-loop ((x xmin) (i 0))
(cond
((< i nxpoints)
(let y-loop ((y ymin) (j 0))
(cond
((< j nypoints)
(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)))
(y-loop (+ y dy) (+ j 1)))))
(x-loop (+ x dx) (+ i 1)))))))
(display "Making a nice 3D plot...\n")
(drawsolid)
(FrameBuffer-writeGIF frame cmap "image.gif")
(display "Wrote image.gif\n")

View file

@ -1,28 +0,0 @@
TOP = ../../..
SWIG = $(TOP)/../swig
SWIGOPT =
SRCS =
TARGET = simple
INTERFACE = simple.i
LIBS = -L../.. -lgifplot
INCLUDES = -I../../Include
all:: static
dynamic::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
static::
$(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \
SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_static
clean::
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
rm -f *.gif
check: all

Some files were not shown because too many files have changed in this diff Show more