Merged trunk up to revision 12551

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12552 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-03-24 05:46:05 +00:00
commit 93499e12af
160 changed files with 3204 additions and 1238 deletions

View file

@ -632,7 +632,7 @@ ocaml_static_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@ -643,13 +643,13 @@ ocaml_static_cpp: $(SRCS)
$(INTERFACE:%.i=%.cmo) \
$(PROGFILE:%.ml=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
-cclib "$(LIBS)" -cc '$(CXX)'
-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_static_cpp_toplevel: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@ -657,17 +657,17 @@ ocaml_static_cpp_toplevel: $(SRCS)
$(OCC) $(OCAMLPP) -c $(PROGFILE)
$(NOLINK) || $(OCAMLMKTOP) \
swig.cmo \
-I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
-I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
$(INTERFACE:%.i=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
-cclib "$(LIBS)" -cc '$(CXX)'
-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_dynamic_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
@ -684,7 +684,7 @@ ocaml_dynamic_cpp: $(SRCS)
$(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
-o $(TARGET) \
-package dl -linkpkg \
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
ocaml_clean:
rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
@ -781,7 +781,7 @@ PHP=@PHP@
PHPSCRIPT ?= runme.php
php_run:
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
$(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
# -----------------------------------------------------------------
# Cleaning the PHP examples

View file

@ -32,7 +32,7 @@ func main() {
// Now try the typemap library
// Now it is no longer necessary to manufacture pointers.
// Instead we use a single element array which in Java is modifiable.
// Instead we use a single element slice which in Go is modifiable.
fmt.Println("Trying the typemap library")
r := []int{0}

View file

@ -1,4 +1,8 @@
/* File : example.i */
%module example
%{
extern "C" void factor(int &x, int &y);
%}
extern "C" void factor(int &x, int &y);

View file

@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
}
double volume::depth( double x, double y ) { return 0.0; }
volume::~volume() { }

View file

@ -9,7 +9,8 @@ public:
class volume {
public:
virtual double depth( double x, double y );
virtual double depth( double x, double y );
virtual ~volume();
};
extern void draw_shape_coverage( shape *s, int div_x, int div_y );

View file

@ -1,3 +1,9 @@
--- New ---
It's not possible to access std::(w)string at the moment as it breaks other string examples.
--- Old ---
This example shows how to use both std::string and std::wstring in Ocaml,
and also demonstrates that one might use this to make a locale-obedient
Ocaml program.

View file

@ -1,14 +1,18 @@
/* -*- mode: c++ -*- */
/* File : example.h -- Tests all string typemaps */
#include <sys/time.h>
#include <time.h>
void takes_std_string( std::string in ) {
cout << "takes_std_string( \"" << in << "\" );" << endl;
}
std::string gives_std_string() {
time_t t;
return std::string( asctime( localtime( &t ) ) );
struct timeval tv;
gettimeofday(&tv, NULL);
return std::string( asctime( localtime( &tv.tv_sec ) ) );
}
void takes_char_ptr( char *p ) {
@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
inout.insert( inout.end(), ']' );
}
void takes_and_gives_char_ptr( char *&ptr ) {
char *pout = strchr( ptr, '.' );
if( pout ) ptr = pout + 1;
else ptr = "foo";
void takes_and_gives_char_ptr( char *&inout ) {
char *pout = strchr( inout, '.' );
if( pout ) inout = pout + 1;
else inout = "foo";
}
/*

View file

@ -148,6 +148,7 @@ CPP_TEST_CASES += \
cpp_static \
cpp_typedef \
default_args \
default_arg_values \
default_constructor \
defvalue_constructor \
derived_byvalue \
@ -268,6 +269,7 @@ CPP_TEST_CASES += \
overload_copy \
overload_extend \
overload_rename \
overload_return_type \
overload_simple \
overload_subtype \
overload_template \
@ -287,6 +289,7 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
rename_simple \
rename_strip_encoder \
rename_pcre_encoder \
rename_pcre_enum \
@ -311,6 +314,7 @@ CPP_TEST_CASES += \
smart_pointer_rename \
smart_pointer_simple \
smart_pointer_static \
smart_pointer_template_const_overload \
smart_pointer_templatemethods \
smart_pointer_templatevariables \
smart_pointer_typedef \
@ -428,6 +432,7 @@ CPP_TEST_CASES += \
valuewrapper_const \
valuewrapper_opaque \
varargs \
varargs_overload \
virtual_destructor \
virtual_poly \
voidtest \
@ -492,6 +497,8 @@ C_TEST_CASES += \
overload_extendc \
preproc \
preproc_constants_c \
preproc_defined \
preproc_include \
preproc_line_file \
ret_by_value \
simple_array \
@ -516,6 +523,7 @@ MULTI_CPP_TEST_CASES += \
# Custom tests - tests with additional commandline options
wallkw.cpptest: SWIGOPT += -Wallkw
preproc_include.ctest: SWIGOPT += -includeall
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \

View file

@ -8,6 +8,12 @@
%newobject Bar::testFoo;
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
#endif
%}
%inline %{
class Foo {

View file

@ -64,12 +64,13 @@ setup = \
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \

View file

@ -68,6 +68,7 @@ public class li_std_map_runme {
{
IList<string> keys = new List<string>(simap.Keys);
IList<int> values = new List<int>(simap.Values);
Dictionary<string, int> check = new Dictionary<string, int>();
if (keys.Count != collectionSize)
throw new Exception("Keys count test failed");
@ -78,6 +79,13 @@ public class li_std_map_runme {
{
if (simap[keys[i]] != values[i])
throw new Exception("Keys and values test failed for index " + i);
check.Add(keys[i], values[i]);
}
for (int i = 0; i < collectionSize; i++)
{
if (!check.ContainsKey(i.ToString()))
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
}
}

View file

@ -2,7 +2,7 @@ using System;
public class runme
{
static void Main()
static void Main()
{
// constructors and destructors
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
@ -62,7 +62,7 @@ public class runme
throw new ApplicationException("Transmission2 wrong");
// turn feature off / ignoring
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
nspaceNamespace.Outer.namespce ns = new nspaceNamespace.Outer.namespce();
ns.Dispose();
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
nons.Dispose();

View file

@ -0,0 +1,30 @@
using System;
using rename_simpleNamespace;
public class rename_simple_runme {
public static void Main() {
NewStruct s = new NewStruct();
check(111, s.NewInstanceVariable, "NewInstanceVariable");
check(222, s.NewInstanceMethod(), "NewInstanceMethod");
check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
check(555, rename_simple.NewFunction(), "NewFunction");
check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
s.NewInstanceVariable = 1111;
NewStruct.NewStaticVariable = 4444;
rename_simple.NewGlobalVariable = 6666;
check(1111, s.NewInstanceVariable, "NewInstanceVariable");
check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
}
public static void check(int expected, int actual, string msg) {
if (expected != actual)
throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
}
}

View file

@ -65,13 +65,13 @@ run_testcase = \
cd $*$(VERSIONSUFFIX) && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
DFLAGS='-of$*_runme' \
DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) $*/*.d' d_compile && \
DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) `find $* -name *.d`' d_compile && \
env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \
else \
cd $*$(VERSIONSUFFIX) && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
DFLAGS='-c' \
DSRCS='$*/*.d' d_compile && cd .. ; \
DSRCS='`find $* -name *.d`' d_compile && cd .. ; \
fi
# Clean: remove testcase directories

View file

@ -44,10 +44,10 @@ void main() {
enforce(!canFind!`a == 20 * 10`(vector[]), "canFind test 4 failed");
foreach (i, _; vector) {
enforce(indexOf(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
enforce(countUntil(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
}
enforce(indexOf(vector[], 42) == -1, "non-existant item indexOf test failed");
enforce(countUntil(vector[], 42) == -1, "non-existant item indexOf test failed");
vector.clear();
enforce(vector.length == 0, "clear test failed");

View file

@ -0,0 +1,32 @@
module nspace_extend_runme;
static import oi1c = nspace_extend.Outer.Inner1.Color;
static import oi2c = nspace_extend.Outer.Inner2.Color;
void main() {
{
// constructors and destructors
scope color1 = new oi1c.Color();
scope color = new oi1c.Color(color1);
// class methods
color.colorInstanceMethod(20.0);
oi1c.Color.colorStaticMethod(20.0);
auto created = oi1c.Color.create();
}
{
// constructors and destructors
scope color2 = new oi2c.Color();
scope color = new oi2c.Color(color2);
// class methods
color.colorInstanceMethod(20.0);
oi2c.Color.colorStaticMethod(20.0);
auto created = oi2c.Color.create();
// Same class different namespaces
auto col1 = new oi1c.Color();
auto col2 = oi2c.Color.create();
col2.colors(col1, col1, col2, col2, col2);
}
}

View file

@ -0,0 +1,32 @@
module nspace_extend_runme;
static import oi1c = nspace_extend.Outer.Inner1.Color;
static import oi2c = nspace_extend.Outer.Inner2.Color;
void main() {
{
// constructors and destructors
scope color1 = new oi1c.Color();
scope color = new oi1c.Color(color1);
// class methods
color.colorInstanceMethod(20.0);
oi1c.Color.colorStaticMethod(20.0);
auto created = oi1c.Color.create();
}
{
// constructors and destructors
scope color2 = new oi2c.Color();
scope color = new oi2c.Color(color2);
// class methods
color.colorInstanceMethod(20.0);
oi2c.Color.colorStaticMethod(20.0);
auto created = oi2c.Color.create();
// Same class different namespaces
auto col1 = new oi1c.Color();
auto col2 = oi2c.Color.create();
col2.colors(col1, col1, col2, col2, col2);
}
}

View file

@ -0,0 +1,87 @@
module nspace_runme;
import nspace.nspace;
static import nspace.NoNSpacePlease;
static import nspace.Outer.namespce;
static import nspace.Outer.Inner1.Channel;
static import oi1c = nspace.Outer.Inner1.Color;
static import nspace.Outer.Inner2.Channel;
static import nspace.Outer.Inner2.Color;
static import nspace.Outer.Inner3.Blue;
static import nspace.Outer.Inner4.Blue;
static import nspace.Outer.SomeClass;
void main() {
// constructors and destructors
auto color1 = new oi1c.Color();
auto color = new oi1c.Color(color1);
// class methods
color.colorInstanceMethod(20.0);
oi1c.Color.colorStaticMethod(20.0);
auto created = oi1c.Color.create();
// class enums
auto someClass = new nspace.Outer.SomeClass.SomeClass();
auto channel = someClass.GetInner1ColorChannel();
if (channel != oi1c.Color.Channel.Transmission) {
throw new Exception("Transmission wrong");
}
// class anonymous enums
int val1 = oi1c.Color.ColorEnumVal1;
int val2 = oi1c.Color.ColorEnumVal2;
if (val1 != 0 || val2 != 0x22) {
throw new Exception("ColorEnumVal wrong");
}
// instance member variables
color.instanceMemberVariable = 123;
if (color.instanceMemberVariable != 123) {
throw new Exception("instance member variable failed");
}
// static member variables
oi1c.Color.staticMemberVariable = 789;
if (oi1c.Color.staticMemberVariable != 789) {
throw new Exception("static member variable failed");
}
if (oi1c.Color.staticConstMemberVariable != 222) {
throw new Exception("static const member variable failed");
}
if (oi1c.Color.staticConstEnumMemberVariable != oi1c.Color.Channel.Transmission) {
throw new Exception("static const enum member variable failed");
}
// check globals in a namespace don't get mangled with the nspace option
nspace.nspace.namespaceFunction(color);
nspace.nspace.namespaceVar = 111;
if (nspace.nspace.namespaceVar != 111) {
throw new Exception("global var failed");
}
// Same class different namespaces
auto col1 = new oi1c.Color();
auto col2 = nspace.Outer.Inner2.Color.Color.create();
col2.colors(col1, col1, col2, col2, col2);
// global enums
auto outerChannel1 = someClass.GetInner1Channel();
if (outerChannel1 != nspace.Outer.Inner1.Channel.Channel.Transmission1) {
throw new Exception("Transmission1 wrong");
}
auto outerChannel2 = someClass.GetInner2Channel();
if (outerChannel2 != nspace.Outer.Inner2.Channel.Channel.Transmission2) {
throw new Exception("Transmission2 wrong");
}
// turn feature off / ignoring
auto ns = new nspace.Outer.namespce.namespce();
auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();
// Derived class
auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
blue3.blueInstanceMethod();
auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
blue4.blueInstanceMethod();
}

View file

@ -0,0 +1,77 @@
module nspace_runme;
import std.exception;
import nspace.nspace;
static import nspace.NoNSpacePlease;
static import nspace.Outer.namespce;
static import nspace.Outer.Inner1.Channel;
static import oi1c = nspace.Outer.Inner1.Color;
static import nspace.Outer.Inner2.Channel;
static import nspace.Outer.Inner2.Color;
static import nspace.Outer.Inner3.Blue;
static import nspace.Outer.Inner4.Blue;
static import nspace.Outer.SomeClass;
void main() {
// constructors and destructors
auto color1 = new oi1c.Color();
auto color = new oi1c.Color(color1);
// class methods
color.colorInstanceMethod(20.0);
oi1c.Color.colorStaticMethod(20.0);
auto created = oi1c.Color.create();
// class enums
auto someClass = new nspace.Outer.SomeClass.SomeClass();
auto channel = someClass.GetInner1ColorChannel();
enforce(channel == oi1c.Color.Channel.Transmission,
"Transmission wrong");
// class anonymous enums
int val1 = oi1c.Color.ColorEnumVal1;
int val2 = oi1c.Color.ColorEnumVal2;
enforce(val1 == 0 && val2 == 0x22, "ColorEnumVal wrong");
// instance member variables
color.instanceMemberVariable = 123;
enforce(color.instanceMemberVariable == 123,
"instance member variable failed");
// static member variables
oi1c.Color.staticMemberVariable = 789;
enforce(oi1c.Color.staticMemberVariable == 789,
"static member variable failed");
enforce(oi1c.Color.staticConstMemberVariable == 222,
"static const member variable failed");
enforce(oi1c.Color.staticConstEnumMemberVariable == oi1c.Color.Channel.Transmission,
"static const enum member variable failed");
// check globals in a namespace don't get mangled with the nspace option
nspace.nspace.namespaceFunction(color);
nspace.nspace.namespaceVar = 111;
enforce(nspace.nspace.namespaceVar == 111, "global var failed");
// Same class different namespaces
auto col1 = new oi1c.Color();
auto col2 = nspace.Outer.Inner2.Color.Color.create();
col2.colors(col1, col1, col2, col2, col2);
// global enums
auto outerChannel1 = someClass.GetInner1Channel();
enforce(outerChannel1 == nspace.Outer.Inner1.Channel.Channel.Transmission1,
"Transmission1 wrong");
auto outerChannel2 = someClass.GetInner2Channel();
enforce(outerChannel2 == nspace.Outer.Inner2.Channel.Channel.Transmission2,
"Transmission2 wrong");
// turn feature off / ignoring
auto ns = new nspace.Outer.namespce.namespce();
auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();
// Derived class
auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
blue3.blueInstanceMethod();
auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
blue4.blueInstanceMethod();
}

View file

@ -0,0 +1,18 @@
%module default_arg_values
%{
struct Display {
// Some compilers warn about 'float v = NULL', so only SWIG sees this peculiarity
// Bad Python wrappers were being generated when NULL used for primitive type
float draw1(float v = 0) { return v; }
float draw2(float *v = 0) { return v ? *v : 0; }
};
float* createPtr(float v) { static float val; val = v; return &val; }
%}
struct Display {
// Bad Python wrappers were being generated when NULL used for primitive type
float draw1(float v = NULL) { return v; }
float draw2(float *v = NULL) { return v ? *v : 0; }
};
float* createPtr(float v) { static float val; val = v; return &val; }

View file

@ -10,6 +10,12 @@
%include "std_string.i"
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, hidevf)
#endif
%}
%inline %{
#include <cstdio>
#include <iostream>

View file

@ -0,0 +1,13 @@
%module xxx
void check(const int *v) {}
void check(int *v) {}
void check(int &v) {}
void check(const int &v) {} // note: no warning as marshalled by value
struct OverStruct {};
void check(const OverStruct *v) {}
void check(OverStruct *v) {}
void check(OverStruct &v) {}
void check(const OverStruct &v) {}

View file

@ -0,0 +1,4 @@
%module cpp_recursive_typedef
typedef std::set<pds> pds;

View file

@ -69,7 +69,7 @@ c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
No module name specified using %module or -module.
:::::::::::::::::::::::::::::::: pp_badeval.i :::::::::::::::::::::::::::::::::::
pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+'
pp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+'
pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
:::::::::::::::::::::::::::::::: pp_constant.i :::::::::::::::::::::::::::::::::::
@ -84,13 +84,12 @@ pp_constant.i:49: Warning 305: Bad constant value (ignored).
:::::::::::::::::::::::::::::::: pp_defined.i :::::::::::::::::::::::::::::::::::
pp_defined.i:6: Error: No arguments given to defined()
pp_defined.i:6: Warning 202: Could not evaluate 'defined'
pp_defined.i:6: Warning 202: Error: 'Expected an expression'
pp_defined.i:6: Error: Missing expression for #if.
:::::::::::::::::::::::::::::::: pp_deprecated.i :::::::::::::::::::::::::::::::::::
pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
pp_deprecated.i:4: Error: Unable to find 'ext;'
pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning
pp_deprecated.i:6: Warning 204: CPP #warning, "Print this warning".
pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
@ -119,6 +118,20 @@ pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *).
pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo'
pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3).
:::::::::::::::::::::::::::::::: pp_macro_missing_expression.i :::::::::::::::::::::::::::::::::::
pp_macro_missing_expression.i:4: Error: Missing identifier for #ifdef.
pp_macro_missing_expression.i:7: Error: Missing identifier for #ifndef.
pp_macro_missing_expression.i:10: Error: Missing expression for #if.
pp_macro_missing_expression.i:14: Error: Missing expression for #elif.
pp_macro_missing_expression.i:21: Error: Missing expression for #elif.
:::::::::::::::::::::::::::::::: pp_macro_unexpected_tokens.i :::::::::::::::::::::::::::::::::::
pp_macro_unexpected_tokens.i:5: Warning 206: Unexpected tokens after #endif directive.
pp_macro_unexpected_tokens.i:8: Warning 206: Unexpected tokens after #endif directive.
pp_macro_unexpected_tokens.i:11: Warning 206: Unexpected tokens after #else directive.
pp_macro_unexpected_tokens.i:18: Warning 206: Unexpected tokens after #endif directive.
pp_macro_unexpected_tokens.i:21: Warning 206: Unexpected tokens after #else directive.
:::::::::::::::::::::::::::::::: pp_macro_nargs.i :::::::::::::::::::::::::::::::::::
pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments
@ -227,8 +240,8 @@ cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one
cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
cpp_macro_locator.i:96: Warning 204: CPP #warning, "an inline warning message 2".
cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).
@ -275,12 +288,27 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
:::::::::::::::::::::::::::::::: cpp_overload.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_overload_const.i :::::::::::::::::::::::::::::::::::
cpp_overload_const.i:4: Warning 509: Overloaded method check(int *) effectively ignored,
cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *).
cpp_overload_const.i:5: Warning 509: Overloaded method check(int &) effectively ignored,
cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *).
cpp_overload_const.i:10: Warning 509: Overloaded method check(OverStruct *) effectively ignored,
cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
cpp_overload_const.i:11: Warning 509: Overloaded method check(OverStruct &) effectively ignored,
cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
cpp_overload_const.i:12: Warning 509: Overloaded method check(OverStruct const &) effectively ignored,
cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored).
cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored).
:::::::::::::::::::::::::::::::: cpp_recursive_typedef.i :::::::::::::::::::::::::::::::::::
:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
:::::::::::::::::::::::::::::::: cpp_shared_ptr.i :::::::::::::::::::::::::::::::::::
cpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer.
cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer.

View file

@ -36,6 +36,8 @@ pp_macro_defined_unterminated
pp_macro_expansion
pp_macro_expansion_multiline
pp_macro_inline_unterminated
pp_macro_missing_expression
pp_macro_unexpected_tokens
pp_macro_nargs
pp_macro_redef
pp_macro_rparen
@ -74,8 +76,10 @@ cpp_nested
cpp_no_access
cpp_nobase
cpp_overload
cpp_overload_const
cpp_private_defvalue
cpp_private_inherit
cpp_recursive_typedef
cpp_shared_ptr
cpp_template_argname
cpp_template_nargs

View file

@ -0,0 +1,22 @@
// Test "Missing identifier for ..." errrors
%module xxx
#ifdef
#endif
#ifndef
#endif
#if
#endif
#if defined(AAA)
#elif
#endif
#define BBB
#if !defined(BBB)
#elif
#endif

View file

@ -0,0 +1,23 @@
// Test "Unexpected tokens after ..." errors
%module xxx
#ifndef AAA
#endif rubbish
#ifdef AAA
#endif rubbish
#ifdef AAA
#else rubbish
#endif
#define BBB
#ifdef BBB
#else
#endif rubbish
#if !defined(BBB)
#else rubbish
#endif

View file

@ -1,5 +1,11 @@
%module funcptr_cpp
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
#endif
%}
%inline %{
int addByValue(const int &a, int b) { return a+b; }

View file

@ -8,7 +8,7 @@ typedef int Integer;
return x;
}
::Integer bar() {
::Integer bar_fn() {
return 1;
}

View file

@ -6,9 +6,9 @@ func main() {
defaults1 := NewDefaults1(1000)
defaults1 = NewDefaults1()
if defaults1.Ret(float64(10.0)) != 10.0 {
println(1, defaults1.Ret(float64(10.0)))
panic(defaults1.Ret(float64(10.0)))
if defaults1.Ret(10.0) != 10.0 {
println(1, defaults1.Ret(10.0))
panic(defaults1.Ret(10.0))
}
if defaults1.Ret() != -1.0 {
@ -19,8 +19,8 @@ func main() {
defaults2 := NewDefaults2(1000)
defaults2 = NewDefaults2()
if defaults2.Ret(float64(10.0)) != 10.0 {
panic(defaults2.Ret(float64(10.0)))
if defaults2.Ret(10.0) != 10.0 {
panic(defaults2.Ret(10.0))
}
if defaults2.Ret() != -1.0 {

View file

@ -0,0 +1,10 @@
package main
import . "./director_alternating"
func main() {
id := GetBar().Id()
if id != IdFromGetBar() {
panic(id)
}
}

View file

@ -15,11 +15,17 @@ func (p *FooBar2) Pang() string {
return "FooBar2::pang();"
}
type FooBar3 struct{} // From Bar
func (p *FooBar3) Cheer() string {
return "FooBar3::cheer();"
}
func main() {
b := NewBar()
f := b.Create()
fb := NewDirectorBar(&FooBar{})
fb2 := NewDirectorBar(&FooBar2{})
fb3 := NewDirectorBar(&FooBar3{})
s := fb.Used()
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" {
@ -45,4 +51,23 @@ func main() {
if s != "Bar::pong();Foo::pong();FooBar::ping();" {
panic(0)
}
s = fb3.DirectorInterface().(*FooBar3).Cheer()
if s != "FooBar3::cheer();" {
panic(s)
}
if fb2.Callping() != "FooBar2::ping();" {
panic("bad fb2.callping")
}
if fb2.Callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" {
panic("bad fb2.callcheer")
}
if fb3.Callping() != "Bar::ping();" {
panic("bad fb3.callping")
}
if fb3.Callcheer() != "FooBar3::cheer();" {
panic("bad fb3.callcheer")
}
}

View file

@ -12,7 +12,7 @@ func main() {
foo.Spam(1, 1)
foo.Spam(1, 1, 1)
foo.Spam(extend_placement.NewFoo())
foo.Spam(extend_placement.NewFoo(), float64(1.0))
foo.Spam(extend_placement.NewFoo(), 1.0)
bar := extend_placement.NewBar()
bar = extend_placement.NewBar(1)
@ -22,7 +22,7 @@ func main() {
bar.Spam(1, 1)
bar.Spam(1, 1, 1)
bar.Spam(extend_placement.NewBar())
bar.Spam(extend_placement.NewBar(), float64(1.0))
bar.Spam(extend_placement.NewBar(), 1.0)
footi := extend_placement.NewFooTi()
footi = extend_placement.NewFooTi(1)
@ -33,7 +33,7 @@ func main() {
footi.Spam(1, 1)
footi.Spam(1, 1, 1)
footi.Spam(extend_placement.NewFoo())
footi.Spam(extend_placement.NewFoo(), float64(1.0))
footi.Spam(extend_placement.NewFoo(), 1.0)
barti := extend_placement.NewBarTi()
barti = extend_placement.NewBarTi(1)
@ -43,5 +43,5 @@ func main() {
barti.Spam(1, 1)
barti.Spam(1, 1, 1)
barti.Spam(extend_placement.NewBar())
barti.Spam(extend_placement.NewBar(), float64(1.0))
barti.Spam(extend_placement.NewBar(), 1.0)
}

View file

@ -38,8 +38,8 @@ func main() {
panic(0)
}
friends.Set(di, float64(4.0))
friends.Set(dd, float64(1.3))
friends.Set(di, 4.0)
friends.Set(dd, 1.3)
if friends.Get_val1(di).(float64) != 4 {
panic(0)

View file

@ -4,5 +4,5 @@ import . "./global_ns_arg"
func main() {
Foo(1)
Bar()
Bar_fn()
}

View file

@ -51,7 +51,7 @@ func main() {
panic(0)
}
c := cmplx(float64(2), float64(3))
c := complex(2, 3)
r := real(c)
if Ctest1(c) != r {

View file

@ -16,7 +16,7 @@ func main() {
if f.Test(float64(3), float64(2)).(float64) != 5 {
panic(0)
}
if f.Test(float64(3.0)).(float64) != 1003 {
if f.Test(3.0).(float64) != 1003 {
panic(0)
}
}

View file

@ -10,7 +10,7 @@ func main() {
if f.Test("hello") != 2 {
panic(0)
}
if f.Test(float64(3.5), float64(2.5)) != 3 {
if f.Test(3.5, 2.5) != 3 {
panic(0)
}
if f.Test("hello", 20) != 1020 {

View file

@ -7,7 +7,7 @@ func main() {
panic("foo(int)")
}
if Foo(float64(3.0)) != "foo:double" {
if Foo(3.0) != "foo:double" {
panic("foo(double)")
}
@ -37,7 +37,7 @@ func main() {
panic("Spam::foo(int)")
}
if s.Foo(float64(3.0)) != "foo:double" {
if s.Foo(3.0) != "foo:double" {
panic("Spam::foo(double)")
}
@ -61,7 +61,7 @@ func main() {
panic("Spam::bar(int)")
}
if SpamBar(float64(3.0)) != "bar:double" {
if SpamBar(3.0) != "bar:double" {
panic("Spam::bar(double)")
}
@ -93,7 +93,7 @@ func main() {
panic("Spam(int)")
}
s = NewSpam(float64(3.4))
s = NewSpam(3.4)
if s.GetXtype() != "double" {
panic("Spam(double)")
}

View file

@ -6,18 +6,18 @@ func main() {
_ = Foo()
_ = Maximum(3, 4)
_ = Maximum(float64(3.4), float64(5.2))
_ = Maximum(3.4, 5.2)
// mix 1
if Mix1("hi") != 101 {
panic("mix1(const char*)")
}
if Mix1(float64(1.0), float64(1.0)) != 102 {
if Mix1(1.0, 1.0) != 102 {
panic("mix1(double, const double &)")
}
if Mix1(float64(1.0)) != 103 {
if Mix1(1.0) != 103 {
panic("mix1(double)")
}
@ -26,11 +26,11 @@ func main() {
panic("mix2(const char*)")
}
if Mix2(float64(1.0), float64(1.0)) != 102 {
if Mix2(1.0, 1.0) != 102 {
panic("mix2(double, const double &)")
}
if Mix2(float64(1.0)) != 103 {
if Mix2(1.0) != 103 {
panic("mix2(double)")
}
@ -39,11 +39,11 @@ func main() {
panic("mix3(const char*)")
}
if Mix3(float64(1.0), float64(1.0)) != 102 {
if Mix3(1.0, 1.0) != 102 {
panic("mix3(double, const double &)")
}
if Mix3(float64(1.0)) != 103 {
if Mix3(1.0) != 103 {
panic("mix3(double)")
}
@ -52,12 +52,12 @@ func main() {
panic("overtparams1(int)")
}
if Overtparams1(float64(100.0), 100) != 20 {
if Overtparams1(100.0, 100) != 20 {
panic("overtparams1(double, int)")
}
// Combination 2
if Overtparams2(float64(100.0), 100) != 40 {
if Overtparams2(100.0, 100) != 40 {
panic("overtparams2(double, int)")
}
@ -66,7 +66,7 @@ func main() {
panic("overloaded()")
}
if Overloaded(float64(100.0), 100) != 70 {
if Overloaded(100.0, 100) != 70 {
panic("overloaded(double, int)")
}
@ -84,7 +84,7 @@ func main() {
panic("specialization(int)")
}
if Specialization(float64(10.0)) != 203 {
if Specialization(10.0) != 203 {
panic("specialization(double)")
}
@ -92,7 +92,7 @@ func main() {
panic("specialization(int, int)")
}
if Specialization(float64(10.0), float64(10.0)) != 205 {
if Specialization(10.0, 10.0) != 205 {
panic("specialization(double, double)")
}
@ -135,7 +135,7 @@ func main() {
panic("overload(Klass t, const char *)")
}
if Overload(float64(10.0), "hi") != 40 {
if Overload(10.0, "hi") != 40 {
panic("overload(double t, const char *)")
}
@ -173,7 +173,7 @@ func main() {
panic("nsoverload(Klass t, const char *)")
}
if Nsoverload(float64(10.0), "hi") != 1040 {
if Nsoverload(10.0, "hi") != 1040 {
panic("nsoverload(double t, const char *)")
}

View file

@ -6,18 +6,18 @@ func main() {
_ = Foo()
_ = Maximum(3, 4)
_ = Maximum(float64(3.4), float64(5.2))
_ = Maximum(3.4, 5.2)
// mix 1
if Mix1("hi") != 101 {
panic("mix1(const char*)")
}
if Mix1(float64(1.0), float64(1.0)) != 102 {
if Mix1(1.0, 1.0) != 102 {
panic("mix1(double, const double &)")
}
if Mix1(float64(1.0)) != 103 {
if Mix1(1.0) != 103 {
panic("mix1(double)")
}
@ -26,11 +26,11 @@ func main() {
panic("mix2(const char*)")
}
if Mix2(float64(1.0), float64(1.0)) != 102 {
if Mix2(1.0, 1.0) != 102 {
panic("mix2(double, const double &)")
}
if Mix2(float64(1.0)) != 103 {
if Mix2(1.0) != 103 {
panic("mix2(double)")
}
@ -39,11 +39,11 @@ func main() {
panic("mix3(const char*)")
}
if Mix3(float64(1.0), float64(1.0)) != 102 {
if Mix3(1.0, 1.0) != 102 {
panic("mix3(double, const double &)")
}
if Mix3(float64(1.0)) != 103 {
if Mix3(1.0) != 103 {
panic("mix3(double)")
}
@ -52,12 +52,12 @@ func main() {
panic("overtparams1(int)")
}
if Overtparams1(float64(100.0), 100) != 20 {
if Overtparams1(100.0, 100) != 20 {
panic("overtparams1(double, int)")
}
// Combination 2
if Overtparams2(float64(100.0), 100) != 40 {
if Overtparams2(100.0, 100) != 40 {
panic("overtparams2(double, int)")
}
@ -66,7 +66,7 @@ func main() {
panic("overloaded()")
}
if Overloaded(float64(100.0), 100) != 70 {
if Overloaded(100.0, 100) != 70 {
panic("overloaded(double, int)")
}
@ -84,7 +84,7 @@ func main() {
panic("specialization(int)")
}
if Specialization(float64(10.0)) != 203 {
if Specialization(10.0) != 203 {
panic("specialization(double)")
}
@ -92,7 +92,7 @@ func main() {
panic("specialization(int, int)")
}
if Specialization(float64(10.0), float64(10.0)) != 205 {
if Specialization(10.0, 10.0) != 205 {
panic("specialization(double, double)")
}
@ -136,7 +136,7 @@ func main() {
panic("overload(Klass t, const char *)")
}
if Overload(float64(10.0), "hi") != 40 {
if Overload(10.0, "hi") != 40 {
panic("overload(double t, const char *)")
}
@ -174,7 +174,7 @@ func main() {
panic("nsoverload(Klass t, const char *)")
}
if Nsoverload(float64(10.0), "hi") != 1040 {
if Nsoverload(10.0, "hi") != 1040 {
panic("nsoverload(double t, const char *)")
}

View file

@ -0,0 +1,29 @@
package main
import "fmt"
import . "./rename_simple"
func main() {
s := NewNewStruct()
check(111, s.GetNewInstanceVariable(), "NewInstanceVariable")
check(222, s.NewInstanceMethod(), "NewInstanceMethod")
check(333, NewStructNewStaticMethod(), "NewStaticMethod")
check(444, GetNewStructNewStaticVariable(), "NewStaticVariable")
check(555, NewFunction(), "NewFunction")
check(666, GetNewGlobalVariable(), "NewGlobalVariable")
s.SetNewInstanceVariable(1111)
SetNewStructNewStaticVariable(4444)
SetNewGlobalVariable(6666)
check(1111, s.GetNewInstanceVariable(), "NewInstanceVariable")
check(4444, GetNewStructNewStaticVariable(), "NewStaticVariable")
check(6666, GetNewGlobalVariable(), "NewGlobalVariable")
}
func check(expected, actual int, msg string) {
if expected != actual {
panic("Failed: Expected: " + fmt.Sprint(expected) +
" actual: " + fmt.Sprint(actual) + " " + msg)
}
}

View file

@ -9,7 +9,7 @@ func main() {
if f.Test(3) != 1 {
panic(0)
}
if f.Test(float64(3.5)) != 2 {
if f.Test(3.5) != 2 {
panic(0)
}
if f.Test("hello") != 3 {
@ -19,7 +19,7 @@ func main() {
if b.Test(3) != 1 {
panic(0)
}
if b.Test(float64(3.5)) != 2 {
if b.Test(3.5) != 2 {
panic(0)
}
if b.Test("hello") != 3 {

View file

@ -7,7 +7,7 @@ func main() {
helloInt.Foo(template_default_arg.Hello_intHi)
x := template_default_arg.NewX_int()
if x.Meth(float64(20.0), 200).(int) != 200 {
if x.Meth(20.0, 200).(int) != 200 {
panic("X_int test 1 failed")
}
if x.Meth(20).(int) != 20 {
@ -18,7 +18,7 @@ func main() {
}
y := template_default_arg.NewY_unsigned()
if y.Meth(float64(20.0), uint(200)).(uint) != 200 {
if y.Meth(20.0, uint(200)).(uint) != 200 {
panic("Y_unsigned test 1 failed")
}
if y.Meth(uint(20)).(uint) != 20 {
@ -29,19 +29,19 @@ func main() {
}
_ = template_default_arg.NewX_longlong()
_ = template_default_arg.NewX_longlong(float64(20.0))
_ = template_default_arg.NewX_longlong(float64(20.0), int64(200))
_ = template_default_arg.NewX_longlong(20.0)
_ = template_default_arg.NewX_longlong(20.0, int64(200))
_ = template_default_arg.NewX_int()
_ = template_default_arg.NewX_int(float64(20.0))
_ = template_default_arg.NewX_int(float64(20.0), 200)
_ = template_default_arg.NewX_int(20.0)
_ = template_default_arg.NewX_int(20.0, 200)
_ = template_default_arg.NewX_hello_unsigned()
_ = template_default_arg.NewX_hello_unsigned(float64(20.0))
_ = template_default_arg.NewX_hello_unsigned(float64(20.0), template_default_arg.NewHello_int())
_ = template_default_arg.NewX_hello_unsigned(20.0)
_ = template_default_arg.NewX_hello_unsigned(20.0, template_default_arg.NewHello_int())
yy := template_default_arg.NewY_hello_unsigned()
yy.Meth(float64(20.0), template_default_arg.NewHello_int())
yy.Meth(20.0, template_default_arg.NewHello_int())
yy.Meth(template_default_arg.NewHello_int())
yy.Meth()
@ -97,7 +97,7 @@ func main() {
}
// %template(ott) ott<double>
if template_default_arg.Ott(template_default_arg.NewHello_int(), float64(1.0)) != 60 {
if template_default_arg.Ott(template_default_arg.NewHello_int(), 1.0) != 60 {
panic("ott test 12 failed")
}

View file

@ -13,7 +13,7 @@ func main() {
panic(0)
}
p3 := NewPairdd(float64(3.5), float64(2.5))
p3 := NewPairdd(3.5, 2.5)
p4 := NewPairdd(p3)
if p4.GetFirst() != 3.5 {

View file

@ -8,7 +8,7 @@ func main() {
panic("FooBar::blah(int)")
}
if f.Blah(float64(3.5)).(float64) != 3.5 {
if f.Blah(3.5) != 3.5 {
panic("FooBar::blah(double)")
}
@ -21,7 +21,7 @@ func main() {
panic("FooBar2::blah(int)")
}
if f2.Blah(float64(3.5)).(float64) != 3.5 {
if f2.Blah(3.5) != 3.5 {
panic("FooBar2::blah(double)")
}
@ -34,7 +34,7 @@ func main() {
panic("FooBar3::blah(int)")
}
if f3.Blah(float64(3.5)).(float64) != 3.5 {
if f3.Blah(3.5) != 3.5 {
panic("FooBar3::blah(double)")
}

View file

@ -8,7 +8,7 @@ func main() {
panic("blah(int)")
}
if f.Blah(float64(3.5)).(float64) != 3.5 {
if f.Blah(3.5) != 3.5 {
panic("blah(double)")
}
@ -20,7 +20,7 @@ func main() {
panic("blah(int,int)")
}
if f.Blah(float64(3.5), float64(7.5)).(float64) != (3.5 + 7.5) {
if f.Blah(3.5, 7.5) != (3.5 + 7.5) {
panic("blah(double,double)")
}

View file

@ -8,7 +8,7 @@ func main() {
panic("Bar::test(int)")
}
if b.Test(float64(3.5)).(float64) != 3.5 {
if b.Test(3.5).(float64) != 3.5 {
panic("Bar::test(double)")
}
@ -17,7 +17,7 @@ func main() {
panic("Bar2::test(int)")
}
if b2.Test(float64(3.5)).(float64) != 7.0 {
if b2.Test(3.5).(float64) != 7.0 {
panic("Bar2::test(double)")
}
@ -26,7 +26,7 @@ func main() {
panic("Bar3::test(int)")
}
if b3.Test(float64(3.5)).(float64) != 7.0 {
if b3.Test(3.5).(float64) != 7.0 {
panic("Bar3::test(double)")
}
@ -35,7 +35,7 @@ func main() {
panic("Bar4::test(int)")
}
if b4.Test(float64(3.5)).(float64) != 7.0 {
if b4.Test(3.5).(float64) != 7.0 {
panic("Bar4::test(double)")
}
@ -44,7 +44,7 @@ func main() {
panic("Fred1::test(int)")
}
if bf1.Test(float64(3.5)).(float64) != 7.0 {
if bf1.Test(3.5).(float64) != 7.0 {
panic("Fred1::test(double)")
}
@ -53,7 +53,7 @@ func main() {
panic("Fred2::test(int)")
}
if bf2.Test(float64(3.5)).(float64) != 7.0 {
if bf2.Test(3.5).(float64) != 7.0 {
panic("Fred2::test(double)")
}
}

View file

@ -0,0 +1,38 @@
package main
import "./varargs_overload"
func main() {
if varargs_overload.Vararg_over1("Hello") != "Hello" {
panic(0)
}
if varargs_overload.Vararg_over1(2) != "2" {
panic(1)
}
if varargs_overload.Vararg_over2("Hello") != "Hello" {
panic(2)
}
if varargs_overload.Vararg_over2(2, 2.2) != "2 2.2" {
panic(3)
}
if varargs_overload.Vararg_over3("Hello") != "Hello" {
panic(4)
}
if varargs_overload.Vararg_over3(2, 2.2, "hey") != "2 2.2 hey" {
panic(5)
}
if varargs_overload.Vararg_over4("Hello") != "Hello" {
panic(6)
}
if varargs_overload.Vararg_over4(123) != "123" {
panic(7)
}
if varargs_overload.Vararg_over4("Hello", 123) != "Hello" {
panic(8)
}
}

View file

@ -68,7 +68,7 @@ public class nspace_runme {
throw new RuntimeException("Transmission2 wrong");
// turn feature off / ignoring
nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace();
nspacePackage.Outer.namespce ns = new nspacePackage.Outer.namespce();
nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease();
// Derived class

View file

@ -1,5 +1,11 @@
%module li_std_stream
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
#endif
%}
%inline %{
struct A;
%}

View file

@ -1,5 +1,11 @@
%module li_std_wstream
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
#endif
%}
%inline %{
struct A;
%}
@ -49,6 +55,7 @@
%}
%extend std::basic_ostream<wchar_t>{
extern "C"
std::basic_ostream<wchar_t>&
operator<<(const A& a)
{

View file

@ -1,5 +1,13 @@
%module member_funcptr_galore
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
#endif
%}
%inline %{
namespace FunkSpace {
@ -50,6 +58,10 @@ double (Space::Shape::*areapt(Space::Shape &ref, int & (FunkSpace::Funktions::*d
return &Space::Shape::area;
}
double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) {
return 0;
}
double (Space::Shape::*abcpt())(Thing<short>, Thing< const Space::Shape * >[]) {
return &Space::Shape::abc;
}

View file

@ -1,5 +1,13 @@
%module member_pointer
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
#endif
%}
%inline %{
class Shape {
public:

View file

@ -1,4 +1,11 @@
%module namespace_spaces
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
#endif
%}
%inline %{
class Foo {

View file

@ -39,6 +39,8 @@ struct Outer {
};
///////////////////////////////////////////
#ifdef SWIG
/* some compilers do not accept these */
class {
public:
Integer a;
@ -47,6 +49,7 @@ struct Outer {
struct {
Integer b;
};
#endif
union {
Integer c;
@ -151,6 +154,8 @@ struct Outer {
Integer xx;
} MultipleInstanceAnonDerived1, MultipleInstanceAnonDerived2, *MultipleInstanceAnonDerived3, MultipleInstanceAnonDerived4[2];
#ifdef SWIG
/* some compilers do not accept these */
struct : public InnerMultiple {
Integer xx;
};
@ -159,6 +164,7 @@ struct Outer {
public:
Integer yy;
};
#endif
///////////////////////////////////////////
typedef struct {

View file

@ -2,7 +2,7 @@
%module nspace
// nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
%nspace;
%nonspace Outer::Inner2::NoNSpacePlease;
@ -15,7 +15,7 @@
%inline %{
namespace Outer {
class nspace {
class namespce {
};
namespace Inner1 {
enum Channel { Diffuse, Specular = 0x10, Transmission1 };
@ -33,12 +33,12 @@ namespace Outer {
static const Channel staticConstEnumMemberVariable = Transmission;
void colorInstanceMethod(double d) {}
static void colorStaticMethod(double d) {}
}; // Color
}; // Color
int Color::staticMemberVariable = 0;
Color namespaceFunction(Color k) { return k; }
int namespaceVar = 0;
} // Inner1
} // Inner1
namespace Inner2 {
enum Channel { Diffuse, Specular = 0x30, Transmission2 };
@ -56,12 +56,12 @@ namespace Outer {
static const Channel staticConstEnumMemberVariable = Transmission;
void colorInstanceMethod(double d) {}
static void colorStaticMethod(double d) {}
void colors(const Inner1::Color& col1a,
const Outer::Inner1::Color& col1b,
const Color &col2a,
const Inner2::Color& col2b,
void colors(const Inner1::Color& col1a,
const Outer::Inner1::Color& col1b,
const Color &col2a,
const Inner2::Color& col2b,
const Outer::Inner2::Color& col2c) {}
}; // Color
}; // Color
int Color::staticMemberVariable = 0;
class NoNSpacePlease {};
} // Inner2

View file

@ -2,7 +2,7 @@
%module nspace_extend
// nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
%nspace;
@ -39,10 +39,10 @@ namespace Outer {
void colorInstanceMethod(double d) {}
static void colorStaticMethod(double d) {}
void colors(const Inner1::Color& col1a,
const Outer::Inner1::Color& col1b,
const Color &col2a,
const Inner2::Color& col2b,
void colors(const Inner1::Color& col1a,
const Outer::Inner1::Color& col1b,
const Color &col2a,
const Inner2::Color& col2b,
const Outer::Inner2::Color& col2c) {}
}

View file

@ -1,44 +1,42 @@
exception_order
function check_lasterror(expected)
if (!strcmp(lasterror.message, expected))
# Take account of older versions prefixing with "error: " and adding a newline at the end
if (!strcmp(regexprep(lasterror.message, 'error: (.*)\n$', '$1'), expected))
error(["Bad exception order. Expected: \"", expected, "\" Got: \"", lasterror.message, "\""])
endif
endif
endfunction
a = A();
try
a.foo()
catch
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
error("bad exception order")
endif
check_lasterror("C++ side threw an exception of type E1")
end_try_catch
try
a.bar()
catch
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2\n"))
error("bad exception order")
endif
check_lasterror("C++ side threw an exception of type E2")
end_try_catch
try
a.foobar()
catch
if (!strcmp(lasterror.message, "error: postcatch unknown (SWIG_RuntimeError)\n"))
error("bad exception order")
endif
check_lasterror("postcatch unknown (SWIG_RuntimeError)")
end_try_catch
try
a.barfoo(1)
catch
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
error("bad exception order")
endif
check_lasterror("C++ side threw an exception of type E1")
end_try_catch
try
a.barfoo(2)
catch
if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2 *\n"))
error("bad exception order")
endif
check_lasterror("C++ side threw an exception of type E2 *")
end_try_catch

View file

@ -1,5 +1,5 @@
global_ns_arg
a = foo(1);
b = bar();
b = bar_fn();

View file

@ -0,0 +1,24 @@
preproc_constants
assert(CONST_INT1, 10)
assert(CONST_DOUBLE3, 12.3)
assert(CONST_BOOL1, true)
assert(CONST_CHAR, 'x')
assert(CONST_STRING1, "const string")
# Test global constants can be seen within functions
function test_global()
global CONST_INT1
global CONST_DOUBLE3
global CONST_BOOL1
global CONST_CHAR
global CONST_STRING1
assert(CONST_INT1, 10)
assert(CONST_DOUBLE3, 12.3)
assert(CONST_BOOL1, true)
assert(CONST_CHAR, 'x')
assert(CONST_STRING1, "const string")
endfunction
test_global

View file

@ -8,11 +8,12 @@
%typemap(default) double y "$1=1000;";
#endif
#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
#endif
#ifdef SWIGLUA
// lua only has one numeric type, so some overloads shadow each other creating warnings
%warnfilter(SWIGWARN_PARSE_REDEFINED, SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test;
#else
%warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test;
#endif

View file

@ -0,0 +1,23 @@
%module overload_return_type
// Regression test for PHP from SF#3168531 (SWIG <= 2.0.1 segfaults).
%inline %{
class A { };
class B {
public:
int foo(int x) { return 0; }
A foo(const char * y) { return A(); }
};
// Regression test for PHP from SF#3208299 (there bar()'s return type wa
// treated as always void).
void foo(int i) {}
int foo() { return 1; }
int bar() { return 1; }
void bar(int i) {}
%}

View file

@ -50,7 +50,7 @@ missingtests: missingcpptests missingctests
$(MAKE) $*.ctest
@echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.cpptest
@echo ' $(MULTICPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
@echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.multicpptest
# Runs the testcase. Tries to run testcase_runme.php, and if that's not

View file

@ -0,0 +1,13 @@
<?php
require "tests.php";
require "overload_return_type.php";
$b = new B;
check::equal($b->foo(1), 0, "");
check::classname("A", $b->foo("test"));
check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
?>

View file

@ -6,8 +6,10 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_CONST; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
#pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */
/* check __cplusplus case */
%header

View file

@ -0,0 +1,109 @@
%module preproc_defined
// Check 'defined' passes through the preprocessor without being processed like '#if defined(ABC)' would be (SF bug #1940536)
%define DEFINED_MACRO
%{
int defined(int b) {
return b > 10;
}
int vvv = -1;
void fn(int val) {
if (defined(val))
vvv = 1;
else
vvv = 0;
}
%}
%enddef
DEFINED_MACRO
%{
int checking(void) {
int okay;
fn(11);
okay = (vvv == 1);
fn(9);
okay = okay && (vvv == 0);
return okay; /* should be 1 */
}
%}
%inline %{
int call_checking(void) {
return checking();
}
%}
/*****************************************************************************/
/* Check #if/#elif defined() macro expansions
Also checks #if/#elif defined() works correctly within macros... this is not
standard C, but is now relied on in the SWIG library. */
/*****************************************************************************/
#define AAA
#define BBB
#define CCC
#if defined(AAA)\
&& defined(BBB) \
&& defined(CCC)
%{
void thing(int i) {}
void stuff(int i) {}
struct Defined {
int defined;
};
void bumpf(int i) {}
%}
#else
#endif
%define ANOTHER_MACRO(TYPE)
#if defined(AAA) && defined(BBB) && defined(CCC)
void thing(TYPE) {}
#else
void thing_not(TYPE) {}
#endif
#if defined(AAA) &&\
defined(BBB) \\
&& defined(CCC)
void stuff(TYPE) {}
#else
void stuff_not(TYPE);
#endif
#if defined(0)
void defined_not(TYPE);
#elif defined(AAA) && defined( BBB ) && defined(CCC)
struct Defined {
int defined;
};
#else
void defined_not(TYPE);
#endif
#if !( defined(AAA) \
defined(BBB) \\
&& defined(CCC) )
void bumpf_not(TYPE);
#else
void bumpf(TYPE) {}
#endif
%enddef
ANOTHER_MACRO(int)
%{
void another_macro_checking(void) {
struct Defined d;
d.defined = 10;
thing(10);
stuff(10);
bumpf(10);
}
%}

View file

@ -0,0 +1,37 @@
%module preproc_include
%{
#include "preproc_include_a.h"
#include "preproc_include_b.h"
int multiply10(int a) { return a*10; }
int multiply20(int a) { return a*20; }
int multiply30(int a) { return a*30; }
int multiply40(int a) { return a*40; }
int multiply50(int a) { return a*50; }
%}
#define INCLUDE_B preproc_include_b.h
#define FILE_INCLUDE(FNAME) #FNAME
%include FILE_INCLUDE(preproc_include_a.h)
// Note that this test uses -includeall, so including preproc_include_b.h also includes preproc_include_c.h
%include INCLUDE_B
%include"preproc_include_d withspace.h"
#define INCLUDE_E "preproc_include_e withspace.h"
%include INCLUDE_E
%inline %{
#define INCLUDE_F /*comments*/ "preproc_include_f withspace.h"/*testing*/
#include INCLUDE_F
#include /*oooo*/"preproc_include_g.h"/*ahhh*/
%}
%{
int multiply60(int a) { return a*60; }
int multiply70(int a) { return a*70; }
%}

View file

@ -0,0 +1,3 @@
int multiply10(int a);

View file

@ -0,0 +1,7 @@
int multiply20(int a);
#define PREPROC_INCLUDE_C "preproc_include_c.h"
#include PREPROC_INCLUDE_C

View file

@ -0,0 +1,3 @@
int multiply30(int a);

View file

@ -0,0 +1,3 @@
int multiply40(int a);

View file

@ -0,0 +1,3 @@
int multiply50(int a);

View file

@ -0,0 +1,3 @@
int multiply60(int a);

View file

@ -0,0 +1,3 @@
int multiply70(int a);

View file

@ -0,0 +1,17 @@
from default_arg_values import *
d = Display()
if d.draw1() != 0:
raise RuntimeError
if d.draw1(12) != 12:
raise RuntimeError
p = createPtr(123);
if d.draw2() != 0:
raise RuntimeError
if d.draw2(p) != 123:
raise RuntimeError

View file

@ -1,5 +1,5 @@
from global_ns_arg import *
a = foo(1)
b = bar()
b = bar_fn()

View file

@ -0,0 +1,11 @@
import preproc_defined
if preproc_defined.call_checking() != 1:
raise RuntimeError
d = preproc_defined.Defined()
d.defined = 10
preproc_defined.thing(10)
preproc_defined.stuff(10)
preproc_defined.bumpf(10)

View file

@ -0,0 +1,23 @@
import preproc_include
if preproc_include.multiply10(10) != 100:
raise RuntimeError
if preproc_include.multiply20(10) != 200:
raise RuntimeError
if preproc_include.multiply30(10) != 300:
raise RuntimeError
if preproc_include.multiply40(10) != 400:
raise RuntimeError
if preproc_include.multiply50(10) != 500:
raise RuntimeError
if preproc_include.multiply60(10) != 600:
raise RuntimeError
if preproc_include.multiply70(10) != 700:
raise RuntimeError

View file

@ -0,0 +1,20 @@
source("unittest.R")
dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep=""))
source("rename_simple.R")
cacheMetaData(1)
s <- NewStruct();
unittest(111, s$NewInstanceVariable)
unittest(222, s$NewInstanceMethod())
unittest(333, NewStruct_NewStaticMethod())
unittest(444, NewStruct_NewStaticVariable())
unittest(555, NewFunction())
unittest(666, NewGlobalVariable())
s$NewInstanceVariable <- 1111
NewStruct_NewStaticVariable(4444)
NewGlobalVariable(6666)
unittest(1111, s$NewInstanceVariable)
unittest(4444, NewStruct_NewStaticVariable())
unittest(6666, NewGlobalVariable())

View file

@ -1,9 +1,17 @@
unittest <- function (x,y) {
if (x==y) print("PASS")
else print("FAIL")
if (x==y) {
print("PASS")
} else {
print("FAIL")
stop("Test failed")
}
}
unittesttol <- function(x,y,z) {
if (abs(x-y) < z) print("PASS")
else print("FAIL")
}
if (abs(x-y) < z) {
print("PASS")
} else {
print("FAIL")
stop("Test failed")
}
}

View file

@ -0,0 +1,24 @@
%module rename_simple
%rename(NewStruct) OldStruct;
%rename(NewVariable) OldVariable;
%rename(NewInstanceMethod) OldInstanceMethod;
%rename(NewInstanceVariable) OldInstanceVariable;
%rename(NewStaticMethod) OldStaticMethod;
%rename(NewStaticVariable) OldStaticVariable;
%rename(NewFunction) OldFunction;
%rename(NewGlobalVariable) OldGlobalVariable;
%inline %{
struct OldStruct {
OldStruct() : OldInstanceVariable(111) {}
int OldInstanceVariable;
int OldInstanceMethod() { return 222; }
static int OldStaticVariable;
static int OldStaticMethod() { return 333; }
};
int OldStruct::OldStaticVariable = 444;
int OldFunction() { return 555; }
int OldGlobalVariable = 666;
%}

View file

@ -1,7 +1,15 @@
%module restrict_cplusplus
%inline %{
%{
// For PHP 5.3 / gcc-4.4
#ifdef restrict
#undef restrict
#endif
struct Foo {
int restrict;
};
%}
struct Foo {
int restrict;
};

View file

@ -1,6 +1,12 @@
// Test cases for classes that do *NOT* result in smart-pointer wrapping
%module smart_pointer_not
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, arrowrtn) /* Questionable return type for ... */
#endif
%}
%inline %{
struct Foo {
int x;

View file

@ -0,0 +1,37 @@
%module smart_pointer_template_const_overload
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) SmartPointer<FooImplementation>::operator->; // Overloaded method SmartPointer< FooImplementation >::operator ->() ignored
%inline %{
template <class T> class SmartPointer {
T *ptr;
public:
SmartPointer(T *t = 0) : ptr(t) {}
inline const T * operator->() const { return ptr; }
inline T * operator->() { return ptr; }
};
class FooImplementation {
public:
int mingy() {}
int constmingy() const {}
static int thingy() {}
static int svariable;
static const int constsvariable;
int normalvariable;
};
int FooImplementation::svariable = 0;
const int FooImplementation::constsvariable = 2;
void tester() {
SmartPointer<FooImplementation> p;
p->mingy();
p->constmingy();
p->thingy();
int a = p->svariable;
a = p->constsvariable;
a = p->normalvariable;
}
%}
%template(FooSmartPointer) SmartPointer<FooImplementation>;

View file

@ -2,6 +2,13 @@
%module typedef_mptr
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
#endif
%}
#if defined(SWIGPYTHON) || defined(SWIGOCAML)
%inline %{

View file

@ -7,6 +7,12 @@
%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant3; /* Java, C# covariant return types */
%warnfilter(SWIGWARN_JAVA_COVARIANT_RET, SWIGWARN_CSHARP_COVARIANT_RET) covariant4; /* Java, C# covariant return types */
%{
#if defined(__SUNPRO_CC)
#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
#endif
%}
//
// Check this example with directors wherever possible.
//