Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12270 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
1842244c93
530 changed files with 22854 additions and 11740 deletions
|
|
@ -29,14 +29,17 @@
|
|||
#
|
||||
# Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used
|
||||
# for invoking tools for the runtime tests and target language
|
||||
# compiler (eg javac) respectively. For example, valgrind can be used
|
||||
# for memory checking of the runtime tests using:
|
||||
# compiler (eg javac), and on SWIG respectively. For example, valgrind
|
||||
# can be used for memory checking of the runtime tests using:
|
||||
# make RUNTOOL="valgrind --leak-check=full"
|
||||
# and valgrind can be used when invoking SWIG using:
|
||||
# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
|
||||
# Note: trace-children needed because of preinst-swig shell wrapper
|
||||
# to the swig executable.
|
||||
#
|
||||
# An individual test run can be debugged easily:
|
||||
# make director_string.cpptest RUNTOOL="gdb --args"
|
||||
#
|
||||
# The variables below can be overridden after including this makefile
|
||||
#######################################################################
|
||||
|
||||
|
|
@ -66,7 +69,7 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
|
|||
LIBS = -L.
|
||||
LIBPREFIX = lib
|
||||
ACTION = check
|
||||
INTERFACEDIR = ../
|
||||
INTERFACEDIR = $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/
|
||||
|
||||
#
|
||||
# Please keep test cases in alphabetical order.
|
||||
|
|
@ -177,6 +180,7 @@ CPP_TEST_CASES += \
|
|||
disown \
|
||||
dynamic_cast \
|
||||
empty \
|
||||
enum_rename \
|
||||
enum_scope_template \
|
||||
enum_template \
|
||||
enum_thorough \
|
||||
|
|
@ -193,9 +197,11 @@ CPP_TEST_CASES += \
|
|||
extern_c \
|
||||
extern_namespace \
|
||||
extern_throws \
|
||||
expressions \
|
||||
features \
|
||||
fragments \
|
||||
friends \
|
||||
funcptr_cpp \
|
||||
fvirtual \
|
||||
global_namespace \
|
||||
global_ns_arg \
|
||||
|
|
@ -278,6 +284,8 @@ CPP_TEST_CASES += \
|
|||
rename4 \
|
||||
rename_scope \
|
||||
rename_strip_encoder \
|
||||
rename_pcre_encoder \
|
||||
rename_pcre_enum \
|
||||
restrict_cplusplus \
|
||||
return_const_value \
|
||||
return_value_scope \
|
||||
|
|
@ -286,6 +294,7 @@ CPP_TEST_CASES += \
|
|||
sizet \
|
||||
smart_pointer_const \
|
||||
smart_pointer_const2 \
|
||||
smart_pointer_const_overload \
|
||||
smart_pointer_extend \
|
||||
smart_pointer_member \
|
||||
smart_pointer_multi \
|
||||
|
|
@ -478,6 +487,7 @@ C_TEST_CASES += \
|
|||
overload_extendc \
|
||||
preproc \
|
||||
preproc_constants_c \
|
||||
preproc_line_file \
|
||||
ret_by_value \
|
||||
simple_array \
|
||||
sizeof_pointer \
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
|
|||
%module constant_pointers
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ public:
|
|||
private:
|
||||
MemberVariablesTest& operator=(const MemberVariablesTest&);
|
||||
};
|
||||
void foo(const int *const i) {}
|
||||
void foofunction(const int *const i) {}
|
||||
|
||||
typedef int *typedef1, typedef2, *const typedef3;
|
||||
int int1, int2=2, *int3, *const int4 = &GlobalInt;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ struct StructWithEnums {
|
|||
enum SOME_ENUM& enum_test8() { return some_enum; };
|
||||
};
|
||||
|
||||
|
||||
struct Foo
|
||||
{
|
||||
enum {Hi, Hello } hola;
|
||||
|
|
@ -41,3 +40,15 @@ extern "C"
|
|||
}
|
||||
|
||||
%}
|
||||
|
||||
// Using true and false in enums is legal in C++. Quoting the standard:
|
||||
// [dcl.enum]
|
||||
// ... The constant-expression shall be of integral or enumeration type.
|
||||
// [basic.fundamental]
|
||||
// ... Types bool, char, wchar_t, and the signed and unsigned integer
|
||||
// types are collectively called integral types.
|
||||
// So this shouldn't lead to a warning, at least in C++ mode.
|
||||
%inline %{
|
||||
typedef enum { PLAY = true, STOP = false } play_state;
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ INTERPRETER = @CSHARPCILINTERPRETER@
|
|||
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
|
||||
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@/..
|
||||
top_builddir = @top_builddir@/..
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
csharp_attributes \
|
||||
|
|
@ -27,7 +27,6 @@ include $(srcdir)/../common.mk
|
|||
|
||||
# Overridden variables here
|
||||
SWIGOPT += -namespace $*Namespace
|
||||
INTERFACEDIR = ../../
|
||||
|
||||
CSHARPFLAGSSPECIAL =
|
||||
|
||||
|
|
|
|||
20
Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
Normal file
20
Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using li_boost_shared_ptr_bitsNamespace;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
VectorIntHolder v = new VectorIntHolder();
|
||||
v.Add(new IntHolder(11));
|
||||
v.Add(new IntHolder(22));
|
||||
v.Add(new IntHolder(33));
|
||||
|
||||
int sum = li_boost_shared_ptr_bits.sum(v);
|
||||
if (sum != 66)
|
||||
throw new ApplicationException("sum is wrong");
|
||||
|
||||
HiddenDestructor hidden = HiddenDestructor.create();
|
||||
hidden.Dispose();
|
||||
}
|
||||
}
|
||||
31
Examples/test-suite/csharp/li_std_combinations_runme.cs
Normal file
31
Examples/test-suite/csharp/li_std_combinations_runme.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using li_std_combinationsNamespace;
|
||||
|
||||
public class li_std_combinations_runme {
|
||||
public static void Main() {
|
||||
VectorPairIntString vpis = new VectorPairIntString();
|
||||
vpis.Add(new PairIntString(123, "one hundred and twenty three"));
|
||||
|
||||
VectorString vs = new VectorString();
|
||||
vs.Add("hi");
|
||||
PairIntVectorString pivs = new PairIntVectorString(456, vs);
|
||||
if (pivs.second[0] != "hi")
|
||||
throw new ApplicationException("PairIntVectorString");
|
||||
|
||||
VectorVectorString vvs = new VectorVectorString();
|
||||
vvs.Add(vs);
|
||||
|
||||
PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4"));
|
||||
if (pipis.first != 12)
|
||||
throw new ApplicationException("PairIntPairIntString");
|
||||
|
||||
PairDoubleString pds = new PairDoubleString(12.34, "okay");
|
||||
VectorPairDoubleString vpds = new VectorPairDoubleString();
|
||||
vpds.Add(pds);
|
||||
|
||||
// Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method
|
||||
if (!vpds.Contains(pds))
|
||||
throw new ApplicationException("VectorPairDoubleString");
|
||||
}
|
||||
}
|
||||
|
||||
24
Examples/test-suite/csharp/rename_pcre_enum_runme.cs
Normal file
24
Examples/test-suite/csharp/rename_pcre_enum_runme.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using rename_pcre_enumNamespace;
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
Foo foo = Foo.First;
|
||||
if ( foo == Foo.Second )
|
||||
throw new Exception("Enum values should be different");
|
||||
|
||||
// Check that Foo_Max enum element was ignored.
|
||||
int numFooEnumElements = Enum.GetValues(typeof(Foo)).Length;
|
||||
if ( numFooEnumElements != 2 )
|
||||
throw new Exception(String.Format("Enum should have 2 elements, not {0}",
|
||||
numFooEnumElements));
|
||||
|
||||
BoundaryCondition bc = BoundaryCondition.MaxMax;
|
||||
if ( (int)bc != 2 )
|
||||
throw new Exception("Wrong enum value");
|
||||
|
||||
Colour c = Colour.red;
|
||||
if ( c == Colour.blue )
|
||||
throw new Exception("Enum values should be different");
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ double MoreStations::WestonSuperMare = 0.0;
|
|||
|
||||
%inline %{
|
||||
struct YetMoreStations {
|
||||
virtual int Slough(int x) {}
|
||||
virtual int Slough(int x) { return x; }
|
||||
virtual ~YetMoreStations() {}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -101,3 +101,19 @@ Number times12(const Number* num) {
|
|||
%inline %{
|
||||
int myInt = 0;
|
||||
%}
|
||||
|
||||
|
||||
// Illegal special variable crash
|
||||
%typemap(cstype) WasCrashing "$csclassname /*cstype $*csclassname*/" // $*csclassname was causing crash
|
||||
%inline %{
|
||||
struct WasCrashing {};
|
||||
void hoop(WasCrashing was) {}
|
||||
%}
|
||||
|
||||
|
||||
// Enum underlying type
|
||||
%typemap(csbase) BigNumbers "uint"
|
||||
%inline %{
|
||||
enum BigNumbers { big=0x80000000, bigger };
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace EnumDirector {
|
|||
|
||||
%inline %{
|
||||
namespace EnumDirector {
|
||||
enum FType{ SA = -1, NA=0, EA=1};
|
||||
enum FType{ SA = -1, NA_=0, EA=1};
|
||||
|
||||
struct A{
|
||||
A(const double a, const double b, const FType c)
|
||||
|
|
@ -71,7 +71,7 @@ struct B : public A{
|
|||
%inline %{
|
||||
namespace EnumDirector {
|
||||
struct A2{
|
||||
A2(const FType c = NA) {}
|
||||
A2(const FType c = NA_) {}
|
||||
|
||||
virtual ~A2() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ namespace Swig {
|
|||
#endif
|
||||
%}
|
||||
|
||||
// Some director implementations do not have Swig::director
|
||||
#if !defined(SWIGGO)
|
||||
%extend SpObject
|
||||
{
|
||||
size_t ExceptionMethod()
|
||||
|
|
@ -29,7 +31,8 @@ namespace Swig {
|
|||
size_t size = sizeof(Swig::Director);
|
||||
return size;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
%inline %{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
%module(directors="1") director_finalizer
|
||||
|
||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'deleteFoo' due to Go name ('DeleteFoo') conflict with '~Foo' */
|
||||
|
||||
%{
|
||||
|
||||
int status = 0;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* File : example.i */
|
||||
%module dynamic_cast
|
||||
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
|
||||
%apply SWIGTYPE *DYNAMIC { Foo * };
|
||||
#endif
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ public:
|
|||
};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO)
|
||||
%typemap(out) Foo *blah {
|
||||
Bar *downcast = dynamic_cast<Bar *>($1);
|
||||
*(Bar **)&$result = downcast;
|
||||
|
|
@ -37,6 +37,14 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(SWIGGO)
|
||||
%insert(go_runtime) %{
|
||||
func FooToBar(f Foo) Bar {
|
||||
return SwigcptrBar(f.Swigcptr())
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
class Bar : public Foo {
|
||||
|
|
@ -54,7 +62,7 @@ char *do_test(Bar *b) {
|
|||
}
|
||||
%}
|
||||
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
|
||||
// A general purpose function for dynamic casting of a Foo *
|
||||
%{
|
||||
static swig_type_info *
|
||||
|
|
|
|||
12
Examples/test-suite/enum_rename.i
Normal file
12
Examples/test-suite/enum_rename.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%module enum_rename
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
|
||||
|
||||
// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code
|
||||
%rename(May) M_May;
|
||||
%rename(May) S_May;
|
||||
|
||||
%inline %{
|
||||
enum Month { M_Jan, M_May, M_Dec };
|
||||
enum Severity { S_May, S_Can, S_Must };
|
||||
%}
|
||||
|
|
@ -43,6 +43,8 @@
|
|||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance2;
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance3;
|
||||
|
||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'one' due to Go name ('ObscureOne') conflict with 'Obscure::One' */
|
||||
|
||||
%inline %{
|
||||
|
||||
enum { AnonEnum1, AnonEnum2 = 100 };
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ enum Exclamation {
|
|||
|
||||
enum ContainYourself {
|
||||
slap = 10,
|
||||
my,
|
||||
mine,
|
||||
thigh
|
||||
} Slap = slap, My = my, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, my, thigh};
|
||||
} Slap = slap, Mine = mine, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, mine, thigh};
|
||||
%}
|
||||
|
||||
|
|
|
|||
47
Examples/test-suite/errors/cpp_inherit.i
Normal file
47
Examples/test-suite/errors/cpp_inherit.i
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
%module xxx
|
||||
|
||||
%inline %{
|
||||
struct A5;
|
||||
int A6;
|
||||
template<typename T> struct A7
|
||||
{
|
||||
};
|
||||
template<typename T> struct A8
|
||||
{
|
||||
};
|
||||
|
||||
struct A0
|
||||
:
|
||||
public A1
|
||||
,
|
||||
A2,
|
||||
private A3
|
||||
,
|
||||
private A4
|
||||
,
|
||||
A5
|
||||
,
|
||||
A6
|
||||
,
|
||||
A7<int>
|
||||
,
|
||||
protected A8<double>
|
||||
{
|
||||
};
|
||||
|
||||
struct A1
|
||||
{
|
||||
};
|
||||
|
||||
class B1 {};
|
||||
|
||||
class B0 :
|
||||
B1,
|
||||
B2<int>
|
||||
{
|
||||
};
|
||||
|
||||
struct Recursive : Recursive
|
||||
{
|
||||
};
|
||||
%}
|
||||
103
Examples/test-suite/errors/cpp_macro_locator.i
Normal file
103
Examples/test-suite/errors/cpp_macro_locator.i
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
%module xxx
|
||||
|
||||
// Test the SWIG preprocessor locator effects on reporting line numbers in warnings when processing SWIG (multiline) macros
|
||||
|
||||
// The ignored overloaded methods warnings should have the correct line number reporting
|
||||
// {} blocks are tested, where the preprocessor expands the macros
|
||||
|
||||
%define CLASSMACRO(KLASS)
|
||||
class KLASS
|
||||
{
|
||||
public:
|
||||
KLASS() {}
|
||||
void methodX(int *) {}
|
||||
void methodX(const int *) {}
|
||||
};
|
||||
%enddef
|
||||
|
||||
%{
|
||||
#define CLASSMACRO(KLASS) \
|
||||
class KLASS \
|
||||
{ \
|
||||
public: \
|
||||
KLASS() {} \
|
||||
void methodX(int *) {} \
|
||||
void methodX(const int *) {} \
|
||||
};
|
||||
%}
|
||||
|
||||
%{
|
||||
#define VARIABLEMACRO(NAME) double NAME;
|
||||
struct Outer {
|
||||
struct Inner {
|
||||
VARIABLEMACRO(MyInnerVar)
|
||||
};
|
||||
};
|
||||
void overload1(int *) {}
|
||||
void overload1(const int *) {}
|
||||
void overload2(int *) {}
|
||||
void overload2(const int *) {}
|
||||
void overload3(int *) {}
|
||||
void overload3(const int *) {}
|
||||
%}
|
||||
|
||||
%define VARIABLEMACRO(NAME)
|
||||
double NAME;
|
||||
%enddef
|
||||
struct Outer {
|
||||
struct Inner {
|
||||
VARIABLEMACRO(MyInnerVar)
|
||||
};
|
||||
};
|
||||
void overload1(int *) {}
|
||||
void overload1(const int *) {}
|
||||
|
||||
%fragment("FragmentMethod", "header") {
|
||||
void fragmentMethod() {
|
||||
}
|
||||
VARIABLEMACRO(fragVar)
|
||||
}
|
||||
void overload2(int *) {}
|
||||
void overload2(const int *) {}
|
||||
|
||||
%inline {
|
||||
CLASSMACRO(Klass1)
|
||||
}
|
||||
#warning inline warning message one
|
||||
void overload3(int *) {}
|
||||
void overload3(const int *) {}
|
||||
|
||||
%{
|
||||
struct Classic {
|
||||
Classic() {
|
||||
VARIABLEMACRO(inconstructor)
|
||||
}
|
||||
double value;
|
||||
};
|
||||
void overload4(int *) {}
|
||||
void overload4(const int *) {}
|
||||
void overload5(int *) {}
|
||||
void overload5(const int *) {}
|
||||
%}
|
||||
|
||||
struct Classic {
|
||||
Classic() {
|
||||
VARIABLEMACRO(inconstructor)
|
||||
}
|
||||
double value;
|
||||
};
|
||||
void overload4(int *) {}
|
||||
void overload4(const int *) {}
|
||||
|
||||
%inline {
|
||||
void overloadinline1(int *) {}
|
||||
void overloadinline1(const int *) {}
|
||||
CLASSMACRO(Klass2)
|
||||
#warning an inline warning message 2
|
||||
void overloadinline2(int *) {}
|
||||
void overloadinline2(const int *) {}
|
||||
}
|
||||
void overload5(int *) {}
|
||||
void overload5(const int *) {}
|
||||
|
||||
|
||||
305
Examples/test-suite/errors/expected.log
Normal file
305
Examples/test-suite/errors/expected.log
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
SWIG error and warning test. opts=
|
||||
-----------------------------------------------------------
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_bad_name.i :::::::::::::::::::::::::::::::::::
|
||||
c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead.
|
||||
c_bad_name.i:3: Error: Missing argument to %name directive.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_bad_native.i :::::::::::::::::::::::::::::::::::
|
||||
c_bad_native.i:3: Error: %native declaration 'foo' is not a function.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_class.i :::::::::::::::::::::::::::::::::::
|
||||
c_class.i:3: Warning 301: class keyword used, but not in C++ mode.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_default_error.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_deprecated.i :::::::::::::::::::::::::::::::::::
|
||||
c_deprecated.i:3: Warning 102: %val directive deprecated (ignored).
|
||||
c_deprecated.i:3: Warning 103: %out directive deprecated (ignored).
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_empty_char.i :::::::::::::::::::::::::::::::::::
|
||||
c_empty_char.i:3: Error: Empty character constant
|
||||
0
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_enum_badvalue.i :::::::::::::::::::::::::::::::::::
|
||||
c_enum_badvalue.i:6: Error: Type error. Expecting an integral type
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_extra_rblock.i :::::::::::::::::::::::::::::::::::
|
||||
c_extra_rblock.i:5: Error: Syntax error in input(1).
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_extra_rbrace.i :::::::::::::::::::::::::::::::::::
|
||||
c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}'
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_extra_unsigned.i :::::::::::::::::::::::::::::::::::
|
||||
c_extra_unsigned.i:3: Error: Extra unsigned specifier.
|
||||
c_extra_unsigned.i:4: Error: Extra signed specifier.
|
||||
c_extra_unsigned.i:5: Error: Extra signed specifier.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_insert_missing.i :::::::::::::::::::::::::::::::::::
|
||||
c_insert_missing.i:3: Error: Couldn't find 'missing_file.i'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_long_short.i :::::::::::::::::::::::::::::::::::
|
||||
c_long_short.i:3: Error: Extra long specifier.
|
||||
c_long_short.i:4: Error: Extra short specifier.
|
||||
c_long_short.i:5: Error: Extra long specifier.
|
||||
c_long_short.i:6: Error: Extra short specifier.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_missing_rbrace.i :::::::::::::::::::::::::::::::::::
|
||||
:168430090: Error: Missing '}'. Reached end of input.
|
||||
c_missing_rbrace.i:3: Error: Syntax error in input(1).
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_missing_semi.i :::::::::::::::::::::::::::::::::::
|
||||
c_missing_semi.i:3: Error: Syntax error in input(1).
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_redefine.i :::::::::::::::::::::::::::::::::::
|
||||
c_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored),
|
||||
c_redefine.i:3: Warning 302: previous definition of 'foo'.
|
||||
c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored),
|
||||
c_redefine.i:6: Warning 302: previous definition of 'bar'.
|
||||
c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'),
|
||||
c_redefine.i:6: Warning 322: previous declaration of 'bar'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_varargs.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: c_varargs_neg.i :::::::::::::::::::::::::::::::::::
|
||||
c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
|
||||
|
||||
:::::::::::::::::::::::::::::::: nomodule.i :::::::::::::::::::::::::::::::::::
|
||||
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: Error: 'Expected an expression'
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_constant.i :::::::::::::::::::::::::::::::::::
|
||||
pp_constant.i:9: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:15: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:23: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:29: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:35: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:42: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:46: Warning 305: Bad constant value (ignored).
|
||||
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_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:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
|
||||
pp_illegal_argument.i:6: Error: Illegal macro argument name '..'
|
||||
pp_illegal_argument.i:10: Error: Illegal macro argument name '..'
|
||||
pp_illegal_argument.i:16: Error: Illegal character in macro argument name
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_args.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_badchar.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_badchar.i:4: Error: Illegal character in macro argument name
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined'
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_expansion.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_expansion.i:9: Error: Macro 'MACRO2' expects 2 arguments
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_expansion_multiline.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_expansion_multiline.i:13: Warning 509: Overloaded method foo(int const *) effectively ignored,
|
||||
pp_macro_expansion_multiline.i:12: Warning 509: as it is shadowed by foo(int *).
|
||||
pp_macro_expansion_multiline.i:31: Warning 509: Overloaded method bar(int const *) effectively ignored,
|
||||
pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *).
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i :::::::::::::::::::::::::::::::::::
|
||||
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_nargs.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
|
||||
pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments
|
||||
pp_macro_nargs.i:10: Error: Macro 'bar' expects 1 argument
|
||||
pp_macro_nargs.i:11: Error: Macro 'spam' expects no arguments
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_redef.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_redef.i:4: Error: Macro 'foo' redefined,
|
||||
pp_macro_redef.i:3: Error: previous definition of 'foo'.
|
||||
pp_macro_redef.i:7: Error: Macro 'foo' redefined,
|
||||
pp_macro_redef.i:3: Error: previous definition of 'foo'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_rparen.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_rparen.i:3: Error: Missing ')' in macro parameters
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_macro_unterminated.i :::::::::::::::::::::::::::::::::::
|
||||
pp_macro_unterminated.i:5: Error: Unterminated call invoking macro 'foo'
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_misplaced_elif.i :::::::::::::::::::::::::::::::::::
|
||||
pp_misplaced_elif.i:4: Error: Misplaced #elif.
|
||||
pp_misplaced_elif.i:6: Error: Extraneous #endif.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_misplaced_else.i :::::::::::::::::::::::::::::::::::
|
||||
pp_misplaced_else.i:4: Error: Misplaced #else.
|
||||
pp_misplaced_else.i:6: Error: Extraneous #endif.
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_missing_enddef.i :::::::::::::::::::::::::::::::::::
|
||||
pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_missing_endif.i :::::::::::::::::::::::::::::::::::
|
||||
pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_missing_file.i :::::::::::::::::::::::::::::::::::
|
||||
pp_missing_file.i:3: Error: Unable to find 'missing_filename.i'
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_missing_rblock.i :::::::::::::::::::::::::::::::::::
|
||||
pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_pragma.i :::::::::::::::::::::::::::::::::::
|
||||
pp_pragma.i:4: Error: Unknown SWIG pragma: rubbish()
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_unterm_char.i :::::::::::::::::::::::::::::::::::
|
||||
pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_unterm_comment.i :::::::::::::::::::::::::::::::::::
|
||||
pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_unterm_string.i :::::::::::::::::::::::::::::::::::
|
||||
pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
|
||||
|
||||
:::::::::::::::::::::::::::::::: pp_variable_args.i :::::::::::::::::::::::::::::::::::
|
||||
pp_variable_args.i:6: Error: Variable length macro argument must be last parameter
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_apply_nargs.i :::::::::::::::::::::::::::::::::::
|
||||
swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_identifier.i :::::::::::::::::::::::::::::::::::
|
||||
swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_insert_bad.i :::::::::::::::::::::::::::::::::::
|
||||
swig_insert_bad.i:5: Error: Unknown target 'foobar' for %insert directive.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_typemap_copy.i :::::::::::::::::::::::::::::::::::
|
||||
swig_typemap_copy.i:3: Error: Can't copy typemap (in) blah = int
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_typemap_old.i :::::::::::::::::::::::::::::::::::
|
||||
swig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target).
|
||||
swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated.
|
||||
For typemaps related to argument input (in,ignore,default,arginit,check), replace
|
||||
$source by $input and $target by $1. For typemaps related to return values (out,
|
||||
argout,ret,except), replace $source by $1 and $target by $result. See the file
|
||||
Doc/Manual/Typemaps.html for complete details.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
|
||||
cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_extend_redefine.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
|
||||
cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
|
||||
cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam',
|
||||
cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_extend_undefined.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_inline_namespace.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_inherit.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored).
|
||||
cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored).
|
||||
cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored).
|
||||
cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored).
|
||||
cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored).
|
||||
cpp_inherit.i:15: Warning 401: Base class 'A1' undefined.
|
||||
cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class.
|
||||
cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored.
|
||||
cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete.
|
||||
cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found.
|
||||
cpp_inherit.i:24: Error: 'A6' is not a valid base class.
|
||||
cpp_inherit.i:5: Error: See definition of 'A6'.
|
||||
cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
|
||||
cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
|
||||
cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
|
||||
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: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 *).
|
||||
cpp_macro_locator.i:61: Warning 509: Overloaded method overload2(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:60: Warning 509: as it is shadowed by overload2(int *).
|
||||
cpp_macro_locator.i:64: Warning 509: Overloaded method Klass1::methodX(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:64: Warning 509: as it is shadowed by Klass1::methodX(int *).
|
||||
cpp_macro_locator.i:68: Warning 509: Overloaded method overload3(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:67: Warning 509: as it is shadowed by overload3(int *).
|
||||
cpp_macro_locator.i:90: Warning 509: Overloaded method overload4(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:89: Warning 509: as it is shadowed by overload4(int *).
|
||||
cpp_macro_locator.i:94: Warning 509: Overloaded method overloadinline1(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:93: Warning 509: as it is shadowed by overloadinline1(int *).
|
||||
cpp_macro_locator.i:95: Warning 509: Overloaded method Klass2::methodX(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:95: Warning 509: as it is shadowed by Klass2::methodX(int *).
|
||||
cpp_macro_locator.i:98: Warning 509: Overloaded method overloadinline2(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *).
|
||||
cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored,
|
||||
cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_namespace_alias.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_namespace_alias.i:8: Warning 308: Namespace alias 'B' not allowed here. Assuming 'blah'
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_namespace_aliasnot.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_namespace_aliasnot.i:4: Error: 'blah' is not a namespace
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_namespace_aliasundef.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_namespace_aliasundef.i:3: Error: Unknown namespace 'blah'
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_nested.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored)
|
||||
cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored)
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored).
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
|
||||
cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored.
|
||||
cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using %template.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_overload.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: 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_template_argname.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_template_nargs.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_template_nargs.i:5: Error: Template 'blah' undefined.
|
||||
cpp_template_nargs.i:6: Error: Template 'blah' undefined.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_template_not.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_template_not.i:5: Error: 'blah' is not defined as a template. (cdecl)
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_template_partial.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_template_partial.i:3: Warning 317: Specialization of non-template 'vector'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_template_repeat.i :::::::::::::::::::::::::::::::::::
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_template_undef.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_template_undef.i:3: Error: Template 'blah' undefined.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_using_not.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_using_not.i:4: Error: 'blah' is not a namespace.
|
||||
|
||||
:::::::::::::::::::::::::::::::: cpp_using_undef.i :::::::::::::::::::::::::::::::::::
|
||||
cpp_using_undef.i:4: Error: Nothing known about namespace 'foo'
|
||||
cpp_using_undef.i:3: Warning 315: Nothing known about 'foo::bar'.
|
||||
|
|
@ -24,11 +24,18 @@ c_missing_semi
|
|||
c_redefine
|
||||
c_varargs
|
||||
c_varargs_neg
|
||||
nomodule
|
||||
nomodule
|
||||
pp_badeval
|
||||
pp_constant
|
||||
pp_defined
|
||||
pp_deprecated
|
||||
pp_illegal_argument
|
||||
pp_macro_args
|
||||
pp_macro_badchar
|
||||
pp_macro_defined_unterminated
|
||||
pp_macro_expansion
|
||||
pp_macro_expansion_multiline
|
||||
pp_macro_inline_unterminated
|
||||
pp_macro_nargs
|
||||
pp_macro_redef
|
||||
pp_macro_rparen
|
||||
|
|
@ -39,9 +46,11 @@ pp_missing_enddef
|
|||
pp_missing_endif
|
||||
pp_missing_file
|
||||
pp_missing_rblock
|
||||
pp_pragma
|
||||
pp_unterm_char
|
||||
pp_unterm_comment
|
||||
pp_unterm_string
|
||||
pp_variable_args
|
||||
swig_apply_nargs
|
||||
swig_identifier
|
||||
swig_insert_bad
|
||||
|
|
@ -55,6 +64,8 @@ cpp_bad_extern
|
|||
cpp_extend_redefine
|
||||
cpp_extend_undefined
|
||||
cpp_inline_namespace
|
||||
cpp_inherit
|
||||
cpp_macro_locator
|
||||
cpp_missing_rtemplate
|
||||
cpp_namespace_alias
|
||||
cpp_namespace_aliasnot
|
||||
|
|
|
|||
50
Examples/test-suite/errors/pp_constant.i
Normal file
50
Examples/test-suite/errors/pp_constant.i
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
%module xxx
|
||||
|
||||
/* Test preprocessor comments and their effect on line number reporting on later errors */
|
||||
|
||||
#define A1 1234
|
||||
#define A2 1234 /*C comment*/
|
||||
#define A3 1234
|
||||
|
||||
%constant int aaa=;
|
||||
|
||||
#define B1 1234
|
||||
#define B2 1234 //C++ comment
|
||||
#define B3 1234
|
||||
|
||||
%constant int bbb=;
|
||||
|
||||
#define C1 1234
|
||||
#define C2 1234 /*multiline
|
||||
C
|
||||
comment */
|
||||
#define C3 1234
|
||||
|
||||
%constant int ccc=;
|
||||
|
||||
#define D1 1234
|
||||
#define /*C Comment*/ D2 1234
|
||||
#define D3 1234
|
||||
|
||||
%constant int ddd=;
|
||||
|
||||
#define E1 1234
|
||||
#/*C comment*/define E2 1234
|
||||
#define E3 1234
|
||||
|
||||
%constant int eee=;
|
||||
|
||||
#define F1 1234
|
||||
#define F2 1234 \
|
||||
// C comment
|
||||
#define F3 1234
|
||||
|
||||
%constant int fff=;
|
||||
|
||||
// Test macro ending in /, that is not a C comment terminator
|
||||
#define G1 1234
|
||||
#define G2 1234 /
|
||||
#define G3 1234
|
||||
|
||||
%constant int ggg=;
|
||||
|
||||
9
Examples/test-suite/errors/pp_deprecated.i
Normal file
9
Examples/test-suite/errors/pp_deprecated.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%module xxx
|
||||
|
||||
|
||||
%extern ext;
|
||||
|
||||
#warning Print this warning
|
||||
|
||||
#error This is an error
|
||||
|
||||
20
Examples/test-suite/errors/pp_illegal_argument.i
Normal file
20
Examples/test-suite/errors/pp_illegal_argument.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module xxx
|
||||
|
||||
|
||||
%define MISSING_DOT1(a,
|
||||
b,
|
||||
..)
|
||||
xxx
|
||||
%enddef
|
||||
|
||||
%define MISSING_DOT2(..)
|
||||
xxx
|
||||
%enddef
|
||||
|
||||
%define BAD_ARGNAME(
|
||||
a,
|
||||
b{c
|
||||
)
|
||||
xxx
|
||||
%enddef
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
%module xxx
|
||||
|
||||
|
||||
#if defined(a
|
||||
#endif
|
||||
|
||||
10
Examples/test-suite/errors/pp_macro_expansion.i
Normal file
10
Examples/test-suite/errors/pp_macro_expansion.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module xxx
|
||||
|
||||
/* Test line number reporting for multiple macro expansions */
|
||||
|
||||
#define MACRO2(a, b)
|
||||
|
||||
#define MACRO1(NAME) MACRO2(NAME,2,3)
|
||||
|
||||
MACRO1(abc)
|
||||
|
||||
32
Examples/test-suite/errors/pp_macro_expansion_multiline.i
Normal file
32
Examples/test-suite/errors/pp_macro_expansion_multiline.i
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
%module xxx
|
||||
// Testing macros split over multiple lines - ensure the warning message for the ignored functions contain the correct line numbering
|
||||
|
||||
#define MYMACRO(NAME, A, B, C) void NAME(int A, int B, int C);
|
||||
|
||||
MYMACRO(funk, x,
|
||||
y,
|
||||
|
||||
z
|
||||
)
|
||||
|
||||
void foo(int *);
|
||||
void foo(const int *);
|
||||
|
||||
%define MYSWIGMACRO(A, B, C)
|
||||
MYMACRO(funk1,
|
||||
AA,
|
||||
BB,
|
||||
CC)
|
||||
MYMACRO(funk2,
|
||||
AA,
|
||||
BB,
|
||||
CC)
|
||||
%enddef
|
||||
|
||||
MYSWIGMACRO(xx,
|
||||
yy,
|
||||
zz)
|
||||
|
||||
void bar(int *);
|
||||
void bar(const int *);
|
||||
|
||||
11
Examples/test-suite/errors/pp_macro_inline_unterminated.i
Normal file
11
Examples/test-suite/errors/pp_macro_inline_unterminated.i
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
%module xxx
|
||||
|
||||
%define foo(a,x)
|
||||
int ii;
|
||||
%enddef
|
||||
|
||||
%inline %{
|
||||
struct Struct {
|
||||
foo(2,
|
||||
};
|
||||
%}
|
||||
6
Examples/test-suite/errors/pp_pragma.i
Normal file
6
Examples/test-suite/errors/pp_pragma.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%module xxx
|
||||
|
||||
|
||||
#pragma SWIG rubbish()
|
||||
|
||||
|
||||
10
Examples/test-suite/errors/pp_variable_args.i
Normal file
10
Examples/test-suite/errors/pp_variable_args.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module xxx
|
||||
|
||||
|
||||
%define VARARGS_WRONG(a,
|
||||
x,
|
||||
...,
|
||||
b)
|
||||
xxx
|
||||
%enddef
|
||||
|
||||
10
Examples/test-suite/expressions.i
Normal file
10
Examples/test-suite/expressions.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module expressions
|
||||
|
||||
%inline %{
|
||||
struct A
|
||||
{
|
||||
A() : k( 20/(5-1) ) {}
|
||||
A(int i) : k( 20/(5-1)*i /* comment */ ) {}
|
||||
int k;
|
||||
};
|
||||
%}
|
||||
16
Examples/test-suite/funcptr_cpp.i
Normal file
16
Examples/test-suite/funcptr_cpp.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module funcptr_cpp
|
||||
|
||||
%inline %{
|
||||
|
||||
int addByValue(const int &a, int b) { return a+b; }
|
||||
int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; }
|
||||
int & addByReference(const int &a, int b) { static int val; val = a+b; return val; }
|
||||
|
||||
int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); }
|
||||
int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); }
|
||||
int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
|
||||
%}
|
||||
|
||||
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
|
||||
%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
|
||||
%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
|
||||
|
|
@ -58,3 +58,25 @@ struct TheEnumMethods {
|
|||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
Klass1 getKlass1A() { return ::Klass1(); }
|
||||
::Klass1 getKlass1B() { return ::Klass1(); }
|
||||
|
||||
Klass2 getKlass2A() { return ::Klass2(); }
|
||||
::Klass2 getKlass2B() { return ::Klass2(); }
|
||||
|
||||
Klass3 getKlass3A() { return ::Klass3(); }
|
||||
::Klass3 getKlass3B() { return ::Klass3(); }
|
||||
|
||||
Klass4 getKlass4A() { return ::Klass4(); }
|
||||
::Klass4 getKlass4B() { return ::Klass4(); }
|
||||
|
||||
Klass5 getKlass5A() { return ::Klass5(); }
|
||||
::Klass5 getKlass5B() { return ::Klass5(); }
|
||||
|
||||
Klass6 getKlass6A() { return ::Klass6(); }
|
||||
::Klass6 getKlass6B() { return ::Klass6(); }
|
||||
|
||||
Klass7 getKlass7A() { return ::Klass7(); }
|
||||
::Klass7 getKlass7B() { return ::Klass7(); }
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ namespace Spac {
|
|||
|
||||
}
|
||||
|
||||
void funcptrtest( void (*)(::Dingaling) ) {}
|
||||
extern "C" void funcptrtest( void (*)(::Dingaling) ) {}
|
||||
%}
|
||||
|
||||
|
|
|
|||
94
Examples/test-suite/go/Makefile.in
Normal file
94
Examples/test-suite/go/Makefile.in
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#######################################################################
|
||||
# Makefile for Go test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = go
|
||||
GO = @GO@
|
||||
GOGCC = false
|
||||
SCRIPTSUFFIX = _runme.go
|
||||
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi`
|
||||
GOC = $(GO:g=c)
|
||||
GOLD = $(GO:g=l)
|
||||
|
||||
GOOBJEXT = $(GO:g=)
|
||||
|
||||
SO = @SO@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
.SUFFIXES: .cpptest .ctest .multicpptest
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_multi_testcase)
|
||||
|
||||
multi_import.multicpptest:
|
||||
$(setup)
|
||||
for f in multi_import_b multi_import_a; do \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
|
||||
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
|
||||
$(LANGUAGE)$(VARIANT)_cpp; \
|
||||
done
|
||||
$(run_multi_testcase)
|
||||
|
||||
# Runs the testcase.
|
||||
run_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
run_multi_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
%.clean:
|
||||
@rm -f $*.go $*_gc.c $*_wrap.* $*_runme
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile go_clean
|
||||
rm -f mod_a.go mod_b.go imports_a.go imports_b.go
|
||||
rm -f clientdata_prop_a.go clientdata_prop_b.go
|
||||
rm -f multi_import_a.go multi_import_b.go
|
||||
rm -f packageoption_a.go packageoption_b.go packageoption_c.go
|
||||
|
||||
cvsignore:
|
||||
@echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib'
|
||||
@echo Makefile
|
||||
@echo mod_a.go mod_b.go imports_a.go imports_b.go
|
||||
@echo clientdata_prop_a.go clientdata_prop_b.go
|
||||
@echo multi_import_a.go multi_import_b.go
|
||||
@echo packageoption_a.go packageoption_b.go packageoption_c.go
|
||||
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.go; done
|
||||
10
Examples/test-suite/go/abstract_access_runme.go
Normal file
10
Examples/test-suite/go/abstract_access_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import "./abstract_access"
|
||||
|
||||
func main() {
|
||||
d := abstract_access.NewD()
|
||||
if d.Do_x() != 1 {
|
||||
panic(d.Do_x())
|
||||
}
|
||||
}
|
||||
7
Examples/test-suite/go/abstract_typedef2_runme.go
Normal file
7
Examples/test-suite/go/abstract_typedef2_runme.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "./abstract_typedef2"
|
||||
|
||||
func main() {
|
||||
abstract_typedef2.NewA_UF()
|
||||
}
|
||||
11
Examples/test-suite/go/abstract_typedef_runme.go
Normal file
11
Examples/test-suite/go/abstract_typedef_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./abstract_typedef"
|
||||
|
||||
func main() {
|
||||
e := abstract_typedef.NewEngine()
|
||||
a := abstract_typedef.NewA()
|
||||
if !a.Write(e) {
|
||||
panic("failed")
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/abstract_virtual_runme.go
Normal file
8
Examples/test-suite/go/abstract_virtual_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import "./abstract_virtual"
|
||||
|
||||
func main() {
|
||||
abstract_virtual.NewD()
|
||||
abstract_virtual.NewE()
|
||||
}
|
||||
26
Examples/test-suite/go/array_member_runme.go
Normal file
26
Examples/test-suite/go/array_member_runme.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import . "./array_member"
|
||||
|
||||
func main() {
|
||||
f := NewFoo()
|
||||
f.SetData(GetGlobal_data())
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) {
|
||||
panic("Bad array assignment")
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
Set_value(f.GetData(), i, -i)
|
||||
}
|
||||
|
||||
SetGlobal_data(f.GetData())
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) {
|
||||
panic("Bad array assignment")
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Examples/test-suite/go/arrays_global_runme.go
Normal file
22
Examples/test-suite/go/arrays_global_runme.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import . "./arrays_global"
|
||||
|
||||
func main() {
|
||||
SetArray_i(GetArray_const_i())
|
||||
|
||||
GetBeginString_FIX44a()
|
||||
GetBeginString_FIX44b()
|
||||
GetBeginString_FIX44c()
|
||||
GetBeginString_FIX44d()
|
||||
GetBeginString_FIX44d()
|
||||
SetBeginString_FIX44b("12\00045")
|
||||
GetBeginString_FIX44b()
|
||||
GetBeginString_FIX44d()
|
||||
GetBeginString_FIX44e()
|
||||
GetBeginString_FIX44f()
|
||||
|
||||
Test_a("hello", "hi", "chello", "chi")
|
||||
|
||||
Test_b("1234567", "hi")
|
||||
}
|
||||
10
Examples/test-suite/go/class_ignore_runme.go
Normal file
10
Examples/test-suite/go/class_ignore_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import "./class_ignore"
|
||||
|
||||
func main() {
|
||||
a := class_ignore.NewBar()
|
||||
if class_ignore.Do_blah(a) != "Bar::blah" {
|
||||
panic(class_ignore.Do_blah(a))
|
||||
}
|
||||
}
|
||||
11
Examples/test-suite/go/class_scope_weird_runme.go
Normal file
11
Examples/test-suite/go/class_scope_weird_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./class_scope_weird"
|
||||
|
||||
func main() {
|
||||
f := class_scope_weird.NewFoo()
|
||||
class_scope_weird.NewFoo(3)
|
||||
if f.Bar(3) != 3 {
|
||||
panic(f.Bar(3))
|
||||
}
|
||||
}
|
||||
29
Examples/test-suite/go/compactdefaultargs_runme.go
Normal file
29
Examples/test-suite/go/compactdefaultargs_runme.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import . "./compactdefaultargs"
|
||||
|
||||
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() != -1.0 {
|
||||
println(2, defaults1.Ret())
|
||||
panic(defaults1.Ret())
|
||||
}
|
||||
|
||||
defaults2 := NewDefaults2(1000)
|
||||
defaults2 = NewDefaults2()
|
||||
|
||||
if defaults2.Ret(float64(10.0)) != 10.0 {
|
||||
panic(defaults2.Ret(float64(10.0)))
|
||||
}
|
||||
|
||||
if defaults2.Ret() != -1.0 {
|
||||
panic(defaults2.Ret())
|
||||
}
|
||||
}
|
||||
50
Examples/test-suite/go/constover_runme.go
Normal file
50
Examples/test-suite/go/constover_runme.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"./constover"
|
||||
)
|
||||
|
||||
func main() {
|
||||
error := 0
|
||||
|
||||
p := constover.Test("test")
|
||||
if p != "test" {
|
||||
fmt.Println("test failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = constover.Test_pconst("test")
|
||||
if p != "test_pconst" {
|
||||
fmt.Println("test_pconst failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
f := constover.NewFoo()
|
||||
p = f.Test("test")
|
||||
if p != "test" {
|
||||
fmt.Println("member-test failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = f.Test_pconst("test")
|
||||
if p != "test_pconst" {
|
||||
fmt.Println("member-test_pconst failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = f.Test_constm("test")
|
||||
if p != "test_constmethod" {
|
||||
fmt.Println("member-test_constm failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = f.Test_pconstm("test")
|
||||
if p != "test_pconstmethod" {
|
||||
fmt.Println("member-test_pconstm failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
os.Exit(error)
|
||||
}
|
||||
34
Examples/test-suite/go/constructor_copy_runme.go
Normal file
34
Examples/test-suite/go/constructor_copy_runme.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import . "./constructor_copy"
|
||||
|
||||
func main() {
|
||||
f1 := NewFoo1(3)
|
||||
f11 := NewFoo1(f1)
|
||||
|
||||
if f1.GetX() != f11.GetX() {
|
||||
panic("f1/f11 x mismatch")
|
||||
}
|
||||
|
||||
bi := NewBari(5)
|
||||
bc := NewBari(bi)
|
||||
|
||||
if bi.GetX() != bc.GetX() {
|
||||
panic("bi/bc x mismatch")
|
||||
}
|
||||
|
||||
bd := NewBard(5)
|
||||
good := false
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
good = true
|
||||
}
|
||||
}()
|
||||
NewBard(bd)
|
||||
}()
|
||||
|
||||
if !good {
|
||||
panic("bd !good")
|
||||
}
|
||||
}
|
||||
208
Examples/test-suite/go/contract_runme.go
Normal file
208
Examples/test-suite/go/contract_runme.go
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
package main
|
||||
|
||||
import "./contract"
|
||||
|
||||
func main() {
|
||||
contract.Test_preassert(1, 2)
|
||||
contract.Test_postassert(3)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Postassertions are broken")
|
||||
}
|
||||
}()
|
||||
contract.Test_postassert(-3)
|
||||
}()
|
||||
|
||||
contract.Test_prepost(2, 3)
|
||||
contract.Test_prepost(5, -4)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Preassertions are broken")
|
||||
}
|
||||
}()
|
||||
contract.Test_prepost(-3, 4)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Postassertions are broken")
|
||||
}
|
||||
}()
|
||||
contract.Test_prepost(4, -10)
|
||||
}()
|
||||
|
||||
f := contract.NewFoo()
|
||||
f.Test_preassert(4, 5)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method preassertion.")
|
||||
}
|
||||
}()
|
||||
f.Test_preassert(-2, 3)
|
||||
}()
|
||||
|
||||
f.Test_postassert(4)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method postassertion")
|
||||
}
|
||||
}()
|
||||
f.Test_postassert(-4)
|
||||
}()
|
||||
|
||||
f.Test_prepost(3, 4)
|
||||
f.Test_prepost(4, -3)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method preassertion.")
|
||||
}
|
||||
}()
|
||||
f.Test_prepost(-4, 2)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method postassertion.")
|
||||
}
|
||||
}()
|
||||
f.Test_prepost(4, -10)
|
||||
}()
|
||||
|
||||
contract.FooStest_prepost(4, 0)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Static method preassertion")
|
||||
}
|
||||
}()
|
||||
contract.FooStest_prepost(-4, 2)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Static method posteassertion")
|
||||
}
|
||||
}()
|
||||
contract.FooStest_prepost(4, -10)
|
||||
}()
|
||||
|
||||
b := contract.NewBar()
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion.")
|
||||
}
|
||||
}()
|
||||
b.Test_prepost(2, -4)
|
||||
}()
|
||||
|
||||
d := contract.NewD()
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(-1, 1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, -1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, 1, -1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, 1, 1, -1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, 1, 1, 1, -1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(-1, 1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, -1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, 1, -1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, 1, 1, -1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, 1, 1, 1, -1)
|
||||
}()
|
||||
|
||||
//Namespace
|
||||
my := contract.NewMyClass(1)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! constructor preassertion")
|
||||
}
|
||||
}()
|
||||
my = contract.NewMyClass(0)
|
||||
}()
|
||||
}
|
||||
27
Examples/test-suite/go/cpp_enum_runme.go
Normal file
27
Examples/test-suite/go/cpp_enum_runme.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import "./cpp_enum"
|
||||
|
||||
func main() {
|
||||
f := cpp_enum.NewFoo()
|
||||
|
||||
if f.GetHola() != cpp_enum.FooHello {
|
||||
panic(f.GetHola())
|
||||
}
|
||||
|
||||
f.SetHola(cpp_enum.FooHi)
|
||||
if f.GetHola() != cpp_enum.FooHi {
|
||||
panic(f.GetHola())
|
||||
}
|
||||
|
||||
f.SetHola(cpp_enum.FooHello)
|
||||
|
||||
if f.GetHola() != cpp_enum.FooHello {
|
||||
panic(f.GetHola())
|
||||
}
|
||||
|
||||
cpp_enum.SetHi(cpp_enum.Hello)
|
||||
if cpp_enum.GetHi() != cpp_enum.Hello {
|
||||
panic(cpp_enum.Hi)
|
||||
}
|
||||
}
|
||||
57
Examples/test-suite/go/cpp_namespace_runme.go
Normal file
57
Examples/test-suite/go/cpp_namespace_runme.go
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// Note: This example assumes that namespaces are flattened
|
||||
package main
|
||||
|
||||
import "./cpp_namespace"
|
||||
|
||||
func main() {
|
||||
n := cpp_namespace.Fact(4)
|
||||
if n != 24 {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.GetFoo() != 42 {
|
||||
panic("Bad variable value!")
|
||||
}
|
||||
|
||||
t := cpp_namespace.NewTest()
|
||||
if t.Method() != "Test::method" {
|
||||
panic("Bad method return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method(t) != "Test::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method2(t) != "Test::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
cpp_namespace.Weird("hello", 4)
|
||||
|
||||
cpp_namespace.DeleteTest(t)
|
||||
|
||||
t2 := cpp_namespace.NewTest2()
|
||||
t3 := cpp_namespace.NewTest3()
|
||||
t4 := cpp_namespace.NewTest4()
|
||||
t5 := cpp_namespace.NewTest5()
|
||||
|
||||
if cpp_namespace.Foo3(42) != 42 {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t2, 40) != "Test2::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t3, 40) != "Test3::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t4, 40) != "Test4::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t5, 40) != "Test5::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
}
|
||||
13
Examples/test-suite/go/cpp_static_runme.go
Normal file
13
Examples/test-suite/go/cpp_static_runme.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import . "./cpp_static"
|
||||
|
||||
func main() {
|
||||
StaticFunctionTestStatic_func()
|
||||
StaticFunctionTestStatic_func_2(1)
|
||||
StaticFunctionTestStatic_func_3(1, 2)
|
||||
SetStaticMemberTestStatic_int(10)
|
||||
if GetStaticMemberTestStatic_int() != 10 {
|
||||
panic(GetStaticMemberTestStatic_int())
|
||||
}
|
||||
}
|
||||
26
Examples/test-suite/go/default_args_runme.go
Normal file
26
Examples/test-suite/go/default_args_runme.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import "./default_args"
|
||||
|
||||
func main() {
|
||||
if default_args.StaticsStaticmethod() != 60 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if default_args.Cfunc1(1) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if default_args.Cfunc2(1) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if default_args.Cfunc3(1) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
f := default_args.NewFoo()
|
||||
|
||||
f.Newname()
|
||||
f.Newname(1)
|
||||
}
|
||||
35
Examples/test-suite/go/default_constructor_runme.go
Normal file
35
Examples/test-suite/go/default_constructor_runme.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import dc "./default_constructor"
|
||||
|
||||
func main() {
|
||||
a := dc.NewA()
|
||||
dc.DeleteA(a)
|
||||
|
||||
aa := dc.NewAA()
|
||||
dc.DeleteAA(aa)
|
||||
|
||||
cc := dc.NewCC()
|
||||
dc.DeleteCC(cc)
|
||||
|
||||
e := dc.NewE()
|
||||
dc.DeleteE(e)
|
||||
|
||||
ee := dc.NewEE()
|
||||
dc.DeleteEE(ee)
|
||||
|
||||
f := dc.NewF()
|
||||
f.Destroy()
|
||||
|
||||
ff := dc.NewFFF()
|
||||
ff.Destroy()
|
||||
|
||||
g := dc.NewG()
|
||||
|
||||
dc.GDestroy(g)
|
||||
|
||||
gg := dc.NewGG()
|
||||
dc.DeleteGG(gg)
|
||||
|
||||
dc.NewHH(1, 1)
|
||||
}
|
||||
62
Examples/test-suite/go/director_abstract_runme.go
Normal file
62
Examples/test-suite/go/director_abstract_runme.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import "./director_abstract"
|
||||
|
||||
type MyFoo struct{}
|
||||
|
||||
func (p *MyFoo) Ping() string {
|
||||
return "MyFoo::ping()"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := director_abstract.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
if a.Ping() != "MyFoo::ping()" {
|
||||
panic(a.Ping())
|
||||
}
|
||||
|
||||
if a.Pong() != "Foo::pong();MyFoo::ping()" {
|
||||
panic(a.Pong())
|
||||
}
|
||||
}
|
||||
|
||||
type MyExample1 struct{}
|
||||
|
||||
func (p *MyExample1) Color(r, g, b byte) int {
|
||||
return int(r)
|
||||
}
|
||||
|
||||
type MyExample2 struct{}
|
||||
|
||||
func (p *MyExample2) Color(r, g, b byte) int {
|
||||
return int(g)
|
||||
}
|
||||
|
||||
type MyExample3 struct{}
|
||||
|
||||
func (p *MyExample3) Color(r, g, b byte) int {
|
||||
return int(b)
|
||||
}
|
||||
|
||||
func f2() {
|
||||
me1 := director_abstract.NewDirectorExample1(&MyExample1{})
|
||||
if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 {
|
||||
println(director_abstract.Example1Get_color(me1, 1, 2, 3))
|
||||
panic(0)
|
||||
}
|
||||
|
||||
me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2)
|
||||
if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
me3 := director_abstract.NewDirectorExample3_i(&MyExample3{})
|
||||
if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
}
|
||||
115
Examples/test-suite/go/director_basic_runme.go
Normal file
115
Examples/test-suite/go/director_basic_runme.go
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
package main
|
||||
|
||||
import "./director_basic"
|
||||
|
||||
type GoFoo struct{}
|
||||
|
||||
func (p *GoFoo) Ping() string {
|
||||
return "GoFoo::ping()"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := director_basic.NewDirectorFoo(&GoFoo{})
|
||||
|
||||
if a.Ping() != "GoFoo::ping()" {
|
||||
panic(a.Ping())
|
||||
}
|
||||
|
||||
if a.Pong() != "Foo::pong();GoFoo::ping()" {
|
||||
panic(a.Pong())
|
||||
}
|
||||
|
||||
b := director_basic.NewFoo()
|
||||
|
||||
if b.Ping() != "Foo::ping()" {
|
||||
panic(b.Ping())
|
||||
}
|
||||
|
||||
if b.Pong() != "Foo::pong();Foo::ping()" {
|
||||
panic(b.Pong())
|
||||
}
|
||||
|
||||
a1 := director_basic.NewA1(1)
|
||||
|
||||
if a1.Rg(2) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
type GoClass struct {
|
||||
cmethod int
|
||||
}
|
||||
|
||||
func (p *GoClass) Method(uintptr) {
|
||||
p.cmethod = 7
|
||||
}
|
||||
func (p *GoClass) Vmethod(b director_basic.Bar) director_basic.Bar {
|
||||
b.SetX(b.GetX() + 31)
|
||||
return b
|
||||
}
|
||||
|
||||
var bc director_basic.Bar
|
||||
|
||||
func f2() {
|
||||
b := director_basic.NewBar(3)
|
||||
d := director_basic.NewMyClass()
|
||||
pc := &GoClass{0}
|
||||
c := director_basic.NewDirectorMyClass(pc)
|
||||
|
||||
cc := director_basic.MyClassGet_self(c)
|
||||
dd := director_basic.MyClassGet_self(d)
|
||||
|
||||
bc = cc.Cmethod(b)
|
||||
bd := dd.Cmethod(b)
|
||||
|
||||
cc.Method(b.Swigcptr())
|
||||
if pc.cmethod != 7 {
|
||||
panic(pc.cmethod)
|
||||
}
|
||||
|
||||
if bc.GetX() != 34 {
|
||||
panic(bc.GetX())
|
||||
}
|
||||
|
||||
if bd.GetX() != 16 {
|
||||
panic(bd.GetX())
|
||||
}
|
||||
}
|
||||
|
||||
type GoMulti struct {
|
||||
GoClass
|
||||
}
|
||||
|
||||
func (p *GoMulti) Vmethod(b director_basic.Bar) director_basic.Bar {
|
||||
b.SetX(b.GetX() + 31)
|
||||
return b
|
||||
}
|
||||
func (p *GoMulti) Ping() string {
|
||||
return "GoFoo::ping()"
|
||||
}
|
||||
|
||||
func f3() {
|
||||
for i := 0; i < 100; i++ {
|
||||
p := &GoMulti{GoClass{0}}
|
||||
gomult := director_basic.NewDirectorFoo(p)
|
||||
gomult.Pong()
|
||||
director_basic.DeleteDirectorFoo(gomult)
|
||||
}
|
||||
|
||||
p := &GoMulti{GoClass{0}}
|
||||
gomult := director_basic.NewDirectorMyClass(p)
|
||||
fgomult := director_basic.NewDirectorFoo(gomult)
|
||||
|
||||
p1 := director_basic.FooGet_self(fgomult.(director_basic.Foo))
|
||||
p2 := director_basic.MyClassGet_self(gomult.(director_basic.MyClass))
|
||||
|
||||
p1.Ping()
|
||||
p2.Vmethod(bc)
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
}
|
||||
135
Examples/test-suite/go/director_classic_runme.go
Normal file
135
Examples/test-suite/go/director_classic_runme.go
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import . "./director_classic"
|
||||
|
||||
type TargetLangPerson struct{} // From Person
|
||||
func (p *TargetLangPerson) Id() string {
|
||||
return "TargetLangPerson"
|
||||
}
|
||||
|
||||
type TargetLangChild struct{} // Form Child
|
||||
func (p *TargetLangChild) Id() string {
|
||||
return "TargetLangChild"
|
||||
}
|
||||
|
||||
type TargetLangGrandChild struct{} // From Grandchild
|
||||
func (p *TargetLangGrandChild) Id() string {
|
||||
return "TargetLangGrandChild"
|
||||
}
|
||||
|
||||
// Semis - don't override id() in target language
|
||||
|
||||
type TargetLangSemiPerson struct{} // From Person
|
||||
|
||||
type TargetLangSemiChild struct{} // From Child
|
||||
|
||||
type TargetLangSemiGrandChild struct{} // From GrandChild
|
||||
|
||||
// Orphans - don't override id() in C++
|
||||
|
||||
type TargetLangOrphanPerson struct{} // From OrphanPerson
|
||||
func (p *TargetLangOrphanPerson) Id() string {
|
||||
return "TargetLangOrphanPerson"
|
||||
}
|
||||
|
||||
type TargetLangOrphanChild struct{} // From OrphanChild
|
||||
func (p *TargetLangOrphanChild) Id() string {
|
||||
return "TargetLangOrphanChild"
|
||||
}
|
||||
|
||||
func check(person Person, expected string) {
|
||||
debug := false
|
||||
|
||||
// Normal target language polymorphic call
|
||||
ret := person.Id()
|
||||
if debug {
|
||||
fmt.Println(ret)
|
||||
}
|
||||
if ret != expected {
|
||||
panic("Failed. Received: " + ret + " Expected: " + expected)
|
||||
}
|
||||
|
||||
// Polymorphic call from C++
|
||||
caller := NewCaller()
|
||||
caller.SetCallback(person)
|
||||
ret = caller.Call()
|
||||
if debug {
|
||||
fmt.Println(ret)
|
||||
}
|
||||
if ret != expected {
|
||||
panic("Failed. Received: " + ret + " Expected: " + expected)
|
||||
}
|
||||
|
||||
// Polymorphic call of object created in target language and
|
||||
// passed to C++ and back again
|
||||
baseclass := caller.BaseClass()
|
||||
ret = baseclass.Id()
|
||||
if debug {
|
||||
fmt.Println(ret)
|
||||
}
|
||||
if ret != expected {
|
||||
panic("Failed. Received: " + ret + " Expected: " + expected)
|
||||
}
|
||||
|
||||
caller.ResetCallback()
|
||||
if debug {
|
||||
fmt.Println("----------------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
person := NewPerson()
|
||||
check(person, "Person")
|
||||
DeletePerson(person)
|
||||
|
||||
person = NewChild()
|
||||
check(person, "Child")
|
||||
DeletePerson(person)
|
||||
|
||||
person = NewGrandChild()
|
||||
check(person, "GrandChild")
|
||||
DeletePerson(person)
|
||||
|
||||
person = NewDirectorPerson(&TargetLangPerson{})
|
||||
check(person, "TargetLangPerson")
|
||||
DeleteDirectorPerson(person)
|
||||
|
||||
person = NewDirectorChild(&TargetLangChild{})
|
||||
check(person, "TargetLangChild")
|
||||
DeleteDirectorChild(person.(Child))
|
||||
|
||||
person = NewDirectorGrandChild(&TargetLangGrandChild{})
|
||||
check(person, "TargetLangGrandChild")
|
||||
DeleteDirectorGrandChild(person.(GrandChild))
|
||||
|
||||
// Semis - don't override id() in target language
|
||||
person = NewDirectorPerson(&TargetLangSemiPerson{})
|
||||
check(person, "Person")
|
||||
DeleteDirectorPerson(person)
|
||||
|
||||
person = NewDirectorChild(&TargetLangSemiChild{})
|
||||
check(person, "Child")
|
||||
DeleteDirectorChild(person.(Child))
|
||||
|
||||
person = NewDirectorGrandChild(&TargetLangSemiGrandChild{})
|
||||
check(person, "GrandChild")
|
||||
DeleteDirectorGrandChild(person.(GrandChild))
|
||||
|
||||
// Orphans - don't override id() in C++
|
||||
person = NewOrphanPerson()
|
||||
check(person, "Person")
|
||||
DeleteOrphanPerson(person.(OrphanPerson))
|
||||
|
||||
person = NewOrphanChild()
|
||||
check(person, "Child")
|
||||
DeleteOrphanChild(person.(OrphanChild))
|
||||
|
||||
person = NewDirectorOrphanPerson(&TargetLangOrphanPerson{})
|
||||
check(person, "TargetLangOrphanPerson")
|
||||
DeleteDirectorOrphanPerson(person.(OrphanPerson))
|
||||
|
||||
person = NewDirectorOrphanChild(&TargetLangOrphanChild{})
|
||||
check(person, "TargetLangOrphanChild")
|
||||
DeleteDirectorOrphanChild(person.(OrphanChild))
|
||||
}
|
||||
11
Examples/test-suite/go/director_default_runme.go
Normal file
11
Examples/test-suite/go/director_default_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import . "./director_default"
|
||||
|
||||
func main() {
|
||||
NewFoo()
|
||||
NewFoo(1)
|
||||
|
||||
NewBar()
|
||||
NewBar(1)
|
||||
}
|
||||
46
Examples/test-suite/go/director_detect_runme.go
Normal file
46
Examples/test-suite/go/director_detect_runme.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import "./director_detect"
|
||||
|
||||
type MyBar struct {
|
||||
val int
|
||||
} // From director_detect.Bar
|
||||
|
||||
func NewMyBar() director_detect.Bar {
|
||||
return director_detect.NewDirectorBar(&MyBar{2})
|
||||
}
|
||||
|
||||
func (p *MyBar) Get_value() int {
|
||||
p.val++
|
||||
return p.val
|
||||
}
|
||||
|
||||
func (p *MyBar) Get_class() director_detect.A {
|
||||
p.val++
|
||||
return director_detect.NewA()
|
||||
}
|
||||
|
||||
func (p *MyBar) Just_do_it() {
|
||||
p.val++
|
||||
}
|
||||
|
||||
func (p *MyBar) Clone() director_detect.Bar {
|
||||
return director_detect.NewDirectorBar(&MyBar{p.val})
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewMyBar()
|
||||
|
||||
f := b.Baseclass()
|
||||
|
||||
v := f.Get_value()
|
||||
_ = f.Get_class()
|
||||
f.Just_do_it()
|
||||
|
||||
c := b.DirectorInterface().(*MyBar).Clone()
|
||||
vc := c.Get_value()
|
||||
|
||||
if (v != 3) || (b.DirectorInterface().(*MyBar).val != 5) || (vc != 6) {
|
||||
panic("Bad virtual detection")
|
||||
}
|
||||
}
|
||||
17
Examples/test-suite/go/director_enum_runme.go
Normal file
17
Examples/test-suite/go/director_enum_runme.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import "./director_enum"
|
||||
|
||||
type MyFoo struct{} // From director_enum.Foo
|
||||
func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello {
|
||||
return val
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := director_enum.NewFoo()
|
||||
a := director_enum.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
if a.Say_hi(director_enum.Hello) != b.Say_hello(director_enum.Hi) {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
95
Examples/test-suite/go/director_exception_runme.go
Normal file
95
Examples/test-suite/go/director_exception_runme.go
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
package main
|
||||
|
||||
import . "./director_exception"
|
||||
|
||||
type Exception struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func NewException(a, b string) *Exception {
|
||||
return &Exception{a + b}
|
||||
}
|
||||
|
||||
type MyFoo struct{} // From Foo
|
||||
func (p *MyFoo) Ping() string {
|
||||
panic("MyFoo::ping() EXCEPTION")
|
||||
}
|
||||
|
||||
type MyFoo2 struct{} // From Foo
|
||||
func (p *MyFoo2) Ping() bool {
|
||||
return true // should return a string
|
||||
}
|
||||
|
||||
type MyFoo3 struct{} // From Foo
|
||||
func (p *MyFoo3) Ping() string {
|
||||
panic(NewException("foo", "bar"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Check that the NotImplementedError raised by MyFoo.ping()
|
||||
// is returned by MyFoo.pong().
|
||||
ok := false
|
||||
a := NewDirectorFoo(&MyFoo{})
|
||||
b := Launder(a)
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e.(string) == "MyFoo::ping() EXCEPTION" {
|
||||
ok = true
|
||||
} else {
|
||||
panic("Unexpected error message: " + e.(string))
|
||||
}
|
||||
}()
|
||||
b.Pong()
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// Check that if the method has the wrong return type it is
|
||||
// not called.
|
||||
ok = false
|
||||
a = NewDirectorFoo(&MyFoo2{})
|
||||
b = Launder(a)
|
||||
e := b.Pong()
|
||||
if e != "Foo::pong();"+"Foo::ping()" {
|
||||
panic(e)
|
||||
}
|
||||
|
||||
// Check that the director can return an exception which
|
||||
// requires two arguments to the constructor, without mangling
|
||||
// it.
|
||||
ok = false
|
||||
a = NewDirectorFoo(&MyFoo3{})
|
||||
b = Launder(a)
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e.(*Exception).msg == "foobar" {
|
||||
ok = true
|
||||
} else {
|
||||
panic("Unexpected error message: " + e.(string))
|
||||
}
|
||||
}()
|
||||
b.Pong()
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
_ = e.(Exception2)
|
||||
}()
|
||||
panic(NewException2())
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
_ = e.(Exception1)
|
||||
}()
|
||||
panic(NewException1())
|
||||
}()
|
||||
}
|
||||
18
Examples/test-suite/go/director_extend_runme.go
Normal file
18
Examples/test-suite/go/director_extend_runme.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Test case from bug #1506850 "When threading is enabled, the
|
||||
// interpreter will infinitely wait on a mutex the second time this
|
||||
// type of extended method is called. Attached is an example program
|
||||
// that waits on the mutex to be unlocked."
|
||||
|
||||
package main
|
||||
|
||||
import . "./director_extend"
|
||||
|
||||
func main() {
|
||||
m := NewSpObject()
|
||||
if m.Dummy() != 666 {
|
||||
panic("1st call")
|
||||
}
|
||||
if m.Dummy() != 666 {
|
||||
panic("2nd call")
|
||||
}
|
||||
}
|
||||
37
Examples/test-suite/go/director_finalizer_runme.go
Normal file
37
Examples/test-suite/go/director_finalizer_runme.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import . "./director_finalizer"
|
||||
|
||||
type MyFoo struct{} // From Foo
|
||||
func DeleteMyFoo(p Foo) {
|
||||
p.OrStatus(2)
|
||||
DeleteFoo(p)
|
||||
}
|
||||
|
||||
func main() {
|
||||
ResetStatus()
|
||||
|
||||
a := NewDirectorFoo(&MyFoo{})
|
||||
DeleteMyFoo(a)
|
||||
|
||||
if GetStatus() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
ResetStatus()
|
||||
|
||||
a = NewDirectorFoo(&MyFoo{})
|
||||
Launder(a)
|
||||
|
||||
if GetStatus() != 0 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
DeleteMyFoo(a)
|
||||
|
||||
if GetStatus() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
ResetStatus()
|
||||
}
|
||||
12
Examples/test-suite/go/director_frob_runme.go
Normal file
12
Examples/test-suite/go/director_frob_runme.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import . "./director_frob"
|
||||
|
||||
func main() {
|
||||
foo := NewBravo()
|
||||
s := foo.Abs_method()
|
||||
|
||||
if s != "Bravo::abs_method()" {
|
||||
panic(s)
|
||||
}
|
||||
}
|
||||
79
Examples/test-suite/go/director_nested_runme.go
Normal file
79
Examples/test-suite/go/director_nested_runme.go
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
package main
|
||||
|
||||
import . "./director_nested"
|
||||
|
||||
type A struct{} // From FooBar_int
|
||||
func (p *A) Do_step() string {
|
||||
return "A::do_step;"
|
||||
}
|
||||
func (p *A) Get_value() string {
|
||||
return "A::get_value"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := NewDirectorFooBar_int(&A{})
|
||||
if a.Step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;" {
|
||||
panic("Bad A virtual resolution")
|
||||
}
|
||||
}
|
||||
|
||||
type B struct{} // From FooBar_int
|
||||
func (p *B) Do_advance() string {
|
||||
return "B::do_advance;" + p.Do_step()
|
||||
}
|
||||
func (p *B) Do_step() string {
|
||||
return "B::do_step;"
|
||||
}
|
||||
func (p *B) Get_value() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func f2() {
|
||||
b := NewDirectorFooBar_int(&B{})
|
||||
|
||||
if b.Step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;" {
|
||||
panic("Bad B virtual resolution")
|
||||
}
|
||||
}
|
||||
|
||||
type C struct {
|
||||
fbi FooBar_int
|
||||
} // From FooBar_int
|
||||
|
||||
func (p *C) Do_advance() string {
|
||||
return "C::do_advance;" + DirectorFooBar_intDo_advance(p.fbi)
|
||||
}
|
||||
|
||||
func (p *C) Do_step() string {
|
||||
return "C::do_step;"
|
||||
}
|
||||
|
||||
func (p *C) Get_value() int {
|
||||
return 2
|
||||
}
|
||||
|
||||
func (p *C) Get_name() string {
|
||||
return DirectorFooBar_intGet_name(p.fbi) + " hello"
|
||||
}
|
||||
|
||||
func f3() {
|
||||
m := &C{nil}
|
||||
cc := NewDirectorFooBar_int(m)
|
||||
m.fbi = cc
|
||||
c := FooBar_intGet_self(cc)
|
||||
c.Advance()
|
||||
|
||||
if c.Get_name() != "FooBar::get_name hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if c.Name() != "FooBar::get_name hello" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
}
|
||||
49
Examples/test-suite/go/director_profile_runme.go
Normal file
49
Examples/test-suite/go/director_profile_runme.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "./director_profile"
|
||||
|
||||
type MyB struct{} // From director_profile.B
|
||||
func (p *MyB) Vfi(a int) int {
|
||||
return a + 3
|
||||
}
|
||||
|
||||
func main() {
|
||||
_ = director_profile.NewA()
|
||||
myb := director_profile.NewDirectorB(&MyB{})
|
||||
b := director_profile.BGet_self(myb)
|
||||
|
||||
fi := func(a int) int {
|
||||
return b.Fi(a)
|
||||
}
|
||||
|
||||
i := 50000
|
||||
a := 1
|
||||
for i != 0 {
|
||||
a = fi(a) // 1
|
||||
a = fi(a) // 2
|
||||
a = fi(a) // 3
|
||||
a = fi(a) // 4
|
||||
a = fi(a) // 5
|
||||
a = fi(a) // 6
|
||||
a = fi(a) // 7
|
||||
a = fi(a) // 8
|
||||
a = fi(a) // 9
|
||||
a = fi(a) // 10
|
||||
a = fi(a) // 1
|
||||
a = fi(a) // 2
|
||||
a = fi(a) // 3
|
||||
a = fi(a) // 4
|
||||
a = fi(a) // 5
|
||||
a = fi(a) // 6
|
||||
a = fi(a) // 7
|
||||
a = fi(a) // 8
|
||||
a = fi(a) // 9
|
||||
a = fi(a) // 20
|
||||
i -= 1
|
||||
}
|
||||
|
||||
if false {
|
||||
fmt.Println(a)
|
||||
}
|
||||
}
|
||||
48
Examples/test-suite/go/director_protected_runme.go
Normal file
48
Examples/test-suite/go/director_protected_runme.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package main
|
||||
|
||||
import . "./director_protected"
|
||||
|
||||
type FooBar struct{} // From Bar
|
||||
func (p *FooBar) Ping() string {
|
||||
return "FooBar::ping();"
|
||||
}
|
||||
|
||||
type FooBar2 struct{} // From Bar
|
||||
func (p *FooBar2) Ping() string {
|
||||
return "FooBar2::ping();"
|
||||
}
|
||||
func (p *FooBar2) Pang() string {
|
||||
return "FooBar2::pang();"
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewBar()
|
||||
f := b.Create()
|
||||
fb := NewDirectorBar(&FooBar{})
|
||||
fb2 := NewDirectorBar(&FooBar2{})
|
||||
|
||||
s := fb.Used()
|
||||
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = fb2.Used()
|
||||
if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = b.Pong()
|
||||
if s != "Bar::pong();Foo::pong();Bar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = f.Pong()
|
||||
if s != "Bar::pong();Foo::pong();Bar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = fb.Pong()
|
||||
if s != "Bar::pong();Foo::pong();FooBar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
39
Examples/test-suite/go/director_string_runme.go
Normal file
39
Examples/test-suite/go/director_string_runme.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import . "./director_string"
|
||||
|
||||
type B struct { // From A
|
||||
abi A
|
||||
smem string
|
||||
}
|
||||
|
||||
func NewB(s string) A {
|
||||
p := &B{nil, ""}
|
||||
ret := NewDirectorA(p, s)
|
||||
p.abi = ret
|
||||
return ret
|
||||
}
|
||||
|
||||
func (p *B) Get_first() string {
|
||||
return DirectorAGet_first(p.abi) + " world!"
|
||||
}
|
||||
|
||||
func (p *B) Process_text(s string) {
|
||||
DirectorAProcess_text(p.abi, s)
|
||||
p.smem = "hello"
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewB("hello")
|
||||
|
||||
b.Get(0)
|
||||
if b.Get_first() != "hello world!" {
|
||||
panic(b.Get_first())
|
||||
}
|
||||
|
||||
b.Call_process_func()
|
||||
|
||||
if b.DirectorInterface().(*B).smem != "hello" {
|
||||
panic(b.DirectorInterface().(*B).smem)
|
||||
}
|
||||
}
|
||||
28
Examples/test-suite/go/director_thread_runme.go
Normal file
28
Examples/test-suite/go/director_thread_runme.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import . "./director_thread"
|
||||
|
||||
type Derived struct {
|
||||
abi Foo
|
||||
} // From Foo
|
||||
func (p *Derived) Do_foo() {
|
||||
p.abi.SetVal(p.abi.GetVal() - 1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// FIXME: This test fails until we fix callbacks from a
|
||||
// different thread.
|
||||
return
|
||||
|
||||
p := &Derived{nil}
|
||||
d := NewDirectorFoo(p)
|
||||
p.abi = d
|
||||
d.Run()
|
||||
|
||||
if d.GetVal() >= 0 {
|
||||
panic(d.GetVal())
|
||||
}
|
||||
|
||||
d.Stop()
|
||||
}
|
||||
21
Examples/test-suite/go/director_unroll_runme.go
Normal file
21
Examples/test-suite/go/director_unroll_runme.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import "./director_unroll"
|
||||
|
||||
type MyFoo struct{} // From director_unroll.Foo
|
||||
func (p *MyFoo) Ping() string {
|
||||
return "MyFoo::ping()"
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := director_unroll.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
b := director_unroll.NewBar()
|
||||
|
||||
b.Set(a)
|
||||
c := b.Get()
|
||||
|
||||
if c.Ping() != "MyFoo::ping()" {
|
||||
panic(c.Ping())
|
||||
}
|
||||
}
|
||||
10
Examples/test-suite/go/disown_runme.go
Normal file
10
Examples/test-suite/go/disown_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import . "./disown"
|
||||
|
||||
func main() {
|
||||
a := NewA()
|
||||
|
||||
b := NewB()
|
||||
b.Acquire(a)
|
||||
}
|
||||
16
Examples/test-suite/go/dynamic_cast_runme.go
Normal file
16
Examples/test-suite/go/dynamic_cast_runme.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import "./dynamic_cast"
|
||||
|
||||
func main() {
|
||||
f := dynamic_cast.NewFoo()
|
||||
b := dynamic_cast.NewBar()
|
||||
|
||||
_ = f.Blah()
|
||||
y := b.Blah()
|
||||
|
||||
a := dynamic_cast.Do_test(dynamic_cast.FooToBar(y))
|
||||
if a != "Bar::test" {
|
||||
panic("Failed!!")
|
||||
}
|
||||
}
|
||||
6
Examples/test-suite/go/empty_runme.go
Normal file
6
Examples/test-suite/go/empty_runme.go
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
|
||||
import _ "./empty"
|
||||
|
||||
func main() {
|
||||
}
|
||||
11
Examples/test-suite/go/enum_template_runme.go
Normal file
11
Examples/test-suite/go/enum_template_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./enum_template"
|
||||
|
||||
func main() {
|
||||
if enum_template.MakeETest() != 1 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
enum_template.TakeETest(0)
|
||||
}
|
||||
25
Examples/test-suite/go/enums_runme.go
Normal file
25
Examples/test-suite/go/enums_runme.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import "./enums"
|
||||
|
||||
func main() {
|
||||
enums.Bar2(1)
|
||||
enums.Bar3(1)
|
||||
enums.Bar1(1)
|
||||
|
||||
if enums.GetEnumInstance() != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if enums.GetSlap() != 10 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if enums.GetMine() != 11 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if enums.GetThigh() != 12 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
58
Examples/test-suite/go/exception_order_runme.go
Normal file
58
Examples/test-suite/go/exception_order_runme.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import "strings"
|
||||
import . "./exception_order"
|
||||
|
||||
func main() {
|
||||
a := NewA()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E1") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Foo()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E2") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Bar()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e.(string) != "postcatch unknown" {
|
||||
panic("bad exception order")
|
||||
}
|
||||
}()
|
||||
a.Foobar()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E1") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Barfoo(1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E2") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Barfoo(2)
|
||||
}()
|
||||
}
|
||||
47
Examples/test-suite/go/extend_placement_runme.go
Normal file
47
Examples/test-suite/go/extend_placement_runme.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import "./extend_placement"
|
||||
|
||||
func main() {
|
||||
foo := extend_placement.NewFoo()
|
||||
foo = extend_placement.NewFoo(1)
|
||||
foo = extend_placement.NewFoo(1, 1)
|
||||
foo.Spam()
|
||||
foo.Spam("hello")
|
||||
foo.Spam(1)
|
||||
foo.Spam(1, 1)
|
||||
foo.Spam(1, 1, 1)
|
||||
foo.Spam(extend_placement.NewFoo())
|
||||
foo.Spam(extend_placement.NewFoo(), float64(1.0))
|
||||
|
||||
bar := extend_placement.NewBar()
|
||||
bar = extend_placement.NewBar(1)
|
||||
bar.Spam()
|
||||
bar.Spam("hello")
|
||||
bar.Spam(1)
|
||||
bar.Spam(1, 1)
|
||||
bar.Spam(1, 1, 1)
|
||||
bar.Spam(extend_placement.NewBar())
|
||||
bar.Spam(extend_placement.NewBar(), float64(1.0))
|
||||
|
||||
footi := extend_placement.NewFooTi()
|
||||
footi = extend_placement.NewFooTi(1)
|
||||
footi = extend_placement.NewFooTi(1, 1)
|
||||
footi.Spam()
|
||||
footi.Spam("hello")
|
||||
footi.Spam(1)
|
||||
footi.Spam(1, 1)
|
||||
footi.Spam(1, 1, 1)
|
||||
footi.Spam(extend_placement.NewFoo())
|
||||
footi.Spam(extend_placement.NewFoo(), float64(1.0))
|
||||
|
||||
barti := extend_placement.NewBarTi()
|
||||
barti = extend_placement.NewBarTi(1)
|
||||
barti.Spam()
|
||||
barti.Spam("hello")
|
||||
barti.Spam(1)
|
||||
barti.Spam(1, 1)
|
||||
barti.Spam(1, 1, 1)
|
||||
barti.Spam(extend_placement.NewBar())
|
||||
barti.Spam(extend_placement.NewBar(), float64(1.0))
|
||||
}
|
||||
14
Examples/test-suite/go/extend_template_ns_runme.go
Normal file
14
Examples/test-suite/go/extend_template_ns_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./extend_template_ns"
|
||||
|
||||
func main() {
|
||||
f := NewFoo_One()
|
||||
if f.Test1(37) != 37 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if f.Test2(42) != 42 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
14
Examples/test-suite/go/extend_template_runme.go
Normal file
14
Examples/test-suite/go/extend_template_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import "./extend_template"
|
||||
|
||||
func main() {
|
||||
f := extend_template.NewFoo_0()
|
||||
if f.Test1(37) != 37 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if f.Test2(42) != 42 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
9
Examples/test-suite/go/extend_variable_runme.go
Normal file
9
Examples/test-suite/go/extend_variable_runme.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import . "./extend_variable"
|
||||
|
||||
func main() {
|
||||
if FooBar != 42 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
7
Examples/test-suite/go/extern_c_runme.go
Normal file
7
Examples/test-suite/go/extern_c_runme.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "./extern_c"
|
||||
|
||||
func main() {
|
||||
extern_c.RealFunction(2)
|
||||
}
|
||||
50
Examples/test-suite/go/friends_runme.go
Normal file
50
Examples/test-suite/go/friends_runme.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import "./friends"
|
||||
|
||||
func main() {
|
||||
a := friends.NewA(2)
|
||||
|
||||
if friends.Get_val1(a).(int) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val2(a) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val3(a) != 6 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// nice overload working fine
|
||||
if friends.Get_val1(1, 2, 3).(int) != 1 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
b := friends.NewB(3)
|
||||
|
||||
// David's case
|
||||
if friends.Mix(a, b) != 5 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
di := friends.NewD_d(2)
|
||||
dd := friends.NewD_d(3.3)
|
||||
|
||||
// incredible template overloading working just fine
|
||||
if friends.Get_val1(di).(float64) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val1(dd).(float64) != 3.3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
friends.Set(di, float64(4.0))
|
||||
friends.Set(dd, float64(1.3))
|
||||
|
||||
if friends.Get_val1(di).(float64) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val1(dd).(float64) != 1.3 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
13
Examples/test-suite/go/fvirtual_runme.go
Normal file
13
Examples/test-suite/go/fvirtual_runme.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import . "./fvirtual"
|
||||
|
||||
func main() {
|
||||
sw := NewNodeSwitch()
|
||||
n := NewNode()
|
||||
i := sw.AddChild(n)
|
||||
|
||||
if i != 2 {
|
||||
panic("addChild")
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/global_ns_arg_runme.go
Normal file
8
Examples/test-suite/go/global_ns_arg_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import . "./global_ns_arg"
|
||||
|
||||
func main() {
|
||||
Foo(1)
|
||||
Bar()
|
||||
}
|
||||
19
Examples/test-suite/go/grouping_runme.go
Normal file
19
Examples/test-suite/go/grouping_runme.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import "./grouping"
|
||||
|
||||
func main() {
|
||||
x := grouping.Test1(42)
|
||||
if x != 42 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
grouping.Test2(42)
|
||||
|
||||
x = grouping.Do_unary(37, grouping.NEGATE)
|
||||
if x != -37 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
grouping.SetTest3(42)
|
||||
}
|
||||
12
Examples/test-suite/go/import_nomodule_runme.go
Normal file
12
Examples/test-suite/go/import_nomodule_runme.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import . "./import_nomodule"
|
||||
|
||||
func main() {
|
||||
f := Create_Foo()
|
||||
Test1(f, 42)
|
||||
Delete_Foo(f)
|
||||
|
||||
b := NewBar()
|
||||
Test1(b, 37)
|
||||
}
|
||||
17
Examples/test-suite/go/imports_runme.go
Normal file
17
Examples/test-suite/go/imports_runme.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// This is the import runtime testcase.
|
||||
|
||||
package main
|
||||
|
||||
import "imports_b"
|
||||
import "imports_a"
|
||||
|
||||
func main() {
|
||||
x := imports_b.NewB()
|
||||
x.Hello()
|
||||
|
||||
_ = imports_a.NewA()
|
||||
|
||||
c := imports_b.NewC()
|
||||
_ = c.Get_a(c)
|
||||
_ = c.Get_a_type(c)
|
||||
}
|
||||
18
Examples/test-suite/go/inctest_runme.go
Normal file
18
Examples/test-suite/go/inctest_runme.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import "./inctest"
|
||||
|
||||
func main() {
|
||||
inctest.NewA()
|
||||
inctest.NewB()
|
||||
|
||||
// Check the import in subdirectory worked
|
||||
if inctest.Importtest1(5) != 15 {
|
||||
panic("import test 1 failed")
|
||||
}
|
||||
|
||||
a := []byte("black")
|
||||
if inctest.Importtest2(string(a)) != "white" {
|
||||
panic("import test 2 failed")
|
||||
}
|
||||
}
|
||||
26
Examples/test-suite/go/inherit_missing_runme.go
Normal file
26
Examples/test-suite/go/inherit_missing_runme.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import "./inherit_missing"
|
||||
|
||||
func main() {
|
||||
a := inherit_missing.New_Foo()
|
||||
b := inherit_missing.NewBar()
|
||||
c := inherit_missing.NewSpam()
|
||||
|
||||
x := inherit_missing.Do_blah(a)
|
||||
if x != "Foo::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
x = inherit_missing.Do_blah(b)
|
||||
if x != "Bar::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
x = inherit_missing.Do_blah(c)
|
||||
if x != "Spam::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
inherit_missing.Delete_Foo(a)
|
||||
}
|
||||
14
Examples/test-suite/go/input_runme.go
Normal file
14
Examples/test-suite/go/input_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./input"
|
||||
|
||||
func main() {
|
||||
f := NewFoo()
|
||||
if f.Foo(2) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Sfoo("Hello") != "Hello world" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/keyword_rename_runme.go
Normal file
8
Examples/test-suite/go/keyword_rename_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import "./keyword_rename"
|
||||
|
||||
func main() {
|
||||
keyword_rename.Xgo(1)
|
||||
keyword_rename.Xchan(1)
|
||||
}
|
||||
90
Examples/test-suite/go/li_attribute_runme.go
Normal file
90
Examples/test-suite/go/li_attribute_runme.go
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
package main
|
||||
|
||||
import "./li_attribute"
|
||||
|
||||
func main() {
|
||||
aa := li_attribute.NewA(1, 2, 3)
|
||||
|
||||
if aa.GetA() != 1 {
|
||||
panic(0)
|
||||
}
|
||||
aa.SetA(3)
|
||||
if aa.GetA() != 3 {
|
||||
panic(aa.GetA())
|
||||
}
|
||||
|
||||
if aa.GetB() != 2 {
|
||||
panic(aa.GetB())
|
||||
}
|
||||
aa.SetB(5)
|
||||
if aa.GetB() != 5 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if aa.GetD() != aa.GetB() {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if aa.GetC() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
pi := li_attribute.NewParam_i(7)
|
||||
if pi.GetValue() != 7 {
|
||||
panic(0)
|
||||
}
|
||||
pi.SetValue(3)
|
||||
if pi.GetValue() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
b := li_attribute.NewB(aa)
|
||||
|
||||
if b.GetA().GetC() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// class/struct attribute with get/set methods using
|
||||
// return/pass by reference
|
||||
myFoo := li_attribute.NewMyFoo()
|
||||
myFoo.SetX(8)
|
||||
myClass := li_attribute.NewMyClass()
|
||||
myClass.SetFoo(myFoo)
|
||||
if myClass.GetFoo().GetX() != 8 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// class/struct attribute with get/set methods using
|
||||
// return/pass by value
|
||||
myClassVal := li_attribute.NewMyClassVal()
|
||||
if myClassVal.GetReadWriteFoo().GetX() != -1 {
|
||||
panic(0)
|
||||
}
|
||||
if myClassVal.GetReadOnlyFoo().GetX() != -1 {
|
||||
panic(0)
|
||||
}
|
||||
myClassVal.SetReadWriteFoo(myFoo)
|
||||
if myClassVal.GetReadWriteFoo().GetX() != 8 {
|
||||
panic(0)
|
||||
}
|
||||
if myClassVal.GetReadOnlyFoo().GetX() != 8 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// string attribute with get/set methods using return/pass by
|
||||
// value
|
||||
myStringyClass := li_attribute.NewMyStringyClass("initial string")
|
||||
if myStringyClass.GetReadWriteString() != "initial string" {
|
||||
panic(0)
|
||||
}
|
||||
if myStringyClass.GetReadOnlyString() != "initial string" {
|
||||
panic(0)
|
||||
}
|
||||
myStringyClass.SetReadWriteString("changed string")
|
||||
if myStringyClass.GetReadWriteString() != "changed string" {
|
||||
panic(0)
|
||||
}
|
||||
if myStringyClass.GetReadOnlyString() != "changed string" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
14
Examples/test-suite/go/li_carrays_runme.go
Normal file
14
Examples/test-suite/go/li_carrays_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./li_carrays"
|
||||
|
||||
func main() {
|
||||
d := NewDoubleArray(10)
|
||||
|
||||
d.Setitem(0, 7)
|
||||
d.Setitem(5, d.Getitem(0)+3)
|
||||
|
||||
if d.Getitem(5)+d.Getitem(0) != 17 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
13
Examples/test-suite/go/li_cdata_runme.go
Normal file
13
Examples/test-suite/go/li_cdata_runme.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import . "./li_cdata"
|
||||
|
||||
func main() {
|
||||
s := "ABC abc"
|
||||
m := Malloc(256)
|
||||
Memmove(m, s, len(s))
|
||||
ss := Cdata(m, 7)
|
||||
if string(ss) != "ABC abc" {
|
||||
panic("failed")
|
||||
}
|
||||
}
|
||||
25
Examples/test-suite/go/li_cmalloc_runme.go
Normal file
25
Examples/test-suite/go/li_cmalloc_runme.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import . "./li_cmalloc"
|
||||
|
||||
func main() {
|
||||
p := Malloc_int()
|
||||
Free_int(p)
|
||||
|
||||
ok := false
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
ok = true
|
||||
}
|
||||
}()
|
||||
p = Calloc_int(-1)
|
||||
if p == nil {
|
||||
ok = true
|
||||
}
|
||||
Free_int(p)
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
14
Examples/test-suite/go/li_cpointer_runme.go
Normal file
14
Examples/test-suite/go/li_cpointer_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./li_cpointer"
|
||||
|
||||
func main() {
|
||||
p := New_intp()
|
||||
Intp_assign(p, 3)
|
||||
|
||||
if Intp_value(p) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
Delete_intp(p)
|
||||
}
|
||||
30
Examples/test-suite/go/li_std_map_runme.go
Normal file
30
Examples/test-suite/go/li_std_map_runme.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import "./li_std_map"
|
||||
|
||||
func main() {
|
||||
a1 := li_std_map.NewA(3)
|
||||
a2 := li_std_map.NewA(7)
|
||||
|
||||
_ = li_std_map.NewPairii(1, 2)
|
||||
p1 := li_std_map.NewPairA(1, a1)
|
||||
m := li_std_map.NewMapA()
|
||||
m.Set(1, a1)
|
||||
m.Set(2, a2)
|
||||
|
||||
_ = li_std_map.P_identa(p1)
|
||||
_ = li_std_map.M_identa(m)
|
||||
|
||||
m = li_std_map.NewMapA()
|
||||
m.Set(1, a1)
|
||||
m.Set(2, a2)
|
||||
|
||||
mii := li_std_map.NewIntIntMap()
|
||||
|
||||
mii.Set(1, 1)
|
||||
mii.Set(1, 2)
|
||||
|
||||
if mii.Get(1) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
12
Examples/test-suite/go/li_std_vector_ptr_runme.go
Normal file
12
Examples/test-suite/go/li_std_vector_ptr_runme.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import . "./li_std_vector_ptr"
|
||||
|
||||
func main() {
|
||||
ip1 := MakeIntPtr(11)
|
||||
ip2 := MakeIntPtr(22)
|
||||
vi := NewIntPtrVector()
|
||||
vi.Add(ip1)
|
||||
vi.Add(ip2)
|
||||
DisplayVector(vi)
|
||||
}
|
||||
49
Examples/test-suite/go/member_pointer_runme.go
Normal file
49
Examples/test-suite/go/member_pointer_runme.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// Example using pointers to member functions
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import . "./member_pointer"
|
||||
|
||||
func check(what string, expected float64, actual float64) {
|
||||
if expected != actual {
|
||||
panic(fmt.Sprintf("Failed: %s Expected: %f Actual; %f", what, expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Get the pointers
|
||||
|
||||
area_pt := Areapt()
|
||||
perim_pt := Perimeterpt()
|
||||
|
||||
// Create some objects
|
||||
|
||||
s := NewSquare(10)
|
||||
|
||||
// Do some calculations
|
||||
|
||||
check("Square area ", 100.0, Do_op(s, area_pt))
|
||||
check("Square perim", 40.0, Do_op(s, perim_pt))
|
||||
|
||||
_ = GetAreavar()
|
||||
_ = GetPerimetervar()
|
||||
|
||||
// Try the variables
|
||||
check("Square area ", 100.0, Do_op(s, GetAreavar()))
|
||||
check("Square perim", 40.0, Do_op(s, GetPerimetervar()))
|
||||
|
||||
// Modify one of the variables
|
||||
SetAreavar(perim_pt)
|
||||
|
||||
check("Square perimeter", 40.0, Do_op(s, GetAreavar()))
|
||||
|
||||
// Try the constants
|
||||
|
||||
_ = AREAPT
|
||||
_ = PERIMPT
|
||||
_ = NULLPT
|
||||
|
||||
check("Square area ", 100.0, Do_op(s, AREAPT))
|
||||
check("Square perim", 40.0, Do_op(s, PERIMPT))
|
||||
}
|
||||
11
Examples/test-suite/go/memberin_extend_c_runme.go
Normal file
11
Examples/test-suite/go/memberin_extend_c_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./memberin_extend_c"
|
||||
|
||||
func main() {
|
||||
t := memberin_extend_c.NewPerson()
|
||||
t.SetName("Fred Bloggs")
|
||||
if t.GetName() != "FRED BLOGGS" {
|
||||
panic("name wrong")
|
||||
}
|
||||
}
|
||||
82
Examples/test-suite/go/minherit_runme.go
Normal file
82
Examples/test-suite/go/minherit_runme.go
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "./minherit"
|
||||
|
||||
func main() {
|
||||
a := minherit.NewFoo()
|
||||
b := minherit.NewBar()
|
||||
c := minherit.NewFooBar()
|
||||
d := minherit.NewSpam()
|
||||
|
||||
if a.Xget() != 1 {
|
||||
panic("1 Bad attribute value")
|
||||
}
|
||||
|
||||
if b.Yget() != 2 {
|
||||
panic("2 Bad attribute value")
|
||||
}
|
||||
|
||||
if c.Xget() != 1 || c.Yget() != 2 || c.Zget() != 3 {
|
||||
panic("3 Bad attribute value")
|
||||
}
|
||||
|
||||
if d.Xget() != 1 || d.Yget() != 2 || d.Zget() != 3 || d.Wget() != 4 {
|
||||
panic("4 Bad attribute value")
|
||||
}
|
||||
|
||||
if minherit.Xget(a) != 1 {
|
||||
panic(fmt.Sprintf("5 Bad attribute value %d", minherit.Xget(a)))
|
||||
}
|
||||
|
||||
if minherit.Yget(b) != 2 {
|
||||
panic(fmt.Sprintf("6 Bad attribute value %d", minherit.Yget(b)))
|
||||
}
|
||||
|
||||
if minherit.Xget(c) != 1 || minherit.Yget(c.SwigGetBar()) != 2 || minherit.Zget(c) != 3 {
|
||||
panic(fmt.Sprintf("7 Bad attribute value %d %d %d", minherit.Xget(c), minherit.Yget(c.SwigGetBar()), minherit.Zget(c)))
|
||||
}
|
||||
|
||||
if minherit.Xget(d) != 1 || minherit.Yget(d.SwigGetBar()) != 2 || minherit.Zget(d) != 3 || minherit.Wget(d) != 4 {
|
||||
panic(fmt.Sprintf("8 Bad attribute value %d %d %d %d", minherit.Xget(d), minherit.Yget(d.SwigGetBar()), minherit.Zget(d), minherit.Wget(d)))
|
||||
}
|
||||
|
||||
// Cleanse all of the pointers and see what happens
|
||||
|
||||
aa := minherit.ToFooPtr(a)
|
||||
bb := minherit.ToBarPtr(b)
|
||||
cc := minherit.ToFooBarPtr(c)
|
||||
dd := minherit.ToSpamPtr(d)
|
||||
|
||||
if aa.Xget() != 1 {
|
||||
panic("9 Bad attribute value")
|
||||
}
|
||||
|
||||
if bb.Yget() != 2 {
|
||||
panic("10 Bad attribute value")
|
||||
}
|
||||
|
||||
if cc.Xget() != 1 || cc.Yget() != 2 || cc.Zget() != 3 {
|
||||
panic("11 Bad attribute value")
|
||||
}
|
||||
|
||||
if dd.Xget() != 1 || dd.Yget() != 2 || dd.Zget() != 3 || dd.Wget() != 4 {
|
||||
panic("12 Bad attribute value")
|
||||
}
|
||||
|
||||
if minherit.Xget(aa) != 1 {
|
||||
panic(fmt.Sprintf("13 Bad attribute value %d", minherit.Xget(aa)))
|
||||
}
|
||||
|
||||
if minherit.Yget(bb) != 2 {
|
||||
panic(fmt.Sprintf("14 Bad attribute value %d", minherit.Yget(bb)))
|
||||
}
|
||||
|
||||
if minherit.Xget(cc) != 1 || minherit.Yget(cc.SwigGetBar()) != 2 || minherit.Zget(cc) != 3 {
|
||||
panic(fmt.Sprintf("15 Bad attribute value %d %d %d", minherit.Xget(cc), minherit.Yget(cc.SwigGetBar()), minherit.Zget(cc)))
|
||||
}
|
||||
|
||||
if minherit.Xget(dd) != 1 || minherit.Yget(dd.SwigGetBar()) != 2 || minherit.Zget(dd) != 3 || minherit.Wget(dd) != 4 {
|
||||
panic(fmt.Sprintf("16 Bad attribute value %d %d %d %d", minherit.Xget(dd), minherit.Yget(dd.SwigGetBar()), minherit.Zget(dd), minherit.Wget(dd)))
|
||||
}
|
||||
}
|
||||
10
Examples/test-suite/go/mod_runme.go
Normal file
10
Examples/test-suite/go/mod_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import "mod_a"
|
||||
import "mod_b"
|
||||
|
||||
func main() {
|
||||
c := mod_b.NewC()
|
||||
d := mod_b.NewD()
|
||||
d.DoSomething(mod_a.SwigcptrA(c.Swigcptr()))
|
||||
}
|
||||
29
Examples/test-suite/go/multi_import_runme.go
Normal file
29
Examples/test-suite/go/multi_import_runme.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import "multi_import_a"
|
||||
import "multi_import_b"
|
||||
|
||||
func main() {
|
||||
x := multi_import_b.NewXXX()
|
||||
if x.Testx() != 0 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
y := multi_import_b.NewYYY()
|
||||
if y.Testx() != 0 {
|
||||
panic(0)
|
||||
}
|
||||
if y.Testy() != 1 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
z := multi_import_a.NewZZZ()
|
||||
if z.Testx() != 0 {
|
||||
println("z.Testx", z.Testx(), z.Testz())
|
||||
panic(0)
|
||||
}
|
||||
if z.Testz() != 2 {
|
||||
println("z.Testz", z.Testz())
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
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