Merge remote-tracking branch 'origin/master' into HEAD
This commit is contained in:
commit
be0b975e6b
977 changed files with 15369 additions and 35050 deletions
|
|
@ -58,6 +58,7 @@ INTERFACE =
|
|||
INTERFACEDIR =
|
||||
INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE)
|
||||
SWIGOPT =
|
||||
PCHSUPPORT = @PCHSUPPORT@
|
||||
|
||||
# SWIG_LIB_DIR and SWIGEXE must be explicitly set by Makefiles using this Makefile
|
||||
SWIG_LIB_DIR = ./Lib
|
||||
|
|
@ -164,6 +165,7 @@ TCL_SO = @TCL_SO@
|
|||
TCLLDSHARED = @TCLLDSHARED@
|
||||
TCLCXXSHARED = @TCLCXXSHARED@
|
||||
TCL_SCRIPT = $(SRCDIR)$(RUNME).tcl
|
||||
TCL_LINK = @TCLLINK@
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Build a new version of the tclsh shell
|
||||
|
|
@ -186,7 +188,7 @@ tclsh_cpp: $(SRCDIR_SRCS)
|
|||
tcl: $(SRCDIR_SRCS)
|
||||
$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ISRCS) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
|
||||
$(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
|
||||
$(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) $(TCL_LINK)
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Build a Tcl7.5 dynamic loadable module for C++
|
||||
|
|
@ -195,7 +197,7 @@ tcl: $(SRCDIR_SRCS)
|
|||
tcl_cpp: $(SRCDIR_SRCS)
|
||||
$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
|
||||
$(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
|
||||
$(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) $(TCL_LINK)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Run Tcl example
|
||||
|
|
@ -380,13 +382,7 @@ python_static_cpp: $(SRCDIR_SRCS)
|
|||
# Running a Python example
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PYSCRIPT = $(RUNME).py
|
||||
else
|
||||
PYSCRIPT = $(RUNME)3.py
|
||||
endif
|
||||
|
||||
PY2TO3 = @PY2TO3@ `@PY2TO3@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
||||
PYSCRIPT = $(RUNME).py
|
||||
|
||||
python_run: $(PYSCRIPT)
|
||||
ifneq (,$(PYCODESTYLE))
|
||||
|
|
@ -399,10 +395,6 @@ $(RUNME).py: $(SRCDIR)$(RUNME).py
|
|||
cp $< $@
|
||||
endif
|
||||
|
||||
$(RUNME)3.py: $(SRCDIR)$(RUNME).py
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
# -----------------------------------------------------------------
|
||||
|
|
@ -420,7 +412,6 @@ python_clean:
|
|||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO)
|
||||
rm -f $(TARGET).py
|
||||
if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
|
||||
case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac
|
||||
|
||||
|
||||
|
|
@ -438,14 +429,37 @@ OCTAVE_SO = @OCTAVE_SO@
|
|||
|
||||
OCTAVE_SCRIPT = $(SRCDIR)$(RUNME).m
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Pre-compile Octave headers, if supported
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
ifeq (yes,$(PCHSUPPORT))
|
||||
|
||||
octave_precompile_headers:
|
||||
echo "precompiling $(OCTHEADERS)"
|
||||
cp -f $(OCTHEADERSSRC) $(OCTHEADERS)
|
||||
if $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(OCTAVE_CXX) $(OCTHEADERS); then \
|
||||
: ; \
|
||||
else \
|
||||
rm -f $(OCTHEADERSGCH); \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
octave_precompile_headers:
|
||||
echo "precompiling Octave headers not supported"; exit 1
|
||||
|
||||
endif
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Build a C dynamically loadable module
|
||||
# Note: Octave requires C++ compiler when compiling C wrappers
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
octave: $(SRCDIR_SRCS)
|
||||
$(SWIG) -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
|
||||
$(SWIG) -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
|
||||
$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) $(INCLUDES)
|
||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
|
||||
|
||||
|
|
@ -454,8 +468,8 @@ octave: $(SRCDIR_SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
octave_cpp: $(SRCDIR_SRCS)
|
||||
$(SWIG) -c++ -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
|
||||
$(SWIG) -c++ -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
|
||||
$(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
|
@ -481,6 +495,7 @@ octave_clean:
|
|||
rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO)
|
||||
rm -f $(OCTHEADERS) $(OCTHEADERSGCH)
|
||||
|
||||
##################################################################
|
||||
##### GUILE ######
|
||||
|
|
@ -1031,20 +1046,21 @@ ruby_clean:
|
|||
rm -f *.@OBJEXT@ *$(RUBY_SO)
|
||||
|
||||
##################################################################
|
||||
##### PHP7 ######
|
||||
##### PHP ######
|
||||
##################################################################
|
||||
|
||||
PHP = @PHP@
|
||||
PHP_INCLUDE = @PHPINC@
|
||||
PHP_SO = @PHP_SO@
|
||||
PHP_SCRIPT = $(SRCDIR)$(RUNME).php
|
||||
PHP_EXTENSION = example$(PHP_SO)
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Build a PHP dynamically loadable module (C)
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
php: $(SRCDIR_SRCS)
|
||||
$(SWIG) -php7 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
$(SWIG) -php $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
|
||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
|
||||
|
||||
|
|
@ -1053,7 +1069,7 @@ php: $(SRCDIR_SRCS)
|
|||
# --------------------------------------------------------------------
|
||||
|
||||
php_cpp: $(SRCDIR_SRCS)
|
||||
$(SWIG) -php7 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(SWIG) -php -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
|
||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
|
||||
|
||||
|
|
@ -1062,7 +1078,7 @@ php_cpp: $(SRCDIR_SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
php_run:
|
||||
$(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off -d display_errors=stderr $(PHP_SCRIPT) $(RUNPIPE)
|
||||
$(RUNTOOL) $(PHP) -n -d extension_dir=. -d extension=$(PHP_EXTENSION) -d display_errors=stderr -r 'set_error_handler(function($$n,$$s,$$f,$$l){if($$f!==Null){print$$f;if($$l!==Null)print":$$l";print": ";}print"$$s\n";exit(1);});include($$argv[1]);' $(PHP_SCRIPT) $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
|
|
@ -1234,46 +1250,6 @@ lua_clean:
|
|||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *$(LUA_SO)
|
||||
|
||||
##################################################################
|
||||
##### ALLEGRO CL ######
|
||||
##################################################################
|
||||
|
||||
ALLEGROCL = @ALLEGROCLBIN@
|
||||
ALLEGROCL_SCRIPT=$(RUNME).lisp
|
||||
|
||||
allegrocl: $(SRCDIR_SRCS)
|
||||
$(SWIG) -allegrocl -cwrap $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS)
|
||||
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
allegrocl_cpp: $(SRCDIR_SRCS)
|
||||
$(SWIG) -c++ -allegrocl $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
|
||||
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
|
||||
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Run ALLEGRO CL example
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
allegrocl_run:
|
||||
$(RUNTOOL) $(ALLEGROCL) -batch -s $(ALLEGROCL_SCRIPT) $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
allegrocl_version:
|
||||
$(ALLEGROCL) --version
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the ALLEGRO CL examples
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
allegrocl_clean:
|
||||
rm -f *_wrap* *~ .~*
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
|
||||
##################################################################
|
||||
##### CFFI ######
|
||||
##################################################################
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
This directory contains examples for CHICKEN.
|
||||
|
||||
class -- illustrates the proxy class C++ interface
|
||||
constants -- handling #define and %constant literals
|
||||
egg -- examples of building chicken extension libraries
|
||||
multimap -- typemaps with multiple sub-types
|
||||
overload -- C++ function overloading
|
||||
simple -- the simple example from the user manual
|
||||
zlib -- a wrapping of the zlib compression library
|
||||
|
||||
You should be able to run make in each of the examples. By default, a shared
|
||||
library will be built. Run make check to execute the test.
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
# see top-level Makefile.in
|
||||
class
|
||||
constants
|
||||
multimap
|
||||
overload
|
||||
simple
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = class
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines)
|
||||
#CHICKEN_MAIN = runme-lowlevel.scm
|
||||
#CHICKEN_MAIN = runme-tinyclos.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run
|
||||
|
||||
build: $(TARGET) $(TARGET)_proxy
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
$(TARGET)_proxy: $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
|
||||
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/* 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;
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/* 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;
|
||||
|
||||
enum SomeEnum {
|
||||
First = 0,
|
||||
Second,
|
||||
Third,
|
||||
Last = 1000
|
||||
};
|
||||
};
|
||||
|
||||
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();
|
||||
};
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
;; This file illustrates the low-level C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(load-library 'example "class.so")
|
||||
(declare (uses example))
|
||||
|
||||
;; ----- Object creation -----
|
||||
|
||||
(display "Creating some objects:\n")
|
||||
(define c (new-Circle 10.0))
|
||||
(display " Created circle ")
|
||||
(display c)
|
||||
(display "\n")
|
||||
(define s (new-Square 10.0))
|
||||
(display " Created square ")
|
||||
(display s)
|
||||
(display "\n")
|
||||
|
||||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes were created\n")
|
||||
|
||||
;; ----- Member data access -----
|
||||
|
||||
;; Set the location of the object
|
||||
|
||||
(Shape-x-set c 20.0)
|
||||
(Shape-y-set c 30.0)
|
||||
|
||||
(Shape-x-set s -10.0)
|
||||
(Shape-y-set s 5.0)
|
||||
|
||||
(display "\nHere is their current position:\n")
|
||||
(display " Circle = (")
|
||||
(display (Shape-x-get c))
|
||||
(display ", ")
|
||||
(display (Shape-y-get c))
|
||||
(display ")\n")
|
||||
(display " Square = (")
|
||||
(display (Shape-x-get s))
|
||||
(display ", ")
|
||||
(display (Shape-y-get s))
|
||||
(display ")\n")
|
||||
|
||||
;; ----- Call some methods -----
|
||||
|
||||
(display "\nHere are some properties of the shapes:\n")
|
||||
(let
|
||||
((disp (lambda (o)
|
||||
(display " ")
|
||||
(display o)
|
||||
(display "\n")
|
||||
(display " area = ")
|
||||
(display (Shape-area o))
|
||||
(display "\n")
|
||||
(display " perimeter = ")
|
||||
(display (Shape-perimeter o))
|
||||
(display "\n"))))
|
||||
(disp c)
|
||||
(disp s))
|
||||
|
||||
(display "\nGuess I'll clean up now\n")
|
||||
|
||||
;; Note: this invokes the virtual destructor
|
||||
(set! c #f)
|
||||
(set! s #f)
|
||||
(gc #t)
|
||||
|
||||
(set! s 3)
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
(exit)
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
;; This file illustrates the proxy C++ interface generated
|
||||
;; by SWIG.
|
||||
|
||||
(load-library 'example "class_proxy.so")
|
||||
(declare (uses example))
|
||||
(declare (uses tinyclos))
|
||||
|
||||
;; ----- Object creation -----
|
||||
|
||||
(display "Creating some objects:\n")
|
||||
(define c (make <Circle> 10.0))
|
||||
(display " Created circle ")
|
||||
(display c)
|
||||
(display "\n")
|
||||
(define s (make <Square> 10.0))
|
||||
(display " Created square ")
|
||||
(display s)
|
||||
(display "\n")
|
||||
|
||||
;; ----- Access a static member -----
|
||||
|
||||
(display "\nA total of ")
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes were created\n")
|
||||
|
||||
;; ----- Member data access -----
|
||||
|
||||
;; Set the location of the object
|
||||
|
||||
(slot-set! c 'x 20.0)
|
||||
(slot-set! c 'y 30.0)
|
||||
|
||||
(slot-set! s 'x -10.0)
|
||||
(slot-set! s 'y 5.0)
|
||||
|
||||
(display "\nHere is their current position:\n")
|
||||
(display " Circle = (")
|
||||
(display (slot-ref c 'x))
|
||||
(display ", ")
|
||||
(display (slot-ref c 'y))
|
||||
(display ")\n")
|
||||
(display " Square = (")
|
||||
(display (slot-ref s 'x))
|
||||
(display ", ")
|
||||
(display (slot-ref s 'y))
|
||||
(display ")\n")
|
||||
|
||||
;; ----- Call some methods -----
|
||||
|
||||
(display "\nHere are some properties of the shapes:\n")
|
||||
(let
|
||||
((disp (lambda (o)
|
||||
(display " ")
|
||||
(display o)
|
||||
(display "\n")
|
||||
(display " area = ")
|
||||
(display (area o))
|
||||
(display "\n")
|
||||
(display " perimeter = ")
|
||||
(display (perimeter o))
|
||||
(display "\n"))))
|
||||
(disp c)
|
||||
(disp s))
|
||||
|
||||
(display "\nGuess I'll clean up now\n")
|
||||
|
||||
;; Note: Invoke the virtual destructors by forcing garbage collection
|
||||
(set! c 77)
|
||||
(set! s 88)
|
||||
(gc #t)
|
||||
|
||||
(display (Shape-nshapes))
|
||||
(display " shapes remain\n")
|
||||
(display "Goodbye\n")
|
||||
|
||||
(exit)
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS =
|
||||
TARGET = constants
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
/* A few preprocessor macros */
|
||||
|
||||
#define ICONST 42
|
||||
#define FCONST 2.1828
|
||||
#define CCONST 'x'
|
||||
#define CCONST2 '\n'
|
||||
#define SCONST "Hello World"
|
||||
#define SCONST2 "\"Hello World\""
|
||||
|
||||
/* This should work just fine */
|
||||
#define EXPR ICONST + 3*(FCONST)
|
||||
|
||||
/* This shouldn't do anything */
|
||||
#define EXTERN extern
|
||||
|
||||
/* Neither should this (BAR isn't defined) */
|
||||
#define FOO (ICONST + BAR)
|
||||
|
||||
/* The following directives also produce constants. Remember that
|
||||
CHICKEN is normally case-insensitive, so don't rely on differing
|
||||
case to differentiate variable names */
|
||||
|
||||
%constant int iconstX = 37;
|
||||
%constant double fconstX = 3.14;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
|
||||
(load-library 'example "./constants.so")
|
||||
|
||||
(display "starting test ... you will see 'finished' if successful.\n")
|
||||
(or (= (ICONST) 42) (exit 1))
|
||||
(or (< (abs (- (FCONST) 2.1828)) 0.00001) (exit 1))
|
||||
(or (char=? (CCONST) #\x) (exit 1))
|
||||
(or (char=? (CCONST2) #\newline) (exit 1))
|
||||
(or (string=? (SCONST) "Hello World") (exit 1))
|
||||
(or (string=? (SCONST2) "\"Hello World\"") (exit 1))
|
||||
(or (< (abs (- (EXPR) (+ (ICONST) (* 3 (FCONST))))) 0.00001) (exit 1))
|
||||
(or (= (iconstX) 37) (exit 1))
|
||||
(or (< (abs (- (fconstX) 3.14)) 0.00001) (exit 1))
|
||||
(display "finished test.\n")
|
||||
(exit 0)
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
|
||||
check: build
|
||||
cd eggs/install && csi ../../test.scm
|
||||
|
||||
build: single multi
|
||||
|
||||
# This creates an egg which contains only the single module. Any additional implementation files
|
||||
# that implement the interface being wrapped should also be added to this egg
|
||||
single: single_wrap.cxx
|
||||
mkdir -p eggs
|
||||
tar czf eggs/single.egg single.setup single.scm single_wrap.cxx
|
||||
rm -f single.scm single_wrap.cxx
|
||||
|
||||
# compile the single module with -nounit
|
||||
single_wrap.cxx: single.i
|
||||
$(SWIGEXE) -chicken -c++ -proxy -nounit single.i
|
||||
|
||||
# Now build both mod1 and mod2 into a single egg
|
||||
multi: mod1_wrap.cxx mod2_wrap.cxx
|
||||
mkdir -p eggs
|
||||
tar czf eggs/multi.egg multi.setup multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
|
||||
rm -f mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx
|
||||
|
||||
mod1_wrap.cxx: mod1.i
|
||||
$(SWIGEXE) -chicken -c++ -proxy mod1.i
|
||||
|
||||
mod2_wrap.cxx: mod2.i
|
||||
$(SWIGEXE) -chicken -c++ -proxy mod2.i
|
||||
|
||||
clean:
|
||||
rm -rf eggs
|
||||
|
||||
# this part is for testing...
|
||||
setup:
|
||||
cd eggs && \
|
||||
mkdir -p install && \
|
||||
chicken-setup -repository `pwd`/install single.egg && \
|
||||
chicken-setup -repository `pwd`/install multi.egg
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
These examples show how to build a chicken extension module in the form of an
|
||||
egg. There are two eggs that get built, single.egg which contains a single
|
||||
module which is built with -nounit and multi.egg, which contains two modules
|
||||
mod1 and mod2. These are built normally, and multi_init.scm loads them both.
|
||||
Read section "17.4.2 Building chicken extension libraries" in the manual
|
||||
for a description of these two techniques.
|
||||
|
||||
To build:
|
||||
|
||||
$ make
|
||||
$ make setup
|
||||
$ make run
|
||||
|
||||
$ make clean
|
||||
|
||||
The eggs are built into an eggs subdirectory, because chicken-setup has
|
||||
problems installing eggs when there are other files named similar in
|
||||
the same directory. The make setup step runs chicken-setup to install
|
||||
the eggs into the eggs/install directory.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
%module mod1
|
||||
|
||||
%inline %{
|
||||
class Bar {
|
||||
public:
|
||||
int b;
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
%module mod2
|
||||
|
||||
%import "mod1.i"
|
||||
|
||||
%{
|
||||
class Bar {
|
||||
public:
|
||||
int b;
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
class Bar2 : public Bar {
|
||||
public:
|
||||
int c;
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(run (csc -s -o multi.so multi_init.scm mod1.scm mod1_wrap.cxx mod2.scm mod2_wrap.cxx))
|
||||
(install-extension 'multi '("multi.so"))
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(declare (uses mod1))
|
||||
(declare (uses mod2))
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
%module single
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
int a;
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(run (csc -s -o single.so single.scm single_wrap.cxx))
|
||||
(install-extension 'single '("single.so"))
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
(require-extension single)
|
||||
(require-extension multi)
|
||||
|
||||
(define f (make <Foo>))
|
||||
(slot-set! f 'a 3)
|
||||
(print (slot-ref f 'a))
|
||||
|
||||
(define b (make <Bar>))
|
||||
(slot-set! b 'b 2)
|
||||
(print (slot-ref b 'b))
|
||||
|
||||
(define b2 (make <Bar2>))
|
||||
(slot-set! b2 'b 4)
|
||||
(slot-set! b2 'c 6)
|
||||
(print (slot-ref b2 'b))
|
||||
(print (slot-ref b2 'c))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
INTERFACE = example.i
|
||||
SRCS = example.c
|
||||
CXXSRCS =
|
||||
TARGET = multimap
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/* File : example.c */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* Compute the greatest common divisor of positive integers */
|
||||
int gcd(int x, int y) {
|
||||
int g;
|
||||
g = y;
|
||||
while (x > 0) {
|
||||
g = x;
|
||||
x = y % x;
|
||||
y = g;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
int gcdmain(int argc, char *argv[]) {
|
||||
int x,y;
|
||||
if (argc != 3) {
|
||||
printf("usage: gcd x y\n");
|
||||
return -1;
|
||||
}
|
||||
x = atoi(argv[1]);
|
||||
y = atoi(argv[2]);
|
||||
printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count(char *bytes, int len, char c) {
|
||||
int i;
|
||||
int count = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (bytes[i] == c) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void capitalize(char *str, int len) {
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
str[i] = (char)toupper(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void circle(double x, double y) {
|
||||
double a = x*x + y*y;
|
||||
if (a > 1.0) {
|
||||
printf("Bad points %g, %g\n", x,y);
|
||||
} else {
|
||||
printf("Good points %g, %g\n", x,y);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
extern int gcd(int x, int y);
|
||||
extern int gcdmain(int argc, char *argv[]);
|
||||
extern int count(char *bytes, int len, char c);
|
||||
extern void capitalize (char *str, int len);
|
||||
extern void circle (double cx, double cy);
|
||||
extern int squareCubed (int n, int *OUTPUT);
|
||||
%}
|
||||
|
||||
%include exception.i
|
||||
%include typemaps.i
|
||||
|
||||
extern int gcd(int x, int y);
|
||||
|
||||
%typemap(in) (int argc, char *argv[]) {
|
||||
int i;
|
||||
if (!C_swig_is_vector ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a vector");
|
||||
}
|
||||
$1 = C_header_size ($input);
|
||||
$2 = (char **) malloc(($1+1)*sizeof(char *));
|
||||
for (i = 0; i < $1; i++) {
|
||||
C_word o = C_block_item ($input, i);
|
||||
if (!C_swig_is_string (o)) {
|
||||
char err[50];
|
||||
free($2);
|
||||
sprintf (err, "$input[%d] is not a string", i);
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, err);
|
||||
}
|
||||
$2[i] = C_c_string (o);
|
||||
}
|
||||
$2[i] = 0;
|
||||
}
|
||||
|
||||
%typemap(freearg) (int argc, char *argv[]) {
|
||||
free($2);
|
||||
}
|
||||
extern int gcdmain(int argc, char *argv[]);
|
||||
|
||||
%typemap(in) (char *bytes, int len) {
|
||||
if (!C_swig_is_string ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
|
||||
}
|
||||
$1 = C_c_string ($input);
|
||||
$2 = C_header_size ($input);
|
||||
}
|
||||
|
||||
extern int count(char *bytes, int len, char c);
|
||||
|
||||
|
||||
/* This example shows how to wrap a function that mutates a string */
|
||||
|
||||
%typemap(in) (char *str, int len)
|
||||
%{ if (!C_swig_is_string ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
|
||||
}
|
||||
$2 = C_header_size ($input);
|
||||
$1 = (char *) malloc ($2+1);
|
||||
memmove ($1, C_c_string ($input), $2);
|
||||
%}
|
||||
|
||||
/* Return the mutated string as a new object. Notice the if MANY construct ... they must be at column 0. */
|
||||
|
||||
%typemap(argout) (char *str, int len) (C_word *scmstr)
|
||||
%{ scmstr = C_alloc (C_SIZEOF_STRING ($2));
|
||||
SWIG_APPEND_VALUE(C_string (&scmstr, $2, $1));
|
||||
free ($1);
|
||||
%}
|
||||
|
||||
extern void capitalize (char *str, int len);
|
||||
|
||||
/* A multi-valued constraint. Force two arguments to lie
|
||||
inside the unit circle */
|
||||
|
||||
%typemap(check) (double cx, double cy) {
|
||||
double a = $1*$1 + $2*$2;
|
||||
if (a > 1.0) {
|
||||
SWIG_exception (SWIG_ValueError, "cx and cy must be in unit circle");
|
||||
}
|
||||
}
|
||||
|
||||
extern void circle (double cx, double cy);
|
||||
|
||||
/* Test out multiple return values */
|
||||
|
||||
extern int squareCubed (int n, int *OUTPUT);
|
||||
%{
|
||||
/* Returns n^3 and set n2 to n^2 */
|
||||
int squareCubed (int n, int *n2) {
|
||||
*n2 = n * n;
|
||||
return (*n2) * n;
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
|
||||
(load-library 'example "multimap.so")
|
||||
|
||||
(display "(gcd 90 12): ")
|
||||
(display (gcd 90 12))
|
||||
(display "\n")
|
||||
|
||||
(display "(circle 0.5 0.5): ")
|
||||
(display (circle 0.5 0.5))
|
||||
(display "\n")
|
||||
|
||||
(display "(circle 1.0 1.0): ")
|
||||
(handle-exceptions exvar
|
||||
(if (= (car exvar) 9)
|
||||
(display "success: exception thrown")
|
||||
(display "an incorrect exception was thrown"))
|
||||
(begin
|
||||
(circle 1.0 1.0)
|
||||
(display "an exception was not thrown when it should have been")))
|
||||
(display "\n")
|
||||
|
||||
(display "(circle 1 1): ")
|
||||
(handle-exceptions exvar
|
||||
(if (= (car exvar) 9)
|
||||
(display "success: exception thrown")
|
||||
(display "an incorrect exception was thrown"))
|
||||
(begin
|
||||
(circle 1 1)
|
||||
(display "an exception was not thrown when it should have been")))
|
||||
(display "\n")
|
||||
|
||||
(display "(capitalize \"will this be all capital letters?\"): ")
|
||||
(display (capitalize "will this be all capital letters?"))
|
||||
(display "\n")
|
||||
|
||||
(display "(count \"jumpity little spider\" #\\t): ")
|
||||
(display (count "jumpity little spider" #\t))
|
||||
(display "\n")
|
||||
|
||||
(display "(gcdmain '#(\"hi\" \"there\")): ")
|
||||
(display (gcdmain '#("hi" "there")))
|
||||
(display "\n")
|
||||
|
||||
(display "(gcdmain '#(\"gcd\" \"9\" \"28\")): ")
|
||||
(gcdmain '#("gcd" "9" "28"))
|
||||
(display "\n")
|
||||
|
||||
(display "(gcdmain '#(\"gcd\" \"12\" \"90\")): ")
|
||||
(gcdmain '#("gcd" "12" "90"))
|
||||
(display "\n")
|
||||
|
||||
(display "squarecubed 3: ")
|
||||
(call-with-values (lambda() (squareCubed 3))
|
||||
(lambda (a b) (printf "~A ~A" a b)))
|
||||
(display "\n")
|
||||
|
||||
(exit)
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = overload
|
||||
INCLUDE =
|
||||
SWIGOPT = -proxy -unhideprimitive
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following lines to build a static exe
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Overloading example from Chapter 5.14 of SWIG Core Documentation for
|
||||
version 1.3.
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/* File : example.c */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void foo(int x) {
|
||||
printf("x is %d\n", x);
|
||||
}
|
||||
|
||||
void foo(char *x) {
|
||||
printf("x is '%s'\n", x);
|
||||
}
|
||||
|
||||
Foo::Foo () {
|
||||
myvar = 55;
|
||||
printf ("Foo constructor called\n");
|
||||
}
|
||||
|
||||
Foo::Foo (const Foo &) {
|
||||
myvar = 66;
|
||||
printf ("Foo copy constructor called\n");
|
||||
}
|
||||
|
||||
void Foo::bar (int x) {
|
||||
printf ("Foo::bar(x) method ... \n");
|
||||
printf("x is %d\n", x);
|
||||
}
|
||||
|
||||
void Foo::bar (char *s, int y) {
|
||||
printf ("Foo::bar(s,y) method ... \n");
|
||||
printf ("s is '%s'\n", s);
|
||||
printf ("y is %d\n", y);
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
extern void foo (int x);
|
||||
extern void foo (char *x);
|
||||
|
||||
class Foo {
|
||||
private:
|
||||
int myvar;
|
||||
public:
|
||||
Foo();
|
||||
Foo(const Foo &); // Copy constructor
|
||||
void bar(int x);
|
||||
void bar(char *s, int y);
|
||||
};
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/* Let "Foo" objects be converted back and forth from TinyCLOS into
|
||||
low-level CHICKEN SWIG procedures */
|
||||
|
||||
%typemap(clos_in) Foo * = SIMPLE_CLOS_OBJECT *;
|
||||
%typemap(clos_out) Foo * = SIMPLE_CLOS_OBJECT *;
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
;; This file demonstrates the overloading capabilities of SWIG
|
||||
|
||||
(load-library 'example "overload.so")
|
||||
|
||||
;; Low level
|
||||
;; ---------
|
||||
|
||||
(display "
|
||||
Trying low level code ...
|
||||
(foo 1)
|
||||
(foo \"some string\")
|
||||
(define A-FOO (new-Foo))
|
||||
(define ANOTHER-FOO (new-Foo A-FOO)) ;; copy constructor
|
||||
(Foo-bar A-FOO 2)
|
||||
(Foo-bar ANOTHER-FOO \"another string\" 3)
|
||||
")
|
||||
|
||||
(primitive:foo 1)
|
||||
(primitive:foo "some string")
|
||||
(define A-FOO (slot-ref (primitive:new-Foo) 'swig-this))
|
||||
(define ANOTHER-FOO (slot-ref (primitive:new-Foo A-FOO) 'swig-this)) ;; copy constructor
|
||||
(primitive:Foo-bar A-FOO 2)
|
||||
(primitive:Foo-bar ANOTHER-FOO "another string" 3)
|
||||
|
||||
;; TinyCLOS
|
||||
;; --------
|
||||
|
||||
(display "
|
||||
Trying TinyCLOS code ...
|
||||
(+foo+ 1)
|
||||
(+foo+ \"some string\")
|
||||
(define A-FOO (make <Foo>))
|
||||
(define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
|
||||
(-bar- A-FOO 2)
|
||||
(-bar- ANOTHER-FOO \"another string\" 3)
|
||||
")
|
||||
|
||||
(foo 1)
|
||||
(foo "some string")
|
||||
(define A-FOO (make <Foo>))
|
||||
(define ANOTHER-FOO (make <Foo> A-FOO)) ;; copy constructor
|
||||
(bar A-FOO 2)
|
||||
(bar ANOTHER-FOO "another string" 3)
|
||||
|
||||
(exit)
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
INTERFACE = example.i
|
||||
SRCS = example.c
|
||||
CXXSRCS =
|
||||
TARGET = simple
|
||||
INCLUDE =
|
||||
SWIGOPT =
|
||||
VARIANT =
|
||||
|
||||
# uncomment the following two lines to build a static exe
|
||||
#CHICKEN_MAIN = runme.scm
|
||||
#VARIANT = _static
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
|
||||
|
||||
build: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
|
||||
INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||
rm -f example.scm example-generic.scm example-clos.scm
|
||||
rm -f $(TARGET)
|
||||
|
|
@ -1 +0,0 @@
|
|||
Simple example from users manual.
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/* Simple example from documentation */
|
||||
/* File : example.c */
|
||||
|
||||
#include <time.h>
|
||||
|
||||
double My_variable = 3.0;
|
||||
|
||||
/* Compute factorial of n */
|
||||
int fact(int n) {
|
||||
if (n <= 1) return 1;
|
||||
else return n*fact(n-1);
|
||||
}
|
||||
|
||||
/* Compute n mod m */
|
||||
int my_mod(int n, int m) {
|
||||
return (n % m);
|
||||
}
|
||||
|
||||
|
||||
char *get_time() {
|
||||
long ltime;
|
||||
time(<ime);
|
||||
return ctime(<ime);
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
%{
|
||||
/* Put headers and other declarations here */
|
||||
%}
|
||||
|
||||
%include typemaps.i
|
||||
|
||||
%rename(mod) my_mod;
|
||||
|
||||
%inline %{
|
||||
extern double My_variable;
|
||||
extern int fact(int);
|
||||
extern int my_mod(int n, int m);
|
||||
extern char *get_time();
|
||||
%}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
;; feel free to uncomment and comment sections
|
||||
(load-library 'example "simple.so")
|
||||
|
||||
(display "(My-variable): ")
|
||||
(display (My-variable))
|
||||
(display "\n")
|
||||
|
||||
(display "(My-variable 3.141259): ")
|
||||
(display (My-variable 3.141259))
|
||||
(display "\n")
|
||||
|
||||
(display "(My-variable): ")
|
||||
(display (My-variable))
|
||||
(display "\n")
|
||||
|
||||
(display "(fact 5): ")
|
||||
(display (fact 5))
|
||||
(display "\n")
|
||||
|
||||
(display "(mod 75 7): ")
|
||||
(display (mod 75 7))
|
||||
(display "\n")
|
||||
|
||||
(display "(get-time): ")
|
||||
(display (get-time))
|
||||
(display "\n")
|
||||
|
||||
(exit)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int Circle (int x, int y, int radius) {
|
||||
/* Draw Circle */
|
||||
printf("Drawing the circle...\n");
|
||||
/* Return -1 to test contract post assertion */
|
||||
if (radius == 2)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/* File : example.i */
|
||||
|
||||
/* Basic C example for swig contract */
|
||||
/* Tiger, University of Chicago, 2003 */
|
||||
|
||||
%module example
|
||||
|
||||
%contract Circle (int x, int y, int radius) {
|
||||
require:
|
||||
x >= 0;
|
||||
y >= 0;
|
||||
radius > x;
|
||||
ensure:
|
||||
Circle >= 0;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
extern int Circle (int x, int y, int radius);
|
||||
%}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import example
|
||||
# Call the Circle() function correctly
|
||||
|
||||
x = 1;
|
||||
y = 1;
|
||||
r = 3;
|
||||
|
||||
c = example.Circle(x, y, r)
|
||||
|
||||
# test post-assertion
|
||||
x = 1;
|
||||
y = 1;
|
||||
r = 2;
|
||||
|
||||
c = example.Circle(x, y, r)
|
||||
|
||||
print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import example
|
||||
|
||||
# Call the Circle() function correctly
|
||||
|
||||
x = 1;
|
||||
y = 1;
|
||||
r = 3;
|
||||
|
||||
c = example.Circle(x, y, r)
|
||||
|
||||
print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
|
||||
|
||||
# test pre-assertion
|
||||
x = 1;
|
||||
y = -1;
|
||||
r = 3;
|
||||
|
||||
c = example.Circle(x, y, r)
|
||||
|
||||
print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c)
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#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(void) {
|
||||
/* return -1 is to test post-assertion */
|
||||
if (radius == 1)
|
||||
return -1;
|
||||
return M_PI*radius*radius;
|
||||
}
|
||||
|
||||
double Circle::perimeter(void) {
|
||||
return 2*M_PI*radius;
|
||||
}
|
||||
|
||||
double Square::area(void) {
|
||||
return width*width;
|
||||
}
|
||||
|
||||
double Square::perimeter(void) {
|
||||
return 4*width;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
class Shape {
|
||||
public:
|
||||
Shape() {
|
||||
nshapes++;
|
||||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
}
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
virtual double perimeter(void) = 0;
|
||||
static int nshapes;
|
||||
};
|
||||
|
||||
class Circle : public Shape {
|
||||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
||||
class Square : public Shape {
|
||||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
%module example
|
||||
|
||||
%contract Circle::Circle(double radius) {
|
||||
require:
|
||||
radius > 0;
|
||||
}
|
||||
|
||||
%contract Circle::area(void) {
|
||||
ensure:
|
||||
area > 0;
|
||||
}
|
||||
|
||||
%contract Shape::move(double dx, double dy) {
|
||||
require:
|
||||
dx > 0;
|
||||
}
|
||||
|
||||
/* should be no effect, since there is no move() for class Circle */
|
||||
%contract Circle::move(double dx, double dy) {
|
||||
require:
|
||||
dy > 1;
|
||||
}
|
||||
|
||||
# include must be after contracts
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
%include "example.h"
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import example
|
||||
|
||||
# Create the Circle object
|
||||
|
||||
r = 2;
|
||||
print " Creating circle (radium: %d) :" % r
|
||||
c = example.Circle(r)
|
||||
|
||||
# Set the location of the object
|
||||
|
||||
c.x = 20
|
||||
c.y = 30
|
||||
print " Here is its current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\n Here are some properties of the Circle:"
|
||||
print " area = ", c.area()
|
||||
print " perimeter = ", c.perimeter()
|
||||
dx = 1;
|
||||
dy = 1;
|
||||
print " Moving with (%d, %d)..." % (dx, dy)
|
||||
c.move(dx, dy)
|
||||
|
||||
del c
|
||||
|
||||
print "==================================="
|
||||
|
||||
# test construction */
|
||||
r = -1;
|
||||
print " Creating circle (radium: %d) :" % r
|
||||
c = example.Circle(r)
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
import example
|
||||
|
||||
# Create the Circle object
|
||||
|
||||
r = 2;
|
||||
print " Creating circle (radium: %d) :" % r
|
||||
c = example.Circle(r)
|
||||
|
||||
# Set the location of the object
|
||||
|
||||
c.x = 20
|
||||
c.y = 30
|
||||
print " Here is its current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\n Here are some properties of the Circle:"
|
||||
print " area = ", c.area()
|
||||
print " perimeter = ", c.perimeter()
|
||||
dx = 1;
|
||||
dy = 1;
|
||||
print " Moving with (%d, %d)..." % (dx, dy)
|
||||
c.move(dx, dy)
|
||||
|
||||
del c
|
||||
|
||||
print "==================================="
|
||||
|
||||
# test area function */
|
||||
r = 1;
|
||||
print " Creating circle (radium: %d) :" % r
|
||||
c = example.Circle(r)
|
||||
# Set the location of the object
|
||||
|
||||
c.x = 20
|
||||
c.y = 30
|
||||
print " Here is its current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\n Here are some properties of the Circle:"
|
||||
print " area = ", c.area()
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
import example
|
||||
|
||||
# Create the Circle object
|
||||
|
||||
r = 2;
|
||||
print " Creating circle (radium: %d) :" % r
|
||||
c = example.Circle(r)
|
||||
|
||||
# Set the location of the object
|
||||
|
||||
c.x = 20
|
||||
c.y = 30
|
||||
print " Here is its current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\n Here are some properties of the Circle:"
|
||||
print " area = ", c.area()
|
||||
print " perimeter = ", c.perimeter()
|
||||
dx = 1;
|
||||
dy = 1;
|
||||
print " Moving with (%d, %d)..." % (dx, dy)
|
||||
c.move(dx, dy)
|
||||
|
||||
del c
|
||||
|
||||
print "==================================="
|
||||
|
||||
# test move function */
|
||||
r = 2;
|
||||
print " Creating circle (radium: %d) :" % r
|
||||
c = example.Circle(r)
|
||||
# Set the location of the object
|
||||
|
||||
c.x = 20
|
||||
c.y = 30
|
||||
print " Here is its current position:"
|
||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
||||
|
||||
# ----- Call some methods -----
|
||||
|
||||
print "\n Here are some properties of the Circle:"
|
||||
print " area = ", c.area()
|
||||
print " perimeter = ", c.perimeter()
|
||||
|
||||
# no error for Circle's pre-assertion
|
||||
dx = 1;
|
||||
dy = -1;
|
||||
print " Moving with (%d, %d)..." % (dx, dy)
|
||||
c.move(dx, dy)
|
||||
|
||||
# error with Shape's pre-assertion
|
||||
dx = -1;
|
||||
dy = 1;
|
||||
print " Moving with (%d, %d)..." % (dx, dy)
|
||||
c.move(dx, dy)
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
# see top-level Makefile.in
|
||||
constants
|
||||
class
|
||||
port
|
||||
simple
|
||||
std_vector
|
||||
constants
|
||||
matrix
|
||||
multimap
|
||||
multivalue
|
||||
port
|
||||
simple
|
||||
std_vector
|
||||
|
|
|
|||
|
|
@ -14,4 +14,8 @@
|
|||
|
||||
%include math.i
|
||||
|
||||
extern double drand48();
|
||||
%{
|
||||
/* Add drand48 declaration as it is posix only and is not in stdlib.h when using strict c99 and later */
|
||||
extern double drand48(void);
|
||||
%}
|
||||
extern double drand48(void);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Exc {
|
|||
public:
|
||||
Exc(int c, const char *m) {
|
||||
code = c;
|
||||
strncpy(msg,m,256);
|
||||
strncpy(msg,m,255);
|
||||
}
|
||||
int code;
|
||||
char msg[256];
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ int placeholder() { return 0; }
|
|||
static SwigV8ReturnValue JavaScript_do_work(const SwigV8Arguments &args) {
|
||||
SWIGV8_HANDLESCOPE();
|
||||
const int MY_MAGIC_NUMBER = 5;
|
||||
v8::Handle<v8::Value> jsresult =
|
||||
SWIGV8_VALUE jsresult =
|
||||
SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER));
|
||||
if (args.Length() != 0)
|
||||
SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Exc {
|
|||
public:
|
||||
Exc(int c, const char *m) {
|
||||
code = c;
|
||||
strncpy(msg,m,256);
|
||||
strncpy(msg,m,255);
|
||||
}
|
||||
int code;
|
||||
char msg[256];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
/* Move the shape to a new location */
|
||||
void Shape::move(double dx, double dy) {
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
# see top-level Makefile.in
|
||||
class
|
||||
enum
|
||||
exception
|
||||
reference
|
||||
simple
|
||||
typemap
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
TARGET = example
|
||||
PLATFORM = LINUXLIBC6
|
||||
INTERFACE = example.i
|
||||
SWIGOPT = -c++
|
||||
MODULA3SRCS = *.[im]3
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
|
||||
m3ppinplace $(MODULA3SRCS)
|
||||
# compilation of example_wrap.cxx is started by cm3
|
||||
# $(CXX) -c $(TARGET)_wrap.cxx
|
||||
mv example_wrap.cxx m3makefile $(MODULA3SRCS) src/
|
||||
ln -sf ../example.h src/example.h
|
||||
cm3
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/* 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;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* 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();
|
||||
};
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module Example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%insert(m3makefile) %{template("../swig")
|
||||
cxx_source("example_wrap")%}
|
||||
|
||||
%typemap(m3rawinmode) Shape *, Circle *, Square * ""
|
||||
%typemap(m3rawrettype) Shape *, Circle *, Square * "$1_basetype"
|
||||
|
||||
%typemap(m3wrapinmode) Shape *, Circle *, Square * ""
|
||||
%typemap(m3wrapargraw) Shape *, Circle *, Square * "self.cxxObj"
|
||||
|
||||
%typemap(m3wrapretvar) Circle *, Square * "cxxObj : ExampleRaw.$1_basetype;"
|
||||
%typemap(m3wrapretraw) Circle *, Square * "cxxObj"
|
||||
%typemap(m3wrapretconv) Circle *, Square * "NEW($1_basetype,cxxObj:=cxxObj)"
|
||||
%typemap(m3wraprettype) Circle *, Square * "$1_basetype"
|
||||
|
||||
/* Should work with and without renaming
|
||||
%rename(M3Shape) Shape;
|
||||
%rename(M3Circle) Circle;
|
||||
%rename(M3Square) Square;
|
||||
%typemap(m3wrapintype) Shape *, Circle *, Square * "M3$1_basetype"
|
||||
%typemap(m3wraprettype) Shape *, Circle *, Square * "M3$1_basetype"
|
||||
%typemap(m3wrapretconv) Circle *, Square * "NEW(M3$1_basetype,cxxObj:=cxxObj)"
|
||||
*/
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
readonly proc cxx_source (X) is
|
||||
local cxxfile = X&".cxx"
|
||||
local objfile = X&".o"
|
||||
%exec("echo $PWD")
|
||||
if stale(objfile,cxxfile)
|
||||
exec("cd",path(),"; g++ -I.. -c -o",objfile,cxxfile)
|
||||
end
|
||||
import_obj(X)
|
||||
%unlink_file(path()&SL&objfile)
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
CONSTNUMERIC = example_const
|
||||
SWIGOPT = -c++
|
||||
MODULA3SRCS = *.[im]3
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
|
||||
|
||||
build:
|
||||
$(SWIGEXE) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h
|
||||
$(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC)
|
||||
$(CONSTNUMERIC) >$(CONSTNUMERIC).i
|
||||
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
|
||||
m3ppinplace $(MODULA3SRCS)
|
||||
mv m3makefile $(MODULA3SRCS) src/
|
||||
cm3
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void Foo::enum_test(speed s) {
|
||||
if (s == IMPULSE) {
|
||||
printf("IMPULSE speed\n");
|
||||
} else if (s == WARP) {
|
||||
printf("WARP speed\n");
|
||||
} else if (s == LUDICROUS) {
|
||||
printf("LUDICROUS speed\n");
|
||||
} else if (s == HYPER) {
|
||||
printf("HYPER speed\n");
|
||||
} else {
|
||||
printf("Unknown speed\n");
|
||||
}
|
||||
}
|
||||
|
||||
void enum_test(color c, Foo::speed s) {
|
||||
if (c == RED) {
|
||||
printf("color = RED, ");
|
||||
} else if (c == BLUE) {
|
||||
printf("color = BLUE, ");
|
||||
} else if (c == GREEN) {
|
||||
printf("color = GREEN, ");
|
||||
} else {
|
||||
printf("color = Unknown color!, ");
|
||||
}
|
||||
Foo obj;
|
||||
obj.enum_test(s);
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
#define PI 3.141
|
||||
|
||||
#define DAY_MONDAY 0
|
||||
#define DAY_TUESDAY 1
|
||||
#define DAY_WEDNESDAY 2
|
||||
#define DAY_THURSDAY 3
|
||||
#define DAY_FRIDAY 4
|
||||
#define DAY_SATURDAY 5
|
||||
#define DAY_SUNDAY 6
|
||||
|
||||
enum color { BLUE, RED, GREEN };
|
||||
|
||||
#define CLB_BLACK 0
|
||||
#define CLB_BLUE 1
|
||||
#define CLB_RED 2
|
||||
#define CLB_MAGENTA 3
|
||||
#define CLB_GREEN 4
|
||||
#define CLB_CYAN 5
|
||||
#define CLB_YELLOW 6
|
||||
#define CLB_WHITE 7
|
||||
|
||||
/* Using this would be good style
|
||||
which cannot be expected for general C header files.
|
||||
Instead I want to demonstrate how to live without it.
|
||||
enum month {
|
||||
MTHF_JANUARY,
|
||||
MTHF_FEBRUARY,
|
||||
MTHF_MARCH,
|
||||
MTHF_APRIL,
|
||||
MTHF_MAY,
|
||||
MTHF_JUNE,
|
||||
MTHF_JULY,
|
||||
MTHF_AUGUST,
|
||||
MTHF_SEPTEMBER,
|
||||
MTHF_OCTOBER,
|
||||
MTHF_NOVEMBER,
|
||||
MTHF_DECEMBER,
|
||||
}
|
||||
*/
|
||||
|
||||
/* Since there are no compile time constants in C / C++
|
||||
it is a common abuse
|
||||
to declare bit set (flag) constants
|
||||
as enumerations. */
|
||||
enum calendar {
|
||||
MTHB_JANUARY = 1 << 0, /* 1 << MTHF_JANUARY, */
|
||||
MTHB_FEBRUARY = 1 << 1, /* 1 << MTHF_FEBRUARY, */
|
||||
MTHB_MARCH = 1 << 2, /* 1 << MTHF_MARCH, */
|
||||
MTHB_APRIL = 1 << 3, /* 1 << MTHF_APRIL, */
|
||||
MTHB_MAY = 1 << 4, /* 1 << MTHF_MAY, */
|
||||
MTHB_JUNE = 1 << 5, /* 1 << MTHF_JUNE, */
|
||||
MTHB_JULY = 1 << 6, /* 1 << MTHF_JULY, */
|
||||
MTHB_AUGUST = 1 << 7, /* 1 << MTHF_AUGUST, */
|
||||
MTHB_SEPTEMBER = 1 << 8, /* 1 << MTHF_SEPTEMBER, */
|
||||
MTHB_OCTOBER = 1 << 9, /* 1 << MTHF_OCTOBER, */
|
||||
MTHB_NOVEMBER = 1 << 10, /* 1 << MTHF_NOVEMBER, */
|
||||
MTHB_DECEMBER = 1 << 11, /* 1 << MTHF_DECEMBER, */
|
||||
|
||||
MTHB_SPRING = MTHB_MARCH | MTHB_APRIL | MTHB_MAY,
|
||||
MTHB_SUMMER = MTHB_JUNE | MTHB_JULY | MTHB_AUGUST,
|
||||
MTHB_AUTUMN = MTHB_SEPTEMBER | MTHB_OCTOBER | MTHB_NOVEMBER,
|
||||
MTHB_WINTER = MTHB_DECEMBER | MTHB_JANUARY | MTHB_FEBRUARY,
|
||||
};
|
||||
|
||||
|
||||
namespace Answer {
|
||||
enum {
|
||||
UNIVERSE_AND_EVERYTHING = 42,
|
||||
SEVENTEEN_AND_FOUR = 21,
|
||||
TWOHUNDRED_PERCENT_OF_NOTHING = 0,
|
||||
};
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo() { }
|
||||
enum speed { IMPULSE = -2, WARP = 0, HYPER, LUDICROUS = 3};
|
||||
void enum_test(speed s);
|
||||
};
|
||||
};
|
||||
|
||||
void enum_test(color c, Answer::Foo::speed s);
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module Example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "example_const.i"
|
||||
|
||||
// such features are generated by the following pragmas
|
||||
#if 0
|
||||
%feature("modula3:enumitem:enum","Days") DAY_MONDAY;
|
||||
%feature("modula3:enumitem:name","monday") DAY_MONDAY;
|
||||
%feature("modula3:enumitem:conv","int:int") DAY_MONDAY;
|
||||
|
||||
%feature("modula3:enumitem:enum","Month") MTHB_JANUARY;
|
||||
%feature("modula3:enumitem:name","january") MTHB_JANUARY;
|
||||
%feature("modula3:enumitem:conv","set:int") MTHB_JANUARY;
|
||||
//%feature("modula3:constset:type","MonthSet") MTHB_JANUARY; /*type in the constant definition*/
|
||||
%feature("modula3:constset:set", "MonthSet") MTHB_JANUARY; /*remarks that the 'type' is a set type*/
|
||||
%feature("modula3:constset:base","Month") MTHB_JANUARY;
|
||||
%feature("modula3:constset:name","monthsJanuary") MTHB_JANUARY;
|
||||
%feature("modula3:constset:conv","set:set") MTHB_JANUARY; /*conversion of the bit pattern: no change*/
|
||||
|
||||
%feature("modula3:enumitem:enum","Color") BLUE;
|
||||
%feature("modula3:enumitem:name","blue") BLUE;
|
||||
%feature("modula3:enumitem:conv","int:int") BLUE;
|
||||
|
||||
%feature("modula3:constint:type","INTEGER") Foo::IMPULSE;
|
||||
%feature("modula3:constint:name","impulse") Foo::IMPULSE;
|
||||
%feature("modula3:constint:conv","int:int") Foo::IMPULSE;
|
||||
#endif
|
||||
|
||||
%rename(pi) PI;
|
||||
|
||||
%pragma(modula3) enumitem="prefix=DAY_;int;srcstyle=underscore;Day";
|
||||
|
||||
%pragma(modula3) enumitem="enum=color;int;srcstyle=underscore;Color";
|
||||
%pragma(modula3) makesetofenum="Color";
|
||||
%pragma(modula3) constset="prefix=CLB_;set;srcstyle=underscore,prefix=clb;ColorSet,Color";
|
||||
|
||||
%pragma(modula3) enumitem="prefix=MTHB_,enum=calendar;set;srcstyle=underscore;Month";
|
||||
%pragma(modula3) makesetofenum="Month";
|
||||
%pragma(modula3) constset="prefix=MTHB_,enum=calendar;set;srcstyle=underscore,prefix=monthset;MonthSet,Month";
|
||||
|
||||
%pragma(modula3) constint="prefix=Answer::Foo::,enum=Answer::Foo::speed;int;srcstyle=underscore,prefix=speed;INTEGER";
|
||||
|
||||
%pragma(modula3) constint="prefix=Answer::,enum=Answer::;int;srcstyle=underscore,prefix=answer;CARDINAL";
|
||||
|
||||
%rename(AnswerFoo) Answer::Foo;
|
||||
%typemap("m3rawrettype") Answer::Foo * %{AnswerFoo%}
|
||||
%typemap("m3rawintype") Answer::Foo * %{AnswerFoo%}
|
||||
%typemap("m3rawinmode") Answer::Foo * %{%}
|
||||
%typemap("m3wraprettype") Answer::Foo * %{AnswerFoo%}
|
||||
%typemap("m3wrapintype") Answer::Foo * %{AnswerFoo%}
|
||||
%typemap("m3wrapinmode") Answer::Foo * %{%}
|
||||
%typemap("m3wrapargraw") Answer::Foo * %{self.cxxObj%}
|
||||
|
||||
%typemap("m3wrapretvar") Answer::Foo * %{cxxObj : ExampleRaw.AnswerFoo;%}
|
||||
%typemap("m3wrapretraw") Answer::Foo * %{cxxObj%}
|
||||
%typemap("m3wrapretconv") Answer::Foo * %{NEW(AnswerFoo,cxxObj:=cxxObj)%}
|
||||
|
||||
|
||||
%typemap("m3rawintype") Answer::Foo::speed %{C.int%};
|
||||
%typemap("m3rawintype:import") Answer::Foo::speed %{Ctypes AS C%};
|
||||
%typemap("m3wrapintype") Answer::Foo::speed %{[-2..3]%};
|
||||
|
||||
%typemap("m3wrapintype") color %{Color%};
|
||||
%typemap("m3wrapargraw") color %{ORD($1_name)%};
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
MODULA3SRCS = *.[im]3
|
||||
MODULA3FLAGS= -o runme
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp
|
||||
# $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile
|
||||
m3ppinplace $(MODULA3SRCS)
|
||||
mv m3makefile $(MODULA3SRCS) src/
|
||||
cm3
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
enum error {OK, OVERFLOW, DIVISION_BY_ZERO, NEGATIVE_RADICAND, NEGATIVE_BASE};
|
||||
typedef error errorstate; /* just to separate the typemaps */
|
||||
|
||||
error acc_add (double &x, double y);
|
||||
error acc_sub (double &x, double y);
|
||||
error acc_mul (double &x, double y);
|
||||
error acc_div (double &x, double y);
|
||||
|
||||
double op_add (double x, double y, errorstate &err);
|
||||
double op_sub (double x, double y, errorstate &err);
|
||||
double op_mul (double x, double y, errorstate &err);
|
||||
double op_div (double x, double y, errorstate &err);
|
||||
double op_sqrt (double x, errorstate &err);
|
||||
double op_pow (double x, double y, errorstate &err);
|
||||
|
||||
double op_noexc (double x, double y);
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module Example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%insert(m3wrapintf) %{
|
||||
EXCEPTION E(Error);
|
||||
%}
|
||||
%insert(m3wrapimpl) %{
|
||||
IMPORT Ctypes AS C;
|
||||
%}
|
||||
|
||||
%pragma(modula3) enumitem="enum=error;int;srcstyle=underscore;Error";
|
||||
|
||||
%typemap("m3rawintype") double & %{C.double%};
|
||||
%typemap("m3wrapintype") double & %{LONGREAL%};
|
||||
|
||||
%typemap("m3wraprettype") error ""
|
||||
%typemap("m3wrapretvar") error "rawerr: C.int;"
|
||||
%typemap("m3wrapretraw") error "rawerr"
|
||||
%typemap("m3wrapretcheck:throws") error "E"
|
||||
%typemap("m3wrapretcheck") error
|
||||
%{VAR err := VAL(rawerr, Error);
|
||||
BEGIN
|
||||
IF err # Error.ok THEN
|
||||
RAISE E(err);
|
||||
END;
|
||||
END;%}
|
||||
|
||||
%typemap("m3rawintype") errorstate & %{C.int%};
|
||||
%typemap("m3wrapintype",numinputs=0) errorstate & %{%};
|
||||
%typemap("m3wrapargvar") errorstate & %{err:C.int:=ORD(Error.ok);%};
|
||||
%typemap("m3wrapoutcheck:throws") errorstate & "E";
|
||||
%typemap("m3wrapoutcheck") errorstate &
|
||||
%{IF VAL(err,Error) # Error.ok THEN
|
||||
RAISE E(VAL(err,Error));
|
||||
END;%}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
|
||||
%include "example.h"
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
SWIGOPT = -c++
|
||||
MODULA3SRCS = *.[im]3
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
|
||||
m3ppinplace $(MODULA3SRCS)
|
||||
mv m3makefile $(MODULA3SRCS) src/
|
||||
cm3
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
||||
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
|
||||
# define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Vector operator+(const Vector &a, const Vector &b) {
|
||||
Vector r;
|
||||
r.x = a.x + b.x;
|
||||
r.y = a.y + b.y;
|
||||
r.z = a.z + b.z;
|
||||
return r;
|
||||
}
|
||||
|
||||
char *Vector::print() {
|
||||
static char temp[512];
|
||||
sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
|
||||
return temp;
|
||||
}
|
||||
|
||||
VectorArray::VectorArray(int size) {
|
||||
items = new Vector[size];
|
||||
maxsize = size;
|
||||
}
|
||||
|
||||
VectorArray::~VectorArray() {
|
||||
delete [] items;
|
||||
}
|
||||
|
||||
Vector &VectorArray::operator[](int index) {
|
||||
if ((index < 0) || (index >= maxsize)) {
|
||||
printf("Panic! Array index out of bounds.\n");
|
||||
exit(1);
|
||||
}
|
||||
return items[index];
|
||||
}
|
||||
|
||||
int VectorArray::size() {
|
||||
return maxsize;
|
||||
}
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
struct Vector {
|
||||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
Vector operator+(const Vector &b) const;
|
||||
char *print();
|
||||
};
|
||||
|
||||
struct VectorArray {
|
||||
private:
|
||||
Vector *items;
|
||||
int maxsize;
|
||||
public:
|
||||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* File : example.i */
|
||||
|
||||
/* This file has a few "typical" uses of C++ references. */
|
||||
|
||||
%module Example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%pragma(modula3) unsafe="1";
|
||||
|
||||
%insert(m3wrapintf) %{FROM ExampleRaw IMPORT Vector, VectorArray;%}
|
||||
%insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Vector, VectorArray;%}
|
||||
|
||||
%typemap(m3wrapretvar) Vector %{vec: UNTRACED REF Vector;%}
|
||||
%typemap(m3wrapretraw) Vector %{vec%}
|
||||
%typemap(m3wrapretconv) Vector %{vec^%}
|
||||
|
||||
|
||||
/* This helper function calls an overloaded operator */
|
||||
%inline %{
|
||||
Vector addv(const Vector &a, const Vector &b) {
|
||||
return a+b;
|
||||
}
|
||||
%}
|
||||
|
||||
%rename(Vector_Clear) Vector::Vector();
|
||||
%rename(Add) Vector::operator+;
|
||||
%rename(GetItem) VectorArray::operator[];
|
||||
|
||||
%include "example.h"
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
MODULA3SRCS = *.[im]3
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
|
||||
m3ppinplace $(MODULA3SRCS)
|
||||
mv m3makefile $(MODULA3SRCS) src/
|
||||
cm3
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* File : example.c */
|
||||
|
||||
/* A global variable */
|
||||
double Foo = 3.0;
|
||||
|
||||
/* Compute the greatest common divisor of positive integers */
|
||||
int gcd(int x, int y) {
|
||||
int g;
|
||||
g = y;
|
||||
while (x > 0) {
|
||||
g = x;
|
||||
x = y % x;
|
||||
y = g;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module Example
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
%}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
SWIGOPT =
|
||||
MODULA3SRCS = *.[im]3
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
|
||||
m3ppinplace $(MODULA3SRCS)
|
||||
mv m3makefile $(MODULA3SRCS) src/
|
||||
cm3
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module Example
|
||||
|
||||
%pragma(modula3) unsafe="true";
|
||||
|
||||
%insert(m3wrapintf) %{FROM ExampleRaw IMPORT Window, Point;
|
||||
%}
|
||||
%insert(m3wrapimpl) %{FROM ExampleRaw IMPORT Window, Point;
|
||||
IMPORT M3toC;
|
||||
IMPORT Ctypes AS C;
|
||||
%}
|
||||
|
||||
/* Typemap applied to patterns of multiple arguments */
|
||||
|
||||
%typemap(m3rawinmode) (char *outstr) %{VAR%}
|
||||
%typemap(m3rawintype) (char *outstr) %{CHAR%}
|
||||
%typemap(m3wrapinmode) (char *outstr, int size) %{VAR%}
|
||||
%typemap(m3wrapintype) (char *outstr, int size) %{ARRAY OF CHAR%}
|
||||
%typemap(m3wrapargraw) (char *outstr, int size) %{$1_name[0], NUMBER($1_name)%}
|
||||
|
||||
|
||||
%typemap(m3rawinmode) (const struct Window *) %{READONLY%}
|
||||
%typemap(m3wrapinmode) (const struct Window *) %{READONLY%}
|
||||
%typemap(m3rawintype) ( struct Window *) %{Window%}
|
||||
%typemap(m3wrapintype) ( struct Window *) %{Window%}
|
||||
|
||||
%typemap(m3rawinmode) (const char *str []) %{READONLY%}
|
||||
%typemap(m3wrapinmode) (const char *str []) %{READONLY%}
|
||||
%typemap(m3rawintype) (const char *str []) %{(*ARRAY OF*) C.char_star%}
|
||||
%typemap(m3wrapintype) (const char *str []) %{ARRAY OF TEXT%}
|
||||
%typemap(m3wrapargvar) (const char *str []) %{$1: REF ARRAY OF C.char_star;%}
|
||||
%typemap(m3wrapargraw) (const char *str []) %{$1[0]%}
|
||||
%typemap(m3wrapinconv) (const char *str []) %{$1:= NEW(REF ARRAY OF C.char_star,NUMBER($1_name));
|
||||
FOR i:=FIRST($1_name) TO LAST($1_name) DO
|
||||
$1[i]:=M3toC.SharedTtoS($1_name[i]);
|
||||
END;%}
|
||||
%typemap(m3wrapfreearg) (const char *str [])
|
||||
%{FOR i:=FIRST($1_name) TO LAST($1_name) DO
|
||||
M3toC.FreeSharedS($1_name[i],$1[i]);
|
||||
END;%}
|
||||
|
||||
%typemap(m3wraprettype) char * %{TEXT%}
|
||||
%typemap(m3wrapretvar) char * %{result_string: C.char_star;%}
|
||||
%typemap(m3wrapretraw) char * %{result_string%}
|
||||
%typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result_string)%}
|
||||
|
||||
struct Window {
|
||||
char *label;
|
||||
int left,top,width,height;
|
||||
};
|
||||
|
||||
|
||||
%typemap(m3wrapinname) (int x, int y) %{p%}
|
||||
%typemap(m3wrapinmode) (int x, int y) %{READONLY%}
|
||||
%typemap(m3wrapintype) (int x, int y) %{Point%}
|
||||
%typemap(m3wrapargraw) (int x, int y) %{p.$1_name, p.$2_name%}
|
||||
|
||||
%typemap(m3wrapargraw) (int &x, int &y) %{p.$1_name, p.$2_name%}
|
||||
%typemap(m3wrapintype) (int &x, int &y) %{Point%}
|
||||
%typemap(m3wrapoutname) (int &x, int &y) %{p%}
|
||||
%typemap(m3wrapouttype) (int &x, int &y) %{Point%}
|
||||
%typemap(m3wrapargdir) (int &x, int &y) "out"
|
||||
|
||||
|
||||
%typemap(m3wrapargvar) int &left, int &top, int &width, int &height "$1:C.int;"
|
||||
%typemap(m3wrapargraw) int &left, int &top, int &width, int &height "$1"
|
||||
%typemap(m3wrapoutconv) int &left, int &top, int &width, int &height "$1"
|
||||
|
||||
%typemap(m3wrapargdir) int &left, int &top "out"
|
||||
|
||||
%typemap(m3wrapouttype) int &width, int &height "CARDINAL"
|
||||
%typemap(m3wrapargdir) int &width, int &height "out"
|
||||
|
||||
struct Point {
|
||||
int x,y;
|
||||
};
|
||||
|
||||
%m3multiretval get_box;
|
||||
|
||||
void set_label ( struct Window *win, const char *str, bool activate);
|
||||
void set_multi_label ( struct Window *win, const char *str []);
|
||||
void write_label (const struct Window *win, char *outstr, int size);
|
||||
int get_label (const struct Window *win, char *outstr, int size);
|
||||
char *get_label_ptr (const struct Window *win);
|
||||
void move(struct Window *win, int x, int y);
|
||||
int get_area(const struct Window *win);
|
||||
void get_box(const struct Window *win, int &left, int &top, int &width, int &height);
|
||||
void get_left(const struct Window *win, int &left);
|
||||
void get_mouse(const struct Window *win, int &x, int &y);
|
||||
int get_attached_data(const struct Window *win, const char *id);
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module(directors="1") example
|
||||
#ifndef SWIGSEXP
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
#endif
|
||||
|
||||
%feature("director");
|
||||
%include "example.h"
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ extend
|
|||
funcptr
|
||||
funcptr2
|
||||
functor
|
||||
operator
|
||||
module_load
|
||||
operator
|
||||
pointer
|
||||
reference
|
||||
simple
|
||||
|
|
|
|||
|
|
@ -8,25 +8,25 @@ TARGET = swigexample
|
|||
INTERFACE = example.i
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
|
||||
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_run
|
||||
|
||||
build:
|
||||
ifneq (,$(SRCS))
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
|
||||
else
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||
endif
|
||||
ifneq (,$(TARGET2)$(SWIGOPT2))
|
||||
ifneq (,$(SRCS))
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave
|
||||
else
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp
|
||||
endif
|
||||
|
|
@ -34,4 +34,4 @@ endif
|
|||
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
|
||||
$(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_clean
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# Class, which overwrites Callback::run().
|
||||
|
||||
class PhpCallback extends Callback {
|
||||
|
|
@ -43,5 +41,3 @@ $caller->delCallback();
|
|||
# All done.
|
||||
|
||||
print "php exit\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This example illustrates how member variables are wrapped.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
@ -56,5 +54,3 @@ $o = NULL;
|
|||
|
||||
print Shape::nshapes() . " shapes remain\n";
|
||||
print "Goodbye\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
print "ICONST = " . ICONST . " (should be 42)\n";
|
||||
print "FCONST = " . FCONST . " (should be 2.1828)\n";
|
||||
print "CCONST = " . CCONST . " (should be 'x')\n";
|
||||
|
|
@ -19,6 +17,3 @@ if (array_key_exists("EXTERN", $c)) {
|
|||
if (array_key_exists("FOO", $c)) {
|
||||
print "FOO = " . $c["FOO"] . " (Arg! This shouldn't print anything)\n";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# First create some objects using the pointer library.
|
||||
|
||||
print "Testing the pointer library\n";
|
||||
|
|
@ -43,5 +41,3 @@
|
|||
# $q = $a[0]
|
||||
# $r = $a[1]
|
||||
# print " 42/37 = $q remainder $r\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
@ -45,5 +43,3 @@ $container = NULL;
|
|||
print "\nA total of " . Shape::nshapes() . " shapes remain\n";
|
||||
|
||||
print "Goodbye\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
# Print out the value of some enums
|
||||
|
|
@ -28,5 +26,3 @@ $f = new Foo();
|
|||
$f->enum_test(Foo::IMPULSE);
|
||||
$f->enum_test(Foo::WARP);
|
||||
$f->enum_test(Foo::LUDICROUS);
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# CEO class, which overrides Employee::getPosition().
|
||||
|
||||
class CEO extends Manager {
|
||||
|
|
@ -72,5 +70,3 @@ print "----------------------\n";
|
|||
# All done.
|
||||
|
||||
print "php exit\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
$a = 37;
|
||||
$b = 42;
|
||||
|
||||
|
|
@ -10,15 +8,11 @@ $b = 42;
|
|||
print "Trying some C callback functions\n";
|
||||
print " a = $a\n";
|
||||
print " b = $b\n";
|
||||
print " ADD(a,b) = ". do_op($a,$b,ADD)."\n";
|
||||
print " SUB(a,b) = ". do_op($a,$b,SUB)."\n";
|
||||
print " MUL(a,b) = ". do_op($a,$b,MUL)."\n";
|
||||
print " ADD(a,b) = ". do_op($a,$b,example::ADD)."\n";
|
||||
print " SUB(a,b) = ". do_op($a,$b,example::SUB)."\n";
|
||||
print " MUL(a,b) = ". do_op($a,$b,example::MUL)."\n";
|
||||
|
||||
print "Here is what the C callback function objects look like in php\n";
|
||||
print "Using swig style string pointers as we need them registered as constants\n";
|
||||
print " ADD = " . ADD . "\n";
|
||||
print " SUB = " . SUB . "\n";
|
||||
print " MUL = " . MUL . "\n";
|
||||
|
||||
?>
|
||||
|
||||
print " ADD = " . example::ADD . "\n";
|
||||
print " SUB = " . example::SUB . "\n";
|
||||
print " MUL = " . example::MUL . "\n";
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
|
||||
include("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
@ -54,5 +52,3 @@ $s = 42;
|
|||
print Shape::nshapes() . " shapes remain\n";
|
||||
|
||||
print "Goodbye\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,5 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
|
|||
|
||||
/* Next we'll use typemaps and the %apply directive */
|
||||
|
||||
//%apply int *OUTPUT { int *r };
|
||||
//extern int divide(int n, int d, int *r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%apply int *OUTPUT { int *r };
|
||||
extern int divide(int n, int d, int *r);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# First create some objects using the pointer library.
|
||||
|
||||
print "Testing the pointer library\n";
|
||||
|
|
@ -14,7 +12,7 @@
|
|||
print " b = $b\n";
|
||||
print " c = $c\n";
|
||||
|
||||
# Call the add() function wuth some pointers
|
||||
# Call the add() function with some pointers
|
||||
add($a,$b,$c);
|
||||
|
||||
print " $a + $b = $c\n";
|
||||
|
|
@ -28,8 +26,8 @@
|
|||
print " 37 - 42 = $r\n";
|
||||
|
||||
# Now try the version with multiple return values
|
||||
# print "Testing multiple return values\n";
|
||||
# ($q,$r) = divide(42,37);
|
||||
# print " 42/37 = $q remainder $r\n";
|
||||
|
||||
?>
|
||||
print "Testing multiple return values\n";
|
||||
$a = divide(42,37);
|
||||
$q = $a[0];
|
||||
$r = $a[1];
|
||||
print " 42/37 = $q remainder $r\n";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,3 @@
|
|||
|
||||
# This code is inserted into example.php
|
||||
echo "This is include.php\n";
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -6,4 +6,3 @@ set_include_path(realpath(dirname(__FILE__)) . PATH_SEPARATOR . get_include_path
|
|||
require "example.php";
|
||||
|
||||
echo "Version - " . ((new ReflectionExtension('example'))->getVersion()) . "\n";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
|
||||
include("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
@ -64,5 +62,3 @@ Shape::nshapes(42);
|
|||
print Shape::get_nshapes() ." == 42\n";
|
||||
|
||||
print "Goodbye\n";
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This file illustrates the manipulation of C++ references in PHP.
|
||||
|
||||
require "example.php";
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
@ -45,5 +43,3 @@ print "Getting some array values\n";
|
|||
for ($i = 0; $i < 5; $i++) {
|
||||
print " va[$i] = {$va->get($i)->as_string()}\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# Call our gcd() function
|
||||
|
||||
$x = "42 aaa";
|
||||
|
|
@ -21,5 +19,3 @@ Foo_set(3.1415926);
|
|||
# manual for why. )
|
||||
print "Foo = " . Foo_get() . "\n";
|
||||
print_Foo();
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
int x = 42;
|
||||
char *s = (char *)"Test";
|
||||
std::string s = "Test";
|
||||
|
||||
void Sync::printer(void) {
|
||||
|
||||
printf("The value of global s is %s\n", s);
|
||||
printf("The value of global x is %d\n", x);
|
||||
printf("The value of class s is %s\n", s);
|
||||
printf("The value of class x is %d\n", x);
|
||||
void Sync::printer() {
|
||||
std::cout << "The value of global s is " << ::s << '\n';
|
||||
std::cout << "The value of global x is " << ::x << '\n';
|
||||
std::cout << "The value of class s is " << this->s << '\n';
|
||||
std::cout << "The value of class x is " << this->x << '\n';
|
||||
}
|
||||
|
||||
void Sync::all_change() {
|
||||
::s = "global change";
|
||||
++::x;
|
||||
this->s = "local change";
|
||||
++this->x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
extern char *s;
|
||||
#include <string>
|
||||
|
||||
extern std::string s;
|
||||
extern int x;
|
||||
|
||||
class Sync {
|
||||
public:
|
||||
int x;
|
||||
char *s;
|
||||
void printer(void);
|
||||
public:
|
||||
int x;
|
||||
std::string s;
|
||||
void printer();
|
||||
void all_change();
|
||||
|
||||
Sync() : x(0) { }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
%module example
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,29 @@
|
|||
<?
|
||||
|
||||
// Load module and PHP classes.
|
||||
include("example.php");
|
||||
echo "PHP reading globals: string is '", s_get(), "' and value is ", x_get(), "\n";
|
||||
|
||||
echo "Got new object\n";
|
||||
echo "Got string $s and value $x \n";
|
||||
|
||||
$s = new Sync();
|
||||
$o = new Sync();
|
||||
echo "Got new object\n";
|
||||
|
||||
$s->printer();
|
||||
echo "PHP reading object: string is '", $o->s, "' and value is ", $o->x, "\n";
|
||||
|
||||
?>
|
||||
$o->printer();
|
||||
|
||||
example::s_set("global string");
|
||||
example::x_set(42);
|
||||
|
||||
$o->s = "object string";
|
||||
$o->x = 1234;
|
||||
|
||||
echo "PHP reading globals: string is '", example::s_get(), "' and int is ", example::x_get(), "\n";
|
||||
echo "PHP reading object: string is '", $o->s, "' and int is ", $o->x, "\n";
|
||||
|
||||
$o->printer();
|
||||
|
||||
echo "Calling all_change() method\n";
|
||||
$o->all_change();
|
||||
|
||||
echo "PHP reading globals: string is '", example::s_get(), "' and int is ", example::x_get(), "\n";
|
||||
echo "PHP reading object: string is '", $o->s, "' and int is ", $o->x, "\n";
|
||||
|
||||
$o->printer();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
|
||||
$v = new Vector();
|
||||
$v->x = 1.0;
|
||||
$v->y = 2.0;
|
||||
|
|
@ -34,10 +31,6 @@
|
|||
|
||||
echo "\nNow I'm going to clean up the return result\n";
|
||||
|
||||
# free($r);
|
||||
unset($r);
|
||||
|
||||
echo "Good\n";
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
echo "\nVariables (values printed from C)\n";
|
||||
|
||||
print_vars();
|
||||
|
|
@ -91,6 +90,3 @@
|
|||
/* And this */
|
||||
//status_set(0);
|
||||
echo "Status = ".status_get()."\n";
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
# see top-level Makefile.in
|
||||
class
|
||||
constants
|
||||
enum
|
||||
overload
|
||||
simple
|
||||
template
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue