Another merge with master.

Updated Doxygen error numbers yet again, as Python errors got added in the
meanwhile, pushing the Doxygen ones further off.

And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again
(if anybody is looking for a motivating example about why significant
whitespace is bad, here is a great use case).
This commit is contained in:
Vadim Zeitlin 2015-07-20 00:40:32 +02:00
commit 302955a152
448 changed files with 8836 additions and 5079 deletions

View file

@ -13,13 +13,8 @@ namespace ArrayExample
{
public:
Eight node_list;
#ifndef _MSC_VER
const Eight node_list2;
ConstEight node_list3;
#else
Eight node_list2;
Eight node_list3;
#endif
void fn1(Eight a) {}
void fn2(const Eight a) {}
@ -32,6 +27,8 @@ namespace ArrayExample
void fn7(Eight*& a) {}
void fn8(ConstEight*& a) {}
void fn9(const ConstEight*& a) {}
ExampleDetail() : node_list(), node_list2(), node_list3() {}
};
}

View file

@ -0,0 +1,15 @@
%module chartest
%inline %{
char printable_global_char = 'a';
char unprintable_global_char = 0x7F;
char GetPrintableChar() {
return 'a';
}
char GetUnprintableChar() {
return 0x7F;
}
%}

View file

@ -138,6 +138,7 @@ CPP_TEST_CASES += \
casts \
char_binary \
char_strings \
chartest \
class_forward \
class_ignore \
class_scope_weird \
@ -156,6 +157,7 @@ CPP_TEST_CASES += \
conversion \
conversion_namespace \
conversion_ns_template \
conversion_operators \
cplusplus_throw \
cpp_basic \
cpp_enum \
@ -198,6 +200,7 @@ CPP_TEST_CASES += \
director_protected \
director_protected_overloaded \
director_redefined \
director_ref \
director_smartptr \
director_thread \
director_unroll \
@ -233,6 +236,7 @@ CPP_TEST_CASES += \
features \
fragments \
friends \
friends_template \
funcptr_cpp \
fvirtual \
global_namespace \
@ -243,6 +247,7 @@ CPP_TEST_CASES += \
ignore_parameter \
import_nomodule \
inherit \
inherit_member \
inherit_missing \
inherit_same_name \
inherit_target_language \
@ -407,6 +412,7 @@ CPP_TEST_CASES += \
template_inherit \
template_inherit_abstract \
template_int_const \
template_keyword_in_type \
template_methods \
template_namespace_forward_declaration \
template_using_directive_and_declaration_forward \
@ -540,6 +546,7 @@ CPP11_TEST_CASES = \
cpp11_template_explicit \
cpp11_template_typedefs \
cpp11_type_traits \
cpp11_type_aliasing \
cpp11_uniform_initialization \
cpp11_unrestricted_unions \
cpp11_userdefined_literals \

View file

@ -0,0 +1,55 @@
%module conversion_operators
// Test bug #401 where the conversion operator name incorrectly included the newline character
// Also test comments around conversion operators due to special handling in the scanner for conversion operators
// These one line ignores should match the conversion operator names to suppress Warning 503 - SWIGWARN_LANG_IDENTIFIER
%ignore operator const EcReal;
%ignore operator EcImaginary const;
%ignore operator EcComplex const;
%inline %{
struct EcReal {};
struct EcImaginary {};
struct EcComplex {};
struct EcAngle {
operator const EcReal
(
) const;
operator EcImaginary
const (
) const;
operator
EcComplex
const (
) const;
};
struct EcAngle2 {
operator const EcReal/* C comment */
(
) const;
operator EcImaginary/* C comment */
const (
) const;
operator/* C comment */
EcComplex
const (
) const;
};
struct EcAngle3 {
operator const EcReal // C++ comment
(
) const;
operator EcImaginary // C++ comment
const (
) const;
operator // C++ comment
EcComplex
const (
) const;
};
%}

View file

@ -100,9 +100,6 @@ int runLambdaInline() {
%{
// TODO
struct LambdaStruct {
static constexpr auto lambda_struct1 = [=]() { return thing; };
};
int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; };
int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2);
void lambda_init(int = ([=]{ return 0; })());

View file

@ -13,7 +13,7 @@ struct NoExceptClass {
NoExceptClass() noexcept {}
NoExceptClass(const NoExceptClass&) noexcept {}
NoExceptClass(NoExceptClass&&) noexcept {}
NoExceptClass& operator=(const NoExceptClass&) noexcept {}
NoExceptClass& operator=(const NoExceptClass&) noexcept { return *this; }
~NoExceptClass() noexcept {}
void noex0() noexcept {}

View file

@ -31,14 +31,17 @@ struct Thingy {
// test both primitive and user defined rvalue reference default arguments and compactdefaultargs
void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {}
void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {}
operator int &&() {}
operator int &&() { return std::move(0); }
Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(copy_int(rhs.rvalref)) {}
Thingy& operator=(const Thingy& rhs) {
val = rhs.val;
lvalref = rhs.lvalref;
rvalref = rhs.rvalref;
return *this;
}
private:
static const bool PrivateTrue;
int copy_int(int& i) { return i; }
Thingy();
};
const bool Thingy::PrivateTrue = true;

View file

@ -2,8 +2,14 @@
%module cpp11_template_typedefs
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefNamePtr;
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator1;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator2;
// This warning should go away when type aliasing is supported
#pragma SWIG nowarn=SWIGWARN_PARSE_USING_UNDEF // Nothing known about 'p.SomeType< char *,T2,4 >'.
%inline %{
template< typename T1, typename T2, int >
@ -16,6 +22,8 @@ class SomeType {
// template aliasing
template< typename T2 >
using TypedefName = SomeType<char*, T2, 5>;
template< typename T2 >
using TypedefNamePtr = SomeType<char*, T2, 4>*;
// type aliasing
typedef void (*PFD)(double); // Old style
@ -28,5 +36,21 @@ class MyCPP11Class {
};
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
MyIntKeyClass<char> intchar;
TypedefName<int> alias1(TypedefName<int> a) { return a; }
TypedefNamePtr<int> alias1(TypedefNamePtr<int> a = nullptr) { return a; }
%}
%inline %{
typedef double Val;
template<typename T> struct ListBucket {
};
namespace Alloc {
template<typename T> struct rebind {
typedef int other;
};
}
using BucketAllocator1 = typename Alloc::template rebind<ListBucket<Val>>::other;
using BucketAllocator2 = typename Alloc::template rebind<::template ListBucket<double>>::other;
%}

View file

@ -0,0 +1,66 @@
%module cpp11_type_aliasing
// Type aliasing seg fault : Github issue #424
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
%inline %{
namespace Halide {
struct Target {
int bits;
Target(int bits=32) : bits(bits) {}
};
class NamesInterface {
public:
using Target = Halide::Target;
};
Target get_host_target() {
return Target();
}
namespace Internal {
template <typename T> class GeneratorParam {
T value;
public:
GeneratorParam(const char *name, const T &v) : value(v) {}
T getValue() {
return value;
}
};
class GeneratorBase : public NamesInterface {
public:
GeneratorParam<Target> target{ "target", Halide::get_host_target() };
};
}
}
%}
%template(Halide_Target) Halide::Internal::GeneratorParam<Halide::Target>;
%inline %{
using Int = int;
using IntRef = int&;
using IntPtrRef = int*&;
using IntRValueRef = int&&;
using IntArray = int[];
using HalideTargetPtr1 = Halide::Target*;
namespace Halide {
using HalideTargetPtr2 = Target*;
}
%}

View file

@ -6,8 +6,7 @@ LANGUAGE = csharp
SCRIPTSUFFIX = _runme.cs
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
CSHARPCONVERTPATH = @top_srcdir@/@CSHARPCONVERTPATH@
srcdir = @srcdir@
top_srcdir = ../@top_srcdir@
@ -79,13 +78,13 @@ run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
CSHARPSRCS='`$(CSHARPCONVERTPATH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCONVERTPATH) "{}" \+`' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
CSHARPSRCS='`find . -name "*.cs" -exec ../$(CSHARPCONVERTPATH) "{}" \+`' csharp_compile; \
fi
# Clean: remove testcase directories

View file

@ -12,13 +12,5 @@ public class runme
throw new Exception("Protected destructor exception should have been thrown");
} catch (MethodAccessException) {
}
// calling private destructor test
try {
using (FFF f = new FFF()) {
}
throw new Exception("Private destructor exception should have been thrown");
} catch (MethodAccessException) {
}
}
}

View file

@ -16,5 +16,12 @@ public class runme
HiddenDestructor hidden = HiddenDestructor.create();
hidden.Dispose();
HiddenPrivateDestructor hiddenPrivate = HiddenPrivateDestructor.create();
if (HiddenPrivateDestructor.DeleteCount != 0)
throw new ApplicationException("Count should be zero");
hiddenPrivate.Dispose();
if (HiddenPrivateDestructor.DeleteCount != 1)
throw new ApplicationException("Count should be one");
}
}

View file

@ -46,7 +46,7 @@ public class runme
}
int actualCount = Klass.getTotal_count();
if (actualCount != expectedCount)
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
}
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();

View file

@ -32,7 +32,7 @@ public class li_std_auto_ptr_runme {
};
int actualCount = Klass.getTotal_count();
if (actualCount != expectedCount)
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
}
if (k2.getLabel() != "second")
@ -51,7 +51,7 @@ public class li_std_auto_ptr_runme {
}
int actualCount = Klass.getTotal_count();
if (actualCount != expectedCount)
throw new ApplicationException("Expected count: " + expectedCount + " Actual count: " + actualCount);
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
}
}
}

View file

@ -1,6 +1,5 @@
module default_constructor_runme;
import default_constructor.FFF;
import default_constructor.G;
void main() {
@ -15,16 +14,4 @@ void main() {
throw e;
}
}
// Private destructor test.
try {
{
scope f = new FFF();
}
throw new Exception("Private destructor exception should have been thrown");
} catch (Exception e) {
if (e.msg != "C++ destructor does not have public access") {
throw e;
}
}
}

View file

@ -1,6 +1,5 @@
module default_constructor_runme;
import default_constructor.FFF;
import default_constructor.G;
void main() {
@ -8,7 +7,6 @@ void main() {
// destruction yet.
// enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
// enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
}
private void enforceThrows(void delegate() dg, string errorMessage) {

View file

@ -6,6 +6,12 @@ struct Display {
// Bad Python wrappers were being generated when NULL used for primitive type
float draw1(float v = 0) { return v; }
float draw2(float *v = 0) { return v ? *v : 0; }
bool bool0(bool x = 0) { return x; }
bool bool1(bool x = 1) { return x; }
typedef bool mybool;
bool mybool0(mybool x = 0) { return x; }
bool mybool1(mybool x = 1) { return x; }
};
float* createPtr(float v) { static float val; val = v; return &val; }
%}
@ -14,5 +20,11 @@ struct Display {
// Bad Python wrappers were being generated when NULL used for primitive type
float draw1(float v = NULL) { return v; }
float draw2(float *v = NULL) { return v ? *v : 0; }
bool bool0(bool x = 0) { return x; }
bool bool1(bool x = 1) { return x; }
typedef bool mybool;
bool mybool0(mybool x = 0) { return x; }
bool mybool1(mybool x = 1) { return x; }
};
float* createPtr(float v) { static float val; val = v; return &val; }

View file

@ -114,7 +114,10 @@
%rename(renamed2arg) Foo::renameme(int x) const;
%rename(renamed1arg) Foo::renameme() const;
%typemap(default) double* null_by_default "$1=0;";
%inline %{
typedef void* MyHandle;
// Define a class
class Foo {
@ -139,6 +142,12 @@
// test the method itself being renamed
void oldname(int x = 1234) {}
void renameme(int x = 1234, double d=123.4) const {}
// test default values for pointer arguments
int double_if_void_ptr_is_null(int n, void* p = NULL) { return p ? n : 2*n; }
int double_if_handle_is_null(int n, MyHandle h = 0) { return h ? n : 2*n; }
int double_if_dbl_ptr_is_null(int n, double* null_by_default)
{ return null_by_default ? n : 2*n; }
};
int Foo::bar = 1;
int Foo::spam = 2;
@ -269,3 +278,26 @@ struct ConstMethods {
} Pointf;
}
%}
// Default arguments after ignored ones.
%typemap(in, numinputs=0) int square_error { $1 = 2; };
%typemap(default, noblock=1) int def17 { $1 = 17; };
// Enabling autodoc feature has a side effect of disabling the generation of
// aliases for functions that can hide problems with default arguments at
// Python level.
%feature("autodoc","0") slightly_off_square;
%inline %{
inline int slightly_off_square(int square_error, int def17) { return def17*def17 + square_error; }
%}
// Python C default args
%feature("python:cdefaultargs") CDA::cdefaultargs_test1;
%inline %{
struct CDA {
int cdefaultargs_test1(int a = 1) { return a; }
int cdefaultargs_test2(int a = 1) { return a; }
};
%}

View file

@ -13,6 +13,16 @@
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) GGG; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) HHH; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
%delobject F::destroy;
@ -103,14 +113,15 @@ public:
void bar(F *) { }
#if defined(_MSC_VER)
#pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible
#endif
// Single inheritance, base has private destructor
class FFF : public F {
};
#if defined(_MSC_VER)
#pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible
#endif
// Multiple inheritance, one base has private destructor
class GGG : public A, public F {
};
class HHH : public F, public A {
};
/* A class with a protected destructor */
class G {

View file

@ -4,6 +4,7 @@
%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) };
%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) };
%apply (char* STRING, size_t LENGTH) { (const void* data, size_t datalen) };
%inline %{
#include <stdlib.h>
@ -20,6 +21,7 @@ public:
if (dataBufferBB)
memset(dataBufferBB, -1, sizeBB);
}
virtual void writeData(const void* data, size_t datalen) = 0;
};
class Caller {
@ -50,6 +52,17 @@ public:
void call_null() {
_callback->run(NULL, 0, NULL, 0);
}
int callWriteData() {
int sum = 0;
if (_callback) {
char* aa = (char*)malloc(BUFFER_SIZE_AA);
memset(aa, 9, BUFFER_SIZE_AA);
_callback->writeData(aa, BUFFER_SIZE_AA);
for (int i = 0; i < BUFFER_SIZE_AA; i++)
sum += aa[i];
}
return sum;
}
};
%}

View file

@ -10,6 +10,7 @@
%ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0);
%ignore DIgnoreConstructor(bool b);
%ignore DIgnoreOnlyConstructor(bool b);
%ignore DIgnoreDestructor::~DIgnoreDestructor;
%ignore Pointers;
%ignore References;
%ignore PublicMethod1;
@ -101,6 +102,13 @@ class DIgnoreOnlyConstructor
DIgnoreOnlyConstructor(bool b) {}
};
class DIgnoreDestructor
{
public:
DIgnoreDestructor() {}
virtual ~DIgnoreDestructor() {}
};
%{
class DIgnoreConstructor
{
@ -118,5 +126,12 @@ class DIgnoreOnlyConstructor
private: // Hide constructor
DIgnoreOnlyConstructor(bool b) {}
};
%}
class DIgnoreDestructor
{
public:
DIgnoreDestructor() {}
virtual ~DIgnoreDestructor() {}
};
%}

View file

@ -0,0 +1,82 @@
%module(directors="1") director_ref
%{
#include <string>
class Foo {
public:
Foo(int i = -1) : count(0) {}
virtual void OnDelete() {}
virtual ~Foo() {}
virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
std::string GetMsg() { return Msg(); }
std::string GetMsg(std::string msg) { return Msg(msg); }
void Ref() { ++count; }
void Unref() { --count; if (count == 0) { OnDelete(); delete this; } }
int GetRefCount() { return count; }
private:
int count;
};
class FooPtr {
public:
FooPtr(Foo* f = NULL) : my_f(f) { if (my_f) { my_f->Ref(); } }
~FooPtr() { if (my_f) { my_f->Unref(); } }
void Reset(Foo* f = NULL) {
if (f) { f->Ref(); }
if (my_f) { my_f->Unref(); }
my_f = f;
}
int GetOwnedRefCount() {
if (my_f) { return my_f->GetRefCount(); }
return 0;
}
private:
Foo* my_f;
};
%}
%include <std_string.i>
%feature("director") Foo;
%feature("ref") Foo "$this->Ref();"
%feature("unref") Foo "$this->Unref();"
class Foo {
public:
Foo(int i = -1) : count(0) {}
virtual void OnDelete() {}
virtual ~Foo() {}
virtual std::string Msg(std::string msg = "default") { return "Foo-" + msg; }
std::string GetMsg() { return Msg(); }
std::string GetMsg(std::string msg) { return Msg(msg); }
void Ref() { ++count; }
void Unref() { --count; if (count == 0) { OnDelete(); delete this; } }
int GetRefCount() { return count; }
private:
int count;
};
class FooPtr {
public:
FooPtr(Foo* f = NULL) : my_f(f) { if (my_f) { my_f->Ref(); } }
~FooPtr() { if (my_f) { my_f->Unref(); } }
void Reset(Foo* f = NULL) {
if (f) { f->Ref(); }
if (my_f) { my_f->Unref(); }
my_f = f;
}
int GetOwnedRefCount() {
if (my_f) { return my_f->GetRefCount(); }
return 0;
}
private:
Foo* my_f;
};

View file

@ -100,4 +100,9 @@ void overloadinline2(const int *) {}
void overload5(int *) {}
void overload5(const int *) {}
%ignore Outer2::QuietInner;
struct Outer2 {
struct QuietInner {
VARIABLEMACRO(MyInnerVar)
};
};

View file

@ -0,0 +1,26 @@
%module cpp_template_friend
template<typename T> T template_friend1(T);
template<typename T> T template_friend1(T);
struct MyTemplate1 {
template<typename T> friend T template_friend1(T);
};
template<typename T> T template_friend2(T);
struct MyTemplate2 {
template<typename T> friend T template_friend2(T);
};
template<typename T> T template_friend2(T);
int normal_friend1(int);
int normal_friend1(int);
struct MyClass1 {
friend int normal_friend1(int);
};
int normal_friend2(int);
struct MyClass2 {
friend int normal_friend2(int);
};
int normal_friend2(int);

View file

@ -0,0 +1,8 @@
cpp_template_friend.i:4: Warning 302: Identifier 'template_friend1' redefined (ignored),
cpp_template_friend.i:3: Warning 302: previous definition of 'template_friend1'.
cpp_template_friend.i:13: Warning 302: Identifier 'template_friend2' redefined (ignored),
cpp_template_friend.i:9: Warning 302: previous definition of 'template_friend2'.
cpp_template_friend.i:17: Warning 322: Redundant redeclaration of 'normal_friend1',
cpp_template_friend.i:16: Warning 322: previous declaration of 'normal_friend1'.
cpp_template_friend.i:26: Warning 322: Redundant redeclaration of 'normal_friend2',
cpp_template_friend.i:22: Warning 322: previous declaration of 'normal_friend2'.

View file

@ -0,0 +1,13 @@
%module cpp_using_type_aliasing
namespace Space {
template<typename T> struct Okay {
};
struct User {
protected:
using OkayInt = Okay<int>;
};
struct Derived : User {
Okay<OkayInt> ff();
};
};

View file

@ -0,0 +1,3 @@
cpp_using_type_aliasing.i:8: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.

View file

@ -1 +1 @@
doxygen_unknown_command.i:4: Warning 740: Doxygen parser warning: unknown command "unknown".
doxygen_unknown_command.i:4: Warning 760: Doxygen parser warning: unknown command "unknown".

View file

@ -1,5 +1,10 @@
%module xxx
/* Regression test for bug introduced in 3.0.4 and fixed in 3.0.6 - the '%std'
* here led to SWIG calling abort().
*/
%typemap(jstype) std::vector<std::string>, const %std::vector<std::string>&, std::vector<std::string>& "List<String>"
/* This used to give the rather cryptic "Syntax error in input(1)." prior to
* SWIG 3.0.4. This testcase checks that the improved message is actually
* issued.

View file

@ -1 +1 @@
pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
pp_unknowndirective.i:12: Error: Unknown directive '%remane'.

View file

@ -1,6 +1,6 @@
%module xxx
#ifdef FOO
#ifndef FOO
long long i;
/* Check we get an error for an unknown directive (this should be #elif).
* Unknown directives were silently ignored by SWIG < 3.0.3. */

View file

@ -0,0 +1,7 @@
%module xxx
%pythoncode %{
def foo():
a = 1 # This line starts with a tab instead of 8 spaces.
return 2
%}

View file

@ -0,0 +1 @@
swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of pythoncode)

View file

@ -0,0 +1,13 @@
%module xxx
%pythoncode %{
def one():
print "in one"
%}
%pythoncode %{
print "still in one"
def two():
print "in two"
%}

View file

@ -0,0 +1 @@
swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of pythoncode)

View file

@ -14,3 +14,18 @@ typedef int Integer2;
void RealFunction(int value) {}
%}
%inline %{
extern "C" {
typedef void (*Hook1_t)(int, const char *);
}
extern "C" typedef void (*Hook2_t)(int, const char *);
void funcy1(Hook1_t) {}
void funcy2(Hook2_t) {}
Hook1_t hook1;
Hook2_t hook2;
extern "C" typedef int Integer;
Integer int1;
%}

View file

@ -0,0 +1,46 @@
%module friends_template
%{
template <typename Type> class MyClass;
template <typename Type> int operator<<(double un, const MyClass <Type> & x) { return 0; }
template <typename Type> int funk_hidden(double is, MyClass <Type> & x) { return 2; }
template <typename T> T template_friend_hidden(T t) { return t + 1; }
%}
%inline %{
template <typename Type> int operator>>(double is, MyClass <Type> & x) { return 1; }
template <typename Type> int funk_seen(double is, MyClass <Type> & x) { return 2; }
template <typename T> T template_friend_seen(T t1, T t2) { return t1 + t2; }
int friend_plain_seen(int i) { return i; }
template <class Type> class MyClass
{
friend int operator<< <Type>(double un, const MyClass <Type> & x);
friend int operator>> <Type>(double is, MyClass <Type> & x);
friend int funk_hidden <Type>(double is, MyClass <Type> & x);
friend int funk_seen <Type>(double is, MyClass <Type> & x);
};
struct MyTemplate {
template <typename T> friend T template_friend_hidden(T);
template <typename T> friend T template_friend_seen(T, T);
friend int friend_plain_seen(int i);
};
MyClass<int> makeMyClassInt() { return MyClass<int>(); }
%}
// Although the friends in MyClass are automatically instantiated via %template(MyClassDouble) MyClass<int>,
// the operator friends are not valid and hence %rename is needed.
%rename(OperatorInputDouble) operator>> <double>;
%rename(OperatorOutputDouble) operator<< <double>;
%template(MyClassDouble) MyClass<double>;
%template(TemplateFriendHiddenInt) template_friend_hidden<int>;
%template(TemplateFriendSeenInt) template_friend_seen<int>;
// These have no %template(XX) MyClass<int> to instantiate, but they can be instantiated separately...
%template(OperatorInputInt) operator>> <int>;
%template(OperatorFunkSeenInt) funk_seen <int>;

View file

@ -5,31 +5,39 @@
LANGUAGE = go
GO = @GO@
GOGCC = @GOGCC@
GCCGO = @GCCGO@
GO1 = @GO1@
GO12 = @GO12@
GO13 = @GO13@
GO15 = @GO15@
GOC = @GOC@
SCRIPTSUFFIX = _runme.go
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi`
GOLD = $(GOC:c=l)
GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1); then echo tool $(GOC:c=g); fi`
GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi`
GOTOOL = `if $(GO1) ; then echo go tool; fi`
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
GOOBJEXT = $(GOC:c=)
GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
SO = @SO@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
abs_top_srcdir = @abs_top_srcdir@
CPP_TEST_CASES = \
go_inout \
go_director_inout
MULTI_CPP_TEST_CASES = \
go_subdir_import
include $(srcdir)/../common.mk
INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
.SUFFIXES: .cpptest .ctest .multicpptest
# Rules for the different types of tests
@ -37,17 +45,37 @@ include $(srcdir)/../common.mk
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase_cpp)
if ! $(GO15); then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp_nocgo; \
$(run_testcase_cpp); \
fi
%.ctest:
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
if ! $(GO15); then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_nocgo; \
$(run_testcase); \
fi
%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_multi_testcase)
li_windows.cpptest:
# Does not work because go build won't build li_windows.go,
# because file names with "windows" are only built on Windows.
multi_import.multicpptest:
$(setup)
for f in multi_import_b multi_import_a; do \
@ -59,15 +87,43 @@ multi_import.multicpptest:
done
$(run_multi_testcase)
go_subdir_import.multicpptest:
$(setup)
mkdir -p testdir/go_subdir_import/
mkdir -p gopath/src/testdir/go_subdir_import/
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INTERFACEPATH="$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) -outdir ." NOLINK=true \
TARGET="$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" \
INTERFACE="testdir/go_subdir_import/go_subdir_import_b.i" \
$(LANGUAGE)$(VARIANT)_cpp;
for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" 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
if $(GOGCC); then \
cp gopath/src/testdir/go_subdir_import/go_subdir_import_b/go_subdir_import_b.a gopath/src/testdir/go_subdir_import/go_subdir_import_b.gox; \
cp gopath/src/testdir/go_subdir_import/go_subdir_import_b/go_subdir_import_b.a .; \
cp gopath/src/testdir/go_subdir_import/go_subdir_import_c/go_subdir_import_c.a gopath/src/testdir/go_subdir_import/go_subdir_import_c.gox; \
cp gopath/src/testdir/go_subdir_import/go_subdir_import_c/go_subdir_import_c.a testdir/go_subdir_import/; \
fi
$(run_multi_testcase)
# Runs the testcase.
run_testcase = \
if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@; \
elif $(GO12) || $(GO13); then \
$(COMPILETOOL) $(GCCGO) -c -g -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
fi && \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
@ -75,12 +131,14 @@ run_testcase = \
run_testcase_cpp = \
if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@ -lstdc++; \
elif $(GO12) || $(GO13); then \
$(COMPILETOOL) $(GCCGO) -c -g -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a -lstdc++; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
fi && \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
@ -88,28 +146,38 @@ run_testcase_cpp = \
run_multi_testcase = \
if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
if $(GOGCC) ; then \
$(COMPILETOOL) $(GCCGO) -c -g -I . -I gopath/src $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $${f}_wrap.@OBJEXT@; done` -lstdc++; \
elif $(GO12) || $(GO13); then \
$(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.a; done` -lstdc++; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env 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
@rm -rf $*.go $*_gc.c $*_wrap.* $*_runme $*.gox $*.a
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" 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
rm -f import_stl_a.go import_stl_b.go
rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox
rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox
rm -f clientdata_prop_a.go clientdata_prop_a.gox
rm -f clientdata_prop_b.go clientdata_prop_b.gox
rm -f multi_import_a.go multi_import_a.gox
rm -f multi_import_b.go multi_import_b.gox
rm -rf go_subdir_import_a.go go_subdir_import_a.gox testdir
rm -f packageoption_a.go packageoption_a.gox
rm -f packageoption_b.go packageoption_b.gox
rm -f packageoption_c.go packageoption_c.gox
rm -f import_stl_a.go import_stl_a.gox
rm -f import_stl_b.go import_stl_b.gox
rm -rf gopath
cvsignore:
@echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib'

View file

@ -21,9 +21,6 @@ func main() {
f := dc.NewF()
f.Destroy()
ff := dc.NewFFF()
ff.Destroy()
g := dc.NewG()
dc.GDestroy(g)

View file

@ -0,0 +1,16 @@
package main
import (
"go_subdir_import_a"
"testdir/go_subdir_import/go_subdir_import_b"
"testdir/go_subdir_import/go_subdir_import_c"
)
func main() {
b := go_subdir_import_b.NewObjB();
c := go_subdir_import_c.NewObjC();
v := go_subdir_import_a.AddFive(b, c)
if v != 50 {
panic(0)
}
}

View file

@ -0,0 +1,15 @@
package main
import wrap "./inherit_member"
func main() {
s := wrap.NewChild()
s.SetPvar("p")
s.SetCvar("c")
if s.GetPvar() != "p" {
panic(s.GetPvar())
}
if s.GetCvar() != "c" {
panic(s.GetCvar())
}
}

View file

@ -6,6 +6,10 @@ func main(){
t := overload_polymorphic.NewDerived()
if overload_polymorphic.Test(t) != 0 {
panic("failed")
panic("failed 1")
}
if overload_polymorphic.Test2(t) != 1 {
panic("failed 2")
}
}

View file

@ -44,14 +44,14 @@ type GoRetStruct struct {
$result.str.assign($input.p, $input.n);
%}
%typemap(out) RetStruct
%typemap(out,fragment="AllocateString") RetStruct
%{
$result = _swig_makegostring($1.str.data(), $1.str.length());
$result = Swig_AllocateString($1.str.data(), $1.str.length());
%}
%typemap(goout) RetStruct
%typemap(goout,fragment="CopyString") RetStruct
%{
$result = GoRetStruct{Str: $input}
$result = GoRetStruct{Str: swigCopyString($input)}
%}
%typemap(godirectorout) RetStruct
@ -81,23 +81,28 @@ type GoRetStruct struct {
}
%}
%typemap(directorin) MyStruct
%typemap(directorin,fragment="AllocateString") MyStruct
%{
$input = _swig_makegostring($1.str.data(), $1.str.length());
$input = Swig_AllocateString($1.str.data(), $1.str.length());
%}
%typemap(out) MyStruct
%typemap(godirectorin,fragment="CopyString") MyStruct
%{
$result = _swig_makegostring($1.str.data(), $1.str.length());
%}
%typemap(godirectorin) MyStruct
%{
if err := json.Unmarshal([]byte($input), &$result); err != nil {
if err := json.Unmarshal([]byte(swigCopyString($input)), &$result); err != nil {
panic(err)
}
%}
%typemap(out,fragment="AllocateString") MyStruct
%{
$result = Swig_AllocateString($1.str.data(), $1.str.length());
%}
%typemap(goout,fragment="CopyString") MyStruct
%{
$result = swigCopyString($input)
%}
%typemap(in) MyStruct
%{
$1.str.assign($input.p, $input.n);

View file

@ -56,14 +56,14 @@ type In json.Marshaler
%typemap(imtype) RetStruct "string"
%typemap(out) RetStruct
%typemap(out,fragment="AllocateString") RetStruct
%{
$result = _swig_makegostring($1.str.data(), $1.str.length());
$result = Swig_AllocateString($1.str.data(), $1.str.length());
%}
%typemap(goout) RetStruct
%typemap(goout,fragment="CopyString") RetStruct
%{
if err := json.Unmarshal([]byte($1), &$result); err != nil {
if err := json.Unmarshal([]byte(swigCopyString($1)), &$result); err != nil {
panic(err)
}
%}
@ -146,7 +146,7 @@ static void putuint64(std::string *s, size_t off, uint64_t v) {
%}
// Pack the vector into a string.
%typemap(argout) MyArray*
%typemap(argout,fragment="AllocateString") MyArray*
%{
{
size_t tot = 8;
@ -164,15 +164,15 @@ static void putuint64(std::string *s, size_t off, uint64_t v) {
str.replace(off, p->size(), *p);
off += p->size();
}
*$input = _swig_makegostring(str.data(), str.size());
*$input = Swig_AllocateString(str.data(), str.size());
}
%}
// Unpack the string into a []string.
%typemap(goargout) MyArray*
%typemap(goargout,fragment="CopyString") MyArray*
%{
{
str := *$input
str := swigCopyString(*$input)
bin := binary.LittleEndian
size := bin.Uint64([]byte(str[:8]))
str = str[8:]

View file

@ -0,0 +1,3 @@
testdir/go_subdir_import/go_subdir_import_c
go_subdir_import_b
go_subdir_import_a

View file

@ -0,0 +1,37 @@
/* File : go_subdir_import_a.i */
/*
* This files helps check the case where the SWIG-generated .go file needs to
* import another, SWIG-generated, module that is in a relative subdirectory.
* This case might happen for two different reasons:
* 1) Importing a module for which the .i file is in a subdirectory relatively
* to this file (this is tested here with go_subdir_import_c).
* 2) Importing a module whos module name is a path (this is tested here with
* go_subdir_import_b).
*
* This file is the "root" file that imports the two modules which will be
* generated (by swig) in a relative subdirectory.
*/
%module go_subdir_import_a
%import(module="testdir/go_subdir_import/go_subdir_import_c") "testdir/go_subdir_import/go_subdir_import_c.i"
%import "go_subdir_import_b.i"
%{
class ObjC {
public:
virtual int getInt() const;
};
class ObjB {
public:
virtual int getInt() const;
};
%}
%inline %{
int AddFive(const ObjB& b, const ObjC& c) {
return b.getInt() + c.getInt() + 5;
}
%}

View file

@ -0,0 +1,12 @@
/* File : go_subdir_import_b.i */
%module "testdir/go_subdir_import/go_subdir_import_b"
%inline %{
class ObjB {
public:
virtual int getInt() const {
return 27;
}
};
%}

View file

@ -0,0 +1,17 @@
// Based on https://github.com/swig/swig/issues/339 .
%module inherit_member
%include <std_string.i>
%inline %{
struct parent_class {
std::string pvar;
};
struct child : public parent_class {
std::string cvar;
};
%}

View file

@ -23,7 +23,7 @@ public class cpp11_constexpr_runme {
check(cpp11_constexpr.CCC(), 30);
check(cpp11_constexpr.DDD(), 40);
ConstExpressions ce = new ConstExpressions();
ConstExpressions ce = new ConstExpressions(0);
check(ce.JJJ, 100);
check(ce.KKK, 200);
check(ce.LLL, 300);

View file

@ -0,0 +1,20 @@
import cpp11_type_aliasing.*;
public class cpp11_type_aliasing_runme {
static {
try {
System.loadLibrary("cpp11_type_aliasing");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
Halide_Target ht = new GeneratorBase().getTarget();
Target x = ht.getValue();
if (x.getBits() != 32)
throw new RuntimeException("Incorrect bits");
}
}

View file

@ -20,13 +20,5 @@ public class default_constructor_runme {
throw new RuntimeException("Protected destructor exception should have been thrown");
} catch (UnsupportedOperationException e) {
}
// calling private destructor test
try {
FFF f = new FFF();
f.delete();
throw new RuntimeException("Private destructor exception should have been thrown");
} catch (UnsupportedOperationException e) {
}
}
}

View file

@ -17,11 +17,15 @@ public class director_binary_string_runme {
Callback callback = new DirectorBinaryStringCallback();
caller.setCallback(callback);
int sum = caller.call();
int sumData = caller.callWriteData();
caller.delCallback();
if (sum != 9*2*8 + 13*3*5)
throw new RuntimeException("Unexpected sum: " + sum);
if (sumData != 9*2*8)
throw new RuntimeException("Unexpected sum: " + sum);
new Callback().run(null, null);
callback = new DirectorBinaryStringCallback();
caller.setCallback(callback);
@ -45,5 +49,13 @@ class DirectorBinaryStringCallback extends Callback {
for (int i = 0; i < dataBufferBB.length; i++)
dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
}
@Override
public void writeData(byte[] dataBufferAA)
{
if (dataBufferAA != null)
for (int i = 0; i < dataBufferAA.length; i++)
dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
}
}

View file

@ -0,0 +1,71 @@
import director_ref.*;
public class director_ref_runme {
static {
try {
System.loadLibrary("director_ref");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
director_ref_MyFoo a = new director_ref_MyFoo();
if (a.GetRefCount() != 1) {
throw new RuntimeException ( "Refcount test 1 failed." );
}
// Make sure director logic still works.
if (!a.GetMsg().equals("director_ref_MyFoo-default")) {
throw new RuntimeException ( "Test 1 failed" );
}
if (!a.GetMsg("boo").equals("director_ref_MyFoo-boo")) {
throw new RuntimeException ( "Test 2 failed" );
}
a.delete(); // should delete the object.
if (a.cppDeleted != true) {
throw new RuntimeException ( "Unref test 1 failed." );
}
a = new director_ref_MyFoo();
FooPtr p = new FooPtr(a);
if (a.GetRefCount() != 2) {
throw new RuntimeException ( "Refcount test 2 failed." );
}
a.delete(); // Shouldn't actually delete the underlying object
if (a.cppDeleted) {
throw new RuntimeException ( "Unref test 2 failed." );
}
if (p.GetOwnedRefCount() != 1) {
throw new RuntimeException ( "Unref test 3 failed." );
}
p.Reset(); // Now it should be deleted on the cpp side.
// We can't check cppDeleted because the director will stop
// working after a delete() call.
if (p.GetOwnedRefCount() != 0) {
throw new RuntimeException ( "Unref test 4 failed." );
}
}
}
class director_ref_MyFoo extends Foo {
public director_ref_MyFoo() {
super();
}
public director_ref_MyFoo(int i) {
super(i);
}
public String Msg(String msg) {
return "director_ref_MyFoo-" + msg;
}
public void OnDelete() {
cppDeleted = true;
}
public boolean cppDeleted = false;
}

View file

@ -0,0 +1,28 @@
import friends_template.*;
public class friends_template_runme {
static {
try {
System.loadLibrary("friends_template");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
friends_template.OperatorOutputDouble(1.1, new MyClassDouble());
friends_template.OperatorInputDouble(1.1, new MyClassDouble());
friends_template.funk_hidden(1.1, new MyClassDouble());
friends_template.funk_seen(1.1, new MyClassDouble());
friends_template.TemplateFriendHiddenInt(0);
friends_template.TemplateFriendSeenInt(0, 0);
SWIGTYPE_p_MyClassT_int_t myClassInt = friends_template.makeMyClassInt();
friends_template.OperatorInputInt(1, myClassInt);
friends_template.OperatorFunkSeenInt(1.1, myClassInt);
}
}

View file

@ -23,5 +23,12 @@ public class li_boost_shared_ptr_bits_runme {
HiddenDestructor hidden = HiddenDestructor.create();
hidden.delete();
HiddenPrivateDestructor hiddenPrivate = HiddenPrivateDestructor.create();
if (HiddenPrivateDestructor.getDeleteCount() != 0)
throw new RuntimeException("Count should be zero");
hiddenPrivate.delete();
if (HiddenPrivateDestructor.getDeleteCount() != 1)
throw new RuntimeException("Count should be one");
}
}

View file

@ -31,7 +31,7 @@ public class li_carrays_runme {
{
// global array variable
int length = 5;
int length = 3;
XY xyArrayPointer = li_carrays.getGlobalXYArray();
XYArray xyArray = XYArray.frompointer(xyArrayPointer);
for (int i=0; i<length; i++) {

View file

@ -128,5 +128,41 @@ HiddenDestructor::~HiddenDestructor()
delete impl_;
}
%}
////////////////////////////
// As above but private instead of protected destructor
////////////////////////////
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
%shared_ptr(HiddenPrivateDestructor)
#endif
%inline %{
class HiddenPrivateDestructor {
private:
HiddenPrivateDestructor() {}
virtual ~HiddenPrivateDestructor() {
DeleteCount++;
}
class Deleter {
public:
void operator()(HiddenPrivateDestructor *hidden) {
delete hidden;
}
};
public:
static boost::shared_ptr<HiddenPrivateDestructor> create() {
boost::shared_ptr<HiddenPrivateDestructor> hidden( new HiddenPrivateDestructor(), HiddenPrivateDestructor::Deleter() );
return hidden;
}
static int DeleteCount;
};
int HiddenPrivateDestructor::DeleteCount = 0;
%}

View file

@ -0,0 +1,14 @@
require("import") -- the import fn
import("chartest") -- import code
function char_assert(char, code)
assert(type(char) == 'string')
assert(char:len() == 1)
assert(char:byte() == code)
end
char_assert(chartest.GetPrintableChar(), 0x61)
char_assert(chartest.GetUnprintableChar(), 0x7F)
char_assert(chartest.printable_global_char, 0x61)
char_assert(chartest.unprintable_global_char, 0x7F)

View file

@ -3,7 +3,7 @@
#######################################################################
LANGUAGE = ocaml
OCAMLC = ocamlc
OCAMLC = @OCAMLC@
VARIANT = _static
SCRIPTSUFFIX = _runme.ml
@ -25,18 +25,11 @@ run_testcase = \
fi ;
check_quant:
cat /dev/null > testing
cat /dev/null > success
cat /dev/null > results
: > testing
: > success
$(MAKE) check
echo "Failed:" >> results
for element in `cat testing` ; do \
if grep $$element success >/dev/null 2>/dev/null ; then \
: ; \
else \
echo $$element >> results ; \
fi ; \
done
echo "Failed:" > results
diff testing success | sed 's/^< //p;d' >> results
echo "Success:" >> results
cat success >> results

View file

@ -14,24 +14,18 @@ try
catch
end_try_catch
del_b = dc.delete_B;
try
bb = dc.new_BB();
error("Whoa. new_BB created.")
catch
end_try_catch
del_bb = dc.delete_BB;
try
c = dc.new_C();
error("Whoa. new_C created.")
catch
end_try_catch
del_c = dc.delete_C;
cc = dc.new_CC();
dc.delete_CC(cc);
@ -41,24 +35,18 @@ try
catch
end_try_catch
del_d = dc.delete_D;
try
dd = dc.new_DD();
error("Whoa. new_DD created")
catch
end_try_catch
dd = dc.delete_DD;
try
ad = dc.new_AD();
error("Whoa. new_AD created")
catch
end_try_catch
del_ad = dc.delete_AD;
e = dc.new_E();
dc.delete_E(e);
@ -71,31 +59,20 @@ try
catch
end_try_catch
del_eb = dc.delete_EB;
f = dc.new_F();
try
del_f = dc.delete_F;
del_f = dc.delete_F(f);
error("Whoa. delete_F created")
catch
end_try_catch
dc.F_destroy(f);
ff = dc.new_FFF();
try
del_ff = dc.delete_FFF;
error("Whoa. delete_FFF created")
catch
end_try_catch
dc.F_destroy(ff);
g = dc.new_G();
try
del_g = dc.delete_G;
del_g = dc.delete_G(g);
error("Whoa. delete_G created")
catch
end_try_catch

View file

@ -12,6 +12,10 @@
%rename(PlusPlusPostfix) operator++(int);
#endif
%ignore operator new (size_t);
%ignore operator delete (void *);
%ignore operator delete[] (void *);
%{
#include <iostream>
using namespace std;
@ -60,4 +64,16 @@ public:
int k;
};
struct Op2 {
void *operator new
(size_t); // definition split over two lines was giving syntax error
void operator delete /* comment here did not work */ (void *);
void operator
delete[] (void *);
};
void *Op2::operator new(size_t) { return malloc(sizeof(Op)); }
void Op2::operator delete(void *p) { free(p); }
void Op2::operator delete[] (void *) {}
%}

View file

@ -19,4 +19,8 @@ public:
int test(Base* base){ return 0;}
int test(int hello){ return 1; }
class Unknown;
int test2(Unknown* unknown) { return 0; }
int test2(Base* base) { return 1; }
%}

View file

@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 38;
use Test::More tests => 34;
BEGIN { use_ok('li_carrays') }
require_ok('li_carrays');
@ -23,7 +23,7 @@ require_ok('li_carrays');
{
# global array variable
my $length = 5;
my $length = 3;
my $xyArrayPointer = $li_carrays::globalXYArray;
my $xyArray = li_carrays::XYArray::frompointer($xyArrayPointer);
for (my $i=0; $i<$length; $i++) {

View file

@ -107,3 +107,18 @@ void another_macro_checking(void) {
bumpf(10);
}
%}
/* Check that unknown preprocessor directives are ignored inside an inactive
* conditional (github issue #394).
*/
#ifdef APPLE_OPENGL
# import <OpenGLES/ES1/gl.h>
#endif
#ifdef AAA
# define B
#else
# wibble wibble
#endif
#if 0
# wobble wobble
#endif

View file

@ -61,6 +61,7 @@ CPP_TEST_CASES += \
python_director \
python_nondynamic \
python_overload_simple_cast \
python_pythoncode \
python_richcompare \
simutry \
std_containers \
@ -125,17 +126,14 @@ py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
check_pep8 = \
if [ -n "$(PEP8)" ]; then \
$(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py;\
fi
ifneq (,$(PEP8))
check_pep8 = $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8_multi_cpp = \
if [ -n "$(PEP8)" ]; then \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(PEP8) $(PEP8_FLAGS) $$f.py; \
done \
fi
done
endif
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)

View file

@ -2,5 +2,4 @@ import abstract_access
d = abstract_access.D()
if d.do_x() != 1:
raise RuntimeError
raise RuntimeError

View file

@ -1,8 +1,3 @@
from abstract_typedef2 import *
from abstract_typedef2 import *
a = A_UF()

View file

@ -1,11 +1,8 @@
from abstract_typedef import *
from abstract_typedef import *
e = Engine()
a = A()
if a.write(e) != 1:
raise RuntimeError
raise RuntimeError

View file

@ -1,27 +1,26 @@
from argcargvtest import *
largs=['hi','hola','hello']
largs = ['hi', 'hola', 'hello']
if mainc(largs) != 3:
raise RuntimeError("bad main typemap")
raise RuntimeError("bad main typemap")
targs=('hi','hola')
if mainv(targs,1) != 'hola':
print(mainv(targs,1))
raise RuntimeError("bad main typemap")
targs = ('hi', 'hola')
if mainv(targs, 1) != 'hola':
print(mainv(targs, 1))
raise RuntimeError("bad main typemap")
targs=('hi', 'hola')
if mainv(targs,1) != 'hola':
raise RuntimeError("bad main typemap")
targs = ('hi', 'hola')
if mainv(targs, 1) != 'hola':
raise RuntimeError("bad main typemap")
try:
error = 0
mainv('hello',1)
error = 1
error = 0
mainv('hello', 1)
error = 1
except TypeError:
pass
pass
if error:
raise RuntimeError("bad main typemap")
raise RuntimeError("bad main typemap")
initializeApp(largs)

View file

@ -3,19 +3,16 @@ from array_member import *
f = Foo()
f.data = cvar.global_data
for i in range(0,8):
if get_value(f.data,i) != get_value(cvar.global_data,i):
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
raise RuntimeError, "Bad array assignment"
for i in range(0,8):
set_value(f.data,i,-i)
for i in range(0, 8):
set_value(f.data, i, -i)
cvar.global_data = f.data
for i in range(0,8):
if get_value(f.data,i) != get_value(cvar.global_data,i):
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
raise RuntimeError, "Bad array assignment"

View file

@ -2,19 +2,19 @@ import arrays_global
arrays_global.cvar.array_i = arrays_global.cvar.array_const_i
from arrays_global import *
from arrays_global import *
BeginString_FIX44a
cvar.BeginString_FIX44b
BeginString_FIX44c
cvar.BeginString_FIX44d
cvar.BeginString_FIX44d
cvar.BeginString_FIX44b ="12"'\0'"45"
cvar.BeginString_FIX44b = "12"'\0'"45"
cvar.BeginString_FIX44b
cvar.BeginString_FIX44d
cvar.BeginString_FIX44e
BeginString_FIX44f
test_a("hello","hi","chello","chi")
test_a("hello", "hi", "chello", "chi")
test_b("1234567","hi")
test_b("1234567", "hi")

View file

@ -3,166 +3,161 @@ from commentVerifier import check
import sys
def is_new_style_class(cls):
return hasattr(cls, "__class__")
return hasattr(cls, "__class__")
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is used!
sys.exit(0)
# Missing static methods make this hard to test... skip if -classic is
# used!
sys.exit(0)
check(A.__doc__, "Proxy of C++ A class")
check(A.funk.__doc__, "just a string")
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
check(A.func2.__doc__,
"func2(self, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
"func2(self, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
check(A.func3.__doc__,
"func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
"func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
check(A.func0default.__doc__,
"func0default(self, e, arg3, hello, f=2) -> int\n"
"func0default(self, e, arg3, hello) -> int"
)
"func0default(self, e, arg3, hello, f=2) -> int\n"
"func0default(self, e, arg3, hello) -> int"
)
check(A.func1default.__doc__,
"func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"func1default(A self, A e, short arg3, Tuple hello) -> int"
)
"func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"func1default(A self, A e, short arg3, Tuple hello) -> int"
)
check(A.func2default.__doc__,
"func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2default(self, e, arg3, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
)
"func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2default(self, e, arg3, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
)
check(A.func3default.__doc__,
"func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3default(A self, A e, short arg3, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
)
"func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3default(A self, A e, short arg3, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
)
check(A.func0static.__doc__,
"func0static(e, arg2, hello, f=2) -> int\n"
"func0static(e, arg2, hello) -> int"
)
"func0static(e, arg2, hello, f=2) -> int\n"
"func0static(e, arg2, hello) -> int"
)
check(A.func1static.__doc__,
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"func1static(A e, short arg2, Tuple hello) -> int"
)
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"func1static(A e, short arg2, Tuple hello) -> int"
)
check(A.func2static.__doc__,
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2static(e, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func2static(e, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
check(A.func3static.__doc__,
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
"func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
if sys.version_info[0:2] > (2, 4):
# Python 2.4 does not seem to work
if is_python_builtin():
check(A.variable_a.__doc__, "A.variable_a")
check(A.variable_b.__doc__, "A.variable_b")
check(A.variable_c.__doc__, "A.variable_c")
check(A.variable_d.__doc__, "A.variable_d")
else:
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int"
)
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
# Python 2.4 does not seem to work
check(A.variable_a.__doc__,
"A_variable_a_get(self) -> int"
)
check(A.variable_b.__doc__,
"A_variable_b_get(A self) -> int"
)
check(A.variable_c.__doc__,
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
)
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
)
check(A.variable_d.__doc__,
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
)
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
)
check(B.__doc__, "Proxy of C++ B class")
# skip builtin check - the autodoc is missing, but it probably should not be
if not is_python_builtin():
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
check(E.__init__.__doc__,
"__init__(self, a, b, h) -> E\n"
"\n"
"Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
)
check(F.__init__.__doc__,
"__init__(F self, int a, int b, Hola h) -> F\n"
"\n"
"Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
)
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
check(E.__init__.__doc__,
"__init__(self, a, b, h) -> E\n"
"\n"
"Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
)
check(F.__init__.__doc__,
"__init__(F self, int a, int b, Hola h) -> F\n"
"\n"
"Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
)
check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
check(funkdefaults.__doc__,
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
"funkdefaults(A e, short arg2, int c, int d) -> int"
)
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
"funkdefaults(A e, short arg2, int c, int d) -> int"
)
check(func_input.__doc__, "func_input(int * INPUT) -> int")
check(func_output.__doc__, "func_output() -> int")

View file

@ -2,30 +2,30 @@ import _callback
from callback import *
if foo(2) != 2:
raise RuntimeError
raise RuntimeError
if A_bar(2) != 4:
raise RuntimeError
raise RuntimeError
if foobar(3, _callback.foo) != foo(3):
raise RuntimeError
raise RuntimeError
if foobar(3, foo) != foo(3):
raise RuntimeError
raise RuntimeError
if foobar(3, A_bar) != A_bar(3):
raise RuntimeError
raise RuntimeError
if foobar(3, foof) != foof(3):
raise RuntimeError
raise RuntimeError
if foobar_i(3, foo_i) != foo_i(3):
raise RuntimeError
raise RuntimeError
if foobar_d(3.5, foo_d) != foo_d(3.5):
raise RuntimeError
raise RuntimeError
a = A()
if foobarm(3, a, A.foom_cb_ptr) != a.foom(3):
raise RuntimeError
raise RuntimeError

View file

@ -2,11 +2,11 @@ from char_binary import *
t = Test()
if t.strlen('hile') != 4:
print t.strlen('hile')
raise RuntimeError, "bad multi-arg typemap"
print t.strlen('hile')
raise RuntimeError, "bad multi-arg typemap"
if t.strlen('hil\0') != 4:
raise RuntimeError, "bad multi-arg typemap"
raise RuntimeError, "bad multi-arg typemap"
#
# creating a raw char*
@ -20,17 +20,16 @@ pchar_setitem(pc, 4, 0)
if t.strlen(pc) != 4:
raise RuntimeError, "bad multi-arg typemap"
raise RuntimeError, "bad multi-arg typemap"
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
cvar.var_namet = pc
#if cvar.var_namet != "hola\0":
# if cvar.var_namet != "hola\0":
if cvar.var_namet != "hola":
raise RuntimeError, "bad pointer case"
raise RuntimeError, "bad pointer case"
delete_pchar(pc)

View file

@ -4,17 +4,16 @@ defaults1 = Defaults1(1000)
defaults1 = Defaults1()
if defaults1.ret(10.0) != 10.0:
raise RuntimeError
raise RuntimeError
if defaults1.ret() != -1.0:
raise RuntimeError
raise RuntimeError
defaults2 = Defaults2(1000)
defaults2 = Defaults2()
if defaults2.ret(10.0) != 10.0:
raise RuntimeError
raise RuntimeError
if defaults2.ret() != -1.0:
raise RuntimeError
raise RuntimeError

View file

@ -1,17 +1,17 @@
import complextest
a = complex(-1,2)
a = complex(-1, 2)
if complextest.Conj(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
raise RuntimeError, "bad complex mapping"
if complextest.Conjf(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
raise RuntimeError, "bad complex mapping"
v = (complex(1,2), complex(2,3), complex(4,3), 1)
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
try:
complextest.Copy_h(v)
complextest.Copy_h(v)
except:
pass
pass

View file

@ -1,15 +1,20 @@
import constant_directive
if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1):
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1)))
if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1):
raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance())))
if not isinstance(constant_directive.TYPE1_CONSTANT1, constant_directive.Type1):
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(
type(constant_directive.TYPE1_CONSTANT1)))
if not isinstance(constant_directive.getType1Instance(), constant_directive.Type1):
raise RuntimeError("Failure: getType1Instance() type: {}".format(
type(constant_directive.getType1Instance())))
if constant_directive.TYPE1_CONSTANT1.val != 1:
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val)
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" %
constant_directive.TYPE1_CONSTANT1.val)
if constant_directive.TYPE1_CONSTANT2.val != 2:
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val)
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" %
constant_directive.TYPE1_CONSTANT2.val)
if constant_directive.TYPE1_CONSTANT3.val != 3:
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val)
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" %
constant_directive.TYPE1_CONSTANT3.val)

View file

@ -11,7 +11,7 @@ p = constover.test_pconst("test")
if p != "test_pconst":
print "test_pconst failed!"
error = 1
f = constover.Foo()
p = f.test("test")
if p != "test":
@ -32,7 +32,5 @@ p = f.test_pconstm("test")
if p != "test_pconstmethod":
print "member-test_pconstm failed!"
error = 1
sys.exit(error)

View file

@ -1,7 +1,7 @@
from constructor_copy import *
f1 = Foo1(3);
f11 = Foo1(f1);
f1 = Foo1(3)
f11 = Foo1(f1)
if f1.x != f11.x:
@ -24,7 +24,7 @@ bc = Bari(bi)
if (bi.x != bc.x):
raise RuntimeError
bd = Bard(5)
try:
@ -35,4 +35,3 @@ except:
if not good:
raise RuntimeError

View file

@ -1,143 +1,142 @@
import contract
contract.test_preassert(1,2)
contract.test_preassert(1, 2)
try:
contract.test_preassert(-1)
print "Failed! Preassertions are broken"
contract.test_preassert(-1)
print "Failed! Preassertions are broken"
except:
pass
pass
contract.test_postassert(3)
try:
contract.test_postassert(-3)
print "Failed! Postassertions are broken"
contract.test_postassert(-3)
print "Failed! Postassertions are broken"
except:
pass
pass
contract.test_prepost(2,3)
contract.test_prepost(5,-4)
contract.test_prepost(2, 3)
contract.test_prepost(5, -4)
try:
contract.test_prepost(-3,4)
print "Failed! Preassertions are broken"
contract.test_prepost(-3, 4)
print "Failed! Preassertions are broken"
except:
pass
pass
try:
contract.test_prepost(4,-10)
print "Failed! Postassertions are broken"
contract.test_prepost(4, -10)
print "Failed! Postassertions are broken"
except:
pass
pass
f = contract.Foo()
f.test_preassert(4,5)
f.test_preassert(4, 5)
try:
f.test_preassert(-2,3)
print "Failed! Method preassertion."
f.test_preassert(-2, 3)
print "Failed! Method preassertion."
except:
pass
pass
f.test_postassert(4)
try:
f.test_postassert(-4)
print "Failed! Method postassertion"
f.test_postassert(-4)
print "Failed! Method postassertion"
except:
pass
pass
f.test_prepost(3,4)
f.test_prepost(4,-3)
f.test_prepost(3, 4)
f.test_prepost(4, -3)
try:
f.test_prepost(-4,2)
print "Failed! Method preassertion."
f.test_prepost(-4, 2)
print "Failed! Method preassertion."
except:
pass
pass
try:
f.test_prepost(4,-10)
print "Failed! Method postassertion."
f.test_prepost(4, -10)
print "Failed! Method postassertion."
except:
pass
pass
contract.Foo_stest_prepost(4,0)
contract.Foo_stest_prepost(4, 0)
try:
contract.Foo_stest_prepost(-4,2)
print "Failed! Static method preassertion"
contract.Foo_stest_prepost(-4, 2)
print "Failed! Static method preassertion"
except:
pass
pass
try:
contract.Foo_stest_prepost(4,-10)
print "Failed! Static method posteassertion"
contract.Foo_stest_prepost(4, -10)
print "Failed! Static method posteassertion"
except:
pass
pass
b = contract.Bar()
try:
b.test_prepost(2,-4)
print "Failed! Inherited preassertion."
b.test_prepost(2, -4)
print "Failed! Inherited preassertion."
except:
pass
pass
d = contract.D()
try:
d.foo(-1,1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.foo(-1, 1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,-1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.foo(1, -1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,1,-1,1,1)
print "Failed! Inherited preassertion (D)."
d.foo(1, 1, -1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,1,1,-1,1)
print "Failed! Inherited preassertion (D)."
d.foo(1, 1, 1, -1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.foo(1,1,1,1,-1)
print "Failed! Inherited preassertion (D)."
d.foo(1, 1, 1, 1, -1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(-1,1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.bar(-1, 1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,-1,1,1,1)
print "Failed! Inherited preassertion (D)."
d.bar(1, -1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,1,-1,1,1)
print "Failed! Inherited preassertion (D)."
d.bar(1, 1, -1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,1,1,-1,1)
print "Failed! Inherited preassertion (D)."
d.bar(1, 1, 1, -1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
try:
d.bar(1,1,1,1,-1)
print "Failed! Inherited preassertion (D)."
d.bar(1, 1, 1, 1, -1)
print "Failed! Inherited preassertion (D)."
except:
pass
pass
#Namespace
# Namespace
my = contract.myClass(1)
try:
my = contract.myClass(0)
print "Failed! constructor preassertion"
my = contract.myClass(0)
print "Failed! constructor preassertion"
except:
pass
pass

View file

@ -2,12 +2,13 @@ import cpp11_alternate_function_syntax
a = cpp11_alternate_function_syntax.SomeStruct()
res = a.addNormal(4,5)
res = a.addNormal(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ",
res, " should be 9.")
res = a.addAlternate(4,5)
res = a.addAlternate(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ",
res, " should be 9.")

View file

@ -3,17 +3,16 @@ import cpp11_decltype
a = cpp11_decltype.A()
a.i = 5
if a.i != 5:
raise RuntimeError, "Assignment to a.i failed."
raise RuntimeError, "Assignment to a.i failed."
a.j = 10
if a.j != 10:
raise RuntimeError, "Assignment to a.j failed."
raise RuntimeError, "Assignment to a.j failed."
b = a.foo(5)
if b != 10:
raise RuntimeError, "foo(5) should return 10."
raise RuntimeError, "foo(5) should return 10."
b = a.foo(6)
if b != 0:
raise RuntimeError, "foo(6) should return 0."
raise RuntimeError, "foo(6) should return 0."

View file

@ -1,7 +1,9 @@
import cpp11_function_objects
import sys
class Test1(cpp11_function_objects.Test):
def __init__(self):
cpp11_function_objects.Test.__init__(self)
@ -10,14 +12,17 @@ class Test1(cpp11_function_objects.Test):
t = cpp11_function_objects.Test()
if t.value != 0:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
t(1,2) # adds numbers and sets value
t(1, 2) # adds numbers and sets value
if t.value != 3:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
t2 = Test1()
a = cpp11_function_objects.testit1(t2, 4,3)
a = cpp11_function_objects.testit1(t2, 4, 3)
if a != 12:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))

View file

@ -1,4 +1,3 @@
import cpp11_initializer_list_extend
c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] )
c = cpp11_initializer_list_extend.Container([10, 20, 30, 40])

View file

@ -2,4 +2,3 @@ import cpp11_initializer_list
a = cpp11_initializer_list.A()
a = cpp11_initializer_list.A(11.1)

View file

@ -3,13 +3,15 @@ import cpp11_null_pointer_constant
a = cpp11_null_pointer_constant.A()
if a._myA != None:
raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
raise RuntimeError, (
"cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
b = cpp11_null_pointer_constant.A()
if a._myA != b._myA:
raise RuntimeError, ("cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
raise RuntimeError, (
"cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
a._myA = cpp11_null_pointer_constant.A()
if a._myA == None:
raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be object, but is None")
raise RuntimeError, (
"cpp11_null_pointer_constant: _myA should be object, but is None")

View file

@ -1,50 +1,48 @@
from cpp11_raw_string_literals import *
if cvar.L != 100:
raise RuntimeError
raise RuntimeError
if cvar.u8 != 100:
raise RuntimeError
raise RuntimeError
if cvar.u != 100:
raise RuntimeError
raise RuntimeError
if UStruct.U != 100:
raise RuntimeError
raise RuntimeError
if cvar.R != 100:
raise RuntimeError
raise RuntimeError
if cvar.LR != 100:
raise RuntimeError
raise RuntimeError
if cvar.u8R != 100:
raise RuntimeError
raise RuntimeError
if cvar.uR != 100:
raise RuntimeError
raise RuntimeError
if URStruct.UR != 100:
raise RuntimeError
raise RuntimeError
if cvar.aa != "Wide string":
raise RuntimeError
raise RuntimeError
if cvar.bb != "UTF-8 string":
raise RuntimeError, cvar.wide
raise RuntimeError, cvar.wide
if cvar.xx != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.xx
raise RuntimeError, cvar.xx
if cvar.ee != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.ee
raise RuntimeError, cvar.ee
if cvar.ff != "I'm a \"raw wide\" \\ string.":
raise RuntimeError, cvar.ff
raise RuntimeError, cvar.ff
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
raise RuntimeError, cvar.gg
raise RuntimeError, cvar.gg

View file

@ -2,8 +2,10 @@ import cpp11_result_of
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
if result != 9.0:
raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(result)
raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(
result)
result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0)
if result != 9.0:
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(result)
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
result)

View file

@ -4,21 +4,24 @@ a = cpp11_rvalue_reference.A()
a.setAcopy(5)
if a.getAcopy() != 5:
raise RunTimeError, ("int A::getAcopy() value is ", a.getAcopy(), " should be 5")
raise RunTimeError, ("int A::getAcopy() value is ",
a.getAcopy(), " should be 5")
ptr = a.getAptr()
a.setAptr(ptr)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
a.setAref(ptr)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
rvalueref = a.getAmove()
a.setAmove(rvalueref)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")

View file

@ -1,9 +1,11 @@
from cpp11_strongly_typed_enumerations import *
def enumCheck(actual, expected):
if actual != expected:
raise RuntimeError("Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
return expected + 1
if actual != expected:
raise RuntimeError(
"Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
return expected + 1
val = 0
val = enumCheck(Enum1_Val1, val)
@ -161,4 +163,3 @@ enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121)
enumCheck(globalTest1(Enum1_Val5a), 13)
enumCheck(globalTest2(Class1.Enum12_Val5c), 1121)
#enumCheck(globalTest3(Class1.Struct1.Enum12_Val5f), 3121)

View file

@ -2,37 +2,36 @@ from cpp11_thread_local import *
t = ThreadLocals()
if t.stval != 11:
raise RuntimeError
raise RuntimeError
if t.tsval != 22:
raise RuntimeError
raise RuntimeError
if t.tscval99 != 99:
raise RuntimeError
raise RuntimeError
cvar.etval = -11
if cvar.etval != -11:
raise RuntimeError
raise RuntimeError
cvar.stval = -22
if cvar.stval != -22:
raise RuntimeError
raise RuntimeError
cvar.tsval = -33
if cvar.tsval != -33:
raise RuntimeError
raise RuntimeError
cvar.etval = -44
if cvar.etval != -44:
raise RuntimeError
raise RuntimeError
cvar.teval = -55
if cvar.teval != -55:
raise RuntimeError
raise RuntimeError
cvar.ectval = -66
if cvar.ectval != -66:
raise RuntimeError
raise RuntimeError
cvar.ecpptval = -66
if cvar.ecpptval != -66:
raise RuntimeError
raise RuntimeError

View file

@ -1,7 +1,7 @@
from cpp11_type_traits import *
if Elaborate(0, 0) != 1:
raise RuntimeError("Elaborate should have returned 1")
raise RuntimeError("Elaborate should have returned 1")
if Elaborate(0, 0.0) != 2:
raise RuntimeError("Elaborate should have returned 2")
raise RuntimeError("Elaborate should have returned 2")

View file

@ -2,20 +2,20 @@ import cpp11_uniform_initialization
var1 = cpp11_uniform_initialization.cvar.var1
if var1.x != 5:
raise RuntimeError
raise RuntimeError
var2 = cpp11_uniform_initialization.cvar.var2
if var2.getX() != 2:
raise RuntimeError
raise RuntimeError
m = cpp11_uniform_initialization.MoreInit()
if m.charptr != None:
raise RuntimeError, m.charptr
raise RuntimeError, m.charptr
m.charptr = "hello sir"
if m.charptr != "hello sir":
raise RuntimeError, m.charptr
raise RuntimeError, m.charptr
if m.more1(m.vi) != 15:
raise RuntimeError, m.vi
if m.more1( [-1,1,2] ) != 2:
raise RuntimeError, m.vi
raise RuntimeError, m.vi
if m.more1([-1, 1, 2]) != 2:
raise RuntimeError, m.vi
if m.more1() != 10:
raise RuntimeError
raise RuntimeError

View file

@ -3,21 +3,21 @@ import cpp_enum
f = cpp_enum.Foo()
if f.hola != f.Hello:
print f.hola
raise RuntimeError
print f.hola
raise RuntimeError
f.hola = f.Hi
if f.hola != f.Hi:
print f.hola
raise RuntimeError
print f.hola
raise RuntimeError
f.hola = f.Hello
if f.hola != f.Hello:
print f.hola
raise RuntimeError
print f.hola
raise RuntimeError
cpp_enum.cvar.hi = cpp_enum.Hello
if cpp_enum.cvar.hi != cpp_enum.Hello:
print cpp_enum.cvar.hi
raise RuntimeError
print cpp_enum.cvar.hi
raise RuntimeError

View file

@ -17,7 +17,7 @@ if cpp_namespace.do_method(t) != "Test::method":
if cpp_namespace.do_method2(t) != "Test::method":
raise RuntimeError("Bad return value!")
cpp_namespace.weird("hello", 4)
del t
@ -30,16 +30,14 @@ t5 = cpp_namespace.Test5()
if cpp_namespace.foo3(42) != 42:
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t2,40) != "Test2::method":
if cpp_namespace.do_method3(t2, 40) != "Test2::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t3,40) != "Test3::method":
if cpp_namespace.do_method3(t3, 40) != "Test3::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t4,40) != "Test4::method":
if cpp_namespace.do_method3(t4, 40) != "Test4::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t5,40) != "Test5::method":
if cpp_namespace.do_method3(t5, 40) != "Test5::method":
raise RuntimeError("Bad return value!")

View file

@ -1,16 +1,17 @@
#!/usr/bin/evn python
from cpp_static import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
return hasattr(cls, "__class__")
if is_new_style_class(StaticFunctionTest):
StaticFunctionTest.static_func()
StaticFunctionTest.static_func_2(1)
StaticFunctionTest.static_func_3(1,2)
StaticFunctionTest.static_func()
StaticFunctionTest.static_func_2(1)
StaticFunctionTest.static_func_3(1, 2)
else:
StaticFunctionTest().static_func()
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1,2)
StaticFunctionTest().static_func()
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1, 2)
StaticMemberTest.static_int = 10
assert StaticMemberTest.static_int == 10

View file

@ -3,15 +3,26 @@ from default_arg_values import *
d = Display()
if d.draw1() != 0:
raise RuntimeError
raise RuntimeError
if d.draw1(12) != 12:
raise RuntimeError
raise RuntimeError
p = createPtr(123);
p = createPtr(123)
if d.draw2() != 0:
raise RuntimeError
raise RuntimeError
if d.draw2(p) != 123:
raise RuntimeError
raise RuntimeError
if d.bool0() != False or type(d.bool0()) != type(False):
raise RuntimeError
if d.bool1() != True or type(d.bool1()) != type(True):
raise RuntimeError
if d.mybool0() != False or type(d.mybool0()) != type(False):
raise RuntimeError
if d.mybool1() != True or type(d.mybool1()) != type(True):
raise RuntimeError

View file

@ -1,98 +1,140 @@
# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
# Note that this test is also used by python_default_args_runme.py hence
# the use of __main__ and the run function
def is_new_style_class(cls):
return hasattr(cls, "__class__")
return hasattr(cls, "__class__")
def run(module_name):
default_args = __import__(module_name)
ec = default_args.EnumClass()
if not ec.blah():
raise RuntimeError("EnumClass::blah() default arguments don't work")
default_args = __import__(module_name)
ec = default_args.EnumClass()
if not ec.blah():
raise RuntimeError("EnumClass::blah() default arguments don't work")
de = default_args.DerivedEnumClass()
de.accelerate()
de.accelerate(default_args.EnumClass.SLOW)
de = default_args.DerivedEnumClass()
de.accelerate()
de.accelerate(default_args.EnumClass.SLOW)
if default_args.Statics_staticMethod() != 60:
raise RuntimeError
if default_args.Statics_staticMethod() != 60:
raise RuntimeError
if default_args.cfunc1(1) != 2:
raise RuntimeError
if default_args.cfunc1(1) != 2:
raise RuntimeError
if default_args.cfunc2(1) != 3:
raise RuntimeError
if default_args.cfunc2(1) != 3:
raise RuntimeError
if default_args.cfunc3(1) != 4:
raise RuntimeError
if default_args.cfunc3(1) != 4:
raise RuntimeError
f = default_args.Foo()
f = default_args.Foo()
f.newname()
f.newname(1)
f.newname()
f.newname(1)
if f.double_if_void_ptr_is_null(2, None) != 4:
raise RuntimeError
if f.double_if_void_ptr_is_null(3) != 6:
raise RuntimeError
try:
f = default_args.Foo(1)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::Foo ignore is not working")
if f.double_if_handle_is_null(4, None) != 8:
raise RuntimeError
try:
f = default_args.Foo(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::Foo ignore is not working")
if f.double_if_handle_is_null(5) != 10:
raise RuntimeError
try:
f = default_args.Foo(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::Foo ignore is not working")
if f.double_if_dbl_ptr_is_null(6, None) != 12:
raise RuntimeError
try:
m = f.meth(1)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::meth ignore is not working")
if f.double_if_dbl_ptr_is_null(7) != 14:
raise RuntimeError
try:
m = f.meth(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::meth ignore is not working")
try:
f = default_args.Foo(1)
error = 1
except:
error = 0
if error:
raise RuntimeError("Foo::Foo ignore is not working")
try:
m = f.meth(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::meth ignore is not working")
try:
f = default_args.Foo(1, 2)
error = 1
except:
error = 0
if error:
raise RuntimeError("Foo::Foo ignore is not working")
if is_new_style_class(default_args.Klass):
Klass_inc = default_args.Klass.inc
else:
Klass_inc = default_args.Klass_inc
try:
f = default_args.Foo(1, 2, 3)
error = 1
except:
error = 0
if error:
raise RuntimeError("Foo::Foo ignore is not working")
if Klass_inc(100, default_args.Klass(22)).val != 122:
raise RuntimeError("Klass::inc failed")
try:
m = f.meth(1)
error = 1
except:
error = 0
if error:
raise RuntimeError("Foo::meth ignore is not working")
if Klass_inc(100).val != 99:
raise RuntimeError("Klass::inc failed")
try:
m = f.meth(1, 2)
error = 1
except:
error = 0
if error:
raise RuntimeError("Foo::meth ignore is not working")
if Klass_inc().val != 0:
raise RuntimeError("Klass::inc failed")
try:
m = f.meth(1, 2, 3)
error = 1
except:
error = 0
if error:
raise RuntimeError("Foo::meth ignore is not working")
default_args.trickyvalue1(10); default_args.trickyvalue1(10, 10)
default_args.trickyvalue2(10); default_args.trickyvalue2(10, 10)
default_args.trickyvalue3(10); default_args.trickyvalue3(10, 10)
default_args.seek(); default_args.seek(10)
if is_new_style_class(default_args.Klass):
Klass_inc = default_args.Klass.inc
else:
Klass_inc = default_args.Klass_inc
if __name__=="__main__":
run('default_args')
if Klass_inc(100, default_args.Klass(22)).val != 122:
raise RuntimeError("Klass::inc failed")
if Klass_inc(100).val != 99:
raise RuntimeError("Klass::inc failed")
if Klass_inc().val != 0:
raise RuntimeError("Klass::inc failed")
default_args.trickyvalue1(10)
default_args.trickyvalue1(10, 10)
default_args.trickyvalue2(10)
default_args.trickyvalue2(10, 10)
default_args.trickyvalue3(10)
default_args.trickyvalue3(10, 10)
default_args.seek()
default_args.seek(10)
if default_args.slightly_off_square(10) != 102:
raise RuntimeError
if default_args.slightly_off_square() != 291:
raise RuntimeError
# It is difficult to test the python:cdefaultargs feature properly as -builtin
# and -fastproxy do not use the Python layer for default args
if default_args.CDA().cdefaultargs_test1() != 1:
raise RuntimeError
if default_args.CDA().cdefaultargs_test2() != 1:
raise RuntimeError
if __name__ == "__main__":
run('default_args')

View file

@ -4,7 +4,7 @@ import _default_constructor
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
# which is not provided with the -builtin option.
if _default_constructor.is_python_builtin():
exit(0)
exit(0)
dc = _default_constructor
@ -23,7 +23,7 @@ except:
del_b = dc.delete_B
try:
bb = dc.new_BB();
bb = dc.new_BB()
print "Whoa. new_BB created."
except:
pass
@ -42,7 +42,7 @@ cc = dc.new_CC()
dc.delete_CC(cc)
try:
d = dc.new_D();
d = dc.new_D()
print "Whoa. new_D created"
except:
pass
@ -89,15 +89,6 @@ except AttributeError:
dc.F_destroy(f)
ff = dc.new_FFF()
try:
del_ff = dc.delete_FFF
print "Whoa. delete_FFF created"
except AttributeError:
pass
dc.F_destroy(ff)
g = dc.new_G()
try:
@ -113,5 +104,4 @@ dc.delete_GG(gg)
import default_constructor
hh = default_constructor.HH(1,1)
hh = default_constructor.HH(1, 1)

View file

@ -1,79 +1,91 @@
import director_abstract
def is_new_style_class(cls):
return hasattr(cls, "__class__")
return hasattr(cls, "__class__")
class MyFoo(director_abstract.Foo):
def __init__(self):
director_abstract.Foo.__init__(self)
def ping(self):
return "MyFoo::ping()"
def __init__(self):
director_abstract.Foo.__init__(self)
def ping(self):
return "MyFoo::ping()"
a = MyFoo()
if a.ping() != "MyFoo::ping()":
raise RuntimeError, a.ping()
raise RuntimeError, a.ping()
if a.pong() != "Foo::pong();MyFoo::ping()":
raise RuntimeError, a.pong()
raise RuntimeError, a.pong()
class MyExample1(director_abstract.Example1):
def Color(self, r, g, b):
return r
def Color(self, r, g, b):
return r
class MyExample2(director_abstract.Example2):
def Color(self, r, g, b):
return g
def Color(self, r, g, b):
return g
class MyExample3(director_abstract.Example3_i):
def Color(self, r, g, b):
return b
def Color(self, r, g, b):
return b
me1 = MyExample1()
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
raise RuntimeError
if director_abstract.Example1_get_color(me1, 1, 2, 3) != 1:
raise RuntimeError
if is_new_style_class(MyExample2):
MyExample2_static = MyExample2
MyExample2_static = MyExample2
else:
MyExample2_static = MyExample2(0, 0)
me2 = MyExample2(1,2)
if MyExample2_static.get_color(me2, 1,2,3) != 2:
raise RuntimeError
MyExample2_static = MyExample2(0, 0)
me2 = MyExample2(1, 2)
if MyExample2_static.get_color(me2, 1, 2, 3) != 2:
raise RuntimeError
if is_new_style_class(MyExample3):
MyExample3_static = MyExample3
MyExample3_static = MyExample3
else:
MyExample3_static = MyExample3()
MyExample3_static = MyExample3()
me3 = MyExample3()
if MyExample3_static.get_color(me3, 1,2,3) != 3:
raise RuntimeError
if MyExample3_static.get_color(me3, 1, 2, 3) != 3:
raise RuntimeError
error = 1
try:
me1 = director_abstract.Example1()
me1 = director_abstract.Example1()
except:
error = 0
if (error): raise RuntimeError
error = 0
if (error):
raise RuntimeError
error = 1
try:
me2 = director_abstract.Example2()
me2 = director_abstract.Example2()
except:
error = 0
if (error): raise RuntimeError
error = 0
if (error):
raise RuntimeError
error = 1
try:
me3 = director_abstract.Example3_i()
me3 = director_abstract.Example3_i()
except:
error = 0
if (error): raise RuntimeError
error = 0
if (error):
raise RuntimeError
try:
f = director_abstract.A.f
f = director_abstract.A.f
except:
raise RuntimeError
raise RuntimeError

Some files were not shown because too many files have changed in this diff Show more