Merge branch 'mzscheme-experimental'
* mzscheme-experimental: Fix mzscheme name and unions testcases Terminology correction in html docs Suppress experimental language warning when running the test-suite Mark MzScheme as an experimental language Add mzscheme to Travis testing Format mzscheme help output Mzscheme out of source examples fixes Standardise Mzscheme simple example Standardise Guile simple example Fix mzscheme static variable wrappers MzScheme missing destructor added in, std_vector example fixed Fix mzscheme simple example Fix mzscheme multimap example Skip failing MzScheme tests
This commit is contained in:
commit
a8f927dd50
30 changed files with 330 additions and 129 deletions
11
.travis.yml
11
.travis.yml
|
|
@ -94,6 +94,11 @@ matrix:
|
||||||
env: SWIGLANG=lua VER=5.3
|
env: SWIGLANG=lua VER=5.3
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=mzscheme
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
os: linux
|
os: linux
|
||||||
env: SWIGLANG=ocaml
|
env: SWIGLANG=ocaml
|
||||||
|
|
@ -384,6 +389,12 @@ matrix:
|
||||||
env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1
|
env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1
|
||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
# Experimental languages
|
||||||
|
- compiler: gcc
|
||||||
|
os: linux
|
||||||
|
env: SWIGLANG=mzscheme
|
||||||
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- date -u
|
- date -u
|
||||||
|
|
|
||||||
|
|
@ -3626,7 +3626,7 @@ A target language is given the 'Experimental' status when
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
It is of sub-standard quality, failing to meet the above 'Standard' status.
|
It is of sub-standard quality, failing to meet the above 'Supported' status.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
It is somewhere between the mid to mature stage of development.
|
It is somewhere between the mid to mature stage of development.
|
||||||
|
|
@ -3652,7 +3652,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat
|
||||||
Have fully functional examples of basic functionality (the simple and class examples).
|
Have fully functional examples of basic functionality (the simple and class examples).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
The test-suite must be implemented and include some runtime tests for wrapped C and C++ tests.
|
The test-suite must be implemented and include a few runtime tests for both C and C++ test cases.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Failing tests must be put into one of the FAILING_CPP_TESTS or FAILING_C_TESTS lists in the test-suite.
|
Failing tests must be put into one of the FAILING_CPP_TESTS or FAILING_C_TESTS lists in the test-suite.
|
||||||
|
|
@ -3668,7 +3668,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat
|
||||||
Any new failed tests will be fixed on a 'best effort' basis by core developers with no promises made.
|
Any new failed tests will be fixed on a 'best effort' basis by core developers with no promises made.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
If a language module has an official maintainer, then the maintainer will be requested to focus on fixing test-suite regressions and commit to migrating the module to become a 'Standard' module.
|
If a language module has an official maintainer, then the maintainer will be requested to focus on fixing test-suite regressions and commit to migrating the module to become a 'Supported' module.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
If a module does not have an official maintainer, then, as maintenance will be on a 'best efforts' basis by the core maintainers, no guarantees will be provided from one release to the next and regressions may creep in.
|
If a module does not have an official maintainer, then, as maintenance will be on a 'best efforts' basis by the core maintainers, no guarantees will be provided from one release to the next and regressions may creep in.
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,6 @@ Supported Target Language Options
|
||||||
-java - Generate Java wrappers
|
-java - Generate Java wrappers
|
||||||
-javascript - Generate Javascript wrappers
|
-javascript - Generate Javascript wrappers
|
||||||
-lua - Generate Lua wrappers
|
-lua - Generate Lua wrappers
|
||||||
-mzscheme - Generate Mzscheme wrappers
|
|
||||||
-ocaml - Generate Ocaml wrappers
|
-ocaml - Generate Ocaml wrappers
|
||||||
-octave - Generate Octave wrappers
|
-octave - Generate Octave wrappers
|
||||||
-perl5 - Generate Perl 5 wrappers
|
-perl5 - Generate Perl 5 wrappers
|
||||||
|
|
@ -138,6 +137,7 @@ Supported Target Language Options
|
||||||
-xml - Generate XML wrappers
|
-xml - Generate XML wrappers
|
||||||
|
|
||||||
Experimental Target Language Options
|
Experimental Target Language Options
|
||||||
|
-mzscheme - Generate MzScheme/Racket wrappers
|
||||||
|
|
||||||
General Options
|
General Options
|
||||||
-addextern - Add extra extern declarations
|
-addextern - Add extra extern declarations
|
||||||
|
|
|
||||||
|
|
@ -813,7 +813,7 @@ MZSCHEME = mzscheme
|
||||||
MZC = @MZC@
|
MZC = @MZC@
|
||||||
MZDYNOBJ = @MZDYNOBJ@
|
MZDYNOBJ = @MZDYNOBJ@
|
||||||
MZSCHEME_SO = @MZSCHEME_SO@
|
MZSCHEME_SO = @MZSCHEME_SO@
|
||||||
MZSCHEME_SCRIPT = $(RUNME).scm
|
MZSCHEME_SCRIPT = $(SRCDIR)$(RUNME).scm
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# Build a C/C++ dynamically loadable module
|
# Build a C/C++ dynamically loadable module
|
||||||
|
|
@ -821,12 +821,12 @@ MZSCHEME_SCRIPT = $(RUNME).scm
|
||||||
|
|
||||||
mzscheme: $(SRCDIR_SRCS)
|
mzscheme: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
|
$(COMPILETOOL) $(MZC) `echo $(CPPFLAGS) $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
|
||||||
$(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
|
$(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
|
||||||
|
|
||||||
mzscheme_cpp: $(SRCDIR_SRCS)
|
mzscheme_cpp: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
$(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||||
$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
$(COMPILETOOL) $(MZC) `echo $(CPPFLAGS) $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
|
||||||
$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
|
$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
/* Simple example from documentation */
|
|
||||||
/* File : example.c */
|
/* File : example.c */
|
||||||
|
|
||||||
#include <time.h>
|
/* A global variable */
|
||||||
|
double Foo = 3.0;
|
||||||
|
|
||||||
double My_variable = 3.0;
|
/* Compute the greatest common divisor of positive integers */
|
||||||
|
int gcd(int x, int y) {
|
||||||
int fact(int n) {
|
int g;
|
||||||
if (n <= 1) return 1;
|
g = y;
|
||||||
else return n*fact(n-1);
|
while (x > 0) {
|
||||||
|
g = x;
|
||||||
|
x = y % x;
|
||||||
|
y = g;
|
||||||
|
}
|
||||||
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mod(int n, int m) {
|
|
||||||
return (n % m);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *get_time() {
|
|
||||||
long ltime;
|
|
||||||
time(<ime);
|
|
||||||
return ctime(<ime);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,8 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
extern double My_variable;
|
extern int gcd(int x, int y);
|
||||||
extern int fact(int);
|
extern double Foo;
|
||||||
extern int mod(int n, int m);
|
|
||||||
extern char *get_time();
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include guile/guilemain.i
|
%include guile/guilemain.i
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,20 @@
|
||||||
(for-each display args)
|
(for-each display args)
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
(mdisplay-newline (get-time) "My variable = " (My-variable))
|
; Call our gcd() function
|
||||||
|
|
||||||
(do ((i 0 (1+ i)))
|
(define x 42)
|
||||||
((= 14 i))
|
(define y 105)
|
||||||
(mdisplay-newline i " factorial is " (fact i)))
|
(define g (gcd x y))
|
||||||
|
(mdisplay-newline "The gcd of " x " and " y " is " g)
|
||||||
|
|
||||||
(define (mods i imax j jmax)
|
; Manipulate the Foo global variable
|
||||||
(if (< i imax)
|
|
||||||
(if (< j jmax)
|
|
||||||
(begin
|
|
||||||
(My-variable (+ (My-variable) (mod i j)))
|
|
||||||
(mods i imax (+ j 1) jmax))
|
|
||||||
(mods (+ i 1) imax 1 jmax))))
|
|
||||||
|
|
||||||
(mods 1 150 1 150)
|
; Output its current value
|
||||||
|
(mdisplay-newline "Foo = " (Foo))
|
||||||
|
|
||||||
(mdisplay-newline "My-variable = " (My-variable))
|
; Change its value
|
||||||
|
(Foo 3.1415926)
|
||||||
(exit (and (= 1932053504 (fact 13))
|
|
||||||
(= 745470.0 (My-variable))))
|
|
||||||
|
|
||||||
|
; See if the change took effect
|
||||||
|
(mdisplay-newline "Foo = " (Foo))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# see top-level Makefile.in
|
# see top-level Makefile.in
|
||||||
|
class
|
||||||
multimap
|
multimap
|
||||||
simple
|
simple
|
||||||
std_vector
|
std_vector
|
||||||
|
|
|
||||||
18
Examples/mzscheme/class/Makefile
Normal file
18
Examples/mzscheme/class/Makefile
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
TOP = ../..
|
||||||
|
SWIGEXE = $(TOP)/../swig
|
||||||
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
|
CXXSRCS = example.cxx
|
||||||
|
TARGET = example
|
||||||
|
INTERFACE = example.i
|
||||||
|
SWIGOPT =
|
||||||
|
|
||||||
|
check: build
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
|
||||||
|
|
||||||
|
build:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
||||||
28
Examples/mzscheme/class/example.cxx
Normal file
28
Examples/mzscheme/class/example.cxx
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* File : example.cxx */
|
||||||
|
|
||||||
|
#include "example.h"
|
||||||
|
#define M_PI 3.14159265358979323846
|
||||||
|
|
||||||
|
/* Move the shape to a new location */
|
||||||
|
void Shape::move(double dx, double dy) {
|
||||||
|
x += dx;
|
||||||
|
y += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Shape::nshapes = 0;
|
||||||
|
|
||||||
|
double Circle::area() {
|
||||||
|
return M_PI*radius*radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Circle::perimeter() {
|
||||||
|
return 2*M_PI*radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Square::area() {
|
||||||
|
return width*width;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Square::perimeter() {
|
||||||
|
return 4*width;
|
||||||
|
}
|
||||||
34
Examples/mzscheme/class/example.h
Normal file
34
Examples/mzscheme/class/example.h
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* File : example.h */
|
||||||
|
|
||||||
|
class Shape {
|
||||||
|
public:
|
||||||
|
Shape() {
|
||||||
|
nshapes++;
|
||||||
|
}
|
||||||
|
virtual ~Shape() {
|
||||||
|
nshapes--;
|
||||||
|
}
|
||||||
|
double x, y;
|
||||||
|
void move(double dx, double dy);
|
||||||
|
virtual double area() = 0;
|
||||||
|
virtual double perimeter() = 0;
|
||||||
|
static int nshapes;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Circle : public Shape {
|
||||||
|
private:
|
||||||
|
double radius;
|
||||||
|
public:
|
||||||
|
Circle(double r) : radius(r) { }
|
||||||
|
virtual double area();
|
||||||
|
virtual double perimeter();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Square : public Shape {
|
||||||
|
private:
|
||||||
|
double width;
|
||||||
|
public:
|
||||||
|
Square(double w) : width(w) { }
|
||||||
|
virtual double area();
|
||||||
|
virtual double perimeter();
|
||||||
|
};
|
||||||
9
Examples/mzscheme/class/example.i
Normal file
9
Examples/mzscheme/class/example.i
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* File : example.i */
|
||||||
|
%module example
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "example.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
/* Let's just grab the original header file here */
|
||||||
|
%include "example.h"
|
||||||
60
Examples/mzscheme/class/runme.scm
Normal file
60
Examples/mzscheme/class/runme.scm
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
; file: runme.scm
|
||||||
|
|
||||||
|
; This file illustrates the proxy class C++ interface generated
|
||||||
|
; by SWIG.
|
||||||
|
|
||||||
|
(load-extension "example.so")
|
||||||
|
|
||||||
|
; Convenience wrapper around the display function
|
||||||
|
; (which only accepts one argument at the time)
|
||||||
|
|
||||||
|
(define (mdisplay-newline . args)
|
||||||
|
(for-each display args)
|
||||||
|
(newline))
|
||||||
|
|
||||||
|
; ----- Object creation -----
|
||||||
|
|
||||||
|
(mdisplay-newline "Creating some objects:")
|
||||||
|
(define c (new-Circle 10))
|
||||||
|
(mdisplay-newline " Created circle " c)
|
||||||
|
(define s (new-Square 10))
|
||||||
|
(mdisplay-newline " Created square " s)
|
||||||
|
|
||||||
|
; ----- Access a static member -----
|
||||||
|
|
||||||
|
(mdisplay-newline "\nA total of " (Shape-nshapes) " shapes were created")
|
||||||
|
|
||||||
|
; ----- Member data access -----
|
||||||
|
|
||||||
|
; Set the location of the object
|
||||||
|
|
||||||
|
(Shape-x-set c 20)
|
||||||
|
(Shape-y-set c 30)
|
||||||
|
|
||||||
|
(Shape-x-set s -10)
|
||||||
|
(Shape-y-set s 5)
|
||||||
|
|
||||||
|
(mdisplay-newline "\nHere is their current position:")
|
||||||
|
(mdisplay-newline " Circle = (" (Shape-x-get c) "," (Shape-y-get c) ")")
|
||||||
|
(mdisplay-newline " Square = (" (Shape-x-get s) "," (Shape-y-get s) ")")
|
||||||
|
|
||||||
|
; ----- Call some methods -----
|
||||||
|
|
||||||
|
(mdisplay-newline "\nHere are some properties of the shapes:")
|
||||||
|
(define (shape-props o)
|
||||||
|
(mdisplay-newline " " o)
|
||||||
|
(mdisplay-newline " area = " (Shape-area o))
|
||||||
|
(mdisplay-newline " perimeter = " (Shape-perimeter o)))
|
||||||
|
(for-each shape-props (list c s))
|
||||||
|
|
||||||
|
(mdisplay-newline "\nGuess I'll clean up now")
|
||||||
|
|
||||||
|
; Note: this invokes the virtual destructor
|
||||||
|
(delete-Shape c)
|
||||||
|
(delete-Shape s)
|
||||||
|
|
||||||
|
(define s 3)
|
||||||
|
(mdisplay-newline (Shape-nshapes) " shapes remain")
|
||||||
|
(mdisplay-newline "Goodbye")
|
||||||
|
|
||||||
|
(exit 0)
|
||||||
|
|
@ -13,5 +13,6 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ int gcdmain(int argc, char *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count(char *bytes, int len, char c) {
|
int charcount(char *bytes, int len, char c) {
|
||||||
int i;
|
int i;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
%{
|
%{
|
||||||
extern int gcd(int x, int y);
|
extern int gcd(int x, int y);
|
||||||
extern int gcdmain(int argc, char *argv[]);
|
extern int gcdmain(int argc, char *argv[]);
|
||||||
extern int count(char *bytes, int len, char c);
|
extern int charcount(char *bytes, int len, char c);
|
||||||
extern void capitalize (char *str, int len);
|
extern void capitalize (char *str, int len);
|
||||||
extern void circle (double cx, double cy);
|
extern void circle (double cx, double cy);
|
||||||
extern int squareCubed (int n, int *OUTPUT);
|
extern int squareCubed (int n, int *OUTPUT);
|
||||||
|
|
@ -50,7 +50,7 @@ extern int gcdmain(int argc, char *argv[]);
|
||||||
$2 = SCHEME_STRLEN_VAL($input);
|
$2 = SCHEME_STRLEN_VAL($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int count(char *bytes, int len, char c);
|
extern int charcount(char *bytes, int len, char c);
|
||||||
|
|
||||||
|
|
||||||
/* This example shows how to wrap a function that mutates a string */
|
/* This example shows how to wrap a function that mutates a string */
|
||||||
|
|
@ -68,7 +68,7 @@ extern int count(char *bytes, int len, char c);
|
||||||
|
|
||||||
%typemap(argout) (char *str, int len) {
|
%typemap(argout) (char *str, int len) {
|
||||||
Scheme_Object *s;
|
Scheme_Object *s;
|
||||||
s = scheme_make_sized_string($1,$2,1);
|
s = scheme_make_sized_string($1,$2);
|
||||||
SWIG_APPEND_VALUE(s);
|
SWIG_APPEND_VALUE(s);
|
||||||
free($1);
|
free($1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
(gcdmain #("gcdmain" "42" "105"))
|
(gcdmain #("gcdmain" "42" "105"))
|
||||||
|
|
||||||
|
|
||||||
(display (count "Hello World" #\l))
|
(display (charcount "Hello World" #\l))
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
(display (capitalize "hello world"))
|
(display (capitalize "hello world"))
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,6 @@ build:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Simple example from users manual.
|
|
||||||
|
|
@ -1,24 +1,18 @@
|
||||||
/* Simple example from documentation */
|
|
||||||
/* File : example.c */
|
/* File : example.c */
|
||||||
|
|
||||||
#include <time.h>
|
/* A global variable */
|
||||||
|
double Foo = 3.0;
|
||||||
|
|
||||||
double My_variable = 3.0;
|
/* Compute the greatest common divisor of positive integers */
|
||||||
|
int gcd(int x, int y) {
|
||||||
/* Compute factorial of n */
|
int g;
|
||||||
int fact(int n) {
|
g = y;
|
||||||
if (n <= 1) return 1;
|
while (x > 0) {
|
||||||
else return n*fact(n-1);
|
g = x;
|
||||||
}
|
x = y % x;
|
||||||
|
y = g;
|
||||||
/* Compute n mod m */
|
}
|
||||||
int my_mod(int n, int m) {
|
return g;
|
||||||
return (n % m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *get_time() {
|
|
||||||
long ltime;
|
|
||||||
time(<ime);
|
|
||||||
return ctime(<ime);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,7 @@
|
||||||
/* File : example.i */
|
/* File : example.i */
|
||||||
%module example
|
%module example
|
||||||
%{
|
|
||||||
/* Put headers and other declarations here */
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include typemaps.i
|
|
||||||
|
|
||||||
%rename(mod) my_mod;
|
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
extern double My_variable;
|
extern int gcd(int x, int y);
|
||||||
extern int fact(int);
|
extern double Foo;
|
||||||
extern int my_mod(int n, int m);
|
|
||||||
extern char *get_time();
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,30 @@
|
||||||
|
|
||||||
(load-extension "example.so")
|
(load-extension "example.so")
|
||||||
|
|
||||||
(display (get-time))
|
; Call our gcd() function
|
||||||
|
|
||||||
(printf "My-variable = ~a~n" (my-variable))
|
(define x 42)
|
||||||
|
(define y 105)
|
||||||
|
(define g (gcd x y))
|
||||||
|
(display "The gcd of ")
|
||||||
|
(display x)
|
||||||
|
(display " and ")
|
||||||
|
(display y)
|
||||||
|
(display " is ")
|
||||||
|
(display g)
|
||||||
|
(newline)
|
||||||
|
|
||||||
(let loop ((i 0))
|
; Manipulate the Foo global variable
|
||||||
(when (< i 14) (begin (display i)
|
|
||||||
(display " factorial is ")
|
|
||||||
(display (fact i))
|
|
||||||
(newline)
|
|
||||||
(loop (+ i 1)))))
|
|
||||||
|
|
||||||
(let loop ((i 1))
|
; Output its current value
|
||||||
(when (< i 250)
|
(display "Foo = ")
|
||||||
(begin
|
(display (Foo))
|
||||||
(let loopi ((j 1))
|
(newline)
|
||||||
(when (< j 250) (begin (my-variable (+ (my-variable) (mod i j)))
|
|
||||||
(loopi (+ j 1)))))
|
|
||||||
(loop (+ i 1)))))
|
|
||||||
|
|
||||||
(printf "My-variable = ~a~n" (my-variable))
|
; Change its value
|
||||||
|
(Foo 3.1415926)
|
||||||
|
|
||||||
|
; See if the change took effect
|
||||||
|
(display "Foo = ")
|
||||||
|
(display (Foo))
|
||||||
|
(newline)
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
TOP = ../..
|
TOP = ../..
|
||||||
SWIGEXE = $(TOP)/../swig
|
SWIGEXE = $(TOP)/../swig
|
||||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||||
SRCS =
|
CXXSRCS =
|
||||||
TARGET = example
|
TARGET = example
|
||||||
INTERFACE = example.i
|
INTERFACE = example.i
|
||||||
SWIGOPT =
|
SWIGOPT =
|
||||||
|
|
||||||
GPP = `which g++`
|
|
||||||
MZC = test -n "/usr/bin/mzc" && /usr/bin/mzc
|
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||||
$(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
|
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||||
$(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
|
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,17 @@
|
||||||
(if (< i size)
|
(if (< i size)
|
||||||
(begin
|
(begin
|
||||||
(proc v i)
|
(proc v i)
|
||||||
(with-vector-item v (+ i 1)))))
|
(with-vector-item v (+ i 1)))
|
||||||
|
(void)))
|
||||||
(with-vector-item v 0)))
|
(with-vector-item v 0)))
|
||||||
|
|
||||||
(define (with-intvector v proc)
|
(define (with-IntVector v proc)
|
||||||
(with-vector v proc intvector-length))
|
(with-vector v proc IntVector-length))
|
||||||
(define (with-doublevector v proc)
|
(define (with-DoubleVector v proc)
|
||||||
(with-vector v proc doublevector-length))
|
(with-vector v proc DoubleVector-length))
|
||||||
|
|
||||||
(define (print-doublevector v)
|
(define (print-DoubleVector v)
|
||||||
(with-doublevector v (lambda (v i) (display (doublevector-ref v i))
|
(with-DoubleVector v (lambda (v i) (display (DoubleVector-ref v i))
|
||||||
(display " ")))
|
(display " ")))
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
|
@ -29,11 +30,11 @@
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
; ... or a wrapped std::vector<int>
|
; ... or a wrapped std::vector<int>
|
||||||
(define v (new-intvector 4))
|
(define v (new-IntVector 4))
|
||||||
(with-intvector v (lambda (v i) (intvector-set! v i (+ i 1))))
|
(with-IntVector v (lambda (v i) (IntVector-set! v i (+ i 1))))
|
||||||
(display (average v))
|
(display (average v))
|
||||||
(newline)
|
(newline)
|
||||||
(delete-intvector v)
|
(delete-IntVector v)
|
||||||
|
|
||||||
; half will return a Scheme vector.
|
; half will return a Scheme vector.
|
||||||
; Call it with a Scheme vector...
|
; Call it with a Scheme vector...
|
||||||
|
|
@ -42,13 +43,12 @@
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
; ... or a wrapped std::vector<double>
|
; ... or a wrapped std::vector<double>
|
||||||
(define v (new-doublevector))
|
(define v (new-DoubleVector))
|
||||||
(map (lambda (i) (doublevector-push! v i)) '(1 2 3 4))
|
(map (lambda (i) (DoubleVector-push! v i)) '(1 2 3 4))
|
||||||
(display (half v))
|
(display (half v))
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
; now halve a wrapped std::vector<double> in place
|
; now halve a wrapped std::vector<double> in place
|
||||||
(halve-in-place v)
|
(halve-in-place v)
|
||||||
(print-doublevector v)
|
(print-DoubleVector v)
|
||||||
(delete-doublevector v)
|
(delete-DoubleVector v)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,67 @@ srcdir = @srcdir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
|
|
||||||
|
FAILING_CPP_TESTS = \
|
||||||
|
allowexcept \
|
||||||
|
apply_strings \
|
||||||
|
arrays_dimensionless \
|
||||||
|
arrays_global \
|
||||||
|
char_strings \
|
||||||
|
class_scope_weird \
|
||||||
|
constant_pointers \
|
||||||
|
cpp_basic \
|
||||||
|
cpp_enum \
|
||||||
|
curiously_recurring_template_pattern \
|
||||||
|
default_arg_expressions \
|
||||||
|
default_constructor \
|
||||||
|
derived_nested \
|
||||||
|
director_ignore \
|
||||||
|
enum_thorough \
|
||||||
|
extend \
|
||||||
|
friends \
|
||||||
|
global_scope_types \
|
||||||
|
inherit_member \
|
||||||
|
li_attribute \
|
||||||
|
li_attribute_template \
|
||||||
|
li_boost_shared_ptr \
|
||||||
|
li_std_combinations \
|
||||||
|
li_std_map \
|
||||||
|
li_std_pair \
|
||||||
|
li_std_pair_using \
|
||||||
|
li_std_string \
|
||||||
|
li_std_vector \
|
||||||
|
li_windows \
|
||||||
|
member_funcptr_galore \
|
||||||
|
member_pointer \
|
||||||
|
member_pointer_const \
|
||||||
|
memberin_extend \
|
||||||
|
namespace_spaces \
|
||||||
|
naturalvar \
|
||||||
|
naturalvar_more \
|
||||||
|
nested_class \
|
||||||
|
nested_template_base \
|
||||||
|
ordering \
|
||||||
|
preproc_constants \
|
||||||
|
samename \
|
||||||
|
template_default2 \
|
||||||
|
template_specialization_defarg \
|
||||||
|
template_typemaps \
|
||||||
|
typemap_variables \
|
||||||
|
valuewrapper_opaque \
|
||||||
|
|
||||||
|
FAILING_C_TESTS = \
|
||||||
|
enums \
|
||||||
|
integers \
|
||||||
|
preproc_constants_c \
|
||||||
|
preproc_line_file \
|
||||||
|
|
||||||
|
FAILING_MULTI_CPP_TESTS = \
|
||||||
|
multi_import \
|
||||||
|
|
||||||
include $(srcdir)/../common.mk
|
include $(srcdir)/../common.mk
|
||||||
|
|
||||||
# Overridden variables here
|
# Overridden variables here
|
||||||
# none!
|
SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
|
||||||
|
|
||||||
# Custom tests - tests with additional commandline options
|
# Custom tests - tests with additional commandline options
|
||||||
# none!
|
# none!
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||||
;; current module. That's enough for such a simple test.
|
;; current module. That's enough for such a simple test.
|
||||||
(load-extension "./name.so")
|
(load-extension "name.so")
|
||||||
|
|
||||||
(foo-2)
|
(foo-2)
|
||||||
bar-2
|
bar-2
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,15 @@
|
||||||
(if (not (= Jill1 200))
|
(if (not (= Jill1 200))
|
||||||
(begin
|
(begin
|
||||||
(display "Runtime test 1 failed.")
|
(display "Runtime test 1 failed.")
|
||||||
(exit 1))))
|
(exit 1))
|
||||||
|
(void)))
|
||||||
|
|
||||||
(let ((Num1 (EmbeddedUnionTest-number-get eut)))
|
(let ((Num1 (EmbeddedUnionTest-number-get eut)))
|
||||||
(if (not (= Num1 1))
|
(if (not (= Num1 1))
|
||||||
(begin
|
(begin
|
||||||
(display "Runtime test 2 failed.")
|
(display "Runtime test 2 failed.")
|
||||||
(exit 1))))
|
(exit 1))
|
||||||
|
(void)))
|
||||||
|
|
||||||
;; that should do
|
;; that should do
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,10 @@
|
||||||
|
|
||||||
static const char *usage = "\
|
static const char *usage = "\
|
||||||
Mzscheme Options (available with -mzscheme)\n\
|
Mzscheme Options (available with -mzscheme)\n\
|
||||||
-declaremodule - Create extension that declares a module\n\
|
-declaremodule - Create extension that declares a module\n\
|
||||||
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
|
-dynamic-load <lib>,[lib,...] - Do not link with these libraries, dynamic load them\n\
|
||||||
them\n\
|
-noinit - Do not emit module initialization code\n\
|
||||||
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
|
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||||
scheme_module_name functions\n\
|
|
||||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
|
||||||
";
|
";
|
||||||
|
|
||||||
static String *fieldnames_tab = 0;
|
static String *fieldnames_tab = 0;
|
||||||
|
|
@ -439,9 +437,8 @@ public:
|
||||||
sprintf(temp, "%d", numargs);
|
sprintf(temp, "%d", numargs);
|
||||||
if (exporting_destructor) {
|
if (exporting_destructor) {
|
||||||
Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
||||||
} else {
|
|
||||||
Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
|
|
||||||
}
|
}
|
||||||
|
Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
|
||||||
} else {
|
} else {
|
||||||
if (!Getattr(n, "sym:nextSibling")) {
|
if (!Getattr(n, "sym:nextSibling")) {
|
||||||
/* Emit overloading dispatch function */
|
/* Emit overloading dispatch function */
|
||||||
|
|
@ -528,7 +525,7 @@ public:
|
||||||
Replaceall(tm, "$source", "argv[0]");
|
Replaceall(tm, "$source", "argv[0]");
|
||||||
Replaceall(tm, "$target", name);
|
Replaceall(tm, "$target", name);
|
||||||
Replaceall(tm, "$input", "argv[0]");
|
Replaceall(tm, "$input", "argv[0]");
|
||||||
/* Printv(f->code, tm, "\n",NIL); */
|
Replaceall(tm, "$argnum", "1");
|
||||||
emit_action_code(n, f->code, tm);
|
emit_action_code(n, f->code, tm);
|
||||||
} else {
|
} else {
|
||||||
throw_unhandled_mzscheme_type_error(t);
|
throw_unhandled_mzscheme_type_error(t);
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ static TargetLanguageModule modules[] = {
|
||||||
{"-javascript", swig_javascript, "Javascript", Supported},
|
{"-javascript", swig_javascript, "Javascript", Supported},
|
||||||
{"-lua", swig_lua, "Lua", Supported},
|
{"-lua", swig_lua, "Lua", Supported},
|
||||||
{"-modula3", NULL, "Modula 3", Disabled},
|
{"-modula3", NULL, "Modula 3", Disabled},
|
||||||
{"-mzscheme", swig_mzscheme, "Mzscheme", Supported},
|
{"-mzscheme", swig_mzscheme, "MzScheme/Racket", Experimental},
|
||||||
{"-ocaml", swig_ocaml, "Ocaml", Supported},
|
{"-ocaml", swig_ocaml, "Ocaml", Supported},
|
||||||
{"-octave", swig_octave, "Octave", Supported},
|
{"-octave", swig_octave, "Octave", Supported},
|
||||||
{"-perl", swig_perl5, NULL, Supported},
|
{"-perl", swig_perl5, NULL, Supported},
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@ case "$SWIGLANG" in
|
||||||
travis_retry sudo apt-get -qq install lua${VER} liblua${VER}-dev
|
travis_retry sudo apt-get -qq install lua${VER} liblua${VER}-dev
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
"mzscheme")
|
||||||
|
travis_retry sudo apt-get -qq install racket
|
||||||
|
;;
|
||||||
"ocaml")
|
"ocaml")
|
||||||
# configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter.
|
# configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter.
|
||||||
travis_retry sudo apt-get -qq install ocaml ocaml-findlib
|
travis_retry sudo apt-get -qq install ocaml ocaml-findlib
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue