Merge branch 'master' into doxygen

Merge with ~3.0.1 sources from master.
This commit is contained in:
Vadim Zeitlin 2014-04-30 18:37:57 +02:00
commit 1ebd2334b8
1593 changed files with 51732 additions and 28076 deletions

View file

@ -4,15 +4,15 @@ CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -7,6 +7,7 @@ extend
funcptr
multimap
native
nested
pointer
reference
simple

View file

@ -4,15 +4,15 @@ CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -1,4 +1,4 @@
/* File : example.c */
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area(void) {
double Square::area() {
return width*width;
}
double Square::perimeter(void) {
double Square::perimeter() {
return 4*width;
}

View file

@ -136,7 +136,7 @@ InputName=example
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -c++ -java $(InputPath)
..\..\..\swig.exe -c++ -java "$(InputPath)"
# End Custom Build
@ -151,7 +151,7 @@ InputName=example
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -c++ -java $(InputPath)
..\..\..\swig.exe -c++ -java "$(InputPath)"
# End Custom Build

View file

@ -7,11 +7,11 @@ public:
}
virtual ~Shape() {
nshapes--;
};
double x, y;
}
double x, y;
void move(double dx, double dy);
virtual double area(void) = 0;
virtual double perimeter(void) = 0;
virtual double area() = 0;
virtual double perimeter() = 0;
static int nshapes;
};
@ -19,21 +19,16 @@ class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { };
virtual double area(void);
virtual double perimeter(void);
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(void);
virtual double perimeter(void);
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};

View file

@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -32,8 +32,8 @@ public:
}
virtual ~Shape() {
nshapes--;
};
double x, y;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
@ -44,7 +44,7 @@ class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { };
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
@ -53,7 +53,7 @@ class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { };
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};
@ -146,50 +146,15 @@ Shape.setNshapes(13); // Set a static data member
<ul>
<li>This high-level interface using proxy classes is not the only way to handle C++ code.
A low level interface using c functions to access member variables and member functions is the alternative SWIG
approach. This entails passing around the c pointer or c++ 'this' pointer and as such it is not difficult to crash the JVM.
A low level interface using C functions to access member variables and member functions is the alternative SWIG
approach. This entails passing around the C pointer or C++ 'this' pointer and as such it is not difficult to crash the JVM.
The abstraction of the underlying pointer by the java proxy classes far better fits the java programming paradigm.
<p>
<li>SWIG *does* know how to properly perform upcasting of objects in an inheritance
<li>SWIG <b>does</b> know how to properly perform upcasting of objects in an inheritance
hierarchy (including multiple inheritance). However Java classes can only derive from one base class so multiple inheritance
is not implemented. Java classes can implement more than one interface so there is scope for improvement in the future.
<p>
<li>A wide variety of C++ features are not currently supported by SWIG. Here is the
short and incomplete list:
<p>
<ul>
<li>Overloaded methods and functions. SWIG wrappers don't know how to resolve name
conflicts so you must give an alternative name to any overloaded method name using the
%name directive like this:
<blockquote>
<pre>
void foo(int a);
%name(foo2) void foo(double a, double b);
</pre>
</blockquote>
<p>
<li>Overloaded operators. Not supported at all. The only workaround for this is
to write a helper function. For example:
<blockquote>
<pre>
%inline %{
Vector *vector_add(Vector *a, Vector *b) {
... whatever ...
}
%}
</pre>
</blockquote>
<p>
<li>Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all).
</ul>
</ul>
<hr>

View file

@ -1,18 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
CXXSRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -4,15 +4,15 @@ CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -4,15 +4,15 @@ CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -55,7 +55,7 @@ public class runme {
// methods of all these instances are treated the same. For items 0, 1, and
// 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
// getPosition which resolves in Java. The call to getPosition is
// slightly different, however, because of the overidden getPosition() call, since
// slightly different, however, because of the overridden getPosition() call, since
// now the object reference has been "laundered" by passing through
// EmployeeList as an Employee*. Previously, Java resolved the call
// immediately in CEO, but now Java thinks the object is an instance of

View file

@ -4,15 +4,15 @@ SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -4,15 +4,15 @@ SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -132,7 +132,7 @@ InputName=example
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -java $(InputPath)
..\..\..\swig.exe -java "$(InputPath)"
# End Custom Build
@ -147,7 +147,7 @@ InputName=example
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -java $(InputPath)
..\..\..\swig.exe -java "$(InputPath)"
# End Custom Build

View file

@ -1,18 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS =
SRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -0,0 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean:
$(MAKE) -f $(TOP)/Makefile java_clean

View file

@ -0,0 +1,62 @@
#include "example.h"
int MotorCar::DesignOpinion::AceDesignCount = 0;
int MotorCar::DesignOpinion::TotalDesignCount = 0;
int MotorCar::DesignOpinion::PercentScore() {
return AceDesignCount*100/TotalDesignCount;
}
MotorCar::Wheels::Wheels(Shape shape, size_t count) : shape(shape), count(count) {}
MotorCar::WindScreen::WindScreen(bool opaque) : opaque(opaque) {}
MotorCar::MotorCar(const std::string &name, const Wheels &wheels, const WindScreen &windscreen) : name(name), wheels(wheels), windscreen(windscreen) {}
MotorCar MotorCar::DesignFromComponents(const std::string &name, const Wheels &wheels, const WindScreen &windscreen) {
MotorCar car = MotorCar(name, wheels, windscreen);
DesignOpinion::TotalDesignCount++;
if (car.wheels.Opinion().itrocks && car.windscreen.Opinion().itrocks)
DesignOpinion::AceDesignCount++;
return car;
}
MotorCar::DesignOpinion MotorCar::Wheels::Opinion() {
DesignOpinion opinion;
opinion.itrocks = true;
if (shape == Square) {
opinion.itrocks = false;
opinion.reason = "you'll have a few issues with wheel rotation";
}
if (count <= 2) {
opinion.reason += opinion.itrocks ? "" : " and ";
opinion.itrocks = false;
opinion.reason += "a few more wheels are needed for stability";
}
if (opinion.itrocks)
opinion.reason = "your choice of wheels was top notch";
return opinion;
}
MotorCar::DesignOpinion MotorCar::WindScreen::Opinion() {
DesignOpinion opinion;
opinion.itrocks = !opaque;
opinion.reason = opinion.itrocks ? "the driver will have a commanding view out the window" : "you can't see out the windscreen";
return opinion;
}
std::string MotorCar::WillItWork() {
DesignOpinion wh = wheels.Opinion();
DesignOpinion ws = windscreen.Opinion();
std::string willit;
if (wh.itrocks && ws.itrocks) {
willit = "Great car design because " + wh.reason + " and " + ws.reason;
} else {
willit = "You need a rethink because ";
willit += wh.itrocks ? "" : wh.reason;
willit += (!wh.itrocks && !ws.itrocks) ? " and " : "";
willit += ws.itrocks ? "" : ws.reason;
}
return willit;
}

View file

@ -0,0 +1,162 @@
# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=example - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "example.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "example - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Java compile post-build step
PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
# End Special Build Tool
!ELSEIF "$(CFG)" == "example - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Java compile post-build step
PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java
# End Special Build Tool
!ENDIF
# Begin Target
# Name "example - Win32 Debug"
# Name "example - Win32 Release"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\example.cxx
# End Source File
# Begin Source File
SOURCE=.\example_wrap.cxx
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\example.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\example.i
!IF "$(CFG)" == "example - Win32 Debug"
# Begin Custom Build
InputPath=.\example.i
InputName=example
"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
echo In order to function correctly, please ensure the following environment variables are correctly set:
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -c++ -java "$(InputPath)"
# End Custom Build
!ELSEIF "$(CFG)" == "example - Win32 Release"
# Begin Custom Build
InputPath=.\example.i
InputName=example
"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
echo In order to function correctly, please ensure the following environment variables are correctly set:
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -c++ -java "$(InputPath)"
# End Custom Build
!ENDIF
# End Source File
# End Target
# End Project

View file

@ -0,0 +1,48 @@
#include <string>
/** Design a motor car from various components */
struct MotorCar {
/** Information about an opinion of the design of a car component */
struct DesignOpinion {
bool itrocks;
std::string reason;
static int AceDesignCount;
static int TotalDesignCount;
static int PercentScore();
};
/** Wheels component */
struct Wheels {
enum Shape { Round, Square };
Wheels(Shape shape, size_t count);
DesignOpinion Opinion();
private:
Shape shape;
size_t count;
};
/** Windscreen component */
struct WindScreen {
WindScreen(bool opaque);
DesignOpinion Opinion();
private:
bool opaque;
};
/** Factory method for creating a car */
static MotorCar DesignFromComponents(const std::string &name, const Wheels &wheels, const WindScreen &windscreen);
std::string Name() {
return name;
}
/** Get an overall opinion on the car design */
std::string WillItWork();
private:
MotorCar(const std::string &name, const Wheels &wheels, const WindScreen &windscreen);
std::string name;
Wheels wheels;
WindScreen windscreen;
};

View file

@ -0,0 +1,13 @@
%module example
// This example shows how wrappers for numerous aspects of C++ nested classes work:
// Nested static and instance variables and methods and nested enums
%include <std_string.i>
%{
#include "example.h"
%}
%include "example.h"

View file

@ -0,0 +1,32 @@
// This example illustrates wrapping of nested C++ classes
public class runme {
static {
try {
System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
MotorCar car1 = MotorCar.DesignFromComponents("Bumpy", new MotorCar.Wheels(MotorCar.Wheels.Shape.Square, 4), new MotorCar.WindScreen(false));
MotorCar car2 = MotorCar.DesignFromComponents("Wobbly", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 2), new MotorCar.WindScreen(false));
MotorCar car3 = MotorCar.DesignFromComponents("Batty", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 4), new MotorCar.WindScreen(true));
MotorCar car4 = MotorCar.DesignFromComponents("Spiffing", new MotorCar.Wheels(MotorCar.Wheels.Shape.Round, 4), new MotorCar.WindScreen(false));
System.out.println("Expert opinion on " + car1.Name() + " : \n " + car1.WillItWork());
System.out.println("Expert opinion on " + car2.Name() + " : \n " + car2.WillItWork());
System.out.println("Expert opinion on " + car3.Name() + " : \n " + car3.WillItWork());
System.out.println("Expert opinion on " + car4.Name() + " : \n " + car4.WillItWork());
int count = MotorCar.DesignOpinion.getAceDesignCount();
int total = MotorCar.DesignOpinion.getTotalDesignCount();
int percent = MotorCar.DesignOpinion.PercentScore();
System.out.println("Overall opinion rating on car design is " + count + "/" + total + " = " + percent + "%");
System.out.println("Single square wheel thoughts: " + new MotorCar.Wheels(MotorCar.Wheels.Shape.Square, 1).Opinion().getReason());
}
}

View file

@ -4,15 +4,15 @@ SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -4,15 +4,15 @@ CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -4,15 +4,15 @@ SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -132,7 +132,7 @@ InputName=example
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -java $(InputPath)
..\..\..\swig.exe -java "$(InputPath)"
# End Custom Build
@ -147,7 +147,7 @@ InputName=example
echo JAVA_INCLUDE: %JAVA_INCLUDE%
echo JAVA_BIN: %JAVA_BIN%
echo on
..\..\..\swig.exe -java $(InputPath)
..\..\..\swig.exe -java "$(InputPath)"
# End Custom Build

View file

@ -1,18 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
CXXSRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -16,7 +16,7 @@ This example illustrates how C++ templates can be used from Java using SWIG.
<h2>The C++ Code</h2>
Lets take a templated function and a templated class as follows:
Let's take a templated function and a templated class as follows:
<blockquote>
<pre>

View file

@ -1,18 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS =
SRCS =
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -4,15 +4,15 @@ SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
JAVASRCS = *.java
all:: java
check: build
$(MAKE) -f $(TOP)/Makefile java_run
java::
build:
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
javac *.java
$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
clean::
clean:
$(MAKE) -f $(TOP)/Makefile java_clean
check: all

View file

@ -51,7 +51,7 @@ void print_vars() {
printf("dvar = %g\n", dvar);
printf("cvar = %c\n", cvar);
printf("strvar = %s\n", strvar ? strvar : "(null)");
printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
printf("cstrvar = %s\n", cstrvar);
printf("iptrvar = %p\n", iptrvar);
printf("name = %s\n", name);
printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);