Merge branch 'master' of https://github.com/swig/swig into Cmerge
This commit is contained in:
commit
5a06ca1ed7
312 changed files with 10813 additions and 7218 deletions
17
Examples/test-suite/catches_strings.i
Normal file
17
Examples/test-suite/catches_strings.i
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
%module catches_strings
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%catches(const char *) StringsThrower::charstring;
|
||||
%catches(std::string) StringsThrower::stdstring;
|
||||
|
||||
%inline %{
|
||||
struct StringsThrower {
|
||||
static void charstring() {
|
||||
throw "charstring message";
|
||||
}
|
||||
static void stdstring() {
|
||||
throw std::string("stdstring message");
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#######################################################################
|
||||
# Makefile for cffi test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = cffi
|
||||
CFFI = @CFFIBIN@
|
||||
SCRIPTSUFFIX = _runme.lisp
|
||||
|
||||
HAVE_CXX11 = @HAVE_CXX11@
|
||||
HAVE_CXX14 = @HAVE_CXX14@
|
||||
HAVE_CXX17 = @HAVE_CXX17@
|
||||
HAVE_CXX20 = @HAVE_CXX20@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# no C++ tests for now
|
||||
CPP_TEST_CASES =
|
||||
#C_TEST_CASES +=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# 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_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we don't generate extra cffi code)
|
||||
%.clean:
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' cffi_clean
|
||||
|
|
@ -90,7 +90,6 @@ CPP_TEST_BROKEN += \
|
|||
nested_private \
|
||||
template_default_pointer \
|
||||
template_private_assignment \
|
||||
template_expr \
|
||||
$(CPP11_TEST_BROKEN) \
|
||||
$(CPP14_TEST_BROKEN) \
|
||||
$(CPP17_TEST_BROKEN) \
|
||||
|
|
@ -133,6 +132,7 @@ CPP_TEST_CASES += \
|
|||
bloody_hell \
|
||||
bools \
|
||||
catches \
|
||||
catches_strings \
|
||||
cast_operator \
|
||||
casts \
|
||||
char_binary \
|
||||
|
|
@ -215,13 +215,16 @@ CPP_TEST_CASES += \
|
|||
director_ref \
|
||||
director_simple \
|
||||
director_smartptr \
|
||||
director_template \
|
||||
director_thread \
|
||||
director_unroll \
|
||||
director_unwrap_result \
|
||||
director_using \
|
||||
director_using_member_scopes \
|
||||
director_void \
|
||||
director_wombat \
|
||||
disown \
|
||||
duplicate_class_name_in_ns \
|
||||
dynamic_cast \
|
||||
empty \
|
||||
enum_ignore \
|
||||
|
|
@ -455,10 +458,12 @@ CPP_TEST_CASES += \
|
|||
template_enum_ns_inherit \
|
||||
template_enum_typedef \
|
||||
template_explicit \
|
||||
template_expr \
|
||||
template_extend1 \
|
||||
template_extend2 \
|
||||
template_extend_overload \
|
||||
template_extend_overload_2 \
|
||||
template_function_parm \
|
||||
template_forward \
|
||||
template_inherit \
|
||||
template_inherit_abstract \
|
||||
|
|
@ -482,6 +487,7 @@ CPP_TEST_CASES += \
|
|||
template_parameters_global_scope \
|
||||
template_partial_arg \
|
||||
template_partial_specialization \
|
||||
template_partial_specialization_more \
|
||||
template_partial_specialization_typedef \
|
||||
template_qualifier \
|
||||
template_ref_type \
|
||||
|
|
@ -493,6 +499,7 @@ CPP_TEST_CASES += \
|
|||
template_static \
|
||||
template_tbase_template \
|
||||
template_template_parameters \
|
||||
template_template_template_parameters \
|
||||
template_typedef \
|
||||
template_typedef_class_template \
|
||||
template_typedef_cplx \
|
||||
|
|
@ -590,6 +597,7 @@ CPP11_TEST_CASES += \
|
|||
cpp11_director_enums \
|
||||
cpp11_directors \
|
||||
cpp11_explicit_conversion_operators \
|
||||
cpp11_final_class \
|
||||
cpp11_final_directors \
|
||||
cpp11_final_override \
|
||||
cpp11_function_objects \
|
||||
|
|
@ -619,16 +627,18 @@ CPP11_TEST_CASES += \
|
|||
cpp11_thread_local \
|
||||
cpp11_template_double_brackets \
|
||||
cpp11_template_explicit \
|
||||
cpp11_template_parameters_decltype \
|
||||
cpp11_template_typedefs \
|
||||
cpp11_type_traits \
|
||||
cpp11_type_aliasing \
|
||||
cpp11_uniform_initialization \
|
||||
cpp11_unrestricted_unions \
|
||||
cpp11_userdefined_literals \
|
||||
cpp11_variadic_function_templates \
|
||||
cpp11_variadic_templates \
|
||||
|
||||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN = \
|
||||
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
|
||||
# cpp11_reference_wrapper \ # No typemaps
|
||||
|
||||
# C++14 test cases.
|
||||
|
|
@ -640,6 +650,7 @@ CPP14_TEST_BROKEN = \
|
|||
|
||||
# C++17 test cases.
|
||||
CPP17_TEST_CASES += \
|
||||
cpp17_enable_if_t \
|
||||
cpp17_hex_floating_literals \
|
||||
cpp17_nested_namespaces \
|
||||
cpp17_nspace_nested_namespaces \
|
||||
|
|
@ -709,6 +720,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_vector_enum \
|
||||
li_std_vector_member_var\
|
||||
li_std_vector_ptr \
|
||||
li_std_vector_vector \
|
||||
li_std_wstring \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
|
|
@ -753,6 +765,7 @@ C_TEST_CASES += \
|
|||
enum_macro \
|
||||
enum_missing \
|
||||
extern_declaration \
|
||||
final_c \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
global_functions \
|
||||
|
|
@ -786,6 +799,7 @@ C_TEST_CASES += \
|
|||
preproc_gcc_output \
|
||||
preproc_include \
|
||||
preproc_line_file \
|
||||
preproc_predefined \
|
||||
register_par \
|
||||
ret_by_value \
|
||||
simple_array \
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4996) // For the deprecated attributes in this testcase
|
||||
#pragma warning(disable : 5030) // attribute is not recognized ('likely' and 'unlikely')
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,35 @@
|
|||
int i;
|
||||
decltype(i) j;
|
||||
|
||||
auto foo( decltype(i) a ) -> decltype(i) {
|
||||
auto get_number(decltype(i) a) -> decltype(i) {
|
||||
if (a==5)
|
||||
return 10;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
%}
|
||||
%}
|
||||
|
||||
|
||||
// These are ignored as unable to deduce decltype for (i+j)
|
||||
%ignore B::k;
|
||||
%ignore B::get_number_sum;
|
||||
%ignore B::get_number_address;
|
||||
#pragma SWIG nowarn=SWIGWARN_CPP11_DECLTYPE
|
||||
|
||||
%inline %{
|
||||
class B {
|
||||
public:
|
||||
int i;
|
||||
decltype(i) j;
|
||||
decltype(i+j) k;
|
||||
|
||||
auto get_number_sum(decltype(i+j) a) -> decltype(i+j) {
|
||||
return i+j;
|
||||
}
|
||||
|
||||
auto get_number_address(decltype(&i) a) -> decltype(&i) {
|
||||
return &i;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
141
Examples/test-suite/cpp11_final_class.i
Normal file
141
Examples/test-suite/cpp11_final_class.i
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
%module cpp11_final_class
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) final; // 'final' is a java keyword, renaming to '_final'
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) override; // 'override' is a C# keyword, renaming to '_override'
|
||||
|
||||
%ignore Space1::final::operator=;
|
||||
#if defined(SWIGPHP)
|
||||
%rename(Space1_final) Space1::final::final;
|
||||
#endif
|
||||
#if defined(SWIGOCAML)
|
||||
%rename(finale) BrokenSpace::FinalEnum1::final;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
struct FinalBase {
|
||||
virtual ~FinalBase() {}
|
||||
};
|
||||
|
||||
struct FinalClass1 final : FinalBase {
|
||||
void method1() {}
|
||||
};
|
||||
|
||||
class FinalClass2 final : public FinalBase {
|
||||
public:
|
||||
void method2() {}
|
||||
};
|
||||
|
||||
struct FinalClass3 final {
|
||||
void method3() {}
|
||||
};
|
||||
|
||||
struct FinalClass4 {
|
||||
void method4() {}
|
||||
} final;
|
||||
|
||||
struct override final {
|
||||
void omethod() {}
|
||||
};
|
||||
%}
|
||||
|
||||
%rename(Space1_final) Space1::final;
|
||||
|
||||
%inline %{
|
||||
namespace Space1 {
|
||||
struct final final {
|
||||
void finalmethod() {}
|
||||
final() {}
|
||||
final(const final &other) = default;
|
||||
final& operator=(const final &other) = default;
|
||||
};
|
||||
struct FinalClass5 final {
|
||||
void method5() {}
|
||||
final final_member_var;
|
||||
final get_final_member() { return final_member_var; }
|
||||
Space1::final get_final_member2() { return final_member_var; }
|
||||
};
|
||||
struct FinalClass6 {
|
||||
void method6() {}
|
||||
virtual void final() final {}
|
||||
virtual ~FinalClass6() = default;
|
||||
};
|
||||
typedef final Space1_final_typedef1;
|
||||
typedef struct final Space1_final_typedef2;
|
||||
}
|
||||
typedef Space1::final Space1_final_typedef3;
|
||||
typedef struct Space1::final Space1_final_typedef4;
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace Space2 {
|
||||
class Y {
|
||||
public:
|
||||
Y(int i=0) {}
|
||||
};
|
||||
|
||||
struct FinalVar1 {
|
||||
class Y notfinal;
|
||||
// class Y final; // SWIG (C++ only) fails to parse (same for struct and union)
|
||||
};
|
||||
struct FinalVar2 {
|
||||
class Y notfinal = {};
|
||||
// class Y final = {}; // SWIG (C++ only) fails to parse (same for struct and union)
|
||||
};
|
||||
struct FinalVar3 {
|
||||
class Y notfinal = Y();
|
||||
// class Y final = Y(); // SWIG (C++ only) fails to parse (same for struct and union)
|
||||
};
|
||||
struct FinalVar4 {
|
||||
class Y* final;
|
||||
FinalVar4() : final() {}
|
||||
};
|
||||
struct FinalVar5 {
|
||||
Y final;
|
||||
};
|
||||
struct FinalVar6 {
|
||||
Y final = {};
|
||||
};
|
||||
struct FinalVar7 {
|
||||
Y final = Y();
|
||||
};
|
||||
struct FinalVar8 {
|
||||
Y final{};
|
||||
};
|
||||
struct FinalVar9 {
|
||||
Y final{9};
|
||||
};
|
||||
struct FinalVar10 {
|
||||
void b10(Y final) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
// Unfortunately the use of final in BrokenSpace does not work with Visual C++
|
||||
// so we limit testing to parsing these by SWIG and then ignoring it all.
|
||||
%ignore BrokenSpace::FinalVar11;
|
||||
%ignore BrokenSpace::FinalEnum1;
|
||||
%ignore BrokenSpace::FinalEnum2;
|
||||
|
||||
namespace BrokenSpace {
|
||||
using Space2::Y;
|
||||
struct FinalVar11 {
|
||||
void a11(class Y final) {}
|
||||
};
|
||||
struct FinalEnum1 {
|
||||
enum Enum1 { one, two, final };
|
||||
void enum_in(Enum1 e) {}
|
||||
};
|
||||
struct FinalEnum2 {
|
||||
enum Enum2 { one, two, three, four };
|
||||
enum Enum2 final;
|
||||
};
|
||||
}
|
||||
|
||||
%rename(Space3_final) Space3::final;
|
||||
%inline %{
|
||||
namespace Space3 {
|
||||
typedef struct final {
|
||||
void fmethod() {}
|
||||
} final;
|
||||
}
|
||||
%}
|
||||
|
|
@ -27,7 +27,7 @@ struct Base {
|
|||
virtual ~Base() {}
|
||||
};
|
||||
|
||||
struct Derived /*final*/ : Base {
|
||||
struct Derived final : Base {
|
||||
virtual void stuff() const noexcept override final {}
|
||||
virtual void override1() const noexcept override;
|
||||
virtual void override2() const noexcept override;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class C {
|
|||
public:
|
||||
C(std::initializer_list<const char *> init) {
|
||||
for (auto& val : init)
|
||||
joined += val;
|
||||
joined = joined + val;
|
||||
}
|
||||
C() {}
|
||||
const char * get_joined_string() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
%include "cpp11_move_only_helper.i"
|
||||
|
||||
#if defined(SWIGOCAML)
|
||||
%rename(valu) val;
|
||||
#endif
|
||||
|
||||
%ignore MoveOnly::operator=;
|
||||
//%valuewrapper MoveOnly; // SWIG sets %valuewrapper by default for move-only types
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This test case checks SwigValueWrapper and move assignment.
|
||||
* Although not necessary, the test case was developed testing with C++98 compatibility for comparing improvements.
|
||||
* C++11 and later is of course required for the move assignment support.
|
||||
* C++98 is not actually necesary now as the test-suite only runs this test with compilers that support C++11 and later.
|
||||
* C++98 is not actually necessary now as the test-suite only runs this test with compilers that support C++11 and later.
|
||||
*/
|
||||
|
||||
%{
|
||||
|
|
|
|||
51
Examples/test-suite/cpp11_template_parameters_decltype.i
Normal file
51
Examples/test-suite/cpp11_template_parameters_decltype.i
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
%module cpp11_template_parameters_decltype
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_pair.i>
|
||||
|
||||
#pragma SWIG nowarn=SWIGWARN_CPP11_DECLTYPE
|
||||
|
||||
#if 0
|
||||
// to fix (non-template expression equivalent to template expression further down):
|
||||
%inline %{
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
void f(bool c = std::is_constructible<std::string, decltype(std::declval<std::vector<std::pair<int, int>>>().begin()->first)>::value) {}
|
||||
%}
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
// Github issue #1590
|
||||
struct Converter {
|
||||
std::string to_json() const { return std::string(); }
|
||||
};
|
||||
struct Json {
|
||||
Json(std::string s) {}
|
||||
template < class T, class = decltype(&T::to_json) >
|
||||
Json(const T & t) : Json(t.to_json()) {}
|
||||
|
||||
// Github issue #1589
|
||||
// To fix
|
||||
#if !defined(SWIG)
|
||||
// Implicit constructor: map-like objects (std::map, std::unordered_map, etc)
|
||||
template <class M, typename std::enable_if<
|
||||
std::is_constructible<std::string, decltype(std::declval<M>().begin()->first)>::value,
|
||||
int>::type = 0>
|
||||
Json(const M & m) : Json(object(m.begin(), m.end())) {}
|
||||
#endif
|
||||
};
|
||||
%}
|
||||
|
||||
// %template(Json) Json::Json<Converter>; // not working
|
||||
%template(Json) Json::Json<Converter, std::string>; // workaround
|
||||
|
||||
|
||||
%inline %{
|
||||
// Github issue #1589
|
||||
template <decltype(true) X = true>
|
||||
void A() { }
|
||||
%}
|
||||
|
||||
// %template(A) A<>; // not working
|
||||
%template(A) A<true>; // workaround
|
||||
|
|
@ -112,3 +112,39 @@ using callback_t = int(*)(int);
|
|||
callback_t get_callback() { return mult2; }
|
||||
int call(callback_t funk, int param) { return funk(param); }
|
||||
%}
|
||||
|
||||
|
||||
// Template template parameters - from #1021
|
||||
%inline %{
|
||||
#include <type_traits>
|
||||
|
||||
class Node {};
|
||||
struct AnyVal { typedef AnyVal Super; };
|
||||
|
||||
template<template<typename D, typename O> class C, typename T, typename Super, typename Root, typename O>
|
||||
using DeriveToBase = typename std::conditional<std::is_same<T, AnyVal>::value, Root, C<Super, O> >::type;
|
||||
|
||||
template<class T, class Root, class RParent>
|
||||
using ImmediateBase = typename std::conditional<std::is_same<T, AnyVal>::value, Root, RParent >::type;
|
||||
|
||||
template<class D, typename _Super=AnyVal> class Expression {
|
||||
typedef _Super Super;
|
||||
};
|
||||
|
||||
void TestInstantiationsPart4() {
|
||||
Expression<AnyVal, AnyVal::Super> express;
|
||||
DeriveToBase<Expression, AnyVal, AnyVal, AnyVal, AnyVal> derive_to_base = AnyVal();
|
||||
}
|
||||
%}
|
||||
|
||||
#if 0
|
||||
// TODO define and instantiate std::conditional and std::is_same
|
||||
%template(ExpressionInstantiation) Expression<AnyVal, AnyVal::Super>;
|
||||
%template(AnyTypeInstantiation) DeriveToBase<Expression, AnyVal, AnyVal, AnyVal, AnyVal>;
|
||||
|
||||
%inline %{
|
||||
AnyVal takeAnyVal(DeriveToBase<Expression, AnyVal, AnyVal, AnyVal, AnyVal> av) {
|
||||
return av;
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
// This doesn't really directly test functionality in type_traits as it doesn't provide
|
||||
// much for use by target languages, rather it tests usage of it.
|
||||
|
||||
%warnfilter(509) elaborate;
|
||||
|
||||
%inline %{
|
||||
#include <type_traits>
|
||||
|
||||
|
|
|
|||
96
Examples/test-suite/cpp11_variadic_function_templates.i
Normal file
96
Examples/test-suite/cpp11_variadic_function_templates.i
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
%module cpp11_variadic_function_templates
|
||||
|
||||
// Some tests for variadic function templates
|
||||
%inline %{
|
||||
class A {
|
||||
public:
|
||||
A() {
|
||||
a = 100;
|
||||
}
|
||||
virtual ~A() {}
|
||||
int a;
|
||||
};
|
||||
|
||||
class B {
|
||||
public:
|
||||
B() {
|
||||
b = 200;
|
||||
}
|
||||
virtual ~B() {}
|
||||
int b;
|
||||
};
|
||||
|
||||
class C {
|
||||
public:
|
||||
C() {
|
||||
c = 300;
|
||||
}
|
||||
virtual ~C() {}
|
||||
int c;
|
||||
};
|
||||
|
||||
class D {
|
||||
public:
|
||||
D() {
|
||||
d = 400;
|
||||
}
|
||||
virtual ~D() {}
|
||||
int d;
|
||||
};
|
||||
%}
|
||||
|
||||
// #1863
|
||||
%inline %{
|
||||
class Container {
|
||||
public:
|
||||
template<typename... Args>
|
||||
static void notifyMyTypes(void (fn)(Args...)); // unconventional function (ptr)
|
||||
template<typename... Args>
|
||||
static void notifyMyTypesA(void (*fn)(Args...)) {} // conventional function ptr
|
||||
template<typename... Args>
|
||||
static void notifyMyTypesB(void fn(Args...)) {}; // unconventional function (ptr)
|
||||
};
|
||||
%}
|
||||
%{
|
||||
template<typename... Args>
|
||||
void Container::notifyMyTypes(void (fn)(Args...)) {}
|
||||
|
||||
// Explicit template instantiations
|
||||
template void Container::notifyMyTypes<>(void (tt)());
|
||||
template void Container::notifyMyTypes<int>(void (tt)(int));
|
||||
template void Container::notifyMyTypes<int, double>(void (tt)(int, double));
|
||||
%}
|
||||
|
||||
// Not supported (most vexing parse), see Extending.html#Extending_nn7
|
||||
//%template(ContainerNotifyMyTypes1) Container::notifyMyTypes<int>;
|
||||
%template(ContainerNotifyMyTypesA1) Container::notifyMyTypesA<int>;
|
||||
%template(ContainerNotifyMyTypesB1) Container::notifyMyTypesB<int>;
|
||||
|
||||
// #1863
|
||||
%inline %{
|
||||
#include <type_traits>
|
||||
class EmplaceContainer {
|
||||
public:
|
||||
template<typename T, typename... Args>
|
||||
void emplace(Args &&... args) noexcept(
|
||||
std::is_nothrow_constructible<T, Args &&...>::value) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(emplace) EmplaceContainer::emplace<int,A>;
|
||||
%template(emplace) EmplaceContainer::emplace<int,A,B>;
|
||||
%template(emplace) EmplaceContainer::emplace<int,A,B,C>;
|
||||
%template(emplace) EmplaceContainer::emplace<int,A,B,C,D>;
|
||||
|
||||
|
||||
// Overloading mix of variadic and non-variadic templates
|
||||
%inline %{
|
||||
template<typename T, typename U> int variadicmix1(T t, U u) { return 10; }
|
||||
template<typename... T> int variadicmix1(T... t) { return 20; }
|
||||
%}
|
||||
|
||||
%template(variadicmix1) variadicmix1<>;
|
||||
%template(variadicmix1) variadicmix1<A>;
|
||||
%template(variadicmix1) variadicmix1<A,B>;
|
||||
%template(variadicmix1) variadicmix1<A,B,C>;
|
||||
%template(variadicmix1) variadicmix1<int, int>;
|
||||
|
|
@ -4,9 +4,21 @@
|
|||
using variadic number of classes.
|
||||
*/
|
||||
%module cpp11_variadic_templates
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiArgs;
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) SizeOf;
|
||||
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiInherit;
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_RUBY_MULTIPLE_INHERITANCE) MultiInherit;
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_RUBY_MULTIPLE_INHERITANCE) NumerousInherit;
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_RUBY_MULTIPLE_INHERITANCE) LotsInherit;
|
||||
|
||||
////////////////////////
|
||||
// Variadic templates //
|
||||
|
|
@ -24,7 +36,6 @@ class MultiArgs<int, std::vector<int>, std::map<std::string, std::vector<int>>>
|
|||
|
||||
%}
|
||||
|
||||
// TODO
|
||||
%template (MultiArgs1) MultiArgs<int, std::vector<int>, std::map<std::string, std::vector<int>>>;
|
||||
|
||||
////////////////////////
|
||||
|
|
@ -36,7 +47,10 @@ template<typename... Args> struct SizeOf {
|
|||
};
|
||||
%}
|
||||
|
||||
%template (SizeOf1) SizeOf<int, int>;
|
||||
%template (SizeOf0) SizeOf<>;
|
||||
%template (SizeOf1) SizeOf<int>;
|
||||
%template (SizeOf2) SizeOf<int, int>;
|
||||
%template (SizeOf3) SizeOf<int, int, int>;
|
||||
|
||||
//////////////////////////
|
||||
// Variadic inheritance //
|
||||
|
|
@ -60,18 +74,147 @@ public:
|
|||
int b;
|
||||
};
|
||||
|
||||
class C {
|
||||
public:
|
||||
C() {
|
||||
c = 300;
|
||||
}
|
||||
virtual ~C() {}
|
||||
int c;
|
||||
};
|
||||
|
||||
class D {
|
||||
public:
|
||||
D() {
|
||||
d = 400;
|
||||
}
|
||||
virtual ~D() {}
|
||||
int d;
|
||||
};
|
||||
|
||||
template <typename... BaseClasses> class MultiInherit : public BaseClasses... {
|
||||
public:
|
||||
MultiInherit(BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {}
|
||||
void MultiInstanceMethod(BaseClasses&... baseClasses) {}
|
||||
static void MultiStaticMethod(BaseClasses&... baseClasses) {}
|
||||
int InstanceMethod() { return 123; }
|
||||
static int StaticMethod() { return 456; }
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
// TODO
|
||||
//%template (MultiInherit0) MultiInherit<>;
|
||||
%template (MultiInherit0) MultiInherit<>;
|
||||
%template (MultiInherit1) MultiInherit<A>;
|
||||
// TODO
|
||||
%template (MultiInherit2) MultiInherit<A,B>;
|
||||
%template (MultiInherit3) MultiInherit<A,B,C>;
|
||||
|
||||
%inline %{
|
||||
template <typename... BaseClasses> class NumerousInherit : public BaseClasses... {
|
||||
public:
|
||||
NumerousInherit(int i, BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {}
|
||||
void NumerousInstanceMethod(int i, BaseClasses&... baseClasses) {}
|
||||
static void NumerousStaticMethod(int i, BaseClasses&... baseClasses) {}
|
||||
int InstanceMethod() { return 123; }
|
||||
static int StaticMethod() { return 456; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template (NumerousInherit0) NumerousInherit<>;
|
||||
%template (NumerousInherit1) NumerousInherit<A>;
|
||||
%template (NumerousInherit2) NumerousInherit<A,B>;
|
||||
%template (NumerousInherit3) NumerousInherit<A,B,C>;
|
||||
|
||||
%inline %{
|
||||
template <typename T, typename... BaseClasses> class LotsInherit : public T, public BaseClasses... {
|
||||
public:
|
||||
LotsInherit(T t, BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {}
|
||||
void LotsInstanceMethod(T t, BaseClasses&... baseClasses) {}
|
||||
static void LotsStaticMethod(T t, BaseClasses&... baseClasses) {}
|
||||
int InstanceMethod() { return 123; }
|
||||
static int StaticMethod() { return 456; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template (LotsInherit1) LotsInherit<A>;
|
||||
%template (LotsInherit2) LotsInherit<A,B>;
|
||||
%template (LotsInherit3) LotsInherit<A,B,C>;
|
||||
%template (LotsInherit4) LotsInherit<A,B,C,D>;
|
||||
|
||||
%inline %{
|
||||
struct KlassMemFuncs {
|
||||
int memfunc0() { return 0; }
|
||||
int memfunc1() { return 1; }
|
||||
int memfunc2() { return 2; }
|
||||
int memfunc3() { return 3; }
|
||||
};
|
||||
template <typename... V> struct VariadicParms {
|
||||
void ParmsVal(V... vparms_v) {}
|
||||
void ParmsPtr(V*... vparms_p) {}
|
||||
void ParmsPtrRef(V*&... vparms_pr) {}
|
||||
void ParmsPtrRValueRef(V*&&... vparms_rvr) {}
|
||||
void ParmsRef(V&... vparms_r) {}
|
||||
void ParmsRValueRef(V&&... vparms_r) {}
|
||||
void ParmsConstRef(const V&... vparms_cr) {}
|
||||
|
||||
// Conventional unnamed parameter function ptr
|
||||
void ParmsFuncPtrVal(int (*)(V...)) {}
|
||||
void ParmsFuncPtrPtr(int (*)(V*...)) {}
|
||||
void ParmsFuncPtrPtrRef(int (*)(V*&...)) {}
|
||||
void ParmsFuncPtrPtrRValueRef(int (*)(V*&&...)) {}
|
||||
void ParmsFuncPtrRef(int (*)(V&...)) {}
|
||||
void ParmsFuncPtrRValueRef(int (*)(V&&...)) {}
|
||||
void ParmsFuncPtrConstRef(int (*)(const V&...)) {}
|
||||
|
||||
// Unconventional unnamed parameter function ptr
|
||||
void ParmsFuncUnnamedVal(int (V...)) {}
|
||||
void ParmsFuncUnnamedPtr(int (V*...)) {}
|
||||
void ParmsFuncUnnamedPtrRef(int (V*&...)) {}
|
||||
void ParmsFuncUnnamedPtrRValueRef(int (V*&&...)) {}
|
||||
void ParmsFuncUnnamedRef(int (V&...)) {}
|
||||
void ParmsFuncUnnamedRValueRef(int (V&&...)) {}
|
||||
void ParmsFuncUnnamedConstRef(int (const V&...)) {}
|
||||
|
||||
// Unconventional named parameter function ptr
|
||||
void ParmsFuncNamedVal(int fn(V...)) {}
|
||||
void ParmsFuncNamedPtr(int fn(V*...)) {}
|
||||
void ParmsFuncNamedPtrRef(int fn(V*&...)) {}
|
||||
void ParmsFuncNamedPtrRValueRef(int fn(V*&&...)) {}
|
||||
void ParmsFuncNamedRef(int fn(V&...)) {}
|
||||
void ParmsFuncNamedRValueRef(int fn(V&&...)) {}
|
||||
void ParmsFuncNamedConstRef(int fn(const V&...)) {}
|
||||
|
||||
// Conventional unnamed parameter member function ptr
|
||||
void ParmsMemFuncPtrVal(int (KlassMemFuncs::*)(V...)) {}
|
||||
void ParmsMemFuncPtrPtr(int (KlassMemFuncs::*)(V*...)) {}
|
||||
void ParmsMemFuncPtrPtrRef(int (KlassMemFuncs::*)(V*&...)) {}
|
||||
void ParmsMemFuncPtrPtrRValueRef(int (KlassMemFuncs::*)(V*&&...)) {}
|
||||
void ParmsMemFuncPtrRef(int (KlassMemFuncs::*)(V&...)) {}
|
||||
void ParmsMemFuncPtrRValueRef(int (KlassMemFuncs::*)(V&&...)) {}
|
||||
void ParmsMemFuncPtrConstRef(int (KlassMemFuncs::*)(const V&...)) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(VariadicParms0) VariadicParms<>;
|
||||
%template(VariadicParms1) VariadicParms<A>;
|
||||
%template(VariadicParms2) VariadicParms<A,B>;
|
||||
%template(VariadicParms3) VariadicParms<A,B,C>;
|
||||
|
||||
%inline %{
|
||||
template <typename... V> struct FixedAndVariadicParms {
|
||||
public:
|
||||
void ParmsVal(short shortvar, V... vparms_v) {}
|
||||
void ParmsPtr(short shortvar, V*... vparms_p) {}
|
||||
void ParmsPtrRef(short shortvar, V*&... vparms_pr) {}
|
||||
void ParmsPtrRValueRef(short shortvar, V*&&... vparms_rvr) {}
|
||||
void ParmsRef(short shortvar, V&... vparms_r) {}
|
||||
void ParmsRValueRef(short shortvar, V&&... vparms_r) {}
|
||||
void ParmsConstRef(short shortvar, const V&... vparms_cr) {}
|
||||
|
||||
void ParmsFuncPtrVal(short shortvar, int (*)(short, V...)) {}
|
||||
void ParmsMemFuncPtrVal(int (KlassMemFuncs::*)(V...)) {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(FixedAndVariadicParms0) FixedAndVariadicParms<>;
|
||||
%template(FixedAndVariadicParms1) FixedAndVariadicParms<A>;
|
||||
%template(FixedAndVariadicParms2) FixedAndVariadicParms<A,B>;
|
||||
%template(FixedAndVariadicParms3) FixedAndVariadicParms<A,B,C>;
|
||||
|
|
|
|||
89
Examples/test-suite/cpp17_enable_if_t.i
Normal file
89
Examples/test-suite/cpp17_enable_if_t.i
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
%module cpp17_enable_if_t
|
||||
|
||||
// test use of enable_if_t but without full %template instantiation, that is no enable_if_t definition is parsed
|
||||
|
||||
%inline %{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1920
|
||||
#define or ||
|
||||
#define and &&
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
typedef int node_t;
|
||||
typedef int position_t;
|
||||
|
||||
template <typename A, typename B, std::enable_if_t<std::is_integral_v<A>, bool> = true>
|
||||
void enableif1(const A a, const B b) {}
|
||||
|
||||
// tests non-type template parameters within () brackets - was causing an infinite loop, issue #2418
|
||||
template <typename A, typename B, std::enable_if_t<(std::is_integral_v<A>), bool> = true>
|
||||
void enableif2(const A a, const B b) {}
|
||||
|
||||
template <typename A, typename B, std::enable_if_t<(std::is_integral_v<A> || std::is_same_v<A, node_t>), bool> = true>
|
||||
void enableif3(const A a, const B b) {}
|
||||
|
||||
template <typename A, typename B, std::enable_if_t<(std::is_integral_v<A> or std::is_same_v<A, node_t>) and (std::is_integral_v<B> or std::is_same_v<B, position_t>), bool> = true>
|
||||
void enableif4(const A a, const B b) {}
|
||||
|
||||
template <typename A, typename B, std::enable_if_t<(std::is_integral_v<A> and std::is_integral_v<B>), bool> = true>
|
||||
int enableif5(const A a, const B b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
void tester() {
|
||||
enableif5<int, int>(10, 20);
|
||||
enableif5(10, 20);
|
||||
}
|
||||
%}
|
||||
|
||||
// non-type template parameters working well in SWIG, below is a simple workaround as the 3rd parameter is defaulted for enable_if_t (which is just SFINAE to give a nice C++ compiler error)
|
||||
%template(enableif5) enableif5<int, int, true>; // workaround (overriding default)
|
||||
|
||||
|
||||
%inline %{
|
||||
// #1037 infinite loop
|
||||
template <typename T, std::enable_if_t<sizeof(T) <= 4>>
|
||||
void destId(T el) {}
|
||||
|
||||
template <typename T, std::enable_if_t<sizeof(T) >= 3>>
|
||||
void destId(const T& el) {}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
// #961 no name for defaulted template parameter
|
||||
template<typename T, typename = std::enable_if_t<std::is_enum<T>::value>>
|
||||
void uuu() {}
|
||||
template<typename T, typename E = std::enable_if_t<std::is_enum<T>::value>>
|
||||
void uuuE() {}
|
||||
|
||||
template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value>::type>
|
||||
void vvv() {}
|
||||
template<typename T, typename E = typename std::enable_if<std::is_floating_point<T>::value>::type>
|
||||
void vvvE() {}
|
||||
|
||||
// More variations of enable_if and enable_if_t
|
||||
template<typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
|
||||
void www() {}
|
||||
|
||||
template<typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
|
||||
void xxx() {}
|
||||
|
||||
enum TestEnum { Enum1 = 1, Enum2 };
|
||||
struct TestStruct {};
|
||||
|
||||
void tester2() {
|
||||
uuu<TestEnum>();
|
||||
// uuu<TestStruct>(); // compilation error
|
||||
uuuE<TestEnum>();
|
||||
// uuuE<TestStruct>(); // compilation error
|
||||
vvv<double>();
|
||||
// vvv<TestStruct>(); // compilation error
|
||||
vvvE<double>();
|
||||
// vvvE<TestStruct>(); // compilation error
|
||||
|
||||
www<double>();
|
||||
// www<TestStruct>(); // compilation error
|
||||
xxx<TestEnum>();
|
||||
// xxx<TestStruct>(); // compilation error
|
||||
}
|
||||
%}
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) global_cint; /* Ruby, wrong constant name */
|
||||
|
||||
%feature("php:allowdynamicproperties", 1) Foo; /* Allow PHP-specific custom property testing in _runme.php */
|
||||
|
||||
%module cpp_basic
|
||||
|
||||
%newobject Bar::testFoo;
|
||||
|
|
|
|||
32
Examples/test-suite/csharp/catches_strings_runme.cs
Normal file
32
Examples/test-suite/csharp/catches_strings_runme.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using catches_stringsNamespace;
|
||||
|
||||
public class catches_strings_runme {
|
||||
public static void Main()
|
||||
{
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.charstring();
|
||||
} catch (ApplicationException e) {
|
||||
if (!e.Message.Contains("charstring message"))
|
||||
throw new ApplicationException("incorrect exception message:" + e);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new ApplicationException("Should have thrown an exception");
|
||||
}
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.stdstring();
|
||||
} catch (ApplicationException e) {
|
||||
if (!e.Message.Contains("stdstring message"))
|
||||
throw new ApplicationException("incorrect exception message:" + e);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new ApplicationException("Should have thrown an exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Examples/test-suite/d/catches_strings_runme.1.d
Normal file
32
Examples/test-suite/d/catches_strings_runme.1.d
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
module catches_strings_runme;
|
||||
|
||||
import catches_strings.catches_strings;
|
||||
import catches_strings.StringsThrower;
|
||||
import std.algorithm;
|
||||
|
||||
void main() {
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.charstring();
|
||||
} catch (Exception e) {
|
||||
if (!canFind(e.msg, "charstring message"))
|
||||
throw new Exception("incorrect exception message:" ~ e.msg);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Exception("Should have thrown an exception");
|
||||
}
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.stdstring();
|
||||
} catch (Exception e) {
|
||||
if (!canFind(e.msg, "stdstring message"))
|
||||
throw new Exception("incorrect exception message:" ~ e.msg);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Exception("Should have thrown an exception");
|
||||
}
|
||||
}
|
||||
32
Examples/test-suite/d/catches_strings_runme.2.d
Normal file
32
Examples/test-suite/d/catches_strings_runme.2.d
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
module catches_strings_runme;
|
||||
|
||||
import catches_strings.catches_strings;
|
||||
import catches_strings.StringsThrower;
|
||||
import std.algorithm;
|
||||
|
||||
void main() {
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.charstring();
|
||||
} catch (Exception e) {
|
||||
if (!canFind(e.msg, "charstring message"))
|
||||
throw new Exception("incorrect exception message:" ~ e.msg);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Exception("Should have thrown an exception");
|
||||
}
|
||||
{
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.stdstring();
|
||||
} catch (Exception e) {
|
||||
if (!canFind(e.msg, "stdstring message"))
|
||||
throw new Exception("incorrect exception message:" ~ e.msg);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Exception("Should have thrown an exception");
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ struct TfToken {
|
|||
struct Tokens {
|
||||
const TfToken face;
|
||||
const TfToken *pface;
|
||||
const TfToken& g_face() const { return face; }
|
||||
const TfToken& g_face(int = 0, int = 0) const { return face; }
|
||||
const TfToken* g_pface() const { return pface; }
|
||||
Tokens() : face(), pface(&face) {}
|
||||
};
|
||||
|
|
@ -68,4 +68,6 @@ void CreateMaterialBindSubsetu(int num = UsdGeomTokensPtr->g_pface()->g_val().g_
|
|||
void CreateMaterialBindSubsetv(int num = UsdGeomTokensPtr->g_pface()->g_ptr()->g_val()) {}
|
||||
void CreateMaterialBindSubsetw(int num = UsdGeomTokensPtr->g_face().g_val().g_val()) {}
|
||||
void CreateMaterialBindSubsetx(int num = UsdGeomTokens.g_face().g_val().g_val()) {}
|
||||
void CreateMaterialBindSubsety(int num = UsdGeomTokens.g_face(1).g_val().g_val()) {}
|
||||
void CreateMaterialBindSubsetz(int num = UsdGeomTokens.g_face(1,2).g_val().g_val()) {}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
%inline %{
|
||||
|
||||
struct A{
|
||||
A(std::complex<int> i, double d=0.0) {}
|
||||
A(std::complex<double> i, double d=0.0) {}
|
||||
A(int i, bool j=false) {}
|
||||
virtual ~A() {}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
namespace hi {
|
||||
|
||||
struct A1 : public A {
|
||||
A1(std::complex<int> i, double d=0.0) : A(i, d) {}
|
||||
A1(std::complex<double> i, double d=0.0) : A(i, d) {}
|
||||
A1(int i, bool j=false) : A(i, j) {}
|
||||
|
||||
virtual int ff(int i = 0) {return i;}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
%inline %{
|
||||
|
||||
struct A{
|
||||
A(std::complex<int> i, double d=0.0) {}
|
||||
A(std::complex<double> i, double d=0.0) {}
|
||||
A(int i, bool j=false) {}
|
||||
virtual ~A() {}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
namespace hi {
|
||||
|
||||
struct A1 : public A {
|
||||
A1(std::complex<int> i, double d=0.0) : A(i, d) {}
|
||||
A1(std::complex<double> i, double d=0.0) : A(i, d) {}
|
||||
A1(int i, bool j=false) : A(i, j) {}
|
||||
|
||||
virtual int ff(int i = 0) {return i;}
|
||||
|
|
|
|||
28
Examples/test-suite/director_template.i
Normal file
28
Examples/test-suite/director_template.i
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
%module(directors="1") director_template
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
%}
|
||||
|
||||
%include <std_vector.i>
|
||||
|
||||
%feature("director") HandleBytes;
|
||||
|
||||
%inline %{
|
||||
template <typename X, typename Y> class TwoTemplateParms {};
|
||||
%}
|
||||
|
||||
%template(TT_int_double) TwoTemplateParms<int, double>;
|
||||
|
||||
%inline %{
|
||||
class HandleBytes {
|
||||
public:
|
||||
virtual void handle(const std::vector<unsigned char> data) = 0; // Note: not instantiated with %template
|
||||
virtual void handle2(TwoTemplateParms<int, double> data) = 0;
|
||||
virtual ~HandleBytes() {}
|
||||
};
|
||||
|
||||
void bytes_wrapper(const std::vector<unsigned char> data, HandleBytes *handler) {
|
||||
handler->handle(data);
|
||||
}
|
||||
%}
|
||||
93
Examples/test-suite/director_unwrap_result.i
Normal file
93
Examples/test-suite/director_unwrap_result.i
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
%module(directors="1") director_unwrap_result
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Storage;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) StorageTmpl;
|
||||
|
||||
%feature("director") Element;
|
||||
%feature("director") Storage;
|
||||
%feature("director") StorageTmpl;
|
||||
|
||||
%inline %{
|
||||
|
||||
class Element {
|
||||
Element* self;
|
||||
Element** selfptr;
|
||||
public:
|
||||
Element() {
|
||||
self = this;
|
||||
selfptr = &self;
|
||||
}
|
||||
virtual ~Element() {}
|
||||
Element **getPtrPtr() {
|
||||
return &self;
|
||||
}
|
||||
Element ***getPtrPtrPtr() {
|
||||
return &selfptr;
|
||||
}
|
||||
};
|
||||
typedef Element * element_ptr_t;
|
||||
typedef Element & element_ref_t;
|
||||
|
||||
class Storage {
|
||||
public:
|
||||
virtual ~Storage() {}
|
||||
virtual Element **getIt() = 0;
|
||||
Element getElement() {
|
||||
return **getIt();
|
||||
}
|
||||
Element* const getElementPtr() {
|
||||
return *getIt();
|
||||
}
|
||||
Element& getElementRef() {
|
||||
return **getIt();
|
||||
}
|
||||
Element* const *getElementPtrPtr() {
|
||||
return getIt();
|
||||
}
|
||||
Element *&getElementPtrRef() {
|
||||
return *getIt();
|
||||
}
|
||||
element_ref_t getElementRefTypedef() {
|
||||
return **getIt();
|
||||
}
|
||||
element_ptr_t getElementPtrTypedef() {
|
||||
return *getIt();
|
||||
}
|
||||
element_ptr_t &getElementPtrRefTypedef() {
|
||||
return *getIt();
|
||||
}
|
||||
};
|
||||
|
||||
template<class T> class StorageTmpl {
|
||||
public:
|
||||
virtual ~StorageTmpl() {}
|
||||
virtual T &getIt() = 0;
|
||||
T getVal() {
|
||||
return getIt();
|
||||
}
|
||||
T *getPtr() {
|
||||
return &getIt();
|
||||
}
|
||||
T &getRef() {
|
||||
return getIt();
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%template(ElementStorage) StorageTmpl<Element>;
|
||||
%template(ElementPtrStorage) StorageTmpl<Element *>;
|
||||
%template(ElementPtrPtrStorage) StorageTmpl<Element *const *>;
|
||||
|
||||
%inline %{
|
||||
|
||||
template<class T> T getParam(T t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(getIntParam) getParam<int>;
|
||||
%template(getIntPtrParam) getParam<int*>;
|
||||
%template(getElementPtrParam) getParam<Element *>;
|
||||
|
||||
|
|
@ -95,13 +95,68 @@
|
|||
class ClassWithNestedEnum {
|
||||
public:
|
||||
/**
|
||||
* Enum description.
|
||||
* ENested description.
|
||||
*/
|
||||
typedef enum {ONE, ///< desc of one
|
||||
TWO, ///< desc of two
|
||||
THREE ///< desc of three
|
||||
} ENested;
|
||||
|
||||
/**
|
||||
* ENestedOdd description.
|
||||
*/
|
||||
typedef enum {ODD_ONE ///< desc of odd_one
|
||||
,ODD_TWO ///< desc of odd_two
|
||||
,ODD_THREE ///< desc of odd_three
|
||||
} ENestedOdd;
|
||||
|
||||
/**
|
||||
* ENestedOddPartial1 description.
|
||||
*/
|
||||
typedef enum {ODD_PARTIAL1_ONE
|
||||
,ODD_PARTIAL1_TWO ///< desc of odd_partial1_two
|
||||
,ODD_PARTIAL1_THREE ///< desc of odd_partial1_three
|
||||
} ENestedOddPartial1;
|
||||
|
||||
/**
|
||||
* ENestedOddPartial3 description.
|
||||
*/
|
||||
typedef enum {ODD_PARTIAL3_ONE ///< desc of odd_partial3_one
|
||||
,ODD_PARTIAL3_TWO ///< desc of odd_partial3_two
|
||||
,ODD_PARTIAL3_THREE
|
||||
} ENestedOddPartial3;
|
||||
|
||||
/** Description for TESTENUM. */
|
||||
enum TESTENUM
|
||||
{
|
||||
/** something for none */
|
||||
TEST_NONE = 0,
|
||||
/** something for one */
|
||||
TEST_ONE,
|
||||
/** something for two */
|
||||
TEST_TWO /** something more for two */
|
||||
};
|
||||
};
|
||||
|
||||
/// SIOBeam struct description
|
||||
struct SIOBeam {
|
||||
|
||||
/** testfunction - testing extra trailing doc comment */
|
||||
void testfunction(
|
||||
/** testfunction aaa parm */
|
||||
int testf_aaa,
|
||||
/** testfunction bbb parm */
|
||||
double testf_bbb,
|
||||
/** testfunction ccc parm */
|
||||
bool testf_ccc /** testfunction more for two parm */
|
||||
) {}
|
||||
|
||||
/// Constructor for input from an existing SIO file
|
||||
explicit SIOBeam(
|
||||
const char * filename, ///< Name of input SIO file.
|
||||
int elevationOrder=1, ///< Interpolation order (0-3) in elevation
|
||||
int bearingOrder=1 ///< Interpolation order (0-3) in bearing
|
||||
) {}
|
||||
};
|
||||
|
||||
/// @return This is a bad place for this tag, but it should be ignored.
|
||||
|
|
@ -121,6 +176,13 @@
|
|||
*/
|
||||
void showList() { }
|
||||
|
||||
/** Incorrectly documented members, these should be post document comments, Github issue #1636 */
|
||||
struct IncorrectlyDocumentedMembers
|
||||
{
|
||||
int aaaa; //! really for bbbb value
|
||||
int bbbb; //! not for bbbb value, is quietly ignored by Doxygen and SWIG
|
||||
};
|
||||
|
||||
#include "doxygen_misc_constructs.h"
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,16 @@ struct SomeAnotherStruct
|
|||
}
|
||||
};
|
||||
|
||||
struct Foo1636
|
||||
{
|
||||
///@{
|
||||
/// groupmember1 description
|
||||
int groupmember1;
|
||||
/// groupmember2 description
|
||||
int groupmember2;
|
||||
///@}
|
||||
};
|
||||
|
||||
struct Foo1750
|
||||
{
|
||||
/// @name Group name
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
* \endif
|
||||
*
|
||||
* \image html testImage.bmp "Hello, world!" width=10cm
|
||||
* \image html "test image.jpg" "Test jpeg" width=10cm
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
|
|
|
|||
88
Examples/test-suite/duplicate_class_name_in_ns.i
Normal file
88
Examples/test-suite/duplicate_class_name_in_ns.i
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
%module duplicate_class_name_in_ns
|
||||
|
||||
%rename(XA) A::X;
|
||||
%rename(XB) B::X;
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace A
|
||||
{
|
||||
class X
|
||||
{
|
||||
public:
|
||||
X(){};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
Foo(){};
|
||||
};
|
||||
|
||||
class Bar
|
||||
{
|
||||
public:
|
||||
Bar(){};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Baz
|
||||
{
|
||||
public:
|
||||
Baz(){};
|
||||
};
|
||||
}
|
||||
|
||||
namespace B
|
||||
{
|
||||
// non-template derived from non-template
|
||||
class X : public A::X
|
||||
{
|
||||
public:
|
||||
X(){};
|
||||
A::X do_x(){return A::X();}
|
||||
};
|
||||
|
||||
// template derived from template with different template args
|
||||
template<typename T, typename U>
|
||||
class Foo : public A::Foo<U>
|
||||
{
|
||||
public:
|
||||
Foo(){};
|
||||
A::Foo<U> do_foo(){return A::Foo<U>();}
|
||||
};
|
||||
|
||||
// template derived from non-template
|
||||
template<typename T, typename U>
|
||||
class Bar : public A::Bar
|
||||
{
|
||||
public:
|
||||
Bar(){};
|
||||
A::Bar do_bar(){return A::Bar();}
|
||||
};
|
||||
|
||||
// template derived from template with same template args
|
||||
template<typename T>
|
||||
class Baz : public A::Baz<T>
|
||||
{
|
||||
public:
|
||||
Baz(){};
|
||||
A::Baz<T> do_baz(){return A::Baz<T>();}
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(AFoo) A::Foo<double>;
|
||||
%template(ABaz) A::Baz<double>;
|
||||
%template(BFoo) B::Foo<int, double>;
|
||||
%template(BBar) B::Bar<int, double>;
|
||||
%template(BBaz) B::Baz<double>;
|
||||
|
||||
%inline %{
|
||||
A::X get_a_x() {B::X x; return x.do_x();}
|
||||
A::Foo<double> get_a_foo() {B::Foo<int, double> x; return x.do_foo();}
|
||||
A::Bar get_a_bar() {B::Bar<int, double> x; return x.do_bar();}
|
||||
A::Baz<double> get_a_baz() {B::Baz<double> x; return x.do_baz();}
|
||||
%}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
%module xxx
|
||||
/* Note: needs -Wextra to see these warnings */
|
||||
|
||||
|
||||
/* Spaceship operator doesn't seem to be allowed in preprocessor expressions. */
|
||||
#if (4 <=> 2) < 0
|
||||
|
|
|
|||
34
Examples/test-suite/errors/cpp_template_class_repeat.i
Normal file
34
Examples/test-suite/errors/cpp_template_class_repeat.i
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
%module xxx
|
||||
|
||||
template<typename T> struct A {};
|
||||
%template(Aint) A<int>;
|
||||
%template(Aint2) A<int>; // Now ignored and issues a warning
|
||||
|
||||
template<typename T> struct B {};
|
||||
%template() B<int>;
|
||||
%template(Bint) B<int>; // OK
|
||||
|
||||
template<typename T> struct C {};
|
||||
%template() C<int>;
|
||||
%template() C<int>; // Quietly ignored now
|
||||
%template(Cint) C<int>; // OK
|
||||
|
||||
template <typename T, typename U = short> struct D {};
|
||||
%template(Dint) D<int>;
|
||||
%template(Dintshort) D<int, short>;
|
||||
|
||||
template<typename T> struct E {};
|
||||
%template(Eint) E<int>;
|
||||
%template(Eint) E<int>; // Always has been ignored as a redefined identifier
|
||||
|
||||
|
||||
template<typename T> struct F {};
|
||||
%template(Fint) F<int>;
|
||||
%template() F<int>; // Quietly ignored
|
||||
%template() F<int>; // Quietly ignored
|
||||
|
||||
template<typename T> struct G {};
|
||||
%template() G<int>;
|
||||
%template() G<int>; // Quietly ignored
|
||||
%template(Gint) G<int>;
|
||||
%template() G<int>; // Quietly ignored
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
cpp_template_class_repeat.i:5: Warning 404: Duplicate template instantiation of 'A< int >' with name 'Aint2' ignored,
|
||||
cpp_template_class_repeat.i:4: Warning 404: previous instantiation of 'A< int >' with name 'Aint'.
|
||||
cpp_template_class_repeat.i:18: Warning 404: Duplicate template instantiation of 'D< int,short >' with name 'Dintshort' ignored,
|
||||
cpp_template_class_repeat.i:17: Warning 404: previous instantiation of 'D< int >' with name 'Dint'.
|
||||
cpp_template_class_repeat.i:22: Warning 404: Duplicate template instantiation of 'E< int >' with name 'Eint' ignored,
|
||||
cpp_template_class_repeat.i:21: Warning 404: previous instantiation of 'E< int >' with name 'Eint'.
|
||||
|
|
@ -2,13 +2,13 @@ cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefine
|
|||
cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
|
||||
cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
|
||||
cpp_template_duplicate_names.i:25: Warning 302: Identifier 'Duplicate2_0' redefined (ignored) (Renamed from 'Duplicate2< 0 >'),
|
||||
cpp_template_duplicate_names.i:24: Warning 302: previous definition of 'Duplicate2_0' (Renamed from 'Duplicate2< 0 >').
|
||||
cpp_template_duplicate_names.i:35: Warning 302: Identifier 'Duplicate3' redefined (ignored) (Renamed from 'Duplicate3< 0 >'),
|
||||
cpp_template_duplicate_names.i:31: Warning 302: previous definition of 'Duplicate3'.
|
||||
cpp_template_duplicate_names.i:25: Warning 404: Duplicate template instantiation of 'Duplicate2< 0 >' with name 'Duplicate2_0' ignored,
|
||||
cpp_template_duplicate_names.i:24: Warning 404: previous instantiation of 'Duplicate2< 0 >' with name 'Duplicate2_0'.
|
||||
cpp_template_duplicate_names.i:35: Warning 404: Duplicate template instantiation of 'Duplicate3< 0 >' with name 'Duplicate3' ignored,
|
||||
cpp_template_duplicate_names.i:34: Warning 404: previous instantiation of 'Duplicate3< 0 >' with name 'Duplicate3'.
|
||||
cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
|
||||
cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
|
||||
cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
|
||||
cpp_template_duplicate_names.i:50: Warning 302: Identifier 'Duplicate4' redefined (ignored) (Renamed from 'Duplicate4< 0 >'),
|
||||
cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
|
||||
cpp_template_duplicate_names.i:50: Warning 404: Duplicate template instantiation of 'Duplicate4< 0 >' with name 'Duplicate4' ignored,
|
||||
cpp_template_duplicate_names.i:49: Warning 404: previous instantiation of 'Duplicate4< 0 >' with name 'Duplicate4'.
|
||||
|
|
|
|||
|
|
@ -4,4 +4,15 @@ template<class T> T blah(T x) { };
|
|||
|
||||
%template(iblah) blah<int>;
|
||||
%template(iiblah) blah<int>;
|
||||
// The second %template instantiation above should surely be ignored with a warning, but doesn't atm
|
||||
|
||||
// empty template instantiations for template functions warn (unlike for template classes)
|
||||
%template() blah<double>;
|
||||
%template() blah<double>;
|
||||
%template() blah<double>;
|
||||
|
||||
%template(sblah) blah<short>;
|
||||
%template(sblah) blah<short>;
|
||||
|
||||
%template() blah<const char *>;
|
||||
%template() blah<const char *>;
|
||||
%template(sblah) blah<const char *>;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
cpp_template_repeat.i:6: Warning 404: Duplicate template instantiation of 'blah< int >' with name 'iiblah' ignored,
|
||||
cpp_template_repeat.i:5: Warning 404: previous instantiation of 'blah< int >' with name 'iblah'.
|
||||
cpp_template_repeat.i:14: Warning 404: Duplicate template instantiation of 'blah< short >' with name 'sblah' ignored,
|
||||
cpp_template_repeat.i:13: Warning 404: previous instantiation of 'blah< short >' with name 'sblah'.
|
||||
cpp_template_repeat.i:9: Warning 519: %template() contains no name. Template method ignored: blah< double >(double)
|
||||
cpp_template_repeat.i:16: Warning 519: %template() contains no name. Template method ignored: blah< char const * >(char const *)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
%module xxx
|
||||
/* Note: needs -Wextra to see these warnings */
|
||||
|
||||
|
||||
/* Divide by zero */
|
||||
#define ZERO 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
%module exception_memory_leak
|
||||
|
||||
%include <std_string.i>
|
||||
%include <exception.i>
|
||||
|
||||
%typemap(in) Foo* foo
|
||||
{
|
||||
|
|
@ -11,12 +12,23 @@
|
|||
Foo::inc_freearg_count();
|
||||
delete $1;
|
||||
}
|
||||
%typemap(out) Foo* verify_no_memory_leak
|
||||
%typemap(out) Foo* trigger_internal_swig_exception
|
||||
{
|
||||
if ($1 == NULL)
|
||||
SWIG_exception_fail(SWIG_RuntimeError, "Let's see how the bindings manage this exception!");
|
||||
if ($1 == NULL) {
|
||||
SWIG_exception(SWIG_RuntimeError, "Let's see how the bindings manage this exception!");
|
||||
#ifdef SWIG_fail
|
||||
SWIG_fail;
|
||||
#endif
|
||||
}
|
||||
$1 = NULL;
|
||||
}
|
||||
%typemap(out) Foo trigger_internal_swig_exception
|
||||
{
|
||||
SWIG_exception(SWIG_RuntimeError, "Let's see how the bindings manage this exception!");
|
||||
#ifdef SWIG_fail
|
||||
SWIG_fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
%inline %{
|
||||
#include <string>
|
||||
|
|
@ -42,4 +54,9 @@
|
|||
return (message == "null") ? NULL : foo;
|
||||
}
|
||||
|
||||
static Foo trigger_internal_swig_exception(const std::string& message)
|
||||
{
|
||||
return Foo();
|
||||
}
|
||||
|
||||
%}
|
||||
|
|
|
|||
13
Examples/test-suite/final_c.i
Normal file
13
Examples/test-suite/final_c.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module final_c
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) final; // 'final' is a java keyword, renaming to '_final'
|
||||
|
||||
%inline %{
|
||||
struct Y {
|
||||
int yval;
|
||||
};
|
||||
struct Y final;
|
||||
void init() {
|
||||
final.yval = 123;
|
||||
}
|
||||
%}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
%module global_immutable_vars
|
||||
|
||||
// Test immutable and mutable global variables,
|
||||
// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
|
||||
// see https://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
|
||||
|
||||
%inline %{
|
||||
int default_mutable_var = 40;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%module global_immutable_vars_cpp
|
||||
|
||||
// Test immutable and mutable global variables,
|
||||
// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
|
||||
// see https://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables
|
||||
|
||||
%inline %{
|
||||
int default_mutable_var = 40;
|
||||
|
|
|
|||
32
Examples/test-suite/go/catches_strings_runme.go
Normal file
32
Examples/test-suite/go/catches_strings_runme.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import "strings"
|
||||
import . "swigtests/catches_strings"
|
||||
|
||||
func main() {
|
||||
{
|
||||
exception_thrown := false
|
||||
func() {
|
||||
defer func() {
|
||||
exception_thrown = strings.Index(recover().(string), "charstring message") == 0
|
||||
}()
|
||||
StringsThrowerCharstring()
|
||||
}()
|
||||
if !exception_thrown {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
exception_thrown := false
|
||||
func() {
|
||||
defer func() {
|
||||
exception_thrown = strings.Index(recover().(string), "stdstring message") == 0
|
||||
}()
|
||||
StringsThrowerStdstring()
|
||||
}()
|
||||
if !exception_thrown {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,4 +28,9 @@ func main() {
|
|||
if x != "Grok::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
x = d.Far()
|
||||
if x != "Spam::far" {
|
||||
panic(x)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
Examples/test-suite/guile/catches_strings_runme.scm
Normal file
3
Examples/test-suite/guile/catches_strings_runme.scm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(dynamic-call "scm_init_catches_strings_module" (dynamic-link "./libcatches_strings"))
|
||||
(load "testsuite.scm")
|
||||
(load "../schemerunme/catches_strings.scm")
|
||||
41
Examples/test-suite/java/catches_strings_runme.java
Normal file
41
Examples/test-suite/java/catches_strings_runme.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import catches_strings.*;
|
||||
|
||||
public class catches_strings_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("catches_strings");
|
||||
} 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[]) throws Throwable
|
||||
{
|
||||
{
|
||||
boolean exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.charstring();
|
||||
} catch (RuntimeException e) {
|
||||
if (!e.getMessage().contains("charstring message"))
|
||||
throw new RuntimeException("incorrect exception message");
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new RuntimeException("Should have thrown an exception");
|
||||
}
|
||||
|
||||
{
|
||||
boolean exception_thrown = false;
|
||||
try {
|
||||
StringsThrower.stdstring();
|
||||
} catch (RuntimeException e) {
|
||||
if (!e.getMessage().contains("stdstring message"))
|
||||
throw new RuntimeException("incorrect exception message");
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new RuntimeException("Should have thrown an exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Examples/test-suite/java/cpp17_enable_if_t_runme.java
Normal file
19
Examples/test-suite/java/cpp17_enable_if_t_runme.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import cpp17_enable_if_t.*;
|
||||
|
||||
public class cpp17_enable_if_t_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp17_enable_if_t");
|
||||
} 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[])
|
||||
{
|
||||
if (cpp17_enable_if_t.enableif5(10, 20) != 30)
|
||||
throw new RuntimeException("enableif5 not working");
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ public class doxygen_misc_constructs_runme {
|
|||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested",
|
||||
" Enum description.\n" +
|
||||
" ENested description.\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.ONE",
|
||||
|
|
@ -109,6 +109,81 @@ public class doxygen_misc_constructs_runme {
|
|||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.THREE",
|
||||
" desc of three\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd",
|
||||
" ENestedOdd description.\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd.ODD_ONE",
|
||||
" desc of odd_one\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd.ODD_TWO",
|
||||
" desc of odd_two\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd.ODD_THREE",
|
||||
" desc of odd_three\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial1",
|
||||
" ENestedOddPartial1 description.\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial1.ODD_PARTIAL1_THREE",
|
||||
" desc of odd_partial1_three\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial1.ODD_PARTIAL1_TWO",
|
||||
" desc of odd_partial1_two\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial3",
|
||||
" ENestedOddPartial3 description.\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial3.ODD_PARTIAL3_ONE",
|
||||
" desc of odd_partial3_one\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial3.ODD_PARTIAL3_TWO",
|
||||
" desc of odd_partial3_two\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.TESTENUM",
|
||||
" Description for TESTENUM.\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.TESTENUM.TEST_NONE",
|
||||
" something for none\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.TESTENUM.TEST_ONE",
|
||||
" something for one\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.TESTENUM.TEST_TWO",
|
||||
" something for two something more for two\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.SIOBeam",
|
||||
" SIOBeam struct description\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.SIOBeam.testfunction(int, double, boolean)",
|
||||
" testfunction - testing extra trailing doc comment <br>\n" +
|
||||
" @param testf_aaa testfunction aaa parm <br>\n" +
|
||||
" @param testf_bbb testfunction bbb parm <br>\n" +
|
||||
" @param testf_ccc testfunction ccc parm testfunction more for two parm\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.SIOBeam(java.lang.String, int, int)",
|
||||
" Constructor for input from an existing SIO file<br>\n" +
|
||||
" @param filename Name of input SIO file.<br>\n" +
|
||||
" @param elevationOrder Interpolation order (0-3) in elevation<br>\n" +
|
||||
" @param bearingOrder Interpolation order (0-3) in bearing\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.SIOBeam(java.lang.String, int)",
|
||||
" Constructor for input from an existing SIO file<br>\n" +
|
||||
" @param filename Name of input SIO file.<br>\n" +
|
||||
" @param elevationOrder Interpolation order (0-3) in elevation<br>\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.SIOBeam(java.lang.String)",
|
||||
" Constructor for input from an existing SIO file<br>\n" +
|
||||
" @param filename Name of input SIO file.<br>\n" +
|
||||
"\n");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.StructWithReturnComment",
|
||||
" @return This is a bad place for this tag, but it should be ignored.");
|
||||
|
||||
|
|
@ -124,6 +199,16 @@ public class doxygen_misc_constructs_runme {
|
|||
" <br>\n" +
|
||||
" And this is not a list item any more.\n" +
|
||||
"");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.IncorrectlyDocumentedMembers",
|
||||
" Incorrectly documented members, these should be post document comments, Github issue #1636");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.IncorrectlyDocumentedMembers.setBbbb(int)",
|
||||
" really for bbbb value");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.IncorrectlyDocumentedMembers.getBbbb()",
|
||||
" really for bbbb value");
|
||||
|
||||
wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.isNoSpaceValidA()",
|
||||
" This comment without space after '*' is valid in Doxygen.\n" +
|
||||
"\n" +
|
||||
|
|
|
|||
|
|
@ -132,6 +132,14 @@ public class doxygen_parsing_runme {
|
|||
wantedComments.put("doxygen_parsing.doxygen_parsingConstants.CONSTANT_VALUE",
|
||||
"The constant comment \n" +
|
||||
"");
|
||||
wantedComments.put("doxygen_parsing.Foo1636.getGroupmember1()",
|
||||
"groupmember1 description");
|
||||
wantedComments.put("doxygen_parsing.Foo1636.setGroupmember1(int)",
|
||||
"groupmember1 description");
|
||||
wantedComments.put("doxygen_parsing.Foo1636.getGroupmember2()",
|
||||
"groupmember2 description");
|
||||
wantedComments.put("doxygen_parsing.Foo1636.setGroupmember2(int)",
|
||||
"groupmember2 description");
|
||||
wantedComments.put("doxygen_parsing.Foo1750.getA()",
|
||||
"");
|
||||
wantedComments.put("doxygen_parsing.Foo1750.getB()",
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class doxygen_translate_all_tags_runme {
|
|||
" If not: SOMECONDITION {\n" +
|
||||
" This is printed if not \n" +
|
||||
" }\n" +
|
||||
" <img src=testImage.bmp alt=\"Hello, world!\" />\n" +
|
||||
" <img src=\"testImage.bmp\" alt=\"Hello, world!\"/>\n" +
|
||||
" Some text \n" +
|
||||
" describing invariant. \n");
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ public class doxygen_translate_runme {
|
|||
" This is printed if not}\n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
" <img src=testImage.bmp alt=\"Hello, world!\"/>\n" +
|
||||
" <img src=\"testImage.bmp\" alt=\"Hello, world!\"/>\n" +
|
||||
" <img src=\"test image.jpg\" alt=\"Test jpeg\"/>\n" +
|
||||
" \n" +
|
||||
" <ul> \n" +
|
||||
" \n" +
|
||||
|
|
|
|||
25
Examples/test-suite/java/template_function_parm_runme.java
Normal file
25
Examples/test-suite/java/template_function_parm_runme.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import template_function_parm.*;
|
||||
|
||||
public class template_function_parm_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_function_parm");
|
||||
} 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[]) {
|
||||
VectorInt vi = new VectorInt();
|
||||
vi.add(10);
|
||||
vi.add(20);
|
||||
vi.add(30);
|
||||
|
||||
MyC myc = new MyC();
|
||||
int sum = myc.take_function(template_function_parmConstants.accumulate_integers, vi);
|
||||
if (sum != 60)
|
||||
throw new RuntimeException("Expected sum of 60, got " + sum);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,12 +12,15 @@ public class template_partial_specialization_typedef_runme {
|
|||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
double dub = 11.1;
|
||||
Concrete concrete = new Concrete();
|
||||
|
||||
// One parameter tests
|
||||
new A().a();
|
||||
new B().b();
|
||||
new C().c();
|
||||
new D().d();
|
||||
new E().e();
|
||||
new B().b(); new B().bb(dub);
|
||||
new C().c(); new C().cc(dub);
|
||||
new D().d(); new D().dd(dub);
|
||||
new E().e(); new E().ee(dub);
|
||||
|
||||
new F().f();
|
||||
new G().g();
|
||||
|
|
@ -28,10 +31,10 @@ public class template_partial_specialization_typedef_runme {
|
|||
new M().m();
|
||||
new N().n();
|
||||
|
||||
new BB().b();
|
||||
new BBB().b();
|
||||
new BBBB().b();
|
||||
new BBBBB().b();
|
||||
new BB().b(); new BB().bb(true);
|
||||
new BBB().b(); new BBB().bb('A');
|
||||
new BBBB().b(); new BBBB().bb((short)12);
|
||||
new BBBBB().b(); new BBBBB().bb(123);
|
||||
|
||||
new B1().b();
|
||||
new B2().b();
|
||||
|
|
@ -40,18 +43,18 @@ public class template_partial_specialization_typedef_runme {
|
|||
|
||||
// Two parameter tests
|
||||
new A_().a();
|
||||
new B_().b();
|
||||
new C_().c();
|
||||
new D_().d();
|
||||
new B_().b(); new B_().bbb(dub);
|
||||
new C_().c(); new C_().ccc(dub);
|
||||
new D_().d(); new D_().ddd(123);
|
||||
new E_().e();
|
||||
new F_().f();
|
||||
new G_().g();
|
||||
|
||||
new C1_().c();
|
||||
new C2_().c();
|
||||
new C3_().c();
|
||||
new C4_().c();
|
||||
new B1_().b();
|
||||
new C1_().c(); new C1_().ccc(concrete);
|
||||
new C2_().c(); new C2_().ccc(concrete);
|
||||
new C3_().c(); new C3_().ccc(concrete);
|
||||
new C4_().c(); new C4_().ccc(concrete);
|
||||
new B1_().b(); new B1_().bbb(concrete);
|
||||
new E1_().e();
|
||||
new E2_().e();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class template_template_parameters_runme {
|
|||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
// Test first part
|
||||
// Test part 1
|
||||
ListFastBool listBool = new ListFastBool();
|
||||
listBool.setItem(true);
|
||||
boolean x_boolean = listBool.getAllotype();
|
||||
|
|
@ -27,7 +27,7 @@ public class template_template_parameters_runme {
|
|||
if (listDouble.getItem() != 10.2)
|
||||
throw new RuntimeException("Failed");
|
||||
|
||||
// Test second part
|
||||
// Test part 2
|
||||
FloatTestStruct floatTestStruct = new FloatTestStruct();
|
||||
FloatContainer2 floatContainer2 = floatTestStruct.getX();
|
||||
floatContainer2.setX(8.1f);
|
||||
|
|
@ -41,6 +41,10 @@ public class template_template_parameters_runme {
|
|||
IntTestStruct intTestStructReturned = template_template_parameters.TestStructContainer1Method(intTestStruct);
|
||||
if (intTestStructReturned.getX().getX() != 101)
|
||||
throw new RuntimeException("Failed");
|
||||
|
||||
// Test part 3
|
||||
MyFootInt99 mfi99 = new MyFootInt99();
|
||||
mfi99.OperatorPlusEquals(mfi99);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
|
||||
import template_template_template_parameters.*;
|
||||
|
||||
public class template_template_template_parameters_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_template_template_parameters");
|
||||
} 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[]) {
|
||||
CustomAttrs custom_attrs = new CustomAttrs();
|
||||
AC ac = new AC();
|
||||
BAC bac = new BAC();
|
||||
CBAC cbac = new CBAC();
|
||||
DBAC dbac = new DBAC();
|
||||
|
||||
custom_attrs = ac.getAttributes();
|
||||
custom_attrs = bac.getAttributes();
|
||||
custom_attrs = cbac.getAttributes();
|
||||
custom_attrs = dbac.getAttributes();
|
||||
|
||||
bac.BMethod(custom_attrs, ac);
|
||||
cbac.BMethod(custom_attrs, ac);
|
||||
dbac.BMethod(custom_attrs, ac);
|
||||
|
||||
cbac.CMethod(custom_attrs, bac);
|
||||
dbac.DMethod(custom_attrs, bac);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ NODEJS = @NODEJS@
|
|||
SCRIPTSUFFIX = _runme.js
|
||||
OBJEXT = @OBJEXT@
|
||||
SO = @SO@
|
||||
GYP_CXXFLAGS = @BOOST_CPPFLAGS@ @PLATCXXFLAGS@
|
||||
|
||||
HAVE_CXX11 = @HAVE_CXX11@
|
||||
HAVE_CXX14 = @HAVE_CXX14@
|
||||
|
|
@ -59,10 +60,11 @@ ifeq (node,$(JSENGINE))
|
|||
director_basic.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
|
||||
enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
|
||||
member_funcptr_galore.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
|
||||
director_unwrap_result.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
|
||||
|
||||
setup_node = \
|
||||
test -d $* || mkdir $* && \
|
||||
sed -e 's|$$testcase|$*|g; s|$$cflags|$(GYP_CFLAGS)|g; s|$$srcdir|$(srcdir)|g' \
|
||||
sed -e 's|$$testcase|$*|g; s|$$cflags|$(GYP_CFLAGS)|g; s|$$cxxflags|"$(GYP_CXXFLAGS)"|g; s|$$srcdir|$(srcdir)|g' \
|
||||
$(srcdir)/node_template/binding.gyp.in > $*/binding.gyp && \
|
||||
sed -e 's|$$testcase|$*|g;' \
|
||||
$(srcdir)/node_template/index.js.in > $*/index.js
|
||||
|
|
|
|||
23
Examples/test-suite/javascript/catches_strings_runme.js
Normal file
23
Examples/test-suite/javascript/catches_strings_runme.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
var catches_strings = require("catches_strings");
|
||||
|
||||
exception_thrown = false;
|
||||
try {
|
||||
catches_strings.StringsThrower.charstring();
|
||||
} catch (e) {
|
||||
if (!e.message.includes("charstring message"))
|
||||
throw new Error("incorrect exception message " + e.message);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Error("Should have thrown an exception");
|
||||
|
||||
exception_thrown = false;
|
||||
try {
|
||||
catches_strings.StringsThrower.stdstring();
|
||||
} catch (e) {
|
||||
if (!e.message.includes("stdstring message"))
|
||||
throw new Error("incorrect exception message " + e.message);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Error("Should have thrown an exception");
|
||||
|
|
@ -1,18 +1,24 @@
|
|||
var integers = require("integers");
|
||||
|
||||
var val = 3902408827
|
||||
ret = integers.signed_long_identity(val)
|
||||
if (ret != val)
|
||||
throw "Incorrect value: " + ret
|
||||
function checkOne(val, signed, typeName) {
|
||||
typeName = (signed ? 'signed_' : 'unsigned_') + typeName
|
||||
|
||||
ret = integers.unsigned_long_identity(val)
|
||||
if (ret != val)
|
||||
throw "Incorrect value: " + ret
|
||||
var size = integers[typeName + '_size']()
|
||||
if ((!signed && val < 0) || (size < 8))
|
||||
return // out of range, skip test
|
||||
|
||||
ret = integers.signed_long_long_identity(val)
|
||||
if (ret != val)
|
||||
throw "Incorrect value: " + ret
|
||||
ret = integers[typeName + '_identity'](val)
|
||||
if (ret !== val)
|
||||
throw "Incorrect value: expected " + val + ", got " + ret
|
||||
}
|
||||
|
||||
ret = integers.unsigned_long_long_identity(val)
|
||||
if (ret != val)
|
||||
throw "Incorrect value: " + ret
|
||||
function checkAll(val) {
|
||||
checkOne(val, true, 'long')
|
||||
checkOne(val, false, 'long')
|
||||
checkOne(val, true, 'long_long')
|
||||
checkOne(val, false, 'long_long')
|
||||
}
|
||||
|
||||
checkAll(3902408827)
|
||||
checkAll(Number.MAX_SAFE_INTEGER)
|
||||
checkAll(Number.MIN_SAFE_INTEGER)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"',
|
||||
{
|
||||
'cflags': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cflags],
|
||||
'cflags_cc': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cflags],
|
||||
'cflags_cc': [ "-Wno-unused-variable", "-Wno-unused-but-set-variable", "-Wno-unused-but-set-parameter", $cxxflags, $cflags],
|
||||
'cflags!': [ '-fno-exceptions' ],
|
||||
'cflags_cc!': [ '-fno-exceptions', '-fno-rtti' ]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,3 +21,7 @@ if (x != "Spam::blah")
|
|||
x = typedef_inherit.do_blah2(d);
|
||||
if (x != "Grok::blah")
|
||||
print ("Whoa! Bad return" + x);
|
||||
|
||||
x = d.far();
|
||||
if (x != "Spam::far")
|
||||
print ("Whoa! Bad return" + x);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
|
||||
#endif
|
||||
|
||||
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
|
||||
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGR)
|
||||
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
|
|
@ -268,6 +268,7 @@ long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) {
|
|||
long use_count(const SwigBoost::shared_ptr<Klass>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
|
||||
const SwigBoost::shared_ptr<Klass>& ref_1() {
|
||||
static SwigBoost::shared_ptr<Klass> sptr;
|
||||
return sptr;
|
||||
|
|
|
|||
68
Examples/test-suite/li_std_vector_vector.i
Normal file
68
Examples/test-suite/li_std_vector_vector.i
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
%module li_std_vector_vector
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
|
||||
namespace std {
|
||||
%template(VectorInt) vector<int>;
|
||||
%template(VectorString) vector<string>;
|
||||
%template(VectorVectorInt) vector<vector<int>>;
|
||||
%template(VectorVectorString) vector<vector<string>>;
|
||||
};
|
||||
|
||||
%inline %{
|
||||
std::vector<std::string> make_vector_int() {
|
||||
std::string x[5] = {"1", "2", "3", "4", "5"};
|
||||
std::vector<std::string> v;
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
v.push_back(x[i]);
|
||||
return v;
|
||||
}
|
||||
|
||||
std::vector<std::vector<int> > make_vector_vector_int() {
|
||||
int x[5] = {1, 2, 3, 4, 5};
|
||||
std::vector<std::vector<int> > vv;
|
||||
std::vector<int> v;
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
v.push_back(x[i]);
|
||||
vv.push_back(v);
|
||||
return vv;
|
||||
}
|
||||
|
||||
std::vector<bool> make_vector_bool() {
|
||||
bool x[5] = {true, false, false, false, true};
|
||||
std::vector<bool> v;
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
v.push_back(x[i]);
|
||||
return v;
|
||||
}
|
||||
|
||||
std::vector<std::vector<bool> > make_vector_vector_bool() {
|
||||
bool x[5] = {false, true, true, true, false};
|
||||
std::vector<std::vector<bool> > vv;
|
||||
std::vector<bool> v;
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
v.push_back(x[i]);
|
||||
vv.push_back(v);
|
||||
return vv;
|
||||
}
|
||||
|
||||
std::vector<std::string> make_vector_string() {
|
||||
std::string x[5] = {"aa", "bb", "cc", "dd", "ee"};
|
||||
std::vector<std::string> v;
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
v.push_back(x[i]);
|
||||
return v;
|
||||
}
|
||||
|
||||
std::vector<std::vector<std::string> > make_vector_vector_string() {
|
||||
std::string x[5] = {"1", "2", "3", "4", "5"};
|
||||
std::vector<std::vector<std::string> > vv;
|
||||
std::vector<std::string> v;
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
v.push_back(x[i]);
|
||||
vv.push_back(v);
|
||||
return vv;
|
||||
}
|
||||
|
||||
%}
|
||||
13
Examples/test-suite/lua/catches_strings_runme.lua
Normal file
13
Examples/test-suite/lua/catches_strings_runme.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
require("import") -- the import fn
|
||||
import("catches_strings") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
s, msg = pcall(function() catches_strings.StringsThrower.charstring() end)
|
||||
assert(s == false and msg:find("charstring message", 1, true))
|
||||
|
||||
s, msg = pcall(function() catches_strings.StringsThrower.stdstring() end)
|
||||
assert(s == false and msg:find("stdstring message", 1, true))
|
||||
29
Examples/test-suite/lua/exception_memory_leak_runme.lua
Normal file
29
Examples/test-suite/lua/exception_memory_leak_runme.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require("import") -- the import fn
|
||||
import("exception_memory_leak") -- import code
|
||||
eml=exception_memory_leak --alias
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
a = eml.Foo()
|
||||
assert(eml.Foo_get_count() == 1)
|
||||
b = eml.Foo()
|
||||
assert(eml.Foo_get_count() == 2)
|
||||
|
||||
-- Normal behaviour
|
||||
eml.trigger_internal_swig_exception("no problem", a)
|
||||
assert(eml.Foo_get_count() == 2)
|
||||
assert(eml.Foo_get_freearg_count() == 1)
|
||||
|
||||
-- SWIG exception triggered and handled (return new object case)
|
||||
ok,ex=pcall(eml.trigger_internal_swig_exception, "null", b)
|
||||
assert(ok==false)
|
||||
assert(eml.Foo_get_count() == 2)
|
||||
assert(eml.Foo_get_freearg_count() == 2)
|
||||
|
||||
-- SWIG exception triggered and handled (return by value case).
|
||||
ok,ex=pcall(eml.trigger_internal_swig_exception, "null")
|
||||
assert(ok==false)
|
||||
assert(eml.Foo_get_count() == 2)
|
||||
12
Examples/test-suite/lua/mod_runme.lua
Normal file
12
Examples/test-suite/lua/mod_runme.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
require("import") -- the import fn
|
||||
import("mod_a") -- import lib
|
||||
import("mod_b") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
c = mod_b.C()
|
||||
d = mod_b.D()
|
||||
d:DoSomething(c)
|
||||
18
Examples/test-suite/mzscheme/catches_strings_runme.scm
Normal file
18
Examples/test-suite/mzscheme/catches_strings_runme.scm
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(load-extension "catches_strings.so")
|
||||
(require (lib "defmacro.ss"))
|
||||
|
||||
(define exception_thrown "no exception thrown for kin")
|
||||
(with-handlers ([exn:fail? (lambda (exn)
|
||||
(set! exception_thrown (exn-message exn)))])
|
||||
(StringsThrower-charstring))
|
||||
(unless (string-contains? exception_thrown "charstring message")
|
||||
(error (format "incorrect exception message: ~a" exception_thrown)))
|
||||
|
||||
(define exception_thrown "no exception thrown for kin")
|
||||
(with-handlers ([exn:fail? (lambda (exn)
|
||||
(set! exception_thrown (exn-message exn)))])
|
||||
(StringsThrower-stdstring))
|
||||
(unless (string-contains? exception_thrown "stdstring message")
|
||||
(error (format "incorrect exception message: ~a" exception_thrown)))
|
||||
|
||||
(exit 0)
|
||||
14
Examples/test-suite/ocaml/catches_strings_runme.ml
Normal file
14
Examples/test-suite/ocaml/catches_strings_runme.ml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
open Swig
|
||||
open Catches_strings
|
||||
|
||||
let _ =
|
||||
try
|
||||
ignore (_StringsThrower_charstring (C_void)); assert false
|
||||
with Failure s ->
|
||||
assert (s = "charstring message")
|
||||
|
||||
let _ =
|
||||
try
|
||||
ignore (_StringsThrower_stdstring (C_void)); assert false
|
||||
with Failure s ->
|
||||
assert (s = "stdstring message")
|
||||
10
Examples/test-suite/ocaml/enum_rename_runme.ml
Normal file
10
Examples/test-suite/ocaml/enum_rename_runme.ml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
open Swig
|
||||
open Enum_rename
|
||||
|
||||
let mydec = C_enum `M_Dec
|
||||
let _ = assert (((enum_to_int `Month mydec)) = C_int 2)
|
||||
let _ = assert (((int_to_enum `Month 2)) = C_enum `M_Dec)
|
||||
|
||||
let mymay = C_enum `May
|
||||
let _ = assert (((enum_to_int `Month mymay)) = C_int 1)
|
||||
let _ = assert (((int_to_enum `Month 1)) = C_enum `May)
|
||||
7
Examples/test-suite/ocaml/mod_runme.ml
Normal file
7
Examples/test-suite/ocaml/mod_runme.ml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
open Swig
|
||||
open Mod_a
|
||||
open Mod_b
|
||||
|
||||
let c = new_C '()
|
||||
let d = new_D '()
|
||||
let _ = d -> "DoSomething" (c)
|
||||
7
Examples/test-suite/ocaml/rename_rstrip_encoder_runme.ml
Normal file
7
Examples/test-suite/ocaml/rename_rstrip_encoder_runme.ml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
open Swig
|
||||
open Rename_rstrip_encoder
|
||||
|
||||
let s = new_SomeThing '()
|
||||
let a = new_AnotherThing '() in
|
||||
assert (a -> DoClsX () = C_void);
|
||||
;;
|
||||
|
|
@ -7,5 +7,6 @@ let _ =
|
|||
assert (_do_blah (b) as string = "Bar::blah");
|
||||
let c = new_Spam '() and d = new_Grok '() in
|
||||
assert (_do_blah2 (c) as string = "Spam::blah");
|
||||
assert (_do_blah2 (d) as string = "Grok::blah")
|
||||
assert (_do_blah2 (d) as string = "Grok::blah");
|
||||
assert (d -> far() as string = "Spam::far")
|
||||
;;
|
||||
|
|
|
|||
4
Examples/test-suite/ocaml/using2_runme.ml
Normal file
4
Examples/test-suite/ocaml/using2_runme.ml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
open Swig
|
||||
open Using2
|
||||
|
||||
let _ = assert (_spam '(37) as int = 37)
|
||||
32
Examples/test-suite/octave/catches_strings_runme.m
Normal file
32
Examples/test-suite/octave/catches_strings_runme.m
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# do not dump Octave core
|
||||
if exist("crash_dumps_octave_core", "builtin")
|
||||
crash_dumps_octave_core(0);
|
||||
endif
|
||||
|
||||
catches_strings
|
||||
|
||||
exception_thrown = false;
|
||||
try
|
||||
StringsThrower.charstring();
|
||||
catch e
|
||||
if (isempty(strfind(e.message, "charstring message")))
|
||||
error("incorrect exception message: %s", e.message)
|
||||
endif
|
||||
exception_thrown = true;
|
||||
end_try_catch
|
||||
if (!exception_thrown)
|
||||
error("Should have thrown an exception");
|
||||
endif
|
||||
|
||||
exception_thrown = false;
|
||||
try
|
||||
StringsThrower.stdstring();
|
||||
catch e
|
||||
if (isempty(strfind(e.message, "stdstring message")))
|
||||
error("incorrect exception message: %s", e.message)
|
||||
endif
|
||||
exception_thrown = true;
|
||||
end_try_catch
|
||||
if (!exception_thrown)
|
||||
error("Should have thrown an exception");
|
||||
endif
|
||||
|
|
@ -30,3 +30,8 @@ x = typedef_inherit.do_blah2(d);
|
|||
if (!strcmp(x,"Grok::blah"))
|
||||
error("Whoa! Bad return", x)
|
||||
endif
|
||||
|
||||
x = d.far();
|
||||
if (!strcmp(x,"Spam::far"))
|
||||
error("Whoa! Bad return", x)
|
||||
endif
|
||||
|
|
|
|||
15
Examples/test-suite/perl5/catches_strings_runme.pl
Normal file
15
Examples/test-suite/perl5/catches_strings_runme.pl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 4;
|
||||
BEGIN { use_ok('catches_strings') }
|
||||
require_ok('catches_strings');
|
||||
|
||||
eval {
|
||||
catches_strings::StringsThrower::charstring();
|
||||
};
|
||||
like($@, qr/\bcharstring message/, "Should have thrown an exception");
|
||||
|
||||
eval {
|
||||
catches_strings::StringsThrower::stdstring();
|
||||
};
|
||||
like($@, qr/\bstdstring message/, "Should have thrown an exception");
|
||||
|
|
@ -57,10 +57,18 @@ missingtests: missingcpptests missingctests
|
|||
+$(swig_and_compile_c)
|
||||
+$(run_testcase)
|
||||
|
||||
# Trying to load the modules for imports.multicpptest fails with:
|
||||
#
|
||||
# Warning: Function registration failed - duplicate name - global_test in Unknown on line 0
|
||||
# Segmentation fault
|
||||
#
|
||||
# This was previously hidden because we didn't even try to load the modules for
|
||||
# .multicpptest testcases, so for now just do the parts of the test we did
|
||||
# before. FIXME: Fix this!
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
+$(run_testcase)
|
||||
+[ "$*" = "imports" ] || $(run_multi_testcase)
|
||||
|
||||
# Smart target
|
||||
%.test:
|
||||
|
|
@ -72,14 +80,23 @@ missingtests: missingcpptests missingctests
|
|||
$(MAKE) $*.multicpptest
|
||||
|
||||
# Runs the testcase. Tries to run testcase_runme.php, and if that's not found,
|
||||
# at least test that the module loads without errors, except for multicpptests.
|
||||
# at least test that the module loads without errors.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php_run; \
|
||||
elif [ ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
|
||||
else \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT= RUNTOOL='$(RUNTOOL)' php_run; \
|
||||
fi
|
||||
|
||||
# Runs a multicpptest testcase. Tries to run testcase_runme.php, and if that's
|
||||
# not found, at least test that the modules load without errors.
|
||||
run_multi_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION_LIST=$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php_run_multi; \
|
||||
else \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION_LIST=$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list PHP_SCRIPT= RUNTOOL='$(RUNTOOL)' php_run_multi; \
|
||||
fi
|
||||
|
||||
# Clean: remove the generated PHP-specific files
|
||||
%.clean:
|
||||
@rm -f php_$*.h
|
||||
|
|
|
|||
23
Examples/test-suite/php/catches_strings_runme.php
Normal file
23
Examples/test-suite/php/catches_strings_runme.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
|
||||
$exception_thrown = false;
|
||||
try {
|
||||
StringsThrower::charstring();
|
||||
} catch (Exception $e) {
|
||||
check::str_contains($e->getMessage(), "charstring message", "incorrect exception message: {$e->getMessage()}");
|
||||
$exception_thrown = true;
|
||||
}
|
||||
check::equal($exception_thrown, true, "Should have thrown an exception");
|
||||
|
||||
$exception_thrown = false;
|
||||
try {
|
||||
StringsThrower::stdstring();
|
||||
} catch (Exception $e) {
|
||||
check::str_contains($e->getMessage(), "stdstring message", "incorrect exception message: {$e->getMessage()}");
|
||||
$exception_thrown = true;
|
||||
}
|
||||
check::equal($exception_thrown, true, "Should have thrown an exception");
|
||||
|
||||
check::done();
|
||||
|
|
@ -90,23 +90,23 @@ function makeCalls($caller, $base) {
|
|||
check::equal($caller->PtrCall($dh)->val, $dh->val, "$bname.Ptr");
|
||||
check::equal($caller->ConstPtrRefCall($dh)->val, $dh->val, "$bname.ConstPtrRef");
|
||||
check::equal($caller->FullyOverloadedCall(1),
|
||||
"${bname}::FullyOverloaded(int)",
|
||||
"{$bname}::FullyOverloaded(int)",
|
||||
"$bname.FullyOverloaded(int)");
|
||||
check::equal($caller->FullyOverloadedCall(false),
|
||||
"${bname}::FullyOverloaded(bool)",
|
||||
"{$bname}::FullyOverloaded(bool)",
|
||||
"$bname.FullyOverloaded(bool)");
|
||||
// This next one is TODO for Perl with PerlDerived.
|
||||
check::equal($caller->SemiOverloadedCall(-678),
|
||||
"${bname}::SemiOverloaded(int)",
|
||||
"{$bname}::SemiOverloaded(int)",
|
||||
"$bname.SemiOverloaded(int)");
|
||||
check::equal($caller->SemiOverloadedCall(false),
|
||||
"Base::SemiOverloaded(bool)",
|
||||
"$bname.SemiOverloaded(bool)");
|
||||
check::equal($caller->DefaultParmsCall(10, 2.2),
|
||||
"${bname}::DefaultParms(int, double)",
|
||||
"{$bname}::DefaultParms(int, double)",
|
||||
"$bname.DefaultParms(int, double)");
|
||||
check::equal($caller->DefaultParmsCall(10),
|
||||
"${bname}::DefaultParms(int)",
|
||||
"{$bname}::DefaultParms(int)",
|
||||
"$bname.DefaultParms(int)");
|
||||
$caller->reset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ check::classes(array('A','Foo','Bar'));
|
|||
check::globals(array());
|
||||
|
||||
class MyBar extends Bar {
|
||||
public $val;
|
||||
|
||||
function __construct($val = 2) {
|
||||
parent::__construct();
|
||||
$this->val = $val;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ check::classes(array('director_exception','Foo','Exception1','Exception2','Base'
|
|||
check::globals(array());
|
||||
|
||||
class MyException extends Exception {
|
||||
public $msg;
|
||||
|
||||
function __construct($a, $b) {
|
||||
$this->msg = $a . $b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ check::classes(array('A','StringVector'));
|
|||
check::globals(array());
|
||||
|
||||
class B extends A {
|
||||
public $smem;
|
||||
|
||||
function get_first() {
|
||||
return parent::get_first() . " world!";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,19 @@ trigger_internal_swig_exception("no problem", $a);
|
|||
check::equal(Foo::get_count(), 2, "Should have 2 Foo objects");
|
||||
check::equal(Foo::get_freearg_count(), 1, "freearg should have been used once");
|
||||
|
||||
// SWIG exception triggered and handled.
|
||||
trigger_internal_swig_exception("null", $b);
|
||||
// SWIG exception triggered and handled (return new object case).
|
||||
try {
|
||||
trigger_internal_swig_exception("null", $b);
|
||||
check::fail("Expected exception not thrown");
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
check::equal(Foo::get_count(), 2, "Should have 2 Foo objects");
|
||||
check::equal(Foo::get_freearg_count(), 2, "freearg should have been used twice");
|
||||
|
||||
// SWIG exception triggered and handled (return by value case).
|
||||
try {
|
||||
trigger_internal_swig_exception("null");
|
||||
check::fail("Expected exception not thrown");
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
check::equal(Foo::get_count(), 2, "Should have 2 Foo objects");
|
||||
|
|
|
|||
9
Examples/test-suite/php/mod_runme.php
Normal file
9
Examples/test-suite/php/mod_runme.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
|
||||
$c = new C();
|
||||
$d = new D();
|
||||
$d->DoSomething($c);
|
||||
|
||||
check::done();
|
||||
|
|
@ -9,18 +9,19 @@ class check {
|
|||
|
||||
private static $_werror = false;
|
||||
|
||||
// This is called automatically at the end of this file.
|
||||
static function init() {
|
||||
foreach(get_included_files() as $f) {
|
||||
$module_name = preg_filter('/.*\/([^\/]+)_runme\.php$/', '\1', $f);
|
||||
if ($module_name !== null) break;
|
||||
static function get_extension() {
|
||||
if (self::$_extension === null) {
|
||||
foreach(get_included_files() as $f) {
|
||||
$module_name = preg_filter('/.*\/([^\/]+)_runme\.php$/', '\1', $f);
|
||||
if ($module_name !== null) break;
|
||||
}
|
||||
if ($module_name === null) {
|
||||
print("Failed to determine module name from get_included_files()\n");
|
||||
exit(1);
|
||||
}
|
||||
self::$_extension = new ReflectionExtension($module_name);
|
||||
}
|
||||
if ($module_name === null) {
|
||||
print("Failed to determine module name from get_included_files()\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
self::$_extension = new ReflectionExtension($module_name);
|
||||
return self::$_extension;
|
||||
}
|
||||
|
||||
static function werror($v) {
|
||||
|
|
@ -92,7 +93,7 @@ class check {
|
|||
if (! is_array($classes)) $classes=array($classes);
|
||||
$message=array();
|
||||
$missing=array();
|
||||
$extra = array_flip(array_filter(self::$_extension->getClassNames(),
|
||||
$extra = array_flip(array_filter(self::get_extension()->getClassNames(),
|
||||
function ($e) { return !preg_match('/^SWIG\\\\/', $e); }));
|
||||
foreach($classes as $class) {
|
||||
if (! class_exists($class)) $missing[]=$class;
|
||||
|
|
@ -109,7 +110,7 @@ class check {
|
|||
if (! is_array($functions)) $functions=array($functions);
|
||||
$message=array();
|
||||
$missing=array();
|
||||
$extra = self::$_extension->getFunctions();
|
||||
$extra = self::get_extension()->getFunctions();
|
||||
foreach ($functions as $func) {
|
||||
if (! function_exists($func)) $missing[]=$func;
|
||||
else unset($extra[$func]);
|
||||
|
|
@ -127,7 +128,7 @@ class check {
|
|||
if (! is_array($globals)) $globals=array($globals);
|
||||
$message=array();
|
||||
$missing=array();
|
||||
$extra = self::$_extension->getFunctions();
|
||||
$extra = self::get_extension()->getFunctions();
|
||||
foreach ($globals as $glob) {
|
||||
if (! function_exists($glob . "_get") && ! function_exists($glob . "_set")) $missing[]=$glob;
|
||||
else {
|
||||
|
|
@ -149,7 +150,7 @@ class check {
|
|||
if (! is_array($constants)) $constants=array($constants);
|
||||
$message=array();
|
||||
$missing=array();
|
||||
$extra = self::$_extension->getConstants();
|
||||
$extra = self::get_extension()->getConstants();
|
||||
unset($extra['swig_runtime_data_type_pointer']);
|
||||
foreach($constants as $constant) {
|
||||
if (! defined($constant)) $missing[]=$constant;
|
||||
|
|
@ -213,5 +214,3 @@ class check {
|
|||
# print $_SERVER[argv][0]." ok\n";
|
||||
}
|
||||
}
|
||||
|
||||
check::init();
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ struct Defined {
|
|||
void defined_not(TYPE);
|
||||
#endif
|
||||
|
||||
#if !( defined(AAA) \
|
||||
#if !( defined(AAA) &&\
|
||||
defined(BBB) \\
|
||||
&& defined(CCC) )
|
||||
void bumpf_not(TYPE);
|
||||
|
|
|
|||
27
Examples/test-suite/preproc_predefined.h
Normal file
27
Examples/test-suite/preproc_predefined.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* This list will need updating when new target languages are added. */
|
||||
#if (0\
|
||||
+defined(SWIGCSHARP)\
|
||||
+defined(SWIGD)\
|
||||
+defined(SWIGGO)\
|
||||
+defined(SWIGGUILE)\
|
||||
+defined(SWIGJAVA)\
|
||||
+defined(SWIGJAVASCRIPT)\
|
||||
+defined(SWIGLUA)\
|
||||
+defined(SWIGMZSCHEME)\
|
||||
+defined(SWIGOCAML)\
|
||||
+defined(SWIGOCTAVE)\
|
||||
+defined(SWIGPERL)\
|
||||
+defined(SWIGPHP)\
|
||||
+defined(SWIGPYTHON)\
|
||||
+defined(SWIGR)\
|
||||
+defined(SWIGRUBY)\
|
||||
+defined(SWIGSCILAB)\
|
||||
+defined(SWIGTCL)\
|
||||
+defined(SWIGXML)\
|
||||
) != 1
|
||||
# ifdef SWIG
|
||||
# error Did not detect exactly one target-language-specific macro defined at SWIG time.
|
||||
# else
|
||||
# error Did not detect exactly one target-language-specific macro defined in the generated wrapper.
|
||||
# endif
|
||||
#endif
|
||||
62
Examples/test-suite/preproc_predefined.i
Normal file
62
Examples/test-suite/preproc_predefined.i
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
%module preproc_predefined
|
||||
|
||||
/* Test that SWIG_VERSION is defined at SWIG-time and in the wrapper. */
|
||||
#ifndef SWIG_VERSION
|
||||
# error SWIG_VERSION not defined at SWIG-time
|
||||
#endif
|
||||
%{
|
||||
#ifndef SWIG_VERSION
|
||||
# error SWIG_VERSION not defined in the generated wrapper
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* Test that SWIG_VERSION has a plausible value - in particular catch if
|
||||
* it isn't defined to a numeric value (which will get replaced by 0).
|
||||
*/
|
||||
#if SWIG_VERSION < 0x040100
|
||||
# error SWIG_VERSION value not plausible at SWIG-time
|
||||
#endif
|
||||
%{
|
||||
#if SWIG_VERSION < 0x040100
|
||||
# error SWIG_VERSION value not plausible in the generated wrapper
|
||||
#endif
|
||||
%}
|
||||
|
||||
%define %generate_swig_version_from_preprocessor()%#define SWIG_VERSION_FROM_SWIG_PREPROCESSOR SWIG_VERSION %enddef
|
||||
%insert("header") {
|
||||
%generate_swig_version_from_preprocessor()
|
||||
}
|
||||
%insert("header") %{
|
||||
#if SWIG_VERSION != SWIG_VERSION_FROM_SWIG_PREPROCESSOR
|
||||
# error SWIG_VERSION in SWIG preprocessor does not match SWIG_VERSION from C preprocessor
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* Test that SWIGVERSION is NOT defined at SWIG-time or in the wrapper.
|
||||
* It used to be defined in the wrapper as a side-effect of how SWIG_VERSION
|
||||
* was defined in the wrapper but was never documented and is redundant.
|
||||
*/
|
||||
#ifdef SWIGVERSION
|
||||
# error SWIGVERSION should not be defined at SWIG-time
|
||||
#endif
|
||||
%{
|
||||
#ifdef SWIGVERSION
|
||||
# error SWIGVERSION should not be defined in the generated wrapper
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* Test that SWIG is defined at SWIG-time but not in the wrapper. */
|
||||
#ifndef SWIG
|
||||
# error SWIG not defined at SWIG-time
|
||||
#endif
|
||||
%{
|
||||
#ifdef SWIG
|
||||
# error SWIG should not be defined in the generated wrapper
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* Test that SWIGxxx is defined at SWIG-time and in the wrapper. */
|
||||
%include "preproc_predefined.h"
|
||||
%{
|
||||
#include "preproc_predefined.h"
|
||||
%}
|
||||
21
Examples/test-suite/python/catches_strings_runme.py
Normal file
21
Examples/test-suite/python/catches_strings_runme.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from catches_strings import *
|
||||
|
||||
exception_thrown = False
|
||||
try:
|
||||
StringsThrower.charstring()
|
||||
except RuntimeError as e:
|
||||
if "charstring message" not in str(e):
|
||||
raise RuntimeError("incorrect exception message:" + str(e))
|
||||
exception_thrown = True
|
||||
if not exception_thrown:
|
||||
raise RuntimeError("Should have thrown an exception")
|
||||
|
||||
exception_thrown = False
|
||||
try:
|
||||
StringsThrower.stdstring()
|
||||
except RuntimeError as e:
|
||||
if "stdstring message" not in str(e):
|
||||
raise RuntimeError("incorrect exception message:" + str(e))
|
||||
exception_thrown = True
|
||||
if not exception_thrown:
|
||||
raise RuntimeError("Should have thrown an exception")
|
||||
|
|
@ -9,10 +9,10 @@ a.j = 10
|
|||
if a.j != 10:
|
||||
raise RuntimeError("Assignment to a.j failed.")
|
||||
|
||||
b = a.foo(5)
|
||||
b = a.get_number(5)
|
||||
if b != 10:
|
||||
raise RuntimeError("foo(5) should return 10.")
|
||||
raise RuntimeError("get_number(5) should return 10.")
|
||||
|
||||
b = a.foo(6)
|
||||
b = a.get_number(6)
|
||||
if b != 0:
|
||||
raise RuntimeError("foo(6) should return 0.")
|
||||
raise RuntimeError("get_number(6) should return 0.")
|
||||
|
|
|
|||
65
Examples/test-suite/python/cpp11_final_class_runme.py
Normal file
65
Examples/test-suite/python/cpp11_final_class_runme.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
from cpp11_final_class import *
|
||||
|
||||
fc1 = FinalClass1()
|
||||
fc1.method1()
|
||||
|
||||
fc2 = FinalClass2()
|
||||
fc2.method2()
|
||||
|
||||
fc3 = FinalClass3()
|
||||
fc3.method3()
|
||||
|
||||
fc4 = FinalClass4()
|
||||
fc4.method4()
|
||||
fc4final = cvar.final
|
||||
cvar.final.method4()
|
||||
|
||||
fc5 = FinalClass5()
|
||||
fc5.method5()
|
||||
fc5.final_member_var.finalmethod()
|
||||
fc5final = fc5.get_final_member()
|
||||
fc5final.finalmethod()
|
||||
fc5final = fc5.get_final_member2()
|
||||
fc5final.finalmethod()
|
||||
|
||||
fc6 = FinalClass6()
|
||||
fc6.method6()
|
||||
fc6.final()
|
||||
|
||||
o = override()
|
||||
o.omethod();
|
||||
|
||||
y = Y()
|
||||
fv4 = FinalVar4()
|
||||
yy = fv4.final
|
||||
|
||||
fv5 = FinalVar5()
|
||||
yy = fv5.final
|
||||
|
||||
fv6 = FinalVar6()
|
||||
yy = fv6.final
|
||||
|
||||
fv7 = FinalVar7()
|
||||
yy = fv7.final
|
||||
|
||||
fv8 = FinalVar8()
|
||||
yy = fv8.final
|
||||
|
||||
fv9 = FinalVar9()
|
||||
yy = fv9.final
|
||||
|
||||
fv10 = FinalVar10()
|
||||
fv10.b10(y)
|
||||
|
||||
# Removed due to Visual C++ compiler limitations
|
||||
# fv11 = FinalVar11()
|
||||
# fv11.a11(y)
|
||||
#
|
||||
# fe1 = FinalEnum1()
|
||||
# fe1.enum_in(FinalEnum1.final)
|
||||
#
|
||||
# fe2 = FinalEnum2()
|
||||
# fe2f = fe2.final
|
||||
|
||||
s3f = Space3_final()
|
||||
s3f.fmethod();
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
from cpp11_variadic_function_templates import *
|
||||
|
||||
ec = EmplaceContainer()
|
||||
ec.emplace(A())
|
||||
ec.emplace(A(), B())
|
||||
ec.emplace(A(), B(), C())
|
||||
ec.emplace(A(), B(), C(), D())
|
||||
|
||||
def check(expected, got):
|
||||
if expected != got:
|
||||
raise RuntimeError("failed: {} != {}".format(expected, got))
|
||||
|
||||
a = A()
|
||||
b = B()
|
||||
c = C()
|
||||
check(variadicmix1(), 20)
|
||||
check(variadicmix1(a), 20)
|
||||
check(variadicmix1(a, b), 10)
|
||||
check(variadicmix1(a, b, c), 20)
|
||||
check(variadicmix1(11, 22), 10)
|
||||
152
Examples/test-suite/python/cpp11_variadic_templates_runme.py
Normal file
152
Examples/test-suite/python/cpp11_variadic_templates_runme.py
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
from cpp11_variadic_templates import *
|
||||
|
||||
ma = MultiArgs1()
|
||||
|
||||
# SizeOf testing
|
||||
so0 = SizeOf0()
|
||||
if so0.size != 0:
|
||||
raise RuntimeError("so0.size")
|
||||
so1 = SizeOf1()
|
||||
if so1.size != 1:
|
||||
raise RuntimeError("so1.size")
|
||||
so2 = SizeOf2()
|
||||
if so2.size != 2:
|
||||
raise RuntimeError("so2.size")
|
||||
so3 = SizeOf3()
|
||||
if so3.size != 3:
|
||||
raise RuntimeError("so3.size")
|
||||
|
||||
a = A()
|
||||
b = B()
|
||||
c = C()
|
||||
d = D()
|
||||
|
||||
# MultiInherit0
|
||||
mi0 = MultiInherit0()
|
||||
mi0.MultiInstanceMethod()
|
||||
MultiInherit0.MultiStaticMethod()
|
||||
mi0.InstanceMethod()
|
||||
MultiInherit0.StaticMethod()
|
||||
|
||||
# MultiInherit1
|
||||
mi1 = MultiInherit1(a)
|
||||
if mi1.a != 100:
|
||||
raise RuntimeError("fail mi1.a")
|
||||
mi1.MultiInstanceMethod(a)
|
||||
MultiInherit1.MultiStaticMethod(a)
|
||||
mi1.InstanceMethod()
|
||||
MultiInherit1.StaticMethod()
|
||||
|
||||
# MultiInherit2
|
||||
mi2 = MultiInherit2(a, b)
|
||||
if mi2.a != 100:
|
||||
raise RuntimeError("fail mi2.a")
|
||||
if mi2.b != 200:
|
||||
raise RuntimeError("fail mi2.b")
|
||||
mi2.MultiInstanceMethod(a, b)
|
||||
MultiInherit2.MultiStaticMethod(a, b)
|
||||
mi2.InstanceMethod()
|
||||
MultiInherit2.StaticMethod()
|
||||
|
||||
# MultiInherit3
|
||||
mi3 = MultiInherit3(a, b, c)
|
||||
if mi3.a != 100:
|
||||
raise RuntimeError("fail mi3.a")
|
||||
if mi3.b != 200:
|
||||
raise RuntimeError("fail mi3.b")
|
||||
if mi3.c != 300:
|
||||
raise RuntimeError("fail mi3.c")
|
||||
mi3.MultiInstanceMethod(a, b, c)
|
||||
MultiInherit3.MultiStaticMethod(a, b, c)
|
||||
mi3.InstanceMethod()
|
||||
MultiInherit3.StaticMethod()
|
||||
|
||||
# NumerousInherit0
|
||||
num = 123
|
||||
ni0 = NumerousInherit0(num)
|
||||
ni0.NumerousInstanceMethod(num)
|
||||
NumerousInherit0.NumerousStaticMethod(num)
|
||||
ni0.InstanceMethod()
|
||||
NumerousInherit0.StaticMethod()
|
||||
|
||||
# NumerousInherit1
|
||||
ni1 = NumerousInherit1(num, a)
|
||||
if ni1.a != 100:
|
||||
raise RuntimeError("fail ni1.a")
|
||||
ni1.NumerousInstanceMethod(num, a)
|
||||
NumerousInherit1.NumerousStaticMethod(num, a)
|
||||
ni1.InstanceMethod()
|
||||
NumerousInherit1.StaticMethod()
|
||||
|
||||
# NumerousInherit2
|
||||
ni2 = NumerousInherit2(num, a, b)
|
||||
if ni2.a != 100:
|
||||
raise RuntimeError("fail ni2.a")
|
||||
if ni2.b != 200:
|
||||
raise RuntimeError("fail ni2.b")
|
||||
ni2.NumerousInstanceMethod(num, a, b)
|
||||
NumerousInherit2.NumerousStaticMethod(num, a, b)
|
||||
ni2.InstanceMethod()
|
||||
NumerousInherit2.StaticMethod()
|
||||
|
||||
# NumerousInherit3
|
||||
ni3 = NumerousInherit3(num, a, b, c)
|
||||
if ni3.a != 100:
|
||||
raise RuntimeError("fail ni3.a")
|
||||
if ni3.b != 200:
|
||||
raise RuntimeError("fail ni3.b")
|
||||
if ni3.c != 300:
|
||||
raise RuntimeError("fail ni3.c")
|
||||
ni3.NumerousInstanceMethod(num, a, b, c)
|
||||
NumerousInherit3.NumerousStaticMethod(num, a, b, c)
|
||||
ni3.InstanceMethod()
|
||||
NumerousInherit3.StaticMethod()
|
||||
|
||||
LotsInherit1
|
||||
lots1 = LotsInherit1(a)
|
||||
if lots1.a != 100:
|
||||
raise RuntimeError("fail lots1.a")
|
||||
lots1.LotsInstanceMethod(a)
|
||||
LotsInherit1.LotsStaticMethod(a)
|
||||
lots1.InstanceMethod()
|
||||
LotsInherit1.StaticMethod()
|
||||
|
||||
# LotsInherit2
|
||||
lots2 = LotsInherit2(a, b)
|
||||
if lots2.a != 100:
|
||||
raise RuntimeError("fail lots2.a")
|
||||
if lots2.b != 200:
|
||||
raise RuntimeError("fail lots2.b")
|
||||
lots2.LotsInstanceMethod(a, b)
|
||||
LotsInherit2.LotsStaticMethod(a, b)
|
||||
lots2.InstanceMethod()
|
||||
LotsInherit2.StaticMethod()
|
||||
|
||||
# LotsInherit3
|
||||
lots3 = LotsInherit3(a, b, c)
|
||||
if lots3.a != 100:
|
||||
raise RuntimeError("fail lots3.a")
|
||||
if lots3.b != 200:
|
||||
raise RuntimeError("fail lots3.b")
|
||||
if lots3.c != 300:
|
||||
raise RuntimeError("fail lots3.c")
|
||||
lots3.LotsInstanceMethod(a, b, c)
|
||||
LotsInherit3.LotsStaticMethod(a, b, c)
|
||||
lots3.InstanceMethod()
|
||||
LotsInherit3.StaticMethod()
|
||||
|
||||
# LotsInherit4
|
||||
lots4 = LotsInherit4(a, b, c, d)
|
||||
if lots4.a != 100:
|
||||
raise RuntimeError("fail lots4.a")
|
||||
if lots4.b != 200:
|
||||
raise RuntimeError("fail lots4.b")
|
||||
if lots4.c != 300:
|
||||
raise RuntimeError("fail lots4.c")
|
||||
if lots4.d != 400:
|
||||
raise RuntimeError("fail lots4.c")
|
||||
lots4.LotsInstanceMethod(a, b, c, d)
|
||||
LotsInherit4.LotsStaticMethod(a, b, c, d)
|
||||
lots4.InstanceMethod()
|
||||
LotsInherit4.StaticMethod()
|
||||
|
||||
|
|
@ -58,6 +58,7 @@ If not: SOMECONDITION {
|
|||
}
|
||||
|
||||
Image: testImage.bmp("Hello, world!")
|
||||
Image: "test image.jpg"("Test jpeg")
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
6
Examples/test-suite/python/final_c_runme.py
Normal file
6
Examples/test-suite/python/final_c_runme.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import final_c
|
||||
|
||||
final_c.init()
|
||||
f = final_c.cvar.final
|
||||
if (f.yval != 123):
|
||||
raise RuntimeError("f.yval fail")
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
from template_template_parameters import *
|
||||
|
||||
# Test first part
|
||||
# Test part 1
|
||||
listBool = ListFastBool()
|
||||
listBool.item = True
|
||||
x_boolean = listBool.allotype
|
||||
|
|
@ -13,7 +13,7 @@ x_double = listDouble.allotype
|
|||
if listDouble.item != 10.2:
|
||||
raise RuntimeError("Failed")
|
||||
|
||||
# Test second part
|
||||
# Test part 2
|
||||
floatTestStruct = FloatTestStruct()
|
||||
floatContainer2 = floatTestStruct.x
|
||||
floatContainer2.x = 8.1
|
||||
|
|
@ -28,3 +28,6 @@ intTestStructReturned = TestStructContainer1Method(intTestStruct)
|
|||
if intTestStructReturned.x.x != 101:
|
||||
raise RuntimeError("Failed")
|
||||
|
||||
# Test part 3
|
||||
mfi99 = MyFootInt99()
|
||||
mfi99 += mfi99 # __iadd__
|
||||
|
|
|
|||
|
|
@ -21,3 +21,7 @@ if x != "Spam::blah":
|
|||
x = typedef_inherit.do_blah2(d)
|
||||
if x != "Grok::blah":
|
||||
raise RuntimeError("Whoa! Bad return {}".format(x))
|
||||
|
||||
x = d.far()
|
||||
if x != "Spam::far":
|
||||
raise RuntimeError("Whoa! Bad return {}".format(x))
|
||||
|
|
|
|||
24
Examples/test-suite/r/catches_strings_runme.R
Normal file
24
Examples/test-suite/r/catches_strings_runme.R
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
|
||||
dyn.load(paste("catches_strings", .Platform$dynlib.ext, sep=""))
|
||||
source("catches_strings.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
exception_thrown = FALSE
|
||||
tryCatch({
|
||||
StringsThrower_charstring()
|
||||
}, error = function(e) {
|
||||
exception_thrown <<- grepl(e$message, "charstring message", fixed=TRUE)
|
||||
}
|
||||
)
|
||||
unittest(exception_thrown, TRUE)
|
||||
|
||||
exception_thrown = FALSE
|
||||
tryCatch({
|
||||
StringsThrower_stdstring()
|
||||
}, error = function(e) {
|
||||
exception_thrown <<- grepl(e$message, "stdstring message", fixed=TRUE)
|
||||
}
|
||||
)
|
||||
unittest(exception_thrown, TRUE)
|
||||
13
Examples/test-suite/r/constant_pointers_runme.R
Normal file
13
Examples/test-suite/r/constant_pointers_runme.R
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
|
||||
dyn.load(paste("constant_pointers", .Platform$dynlib.ext, sep=""))
|
||||
source("constant_pointers.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
myb <- B()
|
||||
bret = bar(myb)
|
||||
bret2 = cbar(myb)
|
||||
bret3 = bar(bret2)
|
||||
|
||||
q(save="no")
|
||||
|
|
@ -14,7 +14,7 @@ unittest(Foo_get_count(), 2);
|
|||
invisible(trigger_internal_swig_exception("no problem", a));
|
||||
unittest(Foo_get_count(), 2);
|
||||
unittest(Foo_get_freearg_count(), 1);
|
||||
# SWIG exception introduced
|
||||
# SWIG exception introduced (return new object case).
|
||||
result <- tryCatch({
|
||||
trigger_internal_swig_exception("null", b);
|
||||
}, warning = function(w) {
|
||||
|
|
@ -26,3 +26,14 @@ result <- tryCatch({
|
|||
})
|
||||
unittest(Foo_get_count(), 2);
|
||||
unittest(Foo_get_freearg_count(), 2);
|
||||
# SWIG exception introduced (return by value case).
|
||||
result <- tryCatch({
|
||||
trigger_internal_swig_exception("null");
|
||||
}, warning = function(w) {
|
||||
# print(" Hum... We received a warning, but this should be an error");
|
||||
unittest(1,0);
|
||||
}, error = function(e) {
|
||||
# print(" Gotcha!");
|
||||
unittest(1,1);
|
||||
})
|
||||
unittest(Foo_get_count(), 2);
|
||||
|
|
|
|||
50
Examples/test-suite/r/extend_template_method_runme.R
Normal file
50
Examples/test-suite/r/extend_template_method_runme.R
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
#source("unittest.R")
|
||||
|
||||
dyn.load(paste("extend_template_method", .Platform$dynlib.ext, sep=""))
|
||||
source("extend_template_method.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
|
||||
em = ExtendMe()
|
||||
|
||||
ret_double = em$do_stuff_double(1, 1.1)
|
||||
unittest(ret_double, 1.1)
|
||||
|
||||
ret_string = em$do_stuff_string(1, "hello there")
|
||||
unittest(ret_string, "hello there")
|
||||
|
||||
ret_double = em$do_overloaded_stuff(1.1)
|
||||
unittest(ret_double, 1.1)
|
||||
|
||||
ret_string = em$do_overloaded_stuff("hello there")
|
||||
unittest(ret_string, "hello there")
|
||||
|
||||
|
||||
unittest(ExtendMe_static_method(123), 123)
|
||||
|
||||
em2 = ExtendMe(123)
|
||||
|
||||
em = TemplateExtend()
|
||||
|
||||
ret_double = em$do_template_stuff_double(1, 1.1)
|
||||
unittest(ret_double, 1.1)
|
||||
|
||||
ret_string = em$do_template_stuff_string(1, "hello there")
|
||||
unittest(ret_string, "hello there")
|
||||
|
||||
|
||||
ret_double = em$do_template_overloaded_stuff(1.1)
|
||||
unittest(ret_double, 1.1)
|
||||
|
||||
ret_string = em$do_template_overloaded_stuff("hello there")
|
||||
unittest(ret_string, "hello there")
|
||||
|
||||
unittest(TemplateExtend_static_template_method(123), 123)
|
||||
|
||||
|
||||
em2 = TemplateExtend(123)
|
||||
|
||||
|
||||
q(save="no")
|
||||
68
Examples/test-suite/r/li_attribute_template_runme.R
Normal file
68
Examples/test-suite/r/li_attribute_template_runme.R
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
#source("unittest.R")
|
||||
|
||||
dyn.load(paste("li_attribute_template", .Platform$dynlib.ext, sep=""))
|
||||
source("li_attribute_template.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
|
||||
# Check usage of template attributes
|
||||
chell = Cintint(1, 2, 3)
|
||||
|
||||
# Testing primitive by value attribute
|
||||
unittest(chell$a, 1)
|
||||
|
||||
chell$a = 3
|
||||
unittest(chell$a, 3)
|
||||
|
||||
# Testing primitive by ref attribute
|
||||
unittest(chell$b, 2)
|
||||
|
||||
chell$b = 5
|
||||
unittest(chell$b, 5)
|
||||
|
||||
# Testing string
|
||||
chell$str = "abc"
|
||||
unittest(chell$str, "abc")
|
||||
|
||||
# Testing class by value
|
||||
unittest(chell$d$value, 1)
|
||||
|
||||
chell$d = Foo(2)
|
||||
unittest(chell$d$value, 2)
|
||||
|
||||
# Testing class by reference
|
||||
unittest(chell$e$value, 2)
|
||||
|
||||
chell$e = Foo(3)
|
||||
unittest(chell$e$value, 3)
|
||||
|
||||
chell$e$value = 4
|
||||
unittest(chell$e$value, 4)
|
||||
|
||||
|
||||
# Testing moderately complex template by value
|
||||
unittest(chell$f$first, 1)
|
||||
unittest(chell$f$second, 2)
|
||||
|
||||
pair = pair_intint(3, 4)
|
||||
chell$f = pair
|
||||
unittest(chell$f$first, 3)
|
||||
unittest(chell$f$second, 4)
|
||||
|
||||
# Testing moderately complex template by ref
|
||||
unittest(chell$g$first, 2)
|
||||
unittest(chell$g$second, 3)
|
||||
|
||||
pair = pair_intint(4, 5)
|
||||
chell$g = pair
|
||||
unittest(chell$g$first, 4)
|
||||
unittest(chell$g$second, 5)
|
||||
|
||||
chell$g$first = 6
|
||||
chell$g$second = 7
|
||||
unittest(chell$g$first, 6)
|
||||
unittest(chell$g$second, 7)
|
||||
|
||||
q(save="no")
|
||||
720
Examples/test-suite/r/li_boost_shared_ptr_runme.R
Normal file
720
Examples/test-suite/r/li_boost_shared_ptr_runme.R
Normal file
|
|
@ -0,0 +1,720 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
#source("unittest.R")
|
||||
|
||||
dyn.load(paste("li_boost_shared_ptr", .Platform$dynlib.ext, sep=""))
|
||||
source("li_boost_shared_ptr.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
# simple shared_ptr usage - created in C++
|
||||
|
||||
invisible(debug_shared(TRUE))
|
||||
unittest(debug_shared(), TRUE)
|
||||
|
||||
|
||||
# Expect 1 instance - the one global variable (GlobalValue)
|
||||
unittest(Klass_getTotal_count(), 1)
|
||||
|
||||
# Change loop count to run for a long time to monitor memory
|
||||
unittest(shared_ptr_wrapper_count(), NOT_COUNTING())
|
||||
|
||||
|
||||
#
|
||||
# test suite to be run in a loop
|
||||
#
|
||||
|
||||
testSuite_verifyCount <- function(expected, k) {
|
||||
got = use_count(k)
|
||||
unittest(expected, got);
|
||||
}
|
||||
|
||||
testSuite <- function() {
|
||||
|
||||
#
|
||||
# Reference Implementation is li_boost_shared_ptr_runme.py
|
||||
#
|
||||
|
||||
# simple shared_ptr usage - created in C++
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
val = k$getValue()
|
||||
unittest("me oh my", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
}
|
||||
|
||||
# simple shared_ptr usage - not created in C++
|
||||
{
|
||||
k = factorycreate()
|
||||
val = k$getValue()
|
||||
unittest("factorycreate", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
}
|
||||
|
||||
# pass by shared_ptr
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
kret = smartpointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointertest", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by shared_ptr pointer
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
kret = smartpointerpointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointerpointertest", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by shared_ptr reference
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
kret = smartpointerreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointerreftest", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by shared_ptr pointer reference
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
kret = smartpointerpointerreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointerpointerreftest", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# const pass by shared_ptr
|
||||
{
|
||||
k = Klass("me oh my");
|
||||
kret = constsmartpointertest(k);
|
||||
val = Klass_getValue(kret);
|
||||
unittest("me oh my", val);
|
||||
testSuite_verifyCount(2, k);
|
||||
testSuite_verifyCount(2, kret);
|
||||
}
|
||||
|
||||
# const pass by shared_ptr pointer
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
kret = constsmartpointerpointertest(k)
|
||||
val = Klass_getValue(kret)
|
||||
unittest("me oh my", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# const pass by shared_ptr reference
|
||||
{
|
||||
k = Klass("me oh my")
|
||||
kret = constsmartpointerreftest(k)
|
||||
val = Klass_getValue(kret)
|
||||
unittest("me oh my", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by value
|
||||
{
|
||||
k = Klass("me oh my");
|
||||
kret = valuetest(k);
|
||||
val = kret$getValue();
|
||||
unittest("me oh my valuetest", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
testSuite_verifyCount(1, kret);
|
||||
}
|
||||
|
||||
# pass by pointer
|
||||
{
|
||||
k = Klass("me oh my");
|
||||
kret = pointertest(k);
|
||||
val = kret$getValue();
|
||||
unittest("me oh my pointertest", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
testSuite_verifyCount(1, kret);
|
||||
}
|
||||
|
||||
# pass by reference
|
||||
{
|
||||
k = Klass("me oh my");
|
||||
kret = reftest(k);
|
||||
val = kret$getValue();
|
||||
unittest("me oh my reftest", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
testSuite_verifyCount(1, kret);
|
||||
}
|
||||
|
||||
# pass by pointer reference
|
||||
{
|
||||
k = Klass("me oh my");
|
||||
kret = pointerreftest(k);
|
||||
val = kret$getValue();
|
||||
unittest("me oh my pointerreftest", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
testSuite_verifyCount(1, kret);
|
||||
}
|
||||
|
||||
# null tests
|
||||
{
|
||||
k = NULL
|
||||
|
||||
if (!is.null(smartpointertest(k))) {
|
||||
stop("return was not null");
|
||||
}
|
||||
|
||||
if (!is.null(smartpointerpointertest(k))) {
|
||||
stop("return was not null");
|
||||
}
|
||||
|
||||
if (!is.null(smartpointerreftest(k))) {
|
||||
stop("return was not null");
|
||||
}
|
||||
|
||||
if (!is.null(smartpointerpointerreftest(k))) {
|
||||
stop("return was not null");
|
||||
}
|
||||
|
||||
if (nullsmartpointerpointertest(k) != "null pointer") {
|
||||
stop("not null smartpointer pointer");
|
||||
}
|
||||
|
||||
bNotCatched = F
|
||||
try({
|
||||
valuetest(k);
|
||||
bNotCatched = T
|
||||
}, silent = T)
|
||||
if (bNotCatched) {
|
||||
stop("Failed to catch null pointer");
|
||||
}
|
||||
|
||||
if (!is.null(pointertest(k))) {
|
||||
stop("return was not null");
|
||||
}
|
||||
|
||||
bNotCatched = F
|
||||
try({
|
||||
reftest(k);
|
||||
bNotCatched = T
|
||||
}, silent = T)
|
||||
if (bNotCatched) {
|
||||
stop("Failed to catch null pointer");
|
||||
}
|
||||
|
||||
# test null pointers emitted from C++
|
||||
|
||||
k = sp_pointer_null()
|
||||
if (!is.null(k)) {
|
||||
stop("return was not null")
|
||||
}
|
||||
|
||||
k = null_sp_pointer()
|
||||
if (!is.null(k)) {
|
||||
stop("return was not null")
|
||||
}
|
||||
|
||||
k = sp_value_null()
|
||||
if (!is.null(k)) {
|
||||
stop("return was not null")
|
||||
}
|
||||
}
|
||||
|
||||
# $owner
|
||||
{
|
||||
k = pointerownertest();
|
||||
val = k$getValue();
|
||||
unittest("pointerownertest", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
}
|
||||
|
||||
{
|
||||
k = smartpointerpointerownertest();
|
||||
val = k$getValue();
|
||||
unittest("smartpointerpointerownertest", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
}
|
||||
|
||||
#
|
||||
# ###################### Derived class ######################
|
||||
#
|
||||
|
||||
# derived pass by shared_ptr
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = derivedsmartptrtest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my derivedsmartptrtest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# derived pass by shared_ptr pointer
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = derivedsmartptrpointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my derivedsmartptrpointertest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# derived pass by shared_ptr ref
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = derivedsmartptrreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my derivedsmartptrreftest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# derived pass by shared_ptr pointer ref
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = derivedsmartptrpointerreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my derivedsmartptrpointerreftest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# derived pass by pointer
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = derivedpointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my derivedpointertest-Derived", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
testSuite_verifyCount(1, kret)
|
||||
}
|
||||
|
||||
# derived pass by ref
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = derivedreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my derivedreftest-Derived", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
testSuite_verifyCount(1, kret)
|
||||
}
|
||||
|
||||
#
|
||||
# ###################### Derived and base class mixed ######################
|
||||
#
|
||||
# pass by shared_ptr (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = smartpointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointertest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by shared_ptr pointer (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = smartpointerpointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointerpointertest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by shared_ptr reference (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = smartpointerreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointerreftest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by shared_ptr pointer reference (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = smartpointerpointerreftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my smartpointerpointerreftest-Derived", val)
|
||||
testSuite_verifyCount(2, k)
|
||||
testSuite_verifyCount(2, kret)
|
||||
}
|
||||
|
||||
# pass by value (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = valuetest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my valuetest", val) # note slicing
|
||||
testSuite_verifyCount(1, k)
|
||||
testSuite_verifyCount(1, kret)
|
||||
}
|
||||
|
||||
# pass by pointer (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = pointertest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my pointertest-Derived", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
testSuite_verifyCount(1, kret)
|
||||
}
|
||||
|
||||
# pass by ref (mixed)
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
kret = reftest(k)
|
||||
val = kret$getValue()
|
||||
unittest("me oh my reftest-Derived", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
testSuite_verifyCount(1, kret)
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# ################# Overloading tests ##################
|
||||
#
|
||||
|
||||
# Base class
|
||||
{
|
||||
k = Klass("me oh my");
|
||||
|
||||
unittest(overload_rawbyval(k), "rawbyval")
|
||||
unittest(overload_rawbyref(k), "rawbyref")
|
||||
unittest(overload_rawbyptr(k), "rawbyptr")
|
||||
unittest(overload_rawbyptrref(k), "rawbyptrref")
|
||||
|
||||
unittest(overload_smartbyval(k), "smartbyval")
|
||||
unittest(overload_smartbyref(k), "smartbyref")
|
||||
unittest(overload_smartbyptr(k), "smartbyptr")
|
||||
unittest(overload_smartbyptrref(k), "smartbyptrref")
|
||||
}
|
||||
|
||||
# Derived class
|
||||
{
|
||||
k = KlassDerived("me oh my")
|
||||
|
||||
unittest(overload_rawbyval(k), "rawbyval")
|
||||
unittest(overload_rawbyref(k), "rawbyref")
|
||||
unittest(overload_rawbyptr(k), "rawbyptr")
|
||||
unittest(overload_rawbyptrref(k), "rawbyptrref")
|
||||
|
||||
unittest(overload_smartbyval(k), "smartbyval")
|
||||
unittest(overload_smartbyref(k), "smartbyref")
|
||||
unittest(overload_smartbyptr(k), "smartbyptr")
|
||||
unittest(overload_smartbyptrref(k), "smartbyptrref")
|
||||
}
|
||||
|
||||
# 3rd derived class
|
||||
{
|
||||
k = Klass3rdDerived("me oh my")
|
||||
|
||||
val = k$getValue()
|
||||
unittest("me oh my-3rdDerived", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
val = test3rdupcast(k)
|
||||
unittest("me oh my-3rdDerived", val)
|
||||
testSuite_verifyCount(1, k)
|
||||
}
|
||||
|
||||
#
|
||||
# ################ Member variables ####################
|
||||
#
|
||||
|
||||
# smart pointer by value
|
||||
{
|
||||
m = MemberVariables();
|
||||
k = Klass("smart member value");
|
||||
m$SmartMemberValue = k;
|
||||
|
||||
val = k$getValue();
|
||||
unittest("smart member value", val);
|
||||
testSuite_verifyCount(2, k);
|
||||
|
||||
kmember = m$SmartMemberValue;
|
||||
val = kmember$getValue();
|
||||
unittest("smart member value", val);
|
||||
testSuite_verifyCount(3, kmember);
|
||||
testSuite_verifyCount(3, k);
|
||||
|
||||
delete_MemberVariables(m)
|
||||
testSuite_verifyCount(2, kmember);
|
||||
testSuite_verifyCount(2, k);
|
||||
}
|
||||
|
||||
# smart pointer by pointer
|
||||
{
|
||||
m = MemberVariables();
|
||||
k = Klass("smart member pointer");
|
||||
m$SmartMemberPointer = k;
|
||||
val = k$getValue();
|
||||
unittest("smart member pointer", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kmember = m$SmartMemberPointer;
|
||||
val = kmember$getValue();
|
||||
unittest("smart member pointer", val);
|
||||
testSuite_verifyCount(2, kmember);
|
||||
testSuite_verifyCount(2, k);
|
||||
|
||||
delete_MemberVariables(m);
|
||||
testSuite_verifyCount(2, kmember);
|
||||
testSuite_verifyCount(2, k);
|
||||
}
|
||||
|
||||
# smart pointer by reference
|
||||
{
|
||||
m = MemberVariables();
|
||||
k = Klass("smart member reference");
|
||||
m$SmartMemberReference = k;
|
||||
val = k$getValue();
|
||||
unittest("smart member reference", val);
|
||||
testSuite_verifyCount(2, k);
|
||||
|
||||
kmember = m$SmartMemberReference;
|
||||
val = kmember$getValue();
|
||||
unittest("smart member reference", val);
|
||||
testSuite_verifyCount(3, kmember);
|
||||
testSuite_verifyCount(3, k);
|
||||
|
||||
# The C++ reference refers to SmartMemberValue...
|
||||
kmemberVal = m$SmartMemberValue;
|
||||
val = kmember$getValue();
|
||||
unittest("smart member reference", val);
|
||||
testSuite_verifyCount(4, kmemberVal);
|
||||
testSuite_verifyCount(4, kmember);
|
||||
testSuite_verifyCount(4, k);
|
||||
|
||||
delete_MemberVariables(m);
|
||||
testSuite_verifyCount(3, kmemberVal);
|
||||
testSuite_verifyCount(3, kmember);
|
||||
testSuite_verifyCount(3, k);
|
||||
}
|
||||
|
||||
# plain by value
|
||||
{
|
||||
m = MemberVariables();
|
||||
k = Klass("plain member value");
|
||||
m$MemberValue = k;
|
||||
val = k$getValue();
|
||||
unittest("plain member value", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kmember = m$MemberValue;
|
||||
val = kmember$getValue();
|
||||
unittest("plain member value", val);
|
||||
testSuite_verifyCount(1, kmember);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
delete_MemberVariables(m);
|
||||
testSuite_verifyCount(1, kmember);
|
||||
testSuite_verifyCount(1, k);
|
||||
}
|
||||
|
||||
# plain by pointer
|
||||
{
|
||||
m = MemberVariables();
|
||||
k = Klass("plain member pointer");
|
||||
m$MemberPointer = k;
|
||||
val = k$getValue();
|
||||
unittest("plain member pointer", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kmember = m$MemberPointer;
|
||||
val = kmember$getValue();
|
||||
unittest("plain member pointer", val);
|
||||
testSuite_verifyCount(1, kmember);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
delete_MemberVariables(m);
|
||||
testSuite_verifyCount(1, kmember);
|
||||
testSuite_verifyCount(1, k);
|
||||
}
|
||||
|
||||
# plain by reference
|
||||
{
|
||||
m = MemberVariables();
|
||||
k = Klass("plain member reference");
|
||||
m$MemberReference = k;
|
||||
val = k$getValue();
|
||||
unittest("plain member reference", val);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kmember = m$MemberReference;
|
||||
val = kmember$getValue();
|
||||
unittest("plain member reference", val);
|
||||
testSuite_verifyCount(1, kmember);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
delete_MemberVariables(m);
|
||||
testSuite_verifyCount(1, kmember);
|
||||
testSuite_verifyCount(1, k);
|
||||
}
|
||||
|
||||
# null member variables
|
||||
{
|
||||
m = MemberVariables();
|
||||
|
||||
# shared_ptr by value
|
||||
k = m$SmartMemberValue;
|
||||
if (!is.null(k))
|
||||
stop("expected null");
|
||||
|
||||
m$SmartMemberValue = NULL;
|
||||
k = m$SmartMemberValue;
|
||||
if (!is.null(k))
|
||||
stop("expected null");
|
||||
testSuite_verifyCount(0, k);
|
||||
|
||||
# plain by value
|
||||
bNotCatched = F
|
||||
try({
|
||||
m$MemberValue = NULL
|
||||
bNotCatched = T
|
||||
}, silent = T)
|
||||
if (bNotCatched) {
|
||||
stop("Failed to catch null pointer")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# ################ Global variables ####################
|
||||
#
|
||||
|
||||
# smart pointer
|
||||
{
|
||||
kglobal = GlobalSmartValue_get();
|
||||
if (!is.null(kglobal))
|
||||
stop("expected null");
|
||||
|
||||
k = Klass("smart global value");
|
||||
GlobalSmartValue_set(k);
|
||||
testSuite_verifyCount(2, k);
|
||||
|
||||
kglobal = GlobalSmartValue_get();
|
||||
val = kglobal$getValue();
|
||||
unittest("smart global value", val);
|
||||
testSuite_verifyCount(3, kglobal);
|
||||
testSuite_verifyCount(3, k);
|
||||
unittest("smart global value", GlobalSmartValue_get()$getValue());
|
||||
|
||||
GlobalSmartValue_set(NULL);
|
||||
}
|
||||
|
||||
# plain value
|
||||
{
|
||||
k = Klass("global value");
|
||||
GlobalValue_set(k);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kglobal = GlobalValue_get();
|
||||
val = kglobal$getValue();
|
||||
unittest("global value", val);
|
||||
testSuite_verifyCount(1, kglobal);
|
||||
testSuite_verifyCount(1, k);
|
||||
unittest("global value", GlobalValue_get()$getValue());
|
||||
|
||||
bNotCatched = F
|
||||
try({
|
||||
GlobalValue_set(NULL)
|
||||
bNotCatched = T
|
||||
}, silent = T)
|
||||
if (bNotCatched) {
|
||||
stop("Failed to catch null pointer")
|
||||
}
|
||||
}
|
||||
|
||||
# plain pointer
|
||||
{
|
||||
kglobal = GlobalPointer_get();
|
||||
if (!is.null(kglobal))
|
||||
stop("expected null");
|
||||
|
||||
k = Klass("global pointer");
|
||||
GlobalPointer_set(k);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kglobal = GlobalPointer_get();
|
||||
val = kglobal$getValue();
|
||||
unittest("global pointer", val);
|
||||
testSuite_verifyCount(1, kglobal);
|
||||
testSuite_verifyCount(1, k);
|
||||
GlobalPointer_set(NULL);
|
||||
}
|
||||
|
||||
# plain reference
|
||||
{
|
||||
k = Klass("global reference");
|
||||
GlobalReference_set(k);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
kglobal = GlobalReference_get();
|
||||
val = kglobal$getValue();
|
||||
unittest("global reference", val);
|
||||
testSuite_verifyCount(1, kglobal);
|
||||
testSuite_verifyCount(1, k);
|
||||
|
||||
bNotCatched = F
|
||||
try({
|
||||
GlobalReference_set(NULL)
|
||||
bNotCatched = T
|
||||
}, silent = T)
|
||||
if (bNotCatched) {
|
||||
stop("Failed to catch null pointer")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# ###################### Templates ######################
|
||||
#
|
||||
{
|
||||
pid = PairIntDouble(10, 20.2);
|
||||
if (pid$baseVal1 != 20 || pid$baseVal2 != 40.4)
|
||||
stop("Base values wrong");
|
||||
if (pid$val1 != 10 || pid$val2 != 20.2)
|
||||
stop("Derived Values wrong");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# actually do the tests
|
||||
for (i in 1:10) {
|
||||
print(paste("Start Loop: ", i))
|
||||
testSuite()
|
||||
print(paste("End Loop: ", i))
|
||||
}
|
||||
|
||||
|
||||
# wait for the GC to collect unused objects
|
||||
|
||||
#for (i in 1:10) {
|
||||
# invisible(gc(verbose = F, full = T))
|
||||
#
|
||||
# if (Klass_getTotal_count() == 1) {
|
||||
# break
|
||||
# }
|
||||
#
|
||||
# print(paste("Still waiting for GC to collect ", Klass_getTotal_count()-1, " objects, ", i))
|
||||
# Sys.sleep(1)
|
||||
#}
|
||||
|
||||
# Expect
|
||||
unittest(shared_ptr_wrapper_count(), NOT_COUNTING())
|
||||
|
||||
# Expect 1 instance - the one global variable (GlobalValue)
|
||||
# -> documented bug - gc does not work on some objects - https://www.swig.org/Doc4.0/SWIGDocumentation.html#R_nn2
|
||||
if (FALSE) {
|
||||
unittest(Klass_getTotal_count(), 1)
|
||||
}
|
||||
|
||||
|
||||
q(save="no")
|
||||
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