Merge remote-tracking branch 'origin/master' into gsoc2012-scilab
Conflicts: .gitignore .travis.yml configure.ac
This commit is contained in:
commit
adc4b788df
352 changed files with 8897 additions and 2812 deletions
|
|
@ -21,7 +21,7 @@ UVW Bar::static_member_variable;
|
|||
%}
|
||||
|
||||
|
||||
// Now test the allowexcept feature by making the usual $action uncompileable and ensuring the %exception is picked up
|
||||
// Now test the allowexcept feature by making the usual $action uncompilable and ensuring the %exception is picked up
|
||||
|
||||
struct XYZ {
|
||||
};
|
||||
|
|
|
|||
|
|
@ -133,3 +133,11 @@ typedef int Integer;
|
|||
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ Makefile: $(srcdir)/Makefile.in ../../../config.status
|
|||
CPP_TEST_BROKEN += \
|
||||
constants \
|
||||
cpp_broken \
|
||||
director_nested_class \
|
||||
exception_partial_info \
|
||||
extend_variable \
|
||||
li_std_vector_ptr \
|
||||
|
|
@ -142,6 +143,7 @@ CPP_TEST_CASES += \
|
|||
class_scope_weird \
|
||||
compactdefaultargs \
|
||||
const_const_2 \
|
||||
constant_directive \
|
||||
constant_pointers \
|
||||
constover \
|
||||
constructor_copy \
|
||||
|
|
@ -172,6 +174,7 @@ CPP_TEST_CASES += \
|
|||
director_abstract \
|
||||
director_alternating \
|
||||
director_basic \
|
||||
director_property \
|
||||
director_binary_string \
|
||||
director_classes \
|
||||
director_classic \
|
||||
|
|
@ -248,6 +251,7 @@ CPP_TEST_CASES += \
|
|||
insert_directive \
|
||||
keyword_rename \
|
||||
kind \
|
||||
kwargs_feature \
|
||||
langobj \
|
||||
li_attribute \
|
||||
li_attribute_template \
|
||||
|
|
@ -295,6 +299,7 @@ CPP_TEST_CASES += \
|
|||
nested_directors \
|
||||
nested_comment \
|
||||
nested_scope \
|
||||
nested_template_base \
|
||||
nested_workaround \
|
||||
newobject1 \
|
||||
null_pointer \
|
||||
|
|
@ -309,6 +314,7 @@ CPP_TEST_CASES += \
|
|||
overload_extend \
|
||||
overload_method \
|
||||
overload_numeric \
|
||||
overload_polymorphic \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
overload_simple \
|
||||
|
|
@ -379,6 +385,7 @@ CPP_TEST_CASES += \
|
|||
template_classes \
|
||||
template_const_ref \
|
||||
template_construct \
|
||||
template_templated_constructors \
|
||||
template_default \
|
||||
template_default2 \
|
||||
template_default_arg \
|
||||
|
|
@ -510,6 +517,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_decltype \
|
||||
cpp11_default_delete \
|
||||
cpp11_delegating_constructors \
|
||||
cpp11_director_enums \
|
||||
cpp11_explicit_conversion_operators \
|
||||
cpp11_final_override \
|
||||
cpp11_function_objects \
|
||||
|
|
@ -526,6 +534,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_rvalue_reference3 \
|
||||
cpp11_sizeof_object \
|
||||
cpp11_static_assert \
|
||||
cpp11_strongly_typed_enumerations \
|
||||
cpp11_thread_local \
|
||||
cpp11_template_double_brackets \
|
||||
cpp11_template_explicit \
|
||||
|
|
@ -538,7 +547,6 @@ CPP11_TEST_CASES = \
|
|||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN = \
|
||||
# cpp11_hash_tables \ # not fully implemented yet
|
||||
# cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs
|
||||
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
|
||||
# cpp11_reference_wrapper \ # No typemaps
|
||||
|
||||
|
|
|
|||
28
Examples/test-suite/constant_directive.i
Normal file
28
Examples/test-suite/constant_directive.i
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
%module constant_directive
|
||||
|
||||
// %constant and struct
|
||||
%{
|
||||
struct Type1 {
|
||||
Type1(int val = 0) : val(val) {}
|
||||
int val;
|
||||
};
|
||||
static Type1 TYPE1_CONSTANT1(1);
|
||||
static Type1 TYPE1_CONST2(2);
|
||||
static Type1 TYPE1_CONST3(3);
|
||||
%}
|
||||
|
||||
struct Type1 {
|
||||
Type1(int val = 0) : val(val) {}
|
||||
int val;
|
||||
};
|
||||
|
||||
%inline %{
|
||||
Type1 getType1Instance() { return Type1(111); }
|
||||
%}
|
||||
|
||||
%constant Type1 TYPE1_CONSTANT1;
|
||||
%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
|
||||
%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
|
||||
|
||||
%constant int TYPE_INT = 0;
|
||||
|
||||
|
|
@ -18,6 +18,12 @@ struct ConstExpressions {
|
|||
static const int LLL = 300;
|
||||
constexpr int MMM() { return 400; }
|
||||
constexpr const int NNN() { return 500; }
|
||||
// Regression tests for support added in SWIG 3.0.4:
|
||||
static constexpr const int JJJ1 = 101;
|
||||
constexpr static int KKK1 = 201;
|
||||
// Regression tests for https://github.com/swig/swig/issues/284 :
|
||||
explicit constexpr ConstExpressions(int) { }
|
||||
constexpr explicit ConstExpressions(double) { }
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
14
Examples/test-suite/cpp11_director_enums.i
Normal file
14
Examples/test-suite/cpp11_director_enums.i
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
%module(directors="1") cpp11_director_enums
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Cpp11DirectorEnumsCallback::g;
|
||||
|
||||
%director Cpp11DirectorEnumsCallback;
|
||||
|
||||
%inline %{
|
||||
enum class Color { Red, Green, Blue=10 };
|
||||
struct Cpp11DirectorEnumsCallback {
|
||||
virtual Color f(Color c) = 0;
|
||||
virtual const Color & g(const Color &c) = 0;
|
||||
virtual ~Cpp11DirectorEnumsCallback() {}
|
||||
};
|
||||
%}
|
||||
|
|
@ -3,25 +3,31 @@
|
|||
Function objects are objects which overload the operator() function.
|
||||
The std::function does not provide any seamless support in the target languages yet.
|
||||
*/
|
||||
%module cpp11_function_objects
|
||||
%module(directors="1") cpp11_function_objects
|
||||
|
||||
%rename(__call__) Test::operator();
|
||||
|
||||
%feature("director") Test;
|
||||
|
||||
%inline %{
|
||||
struct Test {
|
||||
class Test {
|
||||
public:
|
||||
int value;
|
||||
|
||||
void operator()(int x, int y) {
|
||||
virtual void operator()(int x, int y) {
|
||||
value=x+y;
|
||||
}
|
||||
Test() : value(0) {}
|
||||
} test;
|
||||
virtual ~Test() {}
|
||||
};
|
||||
|
||||
Test test;
|
||||
|
||||
#include <functional>
|
||||
std::function<void ( int, int )> pF = test;
|
||||
|
||||
int testit1(Test new_test, int a, int b) {
|
||||
pF = new_test;
|
||||
int testit1(Test &new_test, int a, int b) {
|
||||
pF = std::ref(new_test);
|
||||
pF(a, b);
|
||||
return new_test.value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
/* This testcase checks whether SWIG produces the correct wrapper for the
|
||||
strongly typed enums. Enums with the same type are comparable. Enum classes
|
||||
require support for nested classes. */
|
||||
// This testcase checks whether SWIG produces the correct wrappers for strongly typed enums.
|
||||
|
||||
%module cpp11_strongly_typed_enumerations
|
||||
%warnfilter(302) Val1;
|
||||
%warnfilter(302) Val2;
|
||||
%warnfilter(302) Val3;
|
||||
%warnfilter(302) Val4;
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Class1::Struct1;
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Class2::Struct1;
|
||||
|
||||
/* Forward declarations (illegally accepted by SWIG - oh well!) */
|
||||
enum Enum1 : short;
|
||||
|
|
@ -17,15 +15,19 @@ enum : unsigned short;
|
|||
enum class Enum1 {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3 = 100,
|
||||
Val4 /* = 101 */
|
||||
Val3 = 13,
|
||||
Val4,
|
||||
Val5a = 13,
|
||||
Val6a
|
||||
};
|
||||
|
||||
enum class Enum2 : short {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3 = 100,
|
||||
Val4
|
||||
Val3 = 23,
|
||||
Val4,
|
||||
Val5b = 23,
|
||||
Val6b
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -39,24 +41,24 @@ enum class Enum5; // Legal in C++11, because enum class declarati
|
|||
enum class Enum6 : unsigned int; // Legal C++11.
|
||||
|
||||
enum Enum4 : unsigned int {
|
||||
Val1, Val2, Val3 = 100, Val4
|
||||
Val1, Val2, Val3 = 43, Val4
|
||||
};
|
||||
|
||||
enum class Enum5 {
|
||||
Val1, Val2, Val3 = 100, Val4
|
||||
Val1, Val2, Val3 = 53, Val4
|
||||
};
|
||||
|
||||
enum class Enum6 : unsigned int {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 63, Val4
|
||||
};
|
||||
|
||||
typedef enum class Enum7 : unsigned int {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 73, Val4
|
||||
} Enum7td;
|
||||
|
||||
// enum inherits from non-primitive type
|
||||
enum class Enum8 : size_t {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 83, Val4
|
||||
};
|
||||
|
||||
template <typename T> struct TType {
|
||||
|
|
@ -64,7 +66,7 @@ template <typename T> struct TType {
|
|||
};
|
||||
|
||||
enum class Enum10 : TType<int>::type_name {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 103, Val4
|
||||
};
|
||||
|
||||
// forward declaration, no definition of enum
|
||||
|
|
@ -73,15 +75,144 @@ struct UseEnum11 {
|
|||
Enum11 myenum11;
|
||||
};
|
||||
|
||||
/*
|
||||
TODO
|
||||
enum class MyClass {AAA, BBB, CCC};
|
||||
namespace Space {
|
||||
enum MyEnum {XXX, YYY, ZZZ};
|
||||
}
|
||||
struct SSS {
|
||||
MyClass m;
|
||||
class Class1
|
||||
{
|
||||
public:
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 1121,
|
||||
Val2 = 1122,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5c = 1121,
|
||||
Val6c
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 1131,
|
||||
Val2 = 1132,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5d = 1131,
|
||||
Val6d
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 1141,
|
||||
Val2 = 1142,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5e = 1141,
|
||||
Val6e
|
||||
};
|
||||
|
||||
struct Struct1
|
||||
{
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 3121,
|
||||
Val2 = 3122,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5f = 3121,
|
||||
Val6f
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 3131,
|
||||
Val2 = 3132,
|
||||
Val3,
|
||||
Val4,
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 3141,
|
||||
Val2 = 3142,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5g = 3141,
|
||||
Val6g
|
||||
};
|
||||
};
|
||||
Enum1 class1Test1(Enum1 e) { return e; }
|
||||
Enum12 class1Test2(Enum12 e) { return e; }
|
||||
Struct1::Enum12 class1Test3(Struct1::Enum12 e) { return e; }
|
||||
};
|
||||
*/
|
||||
|
||||
class Class2
|
||||
{
|
||||
public:
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 2121,
|
||||
Val2 = 2122,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5h = 2121,
|
||||
Val6h
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 2131,
|
||||
Val2 = 2132,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5i = 2131,
|
||||
Val6i
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 2141,
|
||||
Val2 = 2142,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5j = 2141,
|
||||
Val6j
|
||||
};
|
||||
|
||||
struct Struct1
|
||||
{
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 4121,
|
||||
Val2 = 4122,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5k = 4121,
|
||||
Val6k
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 4131,
|
||||
Val2 = 4132,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5l = 4131,
|
||||
Val6l
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 4141,
|
||||
Val2 = 4142,
|
||||
Val3,
|
||||
Val4,
|
||||
Val5m = 4141,
|
||||
Val6m
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Enum1 globalTest1(Enum1 e) { return e; }
|
||||
Class1::Enum12 globalTest2(Class1::Enum12 e) { return e; }
|
||||
Class1::Struct1::Enum12 globalTest3(Class1::Struct1::Enum12 e) { return e; }
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
%module cpp11_strongly_typed_enumerations_simple
|
||||
|
||||
%include <enumsimple.swg>
|
||||
|
||||
%include "cpp11_strongly_typed_enumerations.i"
|
||||
|
|
@ -28,6 +28,9 @@ CPP_TEST_CASES = \
|
|||
intermediary_classname \
|
||||
li_boost_intrusive_ptr
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_strongly_typed_enumerations_simple \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
|
|
|
|||
|
|
@ -0,0 +1,169 @@
|
|||
using System;
|
||||
using cpp11_strongly_typed_enumerationsNamespace;
|
||||
|
||||
public class cpp11_strongly_typed_enumerations_runme {
|
||||
|
||||
public static int enumCheck(int actual, int expected) {
|
||||
if (actual != expected)
|
||||
throw new ApplicationException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
|
||||
return expected + 1;
|
||||
}
|
||||
|
||||
public static void Main() {
|
||||
int val = 0;
|
||||
val = enumCheck((int)Enum1.Val1, val);
|
||||
val = enumCheck((int)Enum1.Val2, val);
|
||||
val = enumCheck((int)Enum1.Val3, 13);
|
||||
val = enumCheck((int)Enum1.Val4, val);
|
||||
val = enumCheck((int)Enum1.Val5a, 13);
|
||||
val = enumCheck((int)Enum1.Val6a, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum2.Val1, val);
|
||||
val = enumCheck((int)Enum2.Val2, val);
|
||||
val = enumCheck((int)Enum2.Val3, 23);
|
||||
val = enumCheck((int)Enum2.Val4, val);
|
||||
val = enumCheck((int)Enum2.Val5b, 23);
|
||||
val = enumCheck((int)Enum2.Val6b, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum4.Val1, val);
|
||||
val = enumCheck((int)Enum4.Val2, val);
|
||||
val = enumCheck((int)Enum4.Val3, 43);
|
||||
val = enumCheck((int)Enum4.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum5.Val1, val);
|
||||
val = enumCheck((int)Enum5.Val2, val);
|
||||
val = enumCheck((int)Enum5.Val3, 53);
|
||||
val = enumCheck((int)Enum5.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum6.Val1, val);
|
||||
val = enumCheck((int)Enum6.Val2, val);
|
||||
val = enumCheck((int)Enum6.Val3, 63);
|
||||
val = enumCheck((int)Enum6.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum7td.Val1, val);
|
||||
val = enumCheck((int)Enum7td.Val2, val);
|
||||
val = enumCheck((int)Enum7td.Val3, 73);
|
||||
val = enumCheck((int)Enum7td.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum8.Val1, val);
|
||||
val = enumCheck((int)Enum8.Val2, val);
|
||||
val = enumCheck((int)Enum8.Val3, 83);
|
||||
val = enumCheck((int)Enum8.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Enum10.Val1, val);
|
||||
val = enumCheck((int)Enum10.Val2, val);
|
||||
val = enumCheck((int)Enum10.Val3, 103);
|
||||
val = enumCheck((int)Enum10.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class1.Enum12.Val1, 1121);
|
||||
val = enumCheck((int)Class1.Enum12.Val2, 1122);
|
||||
val = enumCheck((int)Class1.Enum12.Val3, val);
|
||||
val = enumCheck((int)Class1.Enum12.Val4, val);
|
||||
val = enumCheck((int)Class1.Enum12.Val5c, 1121);
|
||||
val = enumCheck((int)Class1.Enum12.Val6c, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class1.Enum13.Val1, 1131);
|
||||
val = enumCheck((int)Class1.Enum13.Val2, 1132);
|
||||
val = enumCheck((int)Class1.Enum13.Val3, val);
|
||||
val = enumCheck((int)Class1.Enum13.Val4, val);
|
||||
val = enumCheck((int)Class1.Enum13.Val5d, 1131);
|
||||
val = enumCheck((int)Class1.Enum13.Val6d, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class1.Enum14.Val1, 1141);
|
||||
val = enumCheck((int)Class1.Enum14.Val2, 1142);
|
||||
val = enumCheck((int)Class1.Enum14.Val3, val);
|
||||
val = enumCheck((int)Class1.Enum14.Val4, val);
|
||||
val = enumCheck((int)Class1.Enum14.Val5e, 1141);
|
||||
val = enumCheck((int)Class1.Enum14.Val6e, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class1.Struct1.Enum12.Val1, 3121);
|
||||
val = enumCheck((int)Class1.Struct1.Enum12.Val2, 3122);
|
||||
val = enumCheck((int)Class1.Struct1.Enum12.Val3, val);
|
||||
val = enumCheck((int)Class1.Struct1.Enum12.Val4, val);
|
||||
val = enumCheck((int)Class1.Struct1.Enum12.Val5f, 3121);
|
||||
val = enumCheck((int)Class1.Struct1.Enum12.Val6f, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class1.Struct1.Enum13.Val1, 3131);
|
||||
val = enumCheck((int)Class1.Struct1.Enum13.Val2, 3132);
|
||||
val = enumCheck((int)Class1.Struct1.Enum13.Val3, val);
|
||||
val = enumCheck((int)Class1.Struct1.Enum13.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class1.Struct1.Enum14.Val1, 3141);
|
||||
val = enumCheck((int)Class1.Struct1.Enum14.Val2, 3142);
|
||||
val = enumCheck((int)Class1.Struct1.Enum14.Val3, val);
|
||||
val = enumCheck((int)Class1.Struct1.Enum14.Val4, val);
|
||||
val = enumCheck((int)Class1.Struct1.Enum14.Val5g, 3141);
|
||||
val = enumCheck((int)Class1.Struct1.Enum14.Val6g, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class2.Enum12.Val1, 2121);
|
||||
val = enumCheck((int)Class2.Enum12.Val2, 2122);
|
||||
val = enumCheck((int)Class2.Enum12.Val3, val);
|
||||
val = enumCheck((int)Class2.Enum12.Val4, val);
|
||||
val = enumCheck((int)Class2.Enum12.Val5h, 2121);
|
||||
val = enumCheck((int)Class2.Enum12.Val6h, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class2.Enum13.Val1, 2131);
|
||||
val = enumCheck((int)Class2.Enum13.Val2, 2132);
|
||||
val = enumCheck((int)Class2.Enum13.Val3, val);
|
||||
val = enumCheck((int)Class2.Enum13.Val4, val);
|
||||
val = enumCheck((int)Class2.Enum13.Val5i, 2131);
|
||||
val = enumCheck((int)Class2.Enum13.Val6i, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class2.Enum14.Val1, 2141);
|
||||
val = enumCheck((int)Class2.Enum14.Val2, 2142);
|
||||
val = enumCheck((int)Class2.Enum14.Val3, val);
|
||||
val = enumCheck((int)Class2.Enum14.Val4, val);
|
||||
val = enumCheck((int)Class2.Enum14.Val5j, 2141);
|
||||
val = enumCheck((int)Class2.Enum14.Val6j, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class2.Struct1.Enum12.Val1, 4121);
|
||||
val = enumCheck((int)Class2.Struct1.Enum12.Val2, 4122);
|
||||
val = enumCheck((int)Class2.Struct1.Enum12.Val3, val);
|
||||
val = enumCheck((int)Class2.Struct1.Enum12.Val4, val);
|
||||
val = enumCheck((int)Class2.Struct1.Enum12.Val5k, 4121);
|
||||
val = enumCheck((int)Class2.Struct1.Enum12.Val6k, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class2.Struct1.Enum13.Val1, 4131);
|
||||
val = enumCheck((int)Class2.Struct1.Enum13.Val2, 4132);
|
||||
val = enumCheck((int)Class2.Struct1.Enum13.Val3, val);
|
||||
val = enumCheck((int)Class2.Struct1.Enum13.Val4, val);
|
||||
val = enumCheck((int)Class2.Struct1.Enum13.Val5l, 4131);
|
||||
val = enumCheck((int)Class2.Struct1.Enum13.Val6l, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck((int)Class2.Struct1.Enum14.Val1, 4141);
|
||||
val = enumCheck((int)Class2.Struct1.Enum14.Val2, 4142);
|
||||
val = enumCheck((int)Class2.Struct1.Enum14.Val3, val);
|
||||
val = enumCheck((int)Class2.Struct1.Enum14.Val4, val);
|
||||
val = enumCheck((int)Class2.Struct1.Enum14.Val5m, 4141);
|
||||
val = enumCheck((int)Class2.Struct1.Enum14.Val6m, val);
|
||||
|
||||
Class1 class1 = new Class1();
|
||||
enumCheck((int)class1.class1Test1(Enum1.Val5a), 13);
|
||||
enumCheck((int)class1.class1Test2(Class1.Enum12.Val5c), 1121);
|
||||
enumCheck((int)class1.class1Test3(Class1.Struct1.Enum12.Val5f), 3121);
|
||||
|
||||
enumCheck((int)cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a), 13);
|
||||
enumCheck((int)cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c), 1121);
|
||||
enumCheck((int)cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f), 3121);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5,8 +5,12 @@
|
|||
LANGUAGE = d
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
|
||||
ifeq (,$(D_VERSION))
|
||||
D_VERSION = @DDEFAULTVERSION@
|
||||
endif
|
||||
|
||||
ifeq (2,$(D_VERSION))
|
||||
VERSIONSUFFIX = .2
|
||||
|
|
@ -22,10 +26,9 @@ CPP_TEST_CASES = \
|
|||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Override some variables from common.mk:
|
||||
|
||||
# Overridden variables here
|
||||
SRCDIR = ../$(srcdir)/
|
||||
TARGETSUFFIX = _wrap
|
||||
|
||||
SWIGOPT+=-splitproxy -package $*
|
||||
|
||||
# Rules for the different types of tests
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ module li_boost_shared_ptr_runme;
|
|||
|
||||
import core.memory;
|
||||
import core.thread;
|
||||
import core.time;
|
||||
import std.conv;
|
||||
import std.exception;
|
||||
import std.stdio;
|
||||
|
|
@ -31,15 +32,6 @@ void main() {
|
|||
if (TRACE)
|
||||
writeln("---> NEARLY FINISHED <---");
|
||||
|
||||
// Try to get the GC to collect everything not referenced anymore.
|
||||
int countdown = 100;
|
||||
while (--countdown) {
|
||||
GC.collect();
|
||||
if (Klass.getTotal_count() == 1)
|
||||
break;
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
// A single remaining instance expected: the global variable (GlobalValue).
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new Exception("Klass.total_count=" ~ to!string(Klass.getTotal_count()));
|
||||
|
|
@ -55,9 +47,15 @@ void main() {
|
|||
}
|
||||
|
||||
void runTest() {
|
||||
// We want to check whether all the C++ Klass instances have been properly
|
||||
// destructed after the tests have run. However, as it is legal for the GC
|
||||
// to leave an object around even if it is unreachable, use deterministic
|
||||
// memory management here.
|
||||
import std.typecons : scoped;
|
||||
|
||||
// simple shared_ptr usage - created in C++
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
string val = k.getValue();
|
||||
verifyValue("me oh my", val);
|
||||
verifyCount(1, k);
|
||||
|
|
@ -73,7 +71,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = smartpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointertest", val);
|
||||
|
|
@ -83,7 +81,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr pointer
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = smartpointerpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointertest", val);
|
||||
|
|
@ -93,7 +91,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr reference
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = smartpointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerreftest", val);
|
||||
|
|
@ -103,7 +101,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr pointer reference
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = smartpointerpointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointerreftest", val);
|
||||
|
|
@ -113,7 +111,7 @@ void runTest() {
|
|||
|
||||
// const pass by shared_ptr
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = constsmartpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my", val);
|
||||
|
|
@ -123,7 +121,7 @@ void runTest() {
|
|||
|
||||
// const pass by shared_ptr pointer
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = constsmartpointerpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my", val);
|
||||
|
|
@ -133,7 +131,7 @@ void runTest() {
|
|||
|
||||
// const pass by shared_ptr reference
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = constsmartpointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my", val);
|
||||
|
|
@ -143,7 +141,7 @@ void runTest() {
|
|||
|
||||
// pass by value
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = valuetest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my valuetest", val);
|
||||
|
|
@ -153,7 +151,7 @@ void runTest() {
|
|||
|
||||
// pass by pointer
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = pointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my pointertest", val);
|
||||
|
|
@ -163,7 +161,7 @@ void runTest() {
|
|||
|
||||
// pass by reference
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = reftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my reftest", val);
|
||||
|
|
@ -173,7 +171,7 @@ void runTest() {
|
|||
|
||||
// pass by pointer reference
|
||||
{
|
||||
auto k = new Klass("me oh my");
|
||||
auto k = scoped!Klass("me oh my");
|
||||
auto kret = pointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my pointerreftest", val);
|
||||
|
|
@ -215,7 +213,7 @@ void runTest() {
|
|||
////////////////////////////////// Derived classes ////////////////////////////////////////
|
||||
// derived pass by shared_ptr
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = derivedsmartptrtest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrtest-Derived", val);
|
||||
|
|
@ -224,7 +222,7 @@ void runTest() {
|
|||
}
|
||||
// derived pass by shared_ptr pointer
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = derivedsmartptrpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
|
||||
|
|
@ -233,7 +231,7 @@ void runTest() {
|
|||
}
|
||||
// derived pass by shared_ptr ref
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = derivedsmartptrreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrreftest-Derived", val);
|
||||
|
|
@ -242,7 +240,7 @@ void runTest() {
|
|||
}
|
||||
// derived pass by shared_ptr pointer ref
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = derivedsmartptrpointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
|
||||
|
|
@ -251,7 +249,7 @@ void runTest() {
|
|||
}
|
||||
// derived pass by pointer
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = derivedpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my derivedpointertest-Derived", val);
|
||||
|
|
@ -260,7 +258,7 @@ void runTest() {
|
|||
}
|
||||
// derived pass by ref
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = derivedreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my derivedreftest-Derived", val);
|
||||
|
|
@ -271,7 +269,7 @@ void runTest() {
|
|||
////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
|
||||
// pass by shared_ptr (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = smartpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointertest-Derived", val);
|
||||
|
|
@ -281,7 +279,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr pointer (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = smartpointerpointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointertest-Derived", val);
|
||||
|
|
@ -291,7 +289,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr reference (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = smartpointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerreftest-Derived", val);
|
||||
|
|
@ -301,7 +299,7 @@ void runTest() {
|
|||
|
||||
// pass by shared_ptr pointer reference (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = smartpointerpointerreftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointerreftest-Derived", val);
|
||||
|
|
@ -311,7 +309,7 @@ void runTest() {
|
|||
|
||||
// pass by value (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = valuetest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my valuetest", val); // note slicing
|
||||
|
|
@ -321,7 +319,7 @@ void runTest() {
|
|||
|
||||
// pass by pointer (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = pointertest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my pointertest-Derived", val);
|
||||
|
|
@ -331,7 +329,7 @@ void runTest() {
|
|||
|
||||
// pass by ref (mixed)
|
||||
{
|
||||
auto k = new KlassDerived("me oh my");
|
||||
auto k = scoped!KlassDerived("me oh my");
|
||||
auto kret = reftest(k);
|
||||
string val = kret.getValue();
|
||||
verifyValue("me oh my reftest-Derived", val);
|
||||
|
|
@ -341,7 +339,7 @@ void runTest() {
|
|||
|
||||
// 3rd derived class
|
||||
{
|
||||
auto k = new Klass3rdDerived("me oh my");
|
||||
auto k = scoped!Klass3rdDerived("me oh my");
|
||||
string val = k.getValue();
|
||||
verifyValue("me oh my-3rdDerived", val);
|
||||
verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
|
||||
|
|
@ -353,128 +351,140 @@ void runTest() {
|
|||
////////////////////////////////// Member variables ////////////////////////////////////////
|
||||
// smart pointer by value
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto k = new Klass("smart member value");
|
||||
m.SmartMemberValue = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("smart member value", val);
|
||||
verifyCount(2, k);
|
||||
auto k = scoped!Klass("smart member value");
|
||||
Klass kmember;
|
||||
|
||||
auto kmember = m.SmartMemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member value", val);
|
||||
verifyCount(3, kmember);
|
||||
verifyCount(3, k);
|
||||
{
|
||||
auto m = scoped!MemberVariables();
|
||||
m.SmartMemberValue = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("smart member value", val);
|
||||
verifyCount(2, k);
|
||||
|
||||
delete m;
|
||||
kmember = m.SmartMemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member value", val);
|
||||
verifyCount(3, kmember);
|
||||
verifyCount(3, k);
|
||||
}
|
||||
|
||||
verifyCount(2, kmember);
|
||||
verifyCount(2, k);
|
||||
}
|
||||
// smart pointer by pointer
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto k = new Klass("smart member pointer");
|
||||
m.SmartMemberPointer = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("smart member pointer", val);
|
||||
verifyCount(1, k);
|
||||
auto k = scoped!Klass("smart member pointer");
|
||||
Klass kmember;
|
||||
|
||||
auto kmember = m.SmartMemberPointer;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member pointer", val);
|
||||
verifyCount(2, kmember);
|
||||
verifyCount(2, k);
|
||||
{
|
||||
auto m = scoped!MemberVariables();
|
||||
m.SmartMemberPointer = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("smart member pointer", val);
|
||||
verifyCount(1, k);
|
||||
|
||||
delete m;
|
||||
kmember = m.SmartMemberPointer;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member pointer", val);
|
||||
verifyCount(2, kmember);
|
||||
verifyCount(2, k);
|
||||
}
|
||||
|
||||
verifyCount(2, kmember);
|
||||
verifyCount(2, k);
|
||||
}
|
||||
// smart pointer by reference
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto k = new Klass("smart member reference");
|
||||
m.SmartMemberReference = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("smart member reference", val);
|
||||
verifyCount(2, k);
|
||||
auto k = scoped!Klass("smart member reference");
|
||||
Klass kmember;
|
||||
|
||||
auto kmember = m.SmartMemberReference;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member reference", val);
|
||||
verifyCount(3, kmember);
|
||||
verifyCount(3, k);
|
||||
{
|
||||
auto m = scoped!MemberVariables();
|
||||
m.SmartMemberReference = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("smart member reference", val);
|
||||
verifyCount(2, k);
|
||||
|
||||
// The C++ reference refers to SmartMemberValue...
|
||||
auto kmemberVal = m.SmartMemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member reference", val);
|
||||
verifyCount(4, kmemberVal);
|
||||
verifyCount(4, kmember);
|
||||
verifyCount(4, k);
|
||||
kmember = m.SmartMemberReference;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member reference", val);
|
||||
verifyCount(3, kmember);
|
||||
verifyCount(3, k);
|
||||
|
||||
delete m;
|
||||
// The C++ reference refers to SmartMemberValue...
|
||||
auto kmemberVal = m.SmartMemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member reference", val);
|
||||
verifyCount(4, kmemberVal);
|
||||
verifyCount(4, kmember);
|
||||
verifyCount(4, k);
|
||||
}
|
||||
|
||||
verifyCount(3, kmember);
|
||||
verifyCount(3, k);
|
||||
}
|
||||
// plain by value
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto k = new Klass("plain member value");
|
||||
m.MemberValue = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("plain member value", val);
|
||||
verifyCount(1, k);
|
||||
auto k = scoped!Klass("plain member value");
|
||||
Klass kmember;
|
||||
|
||||
auto kmember = m.MemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member value", val);
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
{
|
||||
auto m = scoped!MemberVariables();
|
||||
m.MemberValue = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("plain member value", val);
|
||||
verifyCount(1, k);
|
||||
|
||||
delete m;
|
||||
kmember = m.MemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member value", val);
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
}
|
||||
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
}
|
||||
// plain by pointer
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto k = new Klass("plain member pointer");
|
||||
m.MemberPointer = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("plain member pointer", val);
|
||||
verifyCount(1, k);
|
||||
auto k = scoped!Klass("plain member pointer");
|
||||
Klass kmember;
|
||||
|
||||
auto kmember = m.MemberPointer;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member pointer", val);
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
{
|
||||
auto m = scoped!MemberVariables();
|
||||
m.MemberPointer = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("plain member pointer", val);
|
||||
verifyCount(1, k);
|
||||
|
||||
delete m;
|
||||
kmember = m.MemberPointer;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member pointer", val);
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
}
|
||||
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
}
|
||||
// plain by reference
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto k = new Klass("plain member reference");
|
||||
m.MemberReference = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("plain member reference", val);
|
||||
verifyCount(1, k);
|
||||
auto k = scoped!Klass("plain member reference");
|
||||
Klass kmember;
|
||||
|
||||
auto kmember = m.MemberReference;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member reference", val);
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
{
|
||||
auto m = scoped!MemberVariables();
|
||||
m.MemberReference = k;
|
||||
string val = k.getValue();
|
||||
verifyValue("plain member reference", val);
|
||||
verifyCount(1, k);
|
||||
|
||||
delete m;
|
||||
kmember = m.MemberReference;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member reference", val);
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
}
|
||||
|
||||
verifyCount(1, kmember);
|
||||
verifyCount(1, k);
|
||||
|
|
@ -482,7 +492,7 @@ void runTest() {
|
|||
|
||||
// null member variables
|
||||
{
|
||||
auto m = new MemberVariables();
|
||||
auto m = scoped!MemberVariables();
|
||||
|
||||
// shared_ptr by value
|
||||
auto k = m.SmartMemberValue;
|
||||
|
|
@ -504,7 +514,7 @@ void runTest() {
|
|||
auto kglobal = GlobalSmartValue;
|
||||
enforce(kglobal is null, "expected null");
|
||||
|
||||
auto k = new Klass("smart global value");
|
||||
auto k = scoped!Klass("smart global value");
|
||||
GlobalSmartValue = k;
|
||||
verifyCount(2, k);
|
||||
|
||||
|
|
@ -520,7 +530,7 @@ void runTest() {
|
|||
{
|
||||
Klass kglobal;
|
||||
|
||||
auto k = new Klass("global value");
|
||||
auto k = scoped!Klass("global value");
|
||||
GlobalValue = k;
|
||||
verifyCount(1, k);
|
||||
|
||||
|
|
@ -538,7 +548,7 @@ void runTest() {
|
|||
auto kglobal = GlobalPointer;
|
||||
enforce(kglobal is null, "expected null");
|
||||
|
||||
auto k = new Klass("global pointer");
|
||||
auto k = scoped!Klass("global pointer");
|
||||
GlobalPointer = k;
|
||||
verifyCount(1, k);
|
||||
|
||||
|
|
@ -553,7 +563,7 @@ void runTest() {
|
|||
{
|
||||
Klass kglobal;
|
||||
|
||||
auto k = new Klass("global reference");
|
||||
auto k = scoped!Klass("global reference");
|
||||
GlobalReference = k;
|
||||
verifyCount(1, k);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,27 @@
|
|||
%inline %{
|
||||
#include <string>
|
||||
|
||||
// All kinds of numbers: hex, octal (which pose special problems to Python), negative...
|
||||
void trickyvalue1(int first, int pos = -1) {}
|
||||
void trickyvalue2(int first, unsigned rgb = 0xabcdef) {}
|
||||
void trickyvalue3(int first, int mode = 0644) {}
|
||||
|
||||
void doublevalue1(int first, double num = 0.0e-1) {}
|
||||
void doublevalue2(int first, double num = -0.0E2) {}
|
||||
|
||||
// Long long arguments are not handled at Python level currently but still work.
|
||||
void seek(long long offset = 0LL) {}
|
||||
void seek2(unsigned long long offset = 0ULL) {}
|
||||
void seek3(long offset = 0L) {}
|
||||
void seek4(unsigned long offset = 0UL) {}
|
||||
void seek5(unsigned long offset = 0U) {}
|
||||
void seek6(unsigned long offset = 02U) {}
|
||||
void seek7(unsigned long offset = 00U) {}
|
||||
void seek8(unsigned long offset = 1U) {}
|
||||
void seek9(long offset = 1L) {}
|
||||
void seekA(long long offset = 1LL) {}
|
||||
void seekB(unsigned long long offset = 1ULL) {}
|
||||
|
||||
// Anonymous arguments
|
||||
int anonymous(int = 7771);
|
||||
int anonymous(int x) { return x; }
|
||||
|
|
@ -29,6 +50,12 @@
|
|||
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
|
||||
};
|
||||
|
||||
// using base class enum in a derived class
|
||||
class DerivedEnumClass : public EnumClass {
|
||||
public:
|
||||
void accelerate(speed s = SLOW) { }
|
||||
};
|
||||
|
||||
// casts
|
||||
const char * casts1(const char *m = (const char *) NULL) {
|
||||
char *ret = NULL;
|
||||
|
|
@ -199,6 +226,7 @@ namespace Space {
|
|||
struct Klass {
|
||||
int val;
|
||||
Klass(int val = -1) : val(val) {}
|
||||
static Klass inc(int n = 1, const Klass& k = Klass()) { return Klass(k.val + n); }
|
||||
};
|
||||
Klass constructorcall(const Klass& k = Klass()) { return k; }
|
||||
|
||||
|
|
|
|||
|
|
@ -168,5 +168,11 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
%inline %{
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ namespace ns
|
|||
class Example3
|
||||
{
|
||||
protected:
|
||||
/* the default constructor is always emitter, even when protected,
|
||||
/* the default constructor is always emitted, even when protected,
|
||||
having another public constructor, and 'dirprot' is not used.
|
||||
This is just for Java compatibility */
|
||||
Example3()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
%module(directors="1") director_exception
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) return_const_char_star;
|
||||
|
||||
%{
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
|
@ -106,7 +108,7 @@ Foo *launder(Foo *f) {
|
|||
%}
|
||||
|
||||
%feature("director") Bar;
|
||||
|
||||
%feature("director") ReturnAllTypes;
|
||||
|
||||
%inline %{
|
||||
struct Exception1
|
||||
|
|
@ -132,4 +134,28 @@ Foo *launder(Foo *f) {
|
|||
virtual std::string pang() throw () { return "Bar::pang()"; }
|
||||
};
|
||||
|
||||
// Class to allow regression testing SWIG/PHP not checking if an exception
|
||||
// had been thrown in directorout typemaps.
|
||||
class ReturnAllTypes
|
||||
{
|
||||
public:
|
||||
int call_int() { return return_int(); }
|
||||
double call_double() { return return_double(); }
|
||||
const char * call_const_char_star() { return return_const_char_star(); }
|
||||
std::string call_std_string() { return return_std_string(); }
|
||||
Bar call_Bar() { return return_Bar(); }
|
||||
|
||||
virtual int return_int() { return 0; }
|
||||
virtual double return_double() { return 0.0; }
|
||||
virtual const char * return_const_char_star() { return ""; }
|
||||
virtual std::string return_std_string() { return std::string(); }
|
||||
virtual Bar return_Bar() { return Bar(); }
|
||||
virtual ~ReturnAllTypes() {}
|
||||
};
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
// Checks if collisions of argument names with target language keywords are
|
||||
// resolved properly when directors are used (currently only »abstract« for
|
||||
// C#, D and Java is checked).
|
||||
// resolved properly when directors are used
|
||||
%module(directors="1") director_keywords
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD);
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
%inline %{
|
||||
struct Foo {
|
||||
virtual ~Foo() {}
|
||||
virtual void bar(int abstract) {}
|
||||
virtual void check_abstract(int abstract) {} // for Java, C#, D...
|
||||
virtual void check_self(int self) {} // self for Python
|
||||
virtual void check_from(int from) {} // for Python
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
25
Examples/test-suite/director_nested_class.i
Normal file
25
Examples/test-suite/director_nested_class.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%module(directors="1") director_nested_class
|
||||
|
||||
|
||||
%feature("director") DirectorOuter::DirectorInner;
|
||||
%feature("director") DirectorOuter::DirectorInner::DirectorInnerInner;
|
||||
|
||||
%inline %{
|
||||
struct DirectorOuter {
|
||||
struct DirectorInner {
|
||||
virtual ~DirectorInner() {}
|
||||
virtual int vmethod(int input) const = 0;
|
||||
struct DirectorInnerInner {
|
||||
DirectorInnerInner(DirectorInner *din = 0) {}
|
||||
virtual ~DirectorInnerInner() {}
|
||||
virtual int innervmethod(int input) const = 0;
|
||||
};
|
||||
};
|
||||
static int callMethod(const DirectorInner &di, int value) {
|
||||
return di.vmethod(value);
|
||||
}
|
||||
static int callInnerInnerMethod(const DirectorInner::DirectorInnerInner &di, int value) {
|
||||
return di.innervmethod(value);
|
||||
}
|
||||
};
|
||||
%}
|
||||
29
Examples/test-suite/director_nestedmodule.i
Normal file
29
Examples/test-suite/director_nestedmodule.i
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
%module(directors="1") "director::nestedmodule"
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "Foo::ping()"; }
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
|
||||
static Foo* get_self(Foo *slf) {return slf;}
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
|
||||
static Foo* get_self(Foo *slf);
|
||||
};
|
||||
151
Examples/test-suite/director_property.i
Normal file
151
Examples/test-suite/director_property.i
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
%module(directors="1") director_property
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
||||
class Foo {
|
||||
private:
|
||||
std::string a;
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "Foo::ping()"; }
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
virtual std::string getA() { return this->a; }
|
||||
virtual void setA(std::string a) { this->a = a; }
|
||||
|
||||
static Foo* get_self(Foo *slf) {return slf;}
|
||||
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
virtual std::string getA();
|
||||
virtual void setA(std::string a);
|
||||
|
||||
static Foo* get_self(Foo *slf);
|
||||
|
||||
};
|
||||
|
||||
%{
|
||||
#include <complex>
|
||||
%}
|
||||
%feature("director") A;
|
||||
|
||||
// basic renaming
|
||||
%rename(rg) A::gg;
|
||||
%feature("nodirector") hi::A1::gg;
|
||||
|
||||
%inline %{
|
||||
|
||||
struct A{
|
||||
A(std::complex<int> i, double d=0.0) {}
|
||||
A(int i, bool j=false) {}
|
||||
virtual ~A() {}
|
||||
|
||||
virtual int f(int i=0) {return i;}
|
||||
virtual int gg(int i=0) {return i;}
|
||||
};
|
||||
|
||||
namespace hi {
|
||||
|
||||
struct A1 : public A {
|
||||
A1(std::complex<int> 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;}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
%}
|
||||
|
||||
|
||||
%feature("director") MyClass;
|
||||
|
||||
%inline %{
|
||||
|
||||
typedef void VoidType;
|
||||
|
||||
struct Bar
|
||||
{
|
||||
int x;
|
||||
Bar(int _x = 0) : x(_x)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MyClass {
|
||||
public:
|
||||
MyClass(int a = 0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void method(VoidType *)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~MyClass()
|
||||
{
|
||||
}
|
||||
|
||||
virtual Bar vmethod(Bar b)
|
||||
{
|
||||
b.x += 13;
|
||||
return b;
|
||||
}
|
||||
|
||||
virtual Bar* pmethod(Bar *b)
|
||||
{
|
||||
b->x += 12;
|
||||
return b;
|
||||
}
|
||||
|
||||
Bar cmethod(const Bar &b)
|
||||
{
|
||||
return vmethod(b);
|
||||
}
|
||||
|
||||
static MyClass *get_self(MyClass *c)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
static Bar * call_pmethod(MyClass *myclass, Bar *b) {
|
||||
return myclass->pmethod(b);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class MyClassT {
|
||||
public:
|
||||
MyClassT(int a = 0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void method(VoidType *)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~MyClassT()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%template(MyClassT_i) MyClassT<int>;
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
|
||||
|
||||
// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code
|
||||
// %rename using regex can do the equivalent of these two renames, which was resulting in uncompilable code
|
||||
%rename(May) M_May;
|
||||
%rename(May) S_May;
|
||||
|
||||
|
|
|
|||
|
|
@ -277,6 +277,18 @@ OldNameStruct::doublenametag renameTest6(OldNameStruct::doublenametag e)
|
|||
OldNameStruct::singlename renameTest7(OldNameStruct::singlename e) { return e; }
|
||||
%}
|
||||
|
||||
%rename(Clash1_di1) Clash1::di1;
|
||||
%rename(Clash1_di2) Clash1::di2;
|
||||
%rename(Clash1_di3) Clash1::di3;
|
||||
%inline %{
|
||||
namespace Clash1 {
|
||||
enum DuplicateItems1 { di1, di2 = 10, di3 };
|
||||
}
|
||||
namespace Clash2 {
|
||||
enum DuplicateItems2 { di1, di2 = 10, di3 };
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct TreesClass {
|
||||
enum trees {oak, fir, pine };
|
||||
|
|
|
|||
4
Examples/test-suite/errors/.gitignore
vendored
Normal file
4
Examples/test-suite/errors/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*.newerr
|
||||
cpp_recursive_typedef.py
|
||||
cpp_shared_ptr.py
|
||||
xxx.py
|
||||
|
|
@ -1 +1 @@
|
|||
c_extra_rblock.i:5: Error: Syntax error in input(1).
|
||||
c_extra_rblock.i:5: Error: Syntax error. Extraneous '%}'
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
c_missing_semi.i:3: Error: Syntax error in input(1).
|
||||
c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
cpp_extra_brackets.i:5: Error: Syntax error in input(3).
|
||||
cpp_extra_brackets.i:5: Error: Unexpected ')'.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ comment */
|
|||
%constant int ddd=;
|
||||
|
||||
#define E1 1234
|
||||
#/*C comment*/define E2 1234
|
||||
// This case doesn't actually work, but appeared to before we gave an error
|
||||
// for unknown preprocessor directives.
|
||||
// #/*C comment*/define E2 1234
|
||||
#define E3 1234
|
||||
|
||||
%constant int eee=;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pp_constant.i:9: Warning 305: Bad constant value (ignored).
|
|||
pp_constant.i:15: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:23: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:29: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:35: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:42: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:46: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:49: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:37: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:44: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:48: Warning 305: Bad constant value (ignored).
|
||||
pp_constant.i:51: Warning 305: Bad constant value (ignored).
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
|
||||
pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
|
||||
pp_missing_endif.i:3: Error: Missing #endif for conditional starting here
|
||||
|
|
|
|||
7
Examples/test-suite/errors/pp_missing_endoffile.i
Normal file
7
Examples/test-suite/errors/pp_missing_endoffile.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module xxx
|
||||
/* %beginfile and %endoffile are internal directives inserted when %include is
|
||||
* used. Users should never use them directly, but test coverage for this
|
||||
* error message still seems useful to have.
|
||||
*/
|
||||
%includefile "dummy.i" %beginfile
|
||||
|
||||
1
Examples/test-suite/errors/pp_missing_endoffile.stderr
Normal file
1
Examples/test-suite/errors/pp_missing_endoffile.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here
|
||||
|
|
@ -1 +1 @@
|
|||
pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
|
||||
pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block
|
||||
|
|
|
|||
7
Examples/test-suite/errors/pp_unknowndirective.i
Normal file
7
Examples/test-suite/errors/pp_unknowndirective.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module xxx
|
||||
|
||||
/* This used to give the rather cryptic "Syntax error in input(1)." prior to
|
||||
* SWIG 3.0.4. This testcase checks that the improved message is actually
|
||||
* issued.
|
||||
*/
|
||||
%remane("typo") tyop;
|
||||
1
Examples/test-suite/errors/pp_unknowndirective.stderr
Normal file
1
Examples/test-suite/errors/pp_unknowndirective.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
|
||||
11
Examples/test-suite/errors/pp_unknowndirective2.i
Normal file
11
Examples/test-suite/errors/pp_unknowndirective2.i
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
%module xxx
|
||||
|
||||
#ifdef FOO
|
||||
long long i;
|
||||
/* Check we get an error for an unknown directive (this should be #elif).
|
||||
* Unknown directives were silently ignored by SWIG < 3.0.3. */
|
||||
#elsif defined(BAR)
|
||||
long i;
|
||||
#else
|
||||
int i;
|
||||
#endif
|
||||
1
Examples/test-suite/errors/pp_unknowndirective2.stderr
Normal file
1
Examples/test-suite/errors/pp_unknowndirective2.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
pp_unknowndirective2.i:7: Error: Unknown SWIG preprocessor directive: elsif (if this is a block of target language code, delimit it with %{ and %})
|
||||
|
|
@ -1 +1 @@
|
|||
pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
|
||||
pp_unterm_char.i:4: Error: Unterminated character constant
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
|
||||
pp_unterm_comment.i:3: Error: Unterminated comment
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
|
||||
pp_unterm_string.i:4: Error: Unterminated string constant
|
||||
|
|
|
|||
5
Examples/test-suite/errors/pp_unterminated_block.i
Normal file
5
Examples/test-suite/errors/pp_unterminated_block.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%module xxx
|
||||
|
||||
%{
|
||||
int foo(int x);
|
||||
|
||||
1
Examples/test-suite/errors/pp_unterminated_block.stderr
Normal file
1
Examples/test-suite/errors/pp_unterminated_block.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
pp_unterminated_block.i:3: Error: Unterminated %{ ... %} block
|
||||
|
|
@ -125,6 +125,13 @@
|
|||
}
|
||||
};
|
||||
int A::sfoovar = 1;
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
%template(ET_i) ET<int>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
%module exception_partial_info
|
||||
|
||||
// This produced compileable code for Tcl, Python in 1.3.27, fails in 1.3.29
|
||||
// This produced compilable code for Tcl, Python in 1.3.27, fails in 1.3.29
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ struct OverAfter {
|
|||
// %extend overrides the class definition
|
||||
%extend Override {
|
||||
int over(int a) { return a*a; } // SWIG should give a warning then choose this one over the real one
|
||||
int overload(int a) { return a*a; } // Similarly, but this one generated uncompileable code in SWIG-1.3.22
|
||||
int overload(int a) { return a*a; } // Similarly, but this one generated uncompilable code in SWIG-1.3.22
|
||||
}
|
||||
%inline %{
|
||||
struct Override {
|
||||
|
|
|
|||
|
|
@ -19,3 +19,19 @@
|
|||
struct ForExtension {
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
template <class T> class ExtendTemplate {};
|
||||
}
|
||||
%}
|
||||
|
||||
%extend Space::ExtendTemplate
|
||||
{
|
||||
void extending() {
|
||||
$parentclassname tmp;
|
||||
(void)tmp;
|
||||
}
|
||||
}
|
||||
|
||||
%template(ExtendTemplateInt) Space::ExtendTemplate<int>;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ srcdir = @srcdir@
|
|||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
go_inout \
|
||||
go_director_inout
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
.SUFFIXES: .cpptest .ctest .multicpptest
|
||||
|
|
|
|||
41
Examples/test-suite/go/argout_runme.go
Normal file
41
Examples/test-suite/go/argout_runme.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package main
|
||||
|
||||
import wrap "./argout"
|
||||
|
||||
func main() {
|
||||
ip := wrap.New_intp()
|
||||
wrap.Intp_assign(ip, 42)
|
||||
if r := wrap.Incp(ip); r != 42 {
|
||||
panic(r)
|
||||
}
|
||||
if r := wrap.Intp_value(ip); r != 43 {
|
||||
panic(r)
|
||||
}
|
||||
|
||||
p := wrap.New_intp()
|
||||
wrap.Intp_assign(p, 2)
|
||||
if r := wrap.Incp(p); r != 2 {
|
||||
panic(r)
|
||||
}
|
||||
if r := wrap.Intp_value(p); r != 3 {
|
||||
panic(r)
|
||||
}
|
||||
|
||||
r := wrap.New_intp()
|
||||
wrap.Intp_assign(r, 7)
|
||||
if r := wrap.Incr(r); r != 7 {
|
||||
panic(r)
|
||||
}
|
||||
if r := wrap.Intp_value(r); r != 8 {
|
||||
panic(r)
|
||||
}
|
||||
|
||||
tr := wrap.New_intp()
|
||||
wrap.Intp_assign(tr, 4)
|
||||
if r := wrap.Inctr(tr); r != 4 {
|
||||
panic(r)
|
||||
}
|
||||
if r := wrap.Intp_value(tr); r != 5 {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import . "./cpp11_strongly_typed_enumerations"
|
||||
|
||||
func enumCheck(actual int, expected int) int {
|
||||
if actual != expected {
|
||||
panic(fmt.Sprintf("Enum value mismatch. Expected: %d Actual: %d", expected, actual))
|
||||
}
|
||||
return expected + 1
|
||||
}
|
||||
|
||||
func main() {
|
||||
var val = 0
|
||||
val = enumCheck(int(Enum1_Val1), val)
|
||||
val = enumCheck(int(Enum1_Val2), val)
|
||||
val = enumCheck(int(Enum1_Val3), 13)
|
||||
val = enumCheck(int(Enum1_Val4), val)
|
||||
val = enumCheck(int(Enum1_Val5a), 13)
|
||||
val = enumCheck(int(Enum1_Val6a), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Enum2_Val1), val)
|
||||
val = enumCheck(int(Enum2_Val2), val)
|
||||
val = enumCheck(int(Enum2_Val3), 23)
|
||||
val = enumCheck(int(Enum2_Val4), val)
|
||||
val = enumCheck(int(Enum2_Val5b), 23)
|
||||
val = enumCheck(int(Enum2_Val6b), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Val1), val)
|
||||
val = enumCheck(int(Val2), val)
|
||||
val = enumCheck(int(Val3), 43)
|
||||
val = enumCheck(int(Val4), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Enum5_Val1), val)
|
||||
val = enumCheck(int(Enum5_Val2), val)
|
||||
val = enumCheck(int(Enum5_Val3), 53)
|
||||
val = enumCheck(int(Enum5_Val4), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Enum6_Val1), val)
|
||||
val = enumCheck(int(Enum6_Val2), val)
|
||||
val = enumCheck(int(Enum6_Val3), 63)
|
||||
val = enumCheck(int(Enum6_Val4), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Enum7td_Val1), val)
|
||||
val = enumCheck(int(Enum7td_Val2), val)
|
||||
val = enumCheck(int(Enum7td_Val3), 73)
|
||||
val = enumCheck(int(Enum7td_Val4), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Enum8_Val1), val)
|
||||
val = enumCheck(int(Enum8_Val2), val)
|
||||
val = enumCheck(int(Enum8_Val3), 83)
|
||||
val = enumCheck(int(Enum8_Val4), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Enum10_Val1), val)
|
||||
val = enumCheck(int(Enum10_Val2), val)
|
||||
val = enumCheck(int(Enum10_Val3), 103)
|
||||
val = enumCheck(int(Enum10_Val4), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Class1Enum12_Val1), 1121)
|
||||
val = enumCheck(int(Class1Enum12_Val2), 1122)
|
||||
val = enumCheck(int(Class1Enum12_Val3), val)
|
||||
val = enumCheck(int(Class1Enum12_Val4), val)
|
||||
val = enumCheck(int(Class1Enum12_Val5c), 1121)
|
||||
val = enumCheck(int(Class1Enum12_Val6c), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Class1Val1), 1131)
|
||||
val = enumCheck(int(Class1Val2), 1132)
|
||||
val = enumCheck(int(Class1Val3), val)
|
||||
val = enumCheck(int(Class1Val4), val)
|
||||
val = enumCheck(int(Class1Val5d), 1131)
|
||||
val = enumCheck(int(Class1Val6d), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Class1Enum14_Val1), 1141)
|
||||
val = enumCheck(int(Class1Enum14_Val2), 1142)
|
||||
val = enumCheck(int(Class1Enum14_Val3), val)
|
||||
val = enumCheck(int(Class1Enum14_Val4), val)
|
||||
val = enumCheck(int(Class1Enum14_Val5e), 1141)
|
||||
val = enumCheck(int(Class1Enum14_Val6e), val)
|
||||
|
||||
// Requires nested class support to work
|
||||
//val = 0
|
||||
//val = enumCheck(int(Class1Struct1Enum12_Val1), 3121)
|
||||
//val = enumCheck(int(Class1Struct1Enum12_Val2), 3122)
|
||||
//val = enumCheck(int(Class1Struct1Enum12_Val3), val)
|
||||
//val = enumCheck(int(Class1Struct1Enum12_Val4), val)
|
||||
//val = enumCheck(int(Class1Struct1Enum12_Val5f), 3121)
|
||||
//val = enumCheck(int(Class1Struct1Enum12_Val6f), val)
|
||||
//
|
||||
//val = 0
|
||||
//val = enumCheck(int(Class1Struct1Val1), 3131)
|
||||
//val = enumCheck(int(Class1Struct1Val2), 3132)
|
||||
//val = enumCheck(int(Class1Struct1Val3), val)
|
||||
//val = enumCheck(int(Class1Struct1Val4), val)
|
||||
//
|
||||
//val = 0
|
||||
//val = enumCheck(int(Class1Struct1Enum14_Val1), 3141)
|
||||
//val = enumCheck(int(Class1Struct1Enum14_Val2), 3142)
|
||||
//val = enumCheck(int(Class1Struct1Enum14_Val3), val)
|
||||
//val = enumCheck(int(Class1Struct1Enum14_Val4), val)
|
||||
//val = enumCheck(int(Class1Struct1Enum14_Val5g), 3141)
|
||||
//val = enumCheck(int(Class1Struct1Enum14_Val6g), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Class2Enum12_Val1), 2121)
|
||||
val = enumCheck(int(Class2Enum12_Val2), 2122)
|
||||
val = enumCheck(int(Class2Enum12_Val3), val)
|
||||
val = enumCheck(int(Class2Enum12_Val4), val)
|
||||
val = enumCheck(int(Class2Enum12_Val5h), 2121)
|
||||
val = enumCheck(int(Class2Enum12_Val6h), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Class2Val1), 2131)
|
||||
val = enumCheck(int(Class2Val2), 2132)
|
||||
val = enumCheck(int(Class2Val3), val)
|
||||
val = enumCheck(int(Class2Val4), val)
|
||||
val = enumCheck(int(Class2Val5i), 2131)
|
||||
val = enumCheck(int(Class2Val6i), val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(int(Class2Enum14_Val1), 2141)
|
||||
val = enumCheck(int(Class2Enum14_Val2), 2142)
|
||||
val = enumCheck(int(Class2Enum14_Val3), val)
|
||||
val = enumCheck(int(Class2Enum14_Val4), val)
|
||||
val = enumCheck(int(Class2Enum14_Val5j), 2141)
|
||||
val = enumCheck(int(Class2Enum14_Val6j), val)
|
||||
|
||||
// Requires nested class support to work
|
||||
//val = 0
|
||||
//val = enumCheck(int(Class2Struct1Enum12_Val1), 4121)
|
||||
//val = enumCheck(int(Class2Struct1Enum12_Val2), 4122)
|
||||
//val = enumCheck(int(Class2Struct1Enum12_Val3), val)
|
||||
//val = enumCheck(int(Class2Struct1Enum12_Val4), val)
|
||||
//val = enumCheck(int(Class2Struct1Enum12_Val5k), 4121)
|
||||
//val = enumCheck(int(Class2Struct1Enum12_Val6k), val)
|
||||
//
|
||||
//val = 0
|
||||
//val = enumCheck(int(Class2Struct1Val1), 4131)
|
||||
//val = enumCheck(int(Class2Struct1Val2), 4132)
|
||||
//val = enumCheck(int(Class2Struct1Val3), val)
|
||||
//val = enumCheck(int(Class2Struct1Val4), val)
|
||||
//val = enumCheck(int(Class2Struct1Val5l), 4131)
|
||||
//val = enumCheck(int(Class2Struct1Val6l), val)
|
||||
//
|
||||
//val = 0
|
||||
//val = enumCheck(int(Class2Struct1Enum14_Val1), 4141)
|
||||
//val = enumCheck(int(Class2Struct1Enum14_Val2), 4142)
|
||||
//val = enumCheck(int(Class2Struct1Enum14_Val3), val)
|
||||
//val = enumCheck(int(Class2Struct1Enum14_Val4), val)
|
||||
//val = enumCheck(int(Class2Struct1Enum14_Val5m), 4141)
|
||||
//val = enumCheck(int(Class2Struct1Enum14_Val6m), val)
|
||||
|
||||
class1 := NewClass1()
|
||||
enumCheck(int(class1.Class1Test1(Enum1_Val5a)), 13)
|
||||
enumCheck(int(class1.Class1Test2(Class1Enum12_Val5c)), 1121)
|
||||
//enumCheck(int(class1.Class1Test3(Class1Struct1Enum12_Val5f)), 3121)
|
||||
|
||||
enumCheck(int(GlobalTest1(Enum1_Val5a)), 13)
|
||||
enumCheck(int(GlobalTest2(Class1Enum12_Val5c)), 1121)
|
||||
//enumCheck(int(GlobalTest3(Class1Struct1Enum12_Val5f)), 3121)
|
||||
|
||||
}
|
||||
32
Examples/test-suite/go/go_director_inout_runme.go
Normal file
32
Examples/test-suite/go/go_director_inout_runme.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
wrap "./go_director_inout"
|
||||
)
|
||||
|
||||
type GoMyClass struct {}
|
||||
|
||||
func (p *GoMyClass) Adjust(m map[string]interface{}) wrap.GoRetStruct {
|
||||
s := ""
|
||||
for k, v := range m {
|
||||
s += k + "," + v.(string) + ";"
|
||||
}
|
||||
return wrap.GoRetStruct{s}
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := wrap.NewDirectorMyClass(&GoMyClass{})
|
||||
m := map[string]interface{}{
|
||||
"first": "second",
|
||||
}
|
||||
s := a.Adjust(m)
|
||||
if s.Str != "first,second;" {
|
||||
panic(s)
|
||||
}
|
||||
|
||||
a = wrap.NewDirectorMyClass(nil)
|
||||
s = a.Adjust(m)
|
||||
if s.Str != `{"first":"second"}` {
|
||||
panic(s.Str)
|
||||
}
|
||||
}
|
||||
43
Examples/test-suite/go/go_inout_runme.go
Normal file
43
Examples/test-suite/go/go_inout_runme.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"./go_inout"
|
||||
)
|
||||
|
||||
type S struct {
|
||||
A int
|
||||
B string
|
||||
C float64
|
||||
}
|
||||
|
||||
func (p *S) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(*p)
|
||||
}
|
||||
|
||||
func main() {
|
||||
v := &S{12, "hi", 34.5}
|
||||
m := go_inout.Same(v)
|
||||
want := map[string]interface{}{
|
||||
// The type of A changes from int to float64 because
|
||||
// JSON has no ints.
|
||||
"A": float64(12),
|
||||
"B": "hi",
|
||||
"C": 34.5,
|
||||
}
|
||||
if !reflect.DeepEqual(m, want) {
|
||||
fmt.Println("got", m, "want", want)
|
||||
panic(m)
|
||||
}
|
||||
|
||||
a := []string{"a", "bc", "def"}
|
||||
go_inout.DoubleArray(&a)
|
||||
dwant := []string{"a", "bc", "def", "aa", "bcbc", "defdef"}
|
||||
if !reflect.DeepEqual(a, dwant) {
|
||||
fmt.Println("got", a, "want", dwant)
|
||||
panic(a)
|
||||
}
|
||||
}
|
||||
11
Examples/test-suite/go/overload_polymorphic_runme.go
Normal file
11
Examples/test-suite/go/overload_polymorphic_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./overload_polymorphic"
|
||||
|
||||
func main(){
|
||||
t := overload_polymorphic.NewDerived()
|
||||
|
||||
if overload_polymorphic.Test(t) != 0 {
|
||||
panic("failed")
|
||||
}
|
||||
}
|
||||
121
Examples/test-suite/go_director_inout.i
Normal file
121
Examples/test-suite/go_director_inout.i
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
// Test the goin and goout typemaps for directors.
|
||||
|
||||
%module(directors="1") go_director_inout
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
%inline
|
||||
%{
|
||||
|
||||
struct MyStruct {
|
||||
std::string str;
|
||||
};
|
||||
|
||||
struct RetStruct {
|
||||
std::string str;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%go_import("encoding/json")
|
||||
|
||||
%insert(go_header)
|
||||
%{
|
||||
|
||||
type GoRetStruct struct {
|
||||
Str string
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%typemap(gotype) RetStruct "GoRetStruct"
|
||||
|
||||
%typemap(imtype) RetStruct "string"
|
||||
|
||||
%typemap(goin) RetStruct
|
||||
%{
|
||||
$result = $input.Str
|
||||
%}
|
||||
|
||||
%typemap(in) RetStruct
|
||||
%{
|
||||
$result.str.assign($input.p, $input.n);
|
||||
%}
|
||||
|
||||
%typemap(out) RetStruct
|
||||
%{
|
||||
$result = _swig_makegostring($1.str.data(), $1.str.length());
|
||||
%}
|
||||
|
||||
%typemap(goout) RetStruct
|
||||
%{
|
||||
$result = GoRetStruct{Str: $input}
|
||||
%}
|
||||
|
||||
%typemap(godirectorout) RetStruct
|
||||
%{
|
||||
$result = $input.Str
|
||||
%}
|
||||
|
||||
%typemap(directorout) RetStruct
|
||||
%{
|
||||
$result.str.assign($input.p, $input.n);
|
||||
%}
|
||||
|
||||
%typemap(godirectorin) RetStruct
|
||||
%{
|
||||
%}
|
||||
|
||||
%typemap(gotype) MyStruct "map[string]interface{}"
|
||||
|
||||
%typemap(imtype) MyStruct "string"
|
||||
|
||||
%typemap(goin) MyStruct
|
||||
%{
|
||||
if b, err := json.Marshal($input); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
$result = string(b)
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorin) MyStruct
|
||||
%{
|
||||
$input = _swig_makegostring($1.str.data(), $1.str.length());
|
||||
%}
|
||||
|
||||
%typemap(out) MyStruct
|
||||
%{
|
||||
$result = _swig_makegostring($1.str.data(), $1.str.length());
|
||||
%}
|
||||
|
||||
%typemap(godirectorin) MyStruct
|
||||
%{
|
||||
if err := json.Unmarshal([]byte($input), &$result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) MyStruct
|
||||
%{
|
||||
$1.str.assign($input.p, $input.n);
|
||||
%}
|
||||
|
||||
%feature("director") MyClass;
|
||||
|
||||
%inline
|
||||
%{
|
||||
|
||||
class MyClass {
|
||||
public:
|
||||
virtual ~MyClass() {}
|
||||
virtual RetStruct Adjust(MyStruct s) {
|
||||
RetStruct r;
|
||||
r.str = s.str;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
199
Examples/test-suite/go_inout.i
Normal file
199
Examples/test-suite/go_inout.i
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
// Test the goin, goout, and goargout typemaps.
|
||||
|
||||
%module go_inout
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
%}
|
||||
|
||||
%inline
|
||||
%{
|
||||
|
||||
struct MyStruct {
|
||||
std::string str;
|
||||
};
|
||||
|
||||
struct RetStruct {
|
||||
std::string str;
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
// Write a typemap that calls C++ by converting in and out of JSON.
|
||||
|
||||
%go_import("encoding/json", "bytes", "encoding/binary")
|
||||
|
||||
%insert(go_header)
|
||||
%{
|
||||
|
||||
type In json.Marshaler
|
||||
|
||||
%}
|
||||
|
||||
%typemap(gotype) MyStruct "In"
|
||||
|
||||
%typemap(imtype) MyStruct "string"
|
||||
|
||||
%typemap(goin) MyStruct
|
||||
%{
|
||||
{
|
||||
b, err := $input.MarshalJSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
$result = string(b)
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) MyStruct
|
||||
%{
|
||||
$1.str.assign($input.p, $input.n);
|
||||
%}
|
||||
|
||||
%typemap(gotype) RetStruct "map[string]interface{}"
|
||||
|
||||
%typemap(imtype) RetStruct "string"
|
||||
|
||||
%typemap(out) RetStruct
|
||||
%{
|
||||
$result = _swig_makegostring($1.str.data(), $1.str.length());
|
||||
%}
|
||||
|
||||
%typemap(goout) RetStruct
|
||||
%{
|
||||
if err := json.Unmarshal([]byte($1), &$result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
%}
|
||||
|
||||
%inline
|
||||
%{
|
||||
|
||||
RetStruct Same(MyStruct s)
|
||||
{
|
||||
RetStruct r;
|
||||
r.str = s.str;
|
||||
return r;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%inline
|
||||
%{
|
||||
|
||||
struct MyArray {
|
||||
std::vector<std::string> strings;
|
||||
};
|
||||
|
||||
static uint64_t getuint64(const char* s) {
|
||||
uint64_t ret = 0;
|
||||
for (int i = 0; i < 8; i++, s++) {
|
||||
ret |= static_cast<uint64_t>(*s) << i * 8;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void putuint64(std::string *s, size_t off, uint64_t v) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
(*s)[off + i] = (v >> (i * 8)) & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%typemap(gotype) MyArray* "*[]string"
|
||||
|
||||
%typemap(imtype) MyArray* "*string"
|
||||
|
||||
// Encode the slice as a single string, with length prefixes.
|
||||
%typemap(goin) MyArray*
|
||||
%{
|
||||
{
|
||||
var buf bytes.Buffer
|
||||
bin := binary.LittleEndian
|
||||
var b [8]byte
|
||||
bin.PutUint64(b[:], uint64(len(*$input)))
|
||||
buf.Write(b[:])
|
||||
for _, s := range *$input {
|
||||
bin.PutUint64(b[:], uint64(len(s)))
|
||||
buf.Write(b[:])
|
||||
buf.WriteString(s)
|
||||
}
|
||||
str := buf.String()
|
||||
$result = &str
|
||||
}
|
||||
%}
|
||||
|
||||
// Unpack the string holding the packed slice.
|
||||
%typemap(in) MyArray* (MyArray t)
|
||||
%{
|
||||
{
|
||||
_gostring_ *s = $input;
|
||||
const char *p = static_cast<const char *>(s->p);
|
||||
uint64_t len = getuint64(p);
|
||||
p += 8;
|
||||
t.strings.resize(len);
|
||||
for (uint64_t i = 0; i < len; i++) {
|
||||
uint64_t slen = getuint64(p);
|
||||
p += 8;
|
||||
t.strings[i].assign(p, slen);
|
||||
p += slen;
|
||||
}
|
||||
$1 = &t;
|
||||
}
|
||||
%}
|
||||
|
||||
// Pack the vector into a string.
|
||||
%typemap(argout) MyArray*
|
||||
%{
|
||||
{
|
||||
size_t tot = 8;
|
||||
std::vector<std::string>::const_iterator p;
|
||||
for (p = $1->strings.begin(); p != $1->strings.end(); ++p) {
|
||||
tot += 8 + p->size();
|
||||
}
|
||||
std::string str;
|
||||
str.resize(tot);
|
||||
putuint64(&str, 0, $1->strings.size());
|
||||
size_t off = 8;
|
||||
for (p = $1->strings.begin(); p != $1->strings.end(); ++p) {
|
||||
putuint64(&str, off, p->size());
|
||||
off += 8;
|
||||
str.replace(off, p->size(), *p);
|
||||
off += p->size();
|
||||
}
|
||||
*$input = _swig_makegostring(str.data(), str.size());
|
||||
}
|
||||
%}
|
||||
|
||||
// Unpack the string into a []string.
|
||||
%typemap(goargout) MyArray*
|
||||
%{
|
||||
{
|
||||
str := *$input
|
||||
bin := binary.LittleEndian
|
||||
size := bin.Uint64([]byte(str[:8]))
|
||||
str = str[8:]
|
||||
r := make([]string, size)
|
||||
for i := range r {
|
||||
len := bin.Uint64([]byte(str[:8]))
|
||||
str = str[8:]
|
||||
r[i] = str[:len]
|
||||
str = str[len:]
|
||||
}
|
||||
*$1 = r
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%inline
|
||||
%{
|
||||
void DoubleArray(MyArray* v) {
|
||||
size_t size = v->strings.size();
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
v->strings.push_back(v->strings[i] + v->strings[i]);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
%import "import_nomodule.h"
|
||||
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD)
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGPYTHON_BUILTIN)
|
||||
|
||||
/**
|
||||
* The proxy class does not have Bar derived from Foo, yet an instance of Bar
|
||||
|
|
@ -40,3 +40,10 @@ class Bar : public Foo { };
|
|||
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ CPP_TEST_CASES = \
|
|||
java_typemaps_typewrapper
|
||||
# li_boost_intrusive_ptr
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_strongly_typed_enumerations_simple \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
|
|
|
|||
22
Examples/test-suite/java/constant_directive_runme.java
Normal file
22
Examples/test-suite/java/constant_directive_runme.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import constant_directive.*;
|
||||
|
||||
public class constant_directive_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("constant_directive");
|
||||
} 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 (constant_directive.TYPE1_CONSTANT1.getVal() != 1)
|
||||
throw new RuntimeException("fail");
|
||||
if (constant_directive.TYPE1_CONSTANT2.getVal() != 2)
|
||||
throw new RuntimeException("fail");
|
||||
if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
|
||||
throw new RuntimeException("fail");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
import cpp11_strongly_typed_enumerations.*;
|
||||
|
||||
public class cpp11_strongly_typed_enumerations_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_strongly_typed_enumerations");
|
||||
} 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 int enumCheck(int actual, int expected) {
|
||||
if (actual != expected)
|
||||
throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
|
||||
return expected + 1;
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
int val = 0;
|
||||
val = enumCheck(Enum1.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum1.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum1.Val3.swigValue(), 13);
|
||||
val = enumCheck(Enum1.Val4.swigValue(), val);
|
||||
val = enumCheck(Enum1.Val5a.swigValue(), 13);
|
||||
val = enumCheck(Enum1.Val6a.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum2.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum2.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum2.Val3.swigValue(), 23);
|
||||
val = enumCheck(Enum2.Val4.swigValue(), val);
|
||||
val = enumCheck(Enum2.Val5b.swigValue(), 23);
|
||||
val = enumCheck(Enum2.Val6b.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum4.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum4.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum4.Val3.swigValue(), 43);
|
||||
val = enumCheck(Enum4.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum5.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum5.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum5.Val3.swigValue(), 53);
|
||||
val = enumCheck(Enum5.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum6.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum6.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum6.Val3.swigValue(), 63);
|
||||
val = enumCheck(Enum6.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum7td.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum7td.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum7td.Val3.swigValue(), 73);
|
||||
val = enumCheck(Enum7td.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum8.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum8.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum8.Val3.swigValue(), 83);
|
||||
val = enumCheck(Enum8.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Enum10.Val1.swigValue(), val);
|
||||
val = enumCheck(Enum10.Val2.swigValue(), val);
|
||||
val = enumCheck(Enum10.Val3.swigValue(), 103);
|
||||
val = enumCheck(Enum10.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Enum12.Val1.swigValue(), 1121);
|
||||
val = enumCheck(Class1.Enum12.Val2.swigValue(), 1122);
|
||||
val = enumCheck(Class1.Enum12.Val3.swigValue(), val);
|
||||
val = enumCheck(Class1.Enum12.Val4.swigValue(), val);
|
||||
val = enumCheck(Class1.Enum12.Val5c.swigValue(), 1121);
|
||||
val = enumCheck(Class1.Enum12.Val6c.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Enum13.Val1.swigValue(), 1131);
|
||||
val = enumCheck(Class1.Enum13.Val2.swigValue(), 1132);
|
||||
val = enumCheck(Class1.Enum13.Val3.swigValue(), val);
|
||||
val = enumCheck(Class1.Enum13.Val4.swigValue(), val);
|
||||
val = enumCheck(Class1.Enum13.Val5d.swigValue(), 1131);
|
||||
val = enumCheck(Class1.Enum13.Val6d.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Enum14.Val1.swigValue(), 1141);
|
||||
val = enumCheck(Class1.Enum14.Val2.swigValue(), 1142);
|
||||
val = enumCheck(Class1.Enum14.Val3.swigValue(), val);
|
||||
val = enumCheck(Class1.Enum14.Val4.swigValue(), val);
|
||||
val = enumCheck(Class1.Enum14.Val5e.swigValue(), 1141);
|
||||
val = enumCheck(Class1.Enum14.Val6e.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Struct1.Enum12.Val1.swigValue(), 3121);
|
||||
val = enumCheck(Class1.Struct1.Enum12.Val2.swigValue(), 3122);
|
||||
val = enumCheck(Class1.Struct1.Enum12.Val3.swigValue(), val);
|
||||
val = enumCheck(Class1.Struct1.Enum12.Val4.swigValue(), val);
|
||||
val = enumCheck(Class1.Struct1.Enum12.Val5f.swigValue(), 3121);
|
||||
val = enumCheck(Class1.Struct1.Enum12.Val6f.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Struct1.Enum13.Val1.swigValue(), 3131);
|
||||
val = enumCheck(Class1.Struct1.Enum13.Val2.swigValue(), 3132);
|
||||
val = enumCheck(Class1.Struct1.Enum13.Val3.swigValue(), val);
|
||||
val = enumCheck(Class1.Struct1.Enum13.Val4.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Struct1.Enum14.Val1.swigValue(), 3141);
|
||||
val = enumCheck(Class1.Struct1.Enum14.Val2.swigValue(), 3142);
|
||||
val = enumCheck(Class1.Struct1.Enum14.Val3.swigValue(), val);
|
||||
val = enumCheck(Class1.Struct1.Enum14.Val4.swigValue(), val);
|
||||
val = enumCheck(Class1.Struct1.Enum14.Val5g.swigValue(), 3141);
|
||||
val = enumCheck(Class1.Struct1.Enum14.Val6g.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Enum12.Val1.swigValue(), 2121);
|
||||
val = enumCheck(Class2.Enum12.Val2.swigValue(), 2122);
|
||||
val = enumCheck(Class2.Enum12.Val3.swigValue(), val);
|
||||
val = enumCheck(Class2.Enum12.Val4.swigValue(), val);
|
||||
val = enumCheck(Class2.Enum12.Val5h.swigValue(), 2121);
|
||||
val = enumCheck(Class2.Enum12.Val6h.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Enum13.Val1.swigValue(), 2131);
|
||||
val = enumCheck(Class2.Enum13.Val2.swigValue(), 2132);
|
||||
val = enumCheck(Class2.Enum13.Val3.swigValue(), val);
|
||||
val = enumCheck(Class2.Enum13.Val4.swigValue(), val);
|
||||
val = enumCheck(Class2.Enum13.Val5i.swigValue(), 2131);
|
||||
val = enumCheck(Class2.Enum13.Val6i.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Enum14.Val1.swigValue(), 2141);
|
||||
val = enumCheck(Class2.Enum14.Val2.swigValue(), 2142);
|
||||
val = enumCheck(Class2.Enum14.Val3.swigValue(), val);
|
||||
val = enumCheck(Class2.Enum14.Val4.swigValue(), val);
|
||||
val = enumCheck(Class2.Enum14.Val5j.swigValue(), 2141);
|
||||
val = enumCheck(Class2.Enum14.Val6j.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Struct1.Enum12.Val1.swigValue(), 4121);
|
||||
val = enumCheck(Class2.Struct1.Enum12.Val2.swigValue(), 4122);
|
||||
val = enumCheck(Class2.Struct1.Enum12.Val3.swigValue(), val);
|
||||
val = enumCheck(Class2.Struct1.Enum12.Val4.swigValue(), val);
|
||||
val = enumCheck(Class2.Struct1.Enum12.Val5k.swigValue(), 4121);
|
||||
val = enumCheck(Class2.Struct1.Enum12.Val6k.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Struct1.Enum13.Val1.swigValue(), 4131);
|
||||
val = enumCheck(Class2.Struct1.Enum13.Val2.swigValue(), 4132);
|
||||
val = enumCheck(Class2.Struct1.Enum13.Val3.swigValue(), val);
|
||||
val = enumCheck(Class2.Struct1.Enum13.Val4.swigValue(), val);
|
||||
val = enumCheck(Class2.Struct1.Enum13.Val5l.swigValue(), 4131);
|
||||
val = enumCheck(Class2.Struct1.Enum13.Val6l.swigValue(), val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Struct1.Enum14.Val1.swigValue(), 4141);
|
||||
val = enumCheck(Class2.Struct1.Enum14.Val2.swigValue(), 4142);
|
||||
val = enumCheck(Class2.Struct1.Enum14.Val3.swigValue(), val);
|
||||
val = enumCheck(Class2.Struct1.Enum14.Val4.swigValue(), val);
|
||||
val = enumCheck(Class2.Struct1.Enum14.Val5m.swigValue(), 4141);
|
||||
val = enumCheck(Class2.Struct1.Enum14.Val6m.swigValue(), val);
|
||||
|
||||
Class1 class1 = new Class1();
|
||||
enumCheck(class1.class1Test1(Enum1.Val5a).swigValue(), 13);
|
||||
enumCheck(class1.class1Test2(Class1.Enum12.Val5c).swigValue(), 1121);
|
||||
enumCheck(class1.class1Test3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121);
|
||||
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a).swigValue(), 13);
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c).swigValue(), 1121);
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
import cpp11_strongly_typed_enumerations_simple.*;
|
||||
|
||||
public class cpp11_strongly_typed_enumerations_simple_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_strongly_typed_enumerations_simple");
|
||||
} 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 int enumCheck(int actual, int expected) {
|
||||
if (actual != expected)
|
||||
throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
|
||||
return expected + 1;
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
int val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val3, 13);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a, 13);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val6a, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val3, 23);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val5b, 23);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val6b, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val3, 43);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val3, 53);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val3, 63);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val3, 73);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val3, 83);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val3, 103);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Enum12_Val1, 1121);
|
||||
val = enumCheck(Class1.Enum12_Val2, 1122);
|
||||
val = enumCheck(Class1.Enum12_Val3, val);
|
||||
val = enumCheck(Class1.Enum12_Val4, val);
|
||||
val = enumCheck(Class1.Enum12_Val5c, 1121);
|
||||
val = enumCheck(Class1.Enum12_Val6c, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Val1, 1131);
|
||||
val = enumCheck(Class1.Val2, 1132);
|
||||
val = enumCheck(Class1.Val3, val);
|
||||
val = enumCheck(Class1.Val4, val);
|
||||
val = enumCheck(Class1.Val5d, 1131);
|
||||
val = enumCheck(Class1.Val6d, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Enum14_Val1, 1141);
|
||||
val = enumCheck(Class1.Enum14_Val2, 1142);
|
||||
val = enumCheck(Class1.Enum14_Val3, val);
|
||||
val = enumCheck(Class1.Enum14_Val4, val);
|
||||
val = enumCheck(Class1.Enum14_Val5e, 1141);
|
||||
val = enumCheck(Class1.Enum14_Val6e, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Struct1.Enum12_Val1, 3121);
|
||||
val = enumCheck(Class1.Struct1.Enum12_Val2, 3122);
|
||||
val = enumCheck(Class1.Struct1.Enum12_Val3, val);
|
||||
val = enumCheck(Class1.Struct1.Enum12_Val4, val);
|
||||
val = enumCheck(Class1.Struct1.Enum12_Val5f, 3121);
|
||||
val = enumCheck(Class1.Struct1.Enum12_Val6f, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Struct1.Val1, 3131);
|
||||
val = enumCheck(Class1.Struct1.Val2, 3132);
|
||||
val = enumCheck(Class1.Struct1.Val3, val);
|
||||
val = enumCheck(Class1.Struct1.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class1.Struct1.Enum14_Val1, 3141);
|
||||
val = enumCheck(Class1.Struct1.Enum14_Val2, 3142);
|
||||
val = enumCheck(Class1.Struct1.Enum14_Val3, val);
|
||||
val = enumCheck(Class1.Struct1.Enum14_Val4, val);
|
||||
val = enumCheck(Class1.Struct1.Enum14_Val5g, 3141);
|
||||
val = enumCheck(Class1.Struct1.Enum14_Val6g, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Enum12_Val1, 2121);
|
||||
val = enumCheck(Class2.Enum12_Val2, 2122);
|
||||
val = enumCheck(Class2.Enum12_Val3, val);
|
||||
val = enumCheck(Class2.Enum12_Val4, val);
|
||||
val = enumCheck(Class2.Enum12_Val5h, 2121);
|
||||
val = enumCheck(Class2.Enum12_Val6h, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Val1, 2131);
|
||||
val = enumCheck(Class2.Val2, 2132);
|
||||
val = enumCheck(Class2.Val3, val);
|
||||
val = enumCheck(Class2.Val4, val);
|
||||
val = enumCheck(Class2.Val5i, 2131);
|
||||
val = enumCheck(Class2.Val6i, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Enum14_Val1, 2141);
|
||||
val = enumCheck(Class2.Enum14_Val2, 2142);
|
||||
val = enumCheck(Class2.Enum14_Val3, val);
|
||||
val = enumCheck(Class2.Enum14_Val4, val);
|
||||
val = enumCheck(Class2.Enum14_Val5j, 2141);
|
||||
val = enumCheck(Class2.Enum14_Val6j, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Struct1.Enum12_Val1, 4121);
|
||||
val = enumCheck(Class2.Struct1.Enum12_Val2, 4122);
|
||||
val = enumCheck(Class2.Struct1.Enum12_Val3, val);
|
||||
val = enumCheck(Class2.Struct1.Enum12_Val4, val);
|
||||
val = enumCheck(Class2.Struct1.Enum12_Val5k, 4121);
|
||||
val = enumCheck(Class2.Struct1.Enum12_Val6k, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Struct1.Val1, 4131);
|
||||
val = enumCheck(Class2.Struct1.Val2, 4132);
|
||||
val = enumCheck(Class2.Struct1.Val3, val);
|
||||
val = enumCheck(Class2.Struct1.Val4, val);
|
||||
val = enumCheck(Class2.Struct1.Val5l, 4131);
|
||||
val = enumCheck(Class2.Struct1.Val6l, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(Class2.Struct1.Enum14_Val1, 4141);
|
||||
val = enumCheck(Class2.Struct1.Enum14_Val2, 4142);
|
||||
val = enumCheck(Class2.Struct1.Enum14_Val3, val);
|
||||
val = enumCheck(Class2.Struct1.Enum14_Val4, val);
|
||||
val = enumCheck(Class2.Struct1.Enum14_Val5m, 4141);
|
||||
val = enumCheck(Class2.Struct1.Enum14_Val6m, val);
|
||||
|
||||
Class1 class1 = new Class1();
|
||||
enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a), 13);
|
||||
enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121);
|
||||
enumCheck(class1.class1Test3(Class1.Struct1.Enum12_Val5f), 3121);
|
||||
|
||||
enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest1(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a), 13);
|
||||
enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest2(Class1.Enum12_Val5c), 1121);
|
||||
enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest3(Class1.Struct1.Enum12_Val5f), 3121);
|
||||
}
|
||||
}
|
||||
41
Examples/test-suite/java/director_nested_class_runme.java
Normal file
41
Examples/test-suite/java/director_nested_class_runme.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
import director_nested_class.*;
|
||||
|
||||
public class director_nested_class_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_nested_class");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
director_nested_class_Derived d = new director_nested_class_Derived();
|
||||
|
||||
if (DirectorOuter.callMethod(d, 999) != 9990) {
|
||||
throw new RuntimeException("callMethod(999) failed");
|
||||
}
|
||||
|
||||
director_nested_class_DerivedInnerInner dinner = new director_nested_class_DerivedInnerInner();
|
||||
|
||||
if (DirectorOuter.callInnerInnerMethod(dinner, 999) != 999000) {
|
||||
throw new RuntimeException("callMethod(999) failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class director_nested_class_Derived extends DirectorOuter.DirectorInner {
|
||||
public int vmethod(int input) {
|
||||
return input * 10;
|
||||
}
|
||||
}
|
||||
|
||||
class director_nested_class_DerivedInnerInner extends DirectorOuter.DirectorInner.DirectorInnerInner {
|
||||
public int innervmethod(int input) {
|
||||
return input * 1000;
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ public class java_director_runme {
|
|||
};
|
||||
int actualCount = Quux.instances();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
System.err.println("GC failed to run (java_director). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
|
||||
/* Test Quux1's director disconnect method rename */
|
||||
|
|
|
|||
|
|
@ -83,6 +83,25 @@ public class java_lib_various_runme {
|
|||
if (byjove[i] != b[i])
|
||||
throw new RuntimeException("By jove, it failed: [" + new String(b) + "]");
|
||||
}
|
||||
|
||||
// NIOBUFFER typemap check
|
||||
java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocateDirect(10);
|
||||
java_lib_various.niobuffer_fill_hello(buf);
|
||||
if (
|
||||
(char)buf.get(0) != 'h' ||
|
||||
(char)buf.get(1) != 'e' ||
|
||||
(char)buf.get(2) != 'l' ||
|
||||
(char)buf.get(3) != 'l' ||
|
||||
(char)buf.get(4) != 'o'
|
||||
)
|
||||
throw new RuntimeException(
|
||||
"nio test failed: " +
|
||||
(char)buf.get(0) +
|
||||
(char)buf.get(1) +
|
||||
(char)buf.get(2) +
|
||||
(char)buf.get(3) +
|
||||
(char)buf.get(4)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
23
Examples/test-suite/java/kwargs_feature_runme.java
Normal file
23
Examples/test-suite/java/kwargs_feature_runme.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import kwargs_feature.*;
|
||||
|
||||
public class kwargs_feature_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("kwargs_feature");
|
||||
} 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[]) {
|
||||
// Check normal overloading still works (no compactdefaultargs) if the kwargs feature is used,
|
||||
// as the kwargs feature is not supported
|
||||
Foo f = new Foo(99);
|
||||
if (f.foo() != 1)
|
||||
throw new RuntimeException("It went wrong");
|
||||
if (Foo.statfoo(2) != 2)
|
||||
throw new RuntimeException("It went wrong");
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public class li_boost_shared_ptr_runme {
|
|||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
System.err.println("GC failed to run (li_boost_shared_ptr). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
|
||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class li_std_auto_ptr_runme {
|
|||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
System.err.println("GC failed to run (li_std_auto_ptr 1). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
|
||||
if (!k2.getLabel().equals("second"))
|
||||
|
|
@ -62,7 +62,7 @@ public class li_std_auto_ptr_runme {
|
|||
};
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
System.err.println("GC failed to run (li_std_auto_ptr 2). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
Examples/test-suite/java/nested_template_base_runme.java
Normal file
27
Examples/test-suite/java/nested_template_base_runme.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import nested_template_base.*;
|
||||
|
||||
public class nested_template_base_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nested_template_base");
|
||||
} 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[]) {
|
||||
OuterC.InnerS ois = new OuterC.InnerS(123);
|
||||
OuterC.InnerC oic = new OuterC.InnerC();
|
||||
|
||||
// Check base method is available
|
||||
if (oic.outer(ois).getVal() != 123)
|
||||
throw new RuntimeException("Wrong value calling outer");
|
||||
|
||||
// Check non-derived class using base class
|
||||
if (oic.innerc().outer(ois).getVal() != 123)
|
||||
throw new RuntimeException("Wrong value calling innerc");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ public class smart_pointer_const_overload_runme {
|
|||
Assert(f.getAccess() == MUTABLE_ACCESS);
|
||||
|
||||
// Test static method
|
||||
b.stat();
|
||||
b.statMethod();
|
||||
|
||||
Assert(f.getAccess() == CONST_ACCESS);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ public class template_default_class_parms_runme {
|
|||
foo.setTType(a);
|
||||
a = foo.method(a);
|
||||
}
|
||||
|
||||
{
|
||||
MapDefaults md = new MapDefaults();
|
||||
md.test_func(10, 20, new DefaultNodeType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
import template_templated_constructors.*;
|
||||
|
||||
public class template_templated_constructors_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_templated_constructors");
|
||||
} 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[]) {
|
||||
TConstructor1 t1 = new TConstructor1(123);
|
||||
TConstructor2 t2a = new TConstructor2();
|
||||
TConstructor2 t2b = new TConstructor2(123);
|
||||
|
||||
TClass1Int tc1 = new TClass1Int(123.4);
|
||||
TClass2Int tc2a = new TClass2Int();
|
||||
TClass2Int tc2b = new TClass2Int(123.4);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12,13 +12,13 @@ public class template_typedef_typedef_runme {
|
|||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
ObjectBase ob1 = new ObjectBase();
|
||||
ob1.getBlabla1(new ObjectBase());
|
||||
Object1Base ob1 = new Object1Base();
|
||||
ob1.getBlabla1(new Object1Base());
|
||||
Object2Base ob2 = new Object2Base();
|
||||
ob2.getBlabla2(new Object2Base());
|
||||
|
||||
Factory factory = new Factory();
|
||||
factory.getBlabla3(new ObjectBase());
|
||||
factory.getBlabla3(new Object1Base());
|
||||
factory.getBlabla4(new Object2Base());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
%apply char **STRING_ARRAY { char **languages };
|
||||
%apply char *BYTE { char *chars };
|
||||
%apply char **STRING_OUT { char **string_ptr };
|
||||
%apply unsigned char *NIOBUFFER { unsigned char *buf };
|
||||
%typemap(freearg) char **languages "" // don't delete memory when setting global variable
|
||||
|
||||
%{
|
||||
|
|
@ -47,5 +48,8 @@ void char_ptr_ptr_out(char **string_ptr) {
|
|||
*string_ptr = ret;
|
||||
}
|
||||
|
||||
void niobuffer_fill_hello(unsigned char *buf) {
|
||||
sprintf ((char*)buf,"hello");
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ LANGUAGE = javascript
|
|||
NODEGYP = @NODEGYP@
|
||||
NODEJS = @NODEJS@
|
||||
SCRIPTSUFFIX = _runme.js
|
||||
OBJEXT = @OBJEXT@
|
||||
SO = @SO@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
|
@ -19,8 +21,16 @@ else
|
|||
JSENGINE=node
|
||||
endif
|
||||
|
||||
ifneq (, $(V8_VERSION))
|
||||
JSV8_VERSION=$(V8_VERSION)
|
||||
else
|
||||
JSV8_VERSION=0x031110
|
||||
endif
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
SWIGOPT += -DV8_VERSION=$(JSV8_VERSION)
|
||||
|
||||
_setup = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \
|
||||
|
|
@ -108,10 +118,10 @@ endif
|
|||
|
||||
%.clean:
|
||||
@rm -rf $*
|
||||
@rm -f $*_wrap.* $*.so $*.o
|
||||
@rm -f $*_wrap.* $*$(SO) $*.$(OBJEXT)
|
||||
|
||||
clean:
|
||||
for ext in _wrap.cxx _wrap.o .so; do \
|
||||
for ext in _wrap.cxx _wrap.$(OBJEXT) $(SO); do \
|
||||
rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \
|
||||
rm -f imports_a$${ext} imports_b$${ext}; \
|
||||
rm -f import_stl_a$${ext} import_stl_b$${ext}; \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,165 @@
|
|||
var cpp11_strongly_typed_enumerations = require("cpp11_strongly_typed_enumerations");
|
||||
|
||||
function enumCheck(actual, expected) {
|
||||
if (actual != expected) {
|
||||
throw new Error("Enum value mismatch. Expected: " + expected + " Actual: " + actual);
|
||||
}
|
||||
return expected + 1;
|
||||
}
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val1, 1121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val2, 1122);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c, 1121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val6c, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val1, 1131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val2, 1132);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val5d, 1131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val6d, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val1, 1141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val2, 1142);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val5e, 1141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val6e, val);
|
||||
|
||||
// Requires nested class support to work
|
||||
//val = 0;
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val1, 3121);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val2, 3122);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val3, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val4, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f, 3121);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val6f, val);
|
||||
//
|
||||
//val = 0;
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val1, 3131);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val2, 3132);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val3, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val4, val);
|
||||
//
|
||||
//val = 0;
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val1, 3141);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val2, 3142);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val3, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val4, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val5g, 3141);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val6g, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val1, 2121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val2, 2122);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val5h, 2121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val6h, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val1, 2131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val2, 2132);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val5i, 2131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val6i, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val1, 2141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val2, 2142);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val5j, 2141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val6j, val);
|
||||
|
||||
// Requires nested class support to work
|
||||
//val = 0;
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val1, 4121);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val2, 4122);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val3, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val4, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val5k, 4121);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val6k, val);
|
||||
//
|
||||
//val = 0;
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val1, 4131);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val2, 4132);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val3, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val4, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val5l, 4131);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val6l, val);
|
||||
//
|
||||
//val = 0;
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val1, 4141);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val2, 4142);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val3, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val4, val);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val5m, 4141);
|
||||
//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val6m, val);
|
||||
|
||||
class1 = new cpp11_strongly_typed_enumerations.Class1();
|
||||
enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
|
||||
enumCheck(class1.class1Test2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121);
|
||||
//enumCheck(class1.class1Test3(cpp11_strongly_typed_enumerations.Class1.Struct1_Enum12_Val5f), 3121);
|
||||
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121);
|
||||
//enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1.Struct1_Enum12_Val5f), 3121);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
%module kwargs_feature
|
||||
|
||||
%nocopyctor;
|
||||
%kwargs;
|
||||
%feature("kwargs");
|
||||
|
||||
%rename(myDel) del;
|
||||
%inline
|
||||
|
|
@ -35,9 +35,7 @@
|
|||
|
||||
virtual ~Foo() {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
|
@ -64,8 +62,7 @@
|
|||
|
||||
// Functions
|
||||
%inline %{
|
||||
int foo(int a = 1, int b = 0) {return a + b; }
|
||||
|
||||
int foo_fn(int a = 1, int b = 0) {return a + b; }
|
||||
|
||||
template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
|
||||
%}
|
||||
|
|
@ -73,10 +70,8 @@
|
|||
%template(templatedfunction) templatedfunction<int>;
|
||||
|
||||
|
||||
// Deafult args with references
|
||||
%inline
|
||||
%{
|
||||
|
||||
// Default args with references
|
||||
%inline %{
|
||||
typedef int size_type;
|
||||
|
||||
struct Hello
|
||||
|
|
@ -84,13 +79,10 @@
|
|||
static const size_type hello = 3;
|
||||
};
|
||||
|
||||
|
||||
|
||||
int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
|
||||
int rfoo( int n = 0, const size_type& x = Hello::hello, const Hello& y = Hello() )
|
||||
{
|
||||
return x;
|
||||
return n - x;
|
||||
}
|
||||
|
||||
%}
|
||||
%{
|
||||
const int Hello::hello;
|
||||
|
|
@ -104,9 +96,7 @@
|
|||
|
||||
int foo_kw(int from = 1, int except = 2) {return from + except; }
|
||||
|
||||
|
||||
int foo_nu(int from = 1, int = 0) {return from; }
|
||||
|
||||
int foo_mm(int min = 1, int max = 2) {return min + max; }
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
|
||||
#endif
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE)
|
||||
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -23,3 +23,11 @@ void test_domain_error() throw(std::domain_error)
|
|||
%include <std_except.i>
|
||||
void test_domain_error() throw(std::domain_error)
|
||||
{ throw std::domain_error("std::domain_error"); }
|
||||
|
||||
%inline %{
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_
|
|||
return x;
|
||||
}
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
%include "li_std_string.i"
|
||||
|
|
|
|||
|
|
@ -92,6 +92,12 @@ void test_throw() throw(std::wstring){
|
|||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,28 +13,28 @@
|
|||
#include <iostream>
|
||||
struct XXX {
|
||||
XXX(int v) : value(v) {
|
||||
if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl;
|
||||
if (debugging) std::cout << "Default Constructor " << value << " " << this << std::endl;
|
||||
count++;
|
||||
}
|
||||
XXX(const XXX &other) {
|
||||
value = other.value;
|
||||
if (debug) std::cout << "Copy Constructor " << value << " " << this << std::endl;
|
||||
if (debugging) std::cout << "Copy Constructor " << value << " " << this << std::endl;
|
||||
count++;
|
||||
}
|
||||
XXX& operator=(const XXX &other) {
|
||||
value = other.value;
|
||||
if (debug) std::cout << "Assignment operator " << value << " " << this << std::endl;
|
||||
if (debugging) std::cout << "Assignment operator " << value << " " << this << std::endl;
|
||||
return *this;
|
||||
}
|
||||
~XXX() {
|
||||
if (debug) std::cout << "Destructor " << value << " " << this << std::endl;
|
||||
if (debugging) std::cout << "Destructor " << value << " " << this << std::endl;
|
||||
count--;
|
||||
}
|
||||
void showInfo() {
|
||||
if (debug) std::cout << "Info " << value << " " << this << std::endl;
|
||||
if (debugging) std::cout << "Info " << value << " " << this << std::endl;
|
||||
}
|
||||
int value;
|
||||
static const bool debug = false;
|
||||
static const bool debugging = false;
|
||||
static int count;
|
||||
};
|
||||
int XXX::count = 0;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,174 @@
|
|||
require("import") -- the import fn
|
||||
import("cpp11_strongly_typed_enumerations") -- 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})
|
||||
|
||||
function enumCheck(actual, expected)
|
||||
if not (actual == expected) then
|
||||
error("Enum value mismatch. Expected: "..expected.." Actual: "..actual)
|
||||
end
|
||||
return expected + 1
|
||||
end
|
||||
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.cpp11_strongly_typed_enumerations.Enum1_Val1, val)
|
||||
local val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val1, 1121)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val2, 1122)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val3, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c, 1121)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val6c, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val1, 1131)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val2, 1132)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val3, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val5d, 1131)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val6d, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val1, 1141)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val2, 1142)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val3, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val5e, 1141)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val6e, val)
|
||||
|
||||
-- Requires nested class support to work
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val1, 3121)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val2, 3122)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val3, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val4, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f, 3121)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val6f, val)
|
||||
--
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val1, 3131)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val2, 3132)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val3, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val4, val)
|
||||
--
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val1, 3141)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val2, 3142)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val3, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val4, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val5g, 3141)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val6g, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val1, 2121)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val2, 2122)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val3, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val5h, 2121)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val6h, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val1, 2131)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val2, 2132)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val3, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val5i, 2131)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val6i, val)
|
||||
|
||||
val = 0
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val1, 2141)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val2, 2142)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val3, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val4, val)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val5j, 2141)
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val6j, val)
|
||||
|
||||
-- Requires nested class support to work
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val1, 4121)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val2, 4122)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val3, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val4, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val5k, 4121)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val6k, val)
|
||||
--
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val1, 4131)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val2, 4132)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val3, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val4, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val5l, 4131)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val6l, val)
|
||||
--
|
||||
--val = 0
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val1, 4141)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val2, 4142)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val3, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val4, val)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val5m, 4141)
|
||||
--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val6m, val)
|
||||
|
||||
class1 = cpp11_strongly_typed_enumerations.Class1()
|
||||
enumCheck(class1:class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13)
|
||||
enumCheck(class1:class1Test2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121)
|
||||
--enumCheck(class1:class1Test3(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f), 3121)
|
||||
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13)
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121)
|
||||
--enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f), 3121)
|
||||
|
||||
|
|
@ -77,6 +77,9 @@ struct Outer {
|
|||
struct {
|
||||
Integer b;
|
||||
};
|
||||
#else
|
||||
Integer a;
|
||||
Integer b;
|
||||
#endif
|
||||
|
||||
union {
|
||||
|
|
@ -192,6 +195,9 @@ struct Outer {
|
|||
public:
|
||||
Integer yy;
|
||||
};
|
||||
#else
|
||||
Integer xx;
|
||||
Integer yy;
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -26,4 +26,42 @@ namespace ns {
|
|||
#endif
|
||||
};
|
||||
}
|
||||
class Outer1 {
|
||||
struct Nested1;
|
||||
public:
|
||||
struct Nested2;
|
||||
#ifdef __clang__
|
||||
struct Nested2 {
|
||||
int data;
|
||||
};
|
||||
#endif
|
||||
template <class T> class AbstractClass;
|
||||
class Real;
|
||||
};
|
||||
#ifndef __clang__
|
||||
struct Outer1::Nested2 {
|
||||
int data;
|
||||
};
|
||||
#endif
|
||||
|
||||
class Klass {
|
||||
public:
|
||||
template <class T> class AbstractClass;
|
||||
class Real;
|
||||
};
|
||||
|
||||
template <class T> class Klass::AbstractClass {
|
||||
public:
|
||||
virtual void Method() = 0;
|
||||
virtual ~AbstractClass() {}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(abstract_int) Klass::AbstractClass <int>;
|
||||
|
||||
%inline %{
|
||||
class Klass::Real : public AbstractClass <int> {
|
||||
public:
|
||||
virtual void Method() {}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
38
Examples/test-suite/nested_template_base.i
Normal file
38
Examples/test-suite/nested_template_base.i
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
%module nested_template_base
|
||||
|
||||
%inline %{
|
||||
template <class T> class OuterT {
|
||||
public:
|
||||
T outer(T t) { return t; }
|
||||
};
|
||||
%}
|
||||
|
||||
// The %template goes after OuterT and before OuterC as OuterC::InnerC's base is handled inside OuterC
|
||||
%template(OuterTInnerS) OuterT<OuterC::InnerS>;
|
||||
|
||||
#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
|
||||
%feature("flatnested") OuterC::InnerS;
|
||||
%feature("flatnested") OuterC::InnerC;
|
||||
#endif
|
||||
|
||||
|
||||
%inline %{
|
||||
class OuterC {
|
||||
public:
|
||||
struct InnerS;
|
||||
class InnerC;
|
||||
};
|
||||
|
||||
struct OuterC::InnerS {
|
||||
int val;
|
||||
InnerS(int val = 0) : val(val) {}
|
||||
};
|
||||
|
||||
|
||||
class OuterC::InnerC : public OuterT<InnerS> {
|
||||
public:
|
||||
OuterT<InnerS>& innerc() {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
cpp11_strongly_typed_enumerations
|
||||
|
||||
function newvalue = enumCheck(actual, expected)
|
||||
if (actual != expected);
|
||||
error("Enum value mismatch. Expected: %d Actual: %d", expected, actual);
|
||||
endif
|
||||
newvalue = expected + 1;
|
||||
end
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val1, 1121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val2, 1122);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c, 1121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val6c, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val1, 1131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val2, 1132);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val5d, 1131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val6d, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val1, 1141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val2, 1142);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val5e, 1141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val6e, val);
|
||||
|
||||
# Requires nested class support to work
|
||||
#val = 0;
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val1, 3121);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val2, 3122);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val3, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val4, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val5f, 3121);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val6f, val);
|
||||
#
|
||||
#val = 0;
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val1, 3131);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val2, 3132);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val3, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val4, val);
|
||||
#
|
||||
#val = 0;
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val1, 3141);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val2, 3142);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val3, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val4, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val5g, 3141);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val6g, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val1, 2121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val2, 2122);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val5h, 2121);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val6h, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val1, 2131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val2, 2132);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val5i, 2131);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val6i, val);
|
||||
|
||||
val = 0;
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val1, 2141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val2, 2142);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val3, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val4, val);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val5j, 2141);
|
||||
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val6j, val);
|
||||
|
||||
# Requires nested class support to work
|
||||
#val = 0;
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val1, 4121);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val2, 4122);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val3, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val4, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val5k, 4121);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val6k, val);
|
||||
#
|
||||
#val = 0;
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val1, 4131);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val2, 4132);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val3, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val4, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val5l, 4131);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val6l, val);
|
||||
#
|
||||
#val = 0;
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val1, 4141);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val2, 4142);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val3, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val4, val);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val5m, 4141);
|
||||
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val6m, val);
|
||||
|
||||
class1 = Class1();
|
||||
enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
|
||||
enumCheck(class1.class1Test2(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c), 1121);
|
||||
#enumCheck(class1.class1Test3(cpp11_strongly_typed_enumerations.Class1_Struct1_Enum12_Val5f), 3121);
|
||||
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
|
||||
enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c), 1121);
|
||||
#enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1_Struct1_Enum12_Val5f), 3121);
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
director_detect
|
||||
|
||||
global MyBar=@(val=2) \
|
||||
subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone);
|
||||
global MyBar=@(val=2) subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone);
|
||||
|
||||
function val=get_value(self)
|
||||
self.val = self.val + 1;
|
||||
val = self.val;
|
||||
|
|
|
|||
566
Examples/test-suite/octave/li_boost_shared_ptr_runme.m
Normal file
566
Examples/test-suite/octave/li_boost_shared_ptr_runme.m
Normal file
|
|
@ -0,0 +1,566 @@
|
|||
1;
|
||||
li_boost_shared_ptr;
|
||||
|
||||
function verifyValue(expected, got)
|
||||
if (expected ~= got)
|
||||
error("verify value failed.");% Expected: ", expected, " Got: ", got)
|
||||
end
|
||||
endfunction
|
||||
|
||||
function verifyCount(expected, k)
|
||||
got = use_count(k);
|
||||
if (expected ~= got)
|
||||
error("verify use_count failed. Expected: %d Got: %d ", expected, got);
|
||||
end
|
||||
endfunction
|
||||
|
||||
function runtest()
|
||||
li_boost_shared_ptr; # KTTODO this needs to be here at present. Global module failure?
|
||||
# simple shared_ptr usage - created in C++
|
||||
k = Klass("me oh my");
|
||||
val = k.getValue();
|
||||
verifyValue("me oh my", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
# simple shared_ptr usage - not created in C++
|
||||
k = factorycreate();
|
||||
val = k.getValue();
|
||||
verifyValue("factorycreate", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
# pass by shared_ptr
|
||||
k = Klass("me oh my");
|
||||
kret = smartpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointertest", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by shared_ptr pointer
|
||||
k = Klass("me oh my");
|
||||
kret = smartpointerpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointertest", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by shared_ptr reference
|
||||
k = Klass("me oh my");
|
||||
kret = smartpointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerreftest", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by shared_ptr pointer reference
|
||||
k = Klass("me oh my");
|
||||
kret = smartpointerpointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointerreftest", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# const pass by shared_ptr
|
||||
k = Klass("me oh my");
|
||||
kret = constsmartpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# const pass by shared_ptr pointer
|
||||
k = Klass("me oh my");
|
||||
kret = constsmartpointerpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# const pass by shared_ptr reference
|
||||
k = Klass("me oh my");
|
||||
kret = constsmartpointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by value
|
||||
k = Klass("me oh my");
|
||||
kret = valuetest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my valuetest", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# pass by pointer
|
||||
k = Klass("me oh my");
|
||||
kret = pointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my pointertest", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# pass by reference
|
||||
k = Klass("me oh my");
|
||||
kret = reftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my reftest", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# pass by pointer reference
|
||||
k = Klass("me oh my");
|
||||
kret = pointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my pointerreftest", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# null tests
|
||||
#KTODO None not defined
|
||||
# k = None;
|
||||
|
||||
# if (smartpointertest(k) ~= None)
|
||||
# error("return was not null")
|
||||
# end
|
||||
|
||||
# if (smartpointerpointertest(k) ~= None)
|
||||
# error("return was not null")
|
||||
# end
|
||||
|
||||
# if (smartpointerreftest(k) ~= None)
|
||||
# error("return was not null")
|
||||
# end
|
||||
|
||||
# if (smartpointerpointerreftest(k) ~= None)
|
||||
# error("return was not null")
|
||||
# end
|
||||
|
||||
# if (nullsmartpointerpointertest(None) ~= "null pointer")
|
||||
# error("not null smartpointer pointer")
|
||||
# end
|
||||
|
||||
# # try:
|
||||
# # valuetest(k)
|
||||
# # error("Failed to catch null pointer")
|
||||
# # except ValueError:
|
||||
# # pass
|
||||
|
||||
# if (pointertest(k) ~= None)
|
||||
# error("return was not null")
|
||||
# end
|
||||
|
||||
# # try:
|
||||
# # reftest(k)
|
||||
# # error("Failed to catch null pointer")
|
||||
# # except ValueError:
|
||||
# # pass
|
||||
|
||||
# $owner
|
||||
k = pointerownertest();
|
||||
val = k.getValue();
|
||||
verifyValue("pointerownertest", val)
|
||||
verifyCount(1, k)
|
||||
k = smartpointerpointerownertest();
|
||||
val = k.getValue();
|
||||
verifyValue("smartpointerpointerownertest", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
# //////////////////////////////// Derived class ////////////////////////////////////////
|
||||
# derived pass by shared_ptr
|
||||
k = KlassDerived("me oh my");
|
||||
kret = derivedsmartptrtest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrtest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# derived pass by shared_ptr pointer
|
||||
k = KlassDerived("me oh my");
|
||||
kret = derivedsmartptrpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrpointertest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# derived pass by shared_ptr ref
|
||||
k = KlassDerived("me oh my");
|
||||
kret = derivedsmartptrreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrreftest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# derived pass by shared_ptr pointer ref
|
||||
k = KlassDerived("me oh my");
|
||||
kret = derivedsmartptrpointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# derived pass by pointer
|
||||
k = KlassDerived("me oh my");
|
||||
kret = derivedpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my derivedpointertest-Derived", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# derived pass by ref
|
||||
k = KlassDerived("me oh my");
|
||||
kret = derivedreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my derivedreftest-Derived", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# //////////////////////////////// Derived and base class mixed ////////////////////////////////////////
|
||||
# pass by shared_ptr (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = smartpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointertest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by shared_ptr pointer (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = smartpointerpointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointertest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by shared_ptr reference (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = smartpointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerreftest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by shared_ptr pointer reference (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = smartpointerpointerreftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my smartpointerpointerreftest-Derived", val)
|
||||
verifyCount(2, k)
|
||||
verifyCount(2, kret)
|
||||
|
||||
# pass by value (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = valuetest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my valuetest", val) # note slicing
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# pass by pointer (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = pointertest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my pointertest-Derived", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
# pass by ref (mixed)
|
||||
k = KlassDerived("me oh my");
|
||||
kret = reftest(k);
|
||||
val = kret.getValue();
|
||||
verifyValue("me oh my reftest-Derived", val)
|
||||
verifyCount(1, k)
|
||||
verifyCount(1, kret)
|
||||
|
||||
# //////////////////////////////// Overloading tests ////////////////////////////////////////
|
||||
# Base class
|
||||
k = Klass("me oh my");
|
||||
verifyValue(overload_rawbyval(k), "rawbyval")
|
||||
verifyValue(overload_rawbyref(k), "rawbyref")
|
||||
verifyValue(overload_rawbyptr(k), "rawbyptr")
|
||||
verifyValue(overload_rawbyptrref(k), "rawbyptrref")
|
||||
|
||||
verifyValue(overload_smartbyval(k), "smartbyval")
|
||||
verifyValue(overload_smartbyref(k), "smartbyref")
|
||||
verifyValue(overload_smartbyptr(k), "smartbyptr")
|
||||
verifyValue(overload_smartbyptrref(k), "smartbyptrref")
|
||||
|
||||
# Derived class
|
||||
k = KlassDerived("me oh my");
|
||||
verifyValue(overload_rawbyval(k), "rawbyval")
|
||||
verifyValue(overload_rawbyref(k), "rawbyref")
|
||||
verifyValue(overload_rawbyptr(k), "rawbyptr")
|
||||
verifyValue(overload_rawbyptrref(k), "rawbyptrref")
|
||||
|
||||
verifyValue(overload_smartbyval(k), "smartbyval")
|
||||
verifyValue(overload_smartbyref(k), "smartbyref")
|
||||
verifyValue(overload_smartbyptr(k), "smartbyptr")
|
||||
verifyValue(overload_smartbyptrref(k), "smartbyptrref")
|
||||
|
||||
# 3rd derived class
|
||||
k = Klass3rdDerived("me oh my");
|
||||
val = k.getValue();
|
||||
verifyValue("me oh my-3rdDerived", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
val = test3rdupcast(k);
|
||||
verifyValue("me oh my-3rdDerived", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
# //////////////////////////////// Member variables ////////////////////////////////////////
|
||||
# smart pointer by value
|
||||
m = MemberVariables();
|
||||
k = Klass("smart member value");
|
||||
m.SmartMemberValue = k;
|
||||
val = k.getValue();
|
||||
verifyValue("smart member value", val)
|
||||
verifyCount(2, k)
|
||||
|
||||
kmember = m.SmartMemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member value", val)
|
||||
verifyCount(3, kmember)
|
||||
verifyCount(3, k)
|
||||
|
||||
clear m
|
||||
verifyCount(2, kmember)
|
||||
verifyCount(2, k)
|
||||
|
||||
# smart pointer by pointer
|
||||
m = MemberVariables();
|
||||
k = Klass("smart member pointer");
|
||||
m.SmartMemberPointer = k;
|
||||
val = k.getValue();
|
||||
verifyValue("smart member pointer", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
kmember = m.SmartMemberPointer;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member pointer", val)
|
||||
verifyCount(2, kmember)
|
||||
verifyCount(2, k)
|
||||
|
||||
clear m
|
||||
verifyCount(2, kmember)
|
||||
verifyCount(2, k)
|
||||
|
||||
# smart pointer by reference
|
||||
m = MemberVariables();
|
||||
k = Klass("smart member reference");
|
||||
m.SmartMemberReference = k;
|
||||
val = k.getValue();
|
||||
verifyValue("smart member reference", val)
|
||||
verifyCount(2, k)
|
||||
|
||||
kmember = m.SmartMemberReference;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member reference", val)
|
||||
verifyCount(3, kmember)
|
||||
verifyCount(3, k)
|
||||
|
||||
# The C++ reference refers to SmartMemberValue...
|
||||
kmemberVal = m.SmartMemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("smart member reference", val)
|
||||
verifyCount(4, kmemberVal)
|
||||
verifyCount(4, kmember)
|
||||
verifyCount(4, k)
|
||||
|
||||
clear m
|
||||
verifyCount(3, kmemberVal)
|
||||
verifyCount(3, kmember)
|
||||
verifyCount(3, k)
|
||||
|
||||
# plain by value
|
||||
m = MemberVariables();
|
||||
k = Klass("plain member value");
|
||||
m.MemberValue = k;
|
||||
val = k.getValue();
|
||||
verifyValue("plain member value", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
kmember = m.MemberValue;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member value", val)
|
||||
verifyCount(1, kmember)
|
||||
verifyCount(1, k)
|
||||
|
||||
clear m
|
||||
verifyCount(1, kmember)
|
||||
verifyCount(1, k)
|
||||
|
||||
# plain by pointer
|
||||
m = MemberVariables();
|
||||
k = Klass("plain member pointer");
|
||||
m.MemberPointer = k;
|
||||
val = k.getValue();
|
||||
verifyValue("plain member pointer", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
kmember = m.MemberPointer;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member pointer", val)
|
||||
verifyCount(1, kmember)
|
||||
verifyCount(1, k)
|
||||
|
||||
clear m
|
||||
verifyCount(1, kmember)
|
||||
verifyCount(1, k)
|
||||
|
||||
# plain by reference
|
||||
m = MemberVariables();
|
||||
k = Klass("plain member reference");
|
||||
m.MemberReference = k;
|
||||
val = k.getValue();
|
||||
verifyValue("plain member reference", val)
|
||||
verifyCount(1, k)
|
||||
|
||||
kmember = m.MemberReference;
|
||||
val = kmember.getValue();
|
||||
verifyValue("plain member reference", val)
|
||||
verifyCount(1, kmember)
|
||||
verifyCount(1, k)
|
||||
|
||||
clear m
|
||||
verifyCount(1, kmember)
|
||||
verifyCount(1, k)
|
||||
|
||||
# null member variables
|
||||
m = MemberVariables();
|
||||
|
||||
# shared_ptr by value
|
||||
k = m.SmartMemberValue;
|
||||
#KTODO None not defined
|
||||
# if (k ~= None)
|
||||
# error("expected null")
|
||||
# end
|
||||
|
||||
# m.SmartMemberValue = None
|
||||
# k = m.SmartMemberValue
|
||||
# if (k ~= None)
|
||||
# error("expected null")
|
||||
# end
|
||||
# verifyCount(0, k)
|
||||
|
||||
# # plain by value
|
||||
# # try:
|
||||
# # m.MemberValue = None
|
||||
# # error("Failed to catch null pointer")
|
||||
# # except ValueError:
|
||||
# # pass
|
||||
|
||||
# # ////////////////////////////////// Global variables ////////////////////////////////////////
|
||||
# # smart pointer
|
||||
# kglobal = cvar.GlobalSmartValue
|
||||
# if (kglobal ~= None)
|
||||
# error("expected null")
|
||||
# end
|
||||
|
||||
k = Klass("smart global value");
|
||||
cvar.GlobalSmartValue = k;
|
||||
verifyCount(2, k)
|
||||
|
||||
kglobal = cvar.GlobalSmartValue;
|
||||
val = kglobal.getValue();
|
||||
verifyValue("smart global value", val)
|
||||
verifyCount(3, kglobal)
|
||||
verifyCount(3, k)
|
||||
verifyValue("smart global value", cvar.GlobalSmartValue.getValue())
|
||||
#KTTODO cvar.GlobalSmartValue = None
|
||||
|
||||
# plain value
|
||||
k = Klass("global value");
|
||||
cvar.GlobalValue = k;
|
||||
verifyCount(1, k)
|
||||
|
||||
kglobal = cvar.GlobalValue;
|
||||
val = kglobal.getValue();
|
||||
verifyValue("global value", val)
|
||||
verifyCount(1, kglobal)
|
||||
verifyCount(1, k)
|
||||
verifyValue("global value", cvar.GlobalValue.getValue())
|
||||
|
||||
# try:
|
||||
# cvar.GlobalValue = None
|
||||
# error("Failed to catch null pointer")
|
||||
# except ValueError:
|
||||
# pass
|
||||
|
||||
# plain pointer
|
||||
kglobal = cvar.GlobalPointer;
|
||||
#KTODO if (kglobal ~= None)
|
||||
#KTODO error("expected null")
|
||||
#KTODO end
|
||||
|
||||
k = Klass("global pointer");
|
||||
cvar.GlobalPointer = k;
|
||||
verifyCount(1, k)
|
||||
|
||||
kglobal = cvar.GlobalPointer;
|
||||
val = kglobal.getValue();
|
||||
verifyValue("global pointer", val)
|
||||
verifyCount(1, kglobal)
|
||||
verifyCount(1, k)
|
||||
#KTODO cvar.GlobalPointer = None
|
||||
|
||||
# plain reference
|
||||
kglobal;
|
||||
k = Klass("global reference");
|
||||
cvar.GlobalReference = k;
|
||||
verifyCount(1, k)
|
||||
|
||||
kglobal = cvar.GlobalReference;
|
||||
val = kglobal.getValue();
|
||||
verifyValue("global reference", val)
|
||||
verifyCount(1, kglobal)
|
||||
verifyCount(1, k)
|
||||
|
||||
# try:
|
||||
# cvar.GlobalReference = None
|
||||
# error("Failed to catch null pointer")
|
||||
# except ValueError:
|
||||
# pass
|
||||
|
||||
# ////////////////////////////////// Templates ////////////////////////////////////////
|
||||
pid = PairIntDouble(10, 20.2);
|
||||
if (pid.baseVal1 ~= 20 || pid.baseVal2 ~= 40.4)
|
||||
error("Base values wrong")
|
||||
end
|
||||
if (pid.val1 ~= 10 || pid.val2 ~= 20.2)
|
||||
error("Derived Values wrong")
|
||||
end
|
||||
|
||||
endfunction
|
||||
|
||||
debug = false;%true;
|
||||
|
||||
if (debug)
|
||||
fprintf( "Started\n" )
|
||||
end
|
||||
|
||||
cvar.debug_shared = debug;
|
||||
|
||||
# Change loop count to run for a long time to monitor memory
|
||||
loopCount = 1; #5000
|
||||
for i=0:loopCount
|
||||
runtest()
|
||||
end
|
||||
|
||||
# Expect 1 instance - the one global variable (GlobalValue)
|
||||
#KTTODO next fails, possibly because we commented GlobalSmartValue=None
|
||||
#if (Klass.getTotal_count() ~= 1)
|
||||
# error("Klass.total_count=%d", Klass.getTotal_count())
|
||||
#end
|
||||
|
||||
wrapper_count = shared_ptr_wrapper_count() ;
|
||||
#KTTODO next fails as NOT_COUNTING not in octave name space, so we hard-wire it here
|
||||
#if (wrapper_count ~= NOT_COUNTING)
|
||||
if (wrapper_count ~= -123456)
|
||||
# Expect 1 instance - the one global variable (GlobalSmartValue)
|
||||
if (wrapper_count ~= 1)
|
||||
error("shared_ptr wrapper count=%s", wrapper_count)
|
||||
end
|
||||
end
|
||||
|
||||
if (debug)
|
||||
fprintf( "Finished\n" )
|
||||
end
|
||||
22
Examples/test-suite/overload_polymorphic.i
Normal file
22
Examples/test-suite/overload_polymorphic.i
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
%module overload_polymorphic
|
||||
|
||||
%inline %{
|
||||
|
||||
class Base {
|
||||
public:
|
||||
Base(){}
|
||||
virtual ~Base(){}
|
||||
};
|
||||
|
||||
class Derived : public Base {
|
||||
public:
|
||||
Derived(){}
|
||||
virtual ~Derived(){}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int test(Base* base){ return 0;}
|
||||
int test(int hello){ return 1; }
|
||||
|
||||
%}
|
||||
|
|
@ -17,6 +17,7 @@ CPP_TEST_CASES += \
|
|||
li_cstring \
|
||||
li_cdata_carrays \
|
||||
li_reference \
|
||||
director_nestedmodule \
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cdata \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,168 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 78;
|
||||
BEGIN { use_ok('cpp11_strongly_typed_enumerations') }
|
||||
require_ok('cpp11_strongly_typed_enumerations');
|
||||
|
||||
sub enumCheck { my($actual, $expected) = @_;
|
||||
is($actual, $expected);
|
||||
return $expected + 1;
|
||||
}
|
||||
|
||||
my $val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val3, 13);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val5a, 13);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val6a, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val3, 23);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val5b, 23);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val6b, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Val3, 43);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val3, 53);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val3, 63);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val3, 73);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val3, 83);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val1, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val2, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val3, 103);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val1, 1121);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val2, 1122);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val3, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val5c, 1121);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val6c, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val1, 1131);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val2, 1132);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val3, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val5d, 1131);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val6d, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val1, 1141);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val2, 1142);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val3, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val5e, 1141);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val6e, $val);
|
||||
|
||||
# Requires nested class support to work
|
||||
#$val = 0;
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val1, 3121);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val2, 3122);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val3, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val4, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val5f, 3121);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val6f, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val1, 3131);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val2, 3132);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val3, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val4, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val1, 3141);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val2, 3142);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val3, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val4, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val5g, 3141);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val6g, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val1, 2121);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val2, 2122);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val3, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val5h, 2121);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val6h, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val1, 2131);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val2, 2132);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val3, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val5i, 2131);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val6i, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val1, 2141);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val2, 2142);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val3, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val4, $val);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val5j, 2141);
|
||||
$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val6j, $val);
|
||||
|
||||
# Requires nested class support to work
|
||||
#$val = 0;
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val1, 4121);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val2, 4122);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val3, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val4, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val5k, 4121);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val6k, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val1, 4131);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val2, 4132);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val3, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val4, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val5l, 4131);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val6l, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val1, 4141);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val2, 4142);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val3, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val4, $val);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val5m, 4141);
|
||||
#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val6m, $val);
|
||||
|
||||
my $class1 = cpp11_strongly_typed_enumerations::Class1->new();
|
||||
enumCheck($class1->class1Test1($cpp11_strongly_typed_enumerations::Enum1_Val5a), 13);
|
||||
enumCheck($class1->class1Test2($cpp11_strongly_typed_enumerations::Class1::Enum12_Val5c), 1121);
|
||||
#enumCheck($class1->class1Test3($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val5f), 3121);
|
||||
|
||||
enumCheck(cpp11_strongly_typed_enumerations::globalTest1($cpp11_strongly_typed_enumerations::Enum1_Val5a), 13);
|
||||
enumCheck(cpp11_strongly_typed_enumerations::globalTest2($cpp11_strongly_typed_enumerations::Class1::Enum12_Val5c), 1121);
|
||||
#enumCheck(cpp11_strongly_typed_enumerations::globalTest3($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val5f), 3121);
|
||||
|
||||
|
|
@ -10,6 +10,7 @@ top_srcdir = @top_srcdir@
|
|||
top_builddir = @top_builddir@
|
||||
|
||||
CPP_TEST_CASES += \
|
||||
php_iterator \
|
||||
php_namewarn_rename \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
|
|
|||
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "cpp11_strongly_typed_enumerations.php";
|
||||
|
||||
function enumCheck($actual, $expected) {
|
||||
check::equal($actual, $expected, "Enum value mismatch");
|
||||
return $expected + 1;
|
||||
}
|
||||
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum1_Val1, $val);
|
||||
$val = enumCheck(Enum1_Val2, $val);
|
||||
$val = enumCheck(Enum1_Val3, 13);
|
||||
$val = enumCheck(Enum1_Val4, $val);
|
||||
$val = enumCheck(Enum1_Val5a, 13);
|
||||
$val = enumCheck(Enum1_Val6a, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum2_Val1, $val);
|
||||
$val = enumCheck(Enum2_Val2, $val);
|
||||
$val = enumCheck(Enum2_Val3, 23);
|
||||
$val = enumCheck(Enum2_Val4, $val);
|
||||
$val = enumCheck(Enum2_Val5b, 23);
|
||||
$val = enumCheck(Enum2_Val6b, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Val1, $val);
|
||||
$val = enumCheck(Val2, $val);
|
||||
$val = enumCheck(Val3, 43);
|
||||
$val = enumCheck(Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum5_Val1, $val);
|
||||
$val = enumCheck(Enum5_Val2, $val);
|
||||
$val = enumCheck(Enum5_Val3, 53);
|
||||
$val = enumCheck(Enum5_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum6_Val1, $val);
|
||||
$val = enumCheck(Enum6_Val2, $val);
|
||||
$val = enumCheck(Enum6_Val3, 63);
|
||||
$val = enumCheck(Enum6_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum7td_Val1, $val);
|
||||
$val = enumCheck(Enum7td_Val2, $val);
|
||||
$val = enumCheck(Enum7td_Val3, 73);
|
||||
$val = enumCheck(Enum7td_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum8_Val1, $val);
|
||||
$val = enumCheck(Enum8_Val2, $val);
|
||||
$val = enumCheck(Enum8_Val3, 83);
|
||||
$val = enumCheck(Enum8_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Enum10_Val1, $val);
|
||||
$val = enumCheck(Enum10_Val2, $val);
|
||||
$val = enumCheck(Enum10_Val3, 103);
|
||||
$val = enumCheck(Enum10_Val4, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Class1::Enum12_Val1, 1121);
|
||||
$val = enumCheck(Class1::Enum12_Val2, 1122);
|
||||
$val = enumCheck(Class1::Enum12_Val3, $val);
|
||||
$val = enumCheck(Class1::Enum12_Val4, $val);
|
||||
$val = enumCheck(Class1::Enum12_Val5c, 1121);
|
||||
$val = enumCheck(Class1::Enum12_Val6c, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Class1::Val1, 1131);
|
||||
$val = enumCheck(Class1::Val2, 1132);
|
||||
$val = enumCheck(Class1::Val3, $val);
|
||||
$val = enumCheck(Class1::Val4, $val);
|
||||
$val = enumCheck(Class1::Val5d, 1131);
|
||||
$val = enumCheck(Class1::Val6d, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Class1::Enum14_Val1, 1141);
|
||||
$val = enumCheck(Class1::Enum14_Val2, 1142);
|
||||
$val = enumCheck(Class1::Enum14_Val3, $val);
|
||||
$val = enumCheck(Class1::Enum14_Val4, $val);
|
||||
$val = enumCheck(Class1::Enum14_Val5e, 1141);
|
||||
$val = enumCheck(Class1::Enum14_Val6e, $val);
|
||||
|
||||
# Requires nested class support to work
|
||||
#$val = 0;
|
||||
#$val = enumCheck(Class1::Struct1.Enum12_Val1, 3121);
|
||||
#$val = enumCheck(Class1::Struct1.Enum12_Val2, 3122);
|
||||
#$val = enumCheck(Class1::Struct1.Enum12_Val3, $val);
|
||||
#$val = enumCheck(Class1::Struct1.Enum12_Val4, $val);
|
||||
#$val = enumCheck(Class1::Struct1.Enum12_Val5f, 3121);
|
||||
#$val = enumCheck(Class1::Struct1.Enum12_Val6f, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck(Class1::Struct1.$val1, 3131);
|
||||
#$val = enumCheck(Class1::Struct1.$val2, 3132);
|
||||
#$val = enumCheck(Class1::Struct1.$val3, $val);
|
||||
#$val = enumCheck(Class1::Struct1.$val4, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck(Class1::Struct1.Enum14_Val1, 3141);
|
||||
#$val = enumCheck(Class1::Struct1.Enum14_Val2, 3142);
|
||||
#$val = enumCheck(Class1::Struct1.Enum14_Val3, $val);
|
||||
#$val = enumCheck(Class1::Struct1.Enum14_Val4, $val);
|
||||
#$val = enumCheck(Class1::Struct1.Enum14_Val5g, 3141);
|
||||
#$val = enumCheck(Class1::Struct1.Enum14_Val6g, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Class2::Enum12_Val1, 2121);
|
||||
$val = enumCheck(Class2::Enum12_Val2, 2122);
|
||||
$val = enumCheck(Class2::Enum12_Val3, $val);
|
||||
$val = enumCheck(Class2::Enum12_Val4, $val);
|
||||
$val = enumCheck(Class2::Enum12_Val5h, 2121);
|
||||
$val = enumCheck(Class2::Enum12_Val6h, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Class2::Val1, 2131);
|
||||
$val = enumCheck(Class2::Val2, 2132);
|
||||
$val = enumCheck(Class2::Val3, $val);
|
||||
$val = enumCheck(Class2::Val4, $val);
|
||||
$val = enumCheck(Class2::Val5i, 2131);
|
||||
$val = enumCheck(Class2::Val6i, $val);
|
||||
|
||||
$val = 0;
|
||||
$val = enumCheck(Class2::Enum14_Val1, 2141);
|
||||
$val = enumCheck(Class2::Enum14_Val2, 2142);
|
||||
$val = enumCheck(Class2::Enum14_Val3, $val);
|
||||
$val = enumCheck(Class2::Enum14_Val4, $val);
|
||||
$val = enumCheck(Class2::Enum14_Val5j, 2141);
|
||||
$val = enumCheck(Class2::Enum14_Val6j, $val);
|
||||
|
||||
# Requires nested class support to work
|
||||
#$val = 0;
|
||||
#$val = enumCheck(Class2::Struct1.Enum12_Val1, 4121);
|
||||
#$val = enumCheck(Class2::Struct1.Enum12_Val2, 4122);
|
||||
#$val = enumCheck(Class2::Struct1.Enum12_Val3, $val);
|
||||
#$val = enumCheck(Class2::Struct1.Enum12_Val4, $val);
|
||||
#$val = enumCheck(Class2::Struct1.Enum12_Val5k, 4121);
|
||||
#$val = enumCheck(Class2::Struct1.Enum12_Val6k, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck(Class2::Struct1.$val1, 4131);
|
||||
#$val = enumCheck(Class2::Struct1.$val2, 4132);
|
||||
#$val = enumCheck(Class2::Struct1.$val3, $val);
|
||||
#$val = enumCheck(Class2::Struct1.$val4, $val);
|
||||
#$val = enumCheck(Class2::Struct1.$val5l, 4131);
|
||||
#$val = enumCheck(Class2::Struct1.$val6l, $val);
|
||||
#
|
||||
#$val = 0;
|
||||
#$val = enumCheck(Class2::Struct1.Enum14_Val1, 4141);
|
||||
#$val = enumCheck(Class2::Struct1.Enum14_Val2, 4142);
|
||||
#$val = enumCheck(Class2::Struct1.Enum14_Val3, $val);
|
||||
#$val = enumCheck(Class2::Struct1.Enum14_Val4, $val);
|
||||
#$val = enumCheck(Class2::Struct1.Enum14_Val5m, 4141);
|
||||
#$val = enumCheck(Class2::Struct1.Enum14_Val6m, $val);
|
||||
|
||||
$class1 = new Class1();
|
||||
enumCheck($class1->class1Test1(Enum1_Val5a), 13);
|
||||
enumCheck($class1->class1Test2(Class1::Enum12_Val5c), 1121);
|
||||
#enumCheck($class1.class1Test3(Class1::Struct1.Enum12_Val5f), 3121);
|
||||
|
||||
enumCheck(globalTest1(Enum1_Val5a), 13);
|
||||
enumCheck(globalTest2(Class1::Enum12_Val5c), 1121);
|
||||
#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121);
|
||||
|
||||
?>
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
require "tests.php";
|
||||
require "director_basic.php";
|
||||
|
||||
/* Removed until runtime error is fixed, see https://github.com/swig/swig/issues/164
|
||||
// No new functions
|
||||
check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method));
|
||||
// No new classes
|
||||
|
|
@ -54,7 +53,6 @@ $cc->method($b);
|
|||
|
||||
check::equal($bc->x, 34, "bc failed");
|
||||
check::equal($bd->x, 16, "bd failed");
|
||||
*/
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ require "tests.php";
|
|||
require "director_exception.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang));
|
||||
check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
|
||||
// No new classes
|
||||
check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar));
|
||||
check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
|
||||
// now new vars
|
||||
check::globals(array());
|
||||
|
||||
|
|
@ -74,5 +74,54 @@ try {
|
|||
} catch (Exception1 $e1) {
|
||||
}
|
||||
|
||||
// Check that we can throw exceptions from director methods (this didn't used
|
||||
// to work in all cases, as the exception gets "set" in PHP and the method
|
||||
// then returns PHP NULL, which the directorout template may fail to convert.
|
||||
|
||||
class Bad extends ReturnAllTypes {
|
||||
function return_int() { throw new Exception("bad int"); }
|
||||
function return_double() { throw new Exception("bad double"); }
|
||||
function return_const_char_star() { throw new Exception("bad const_char_star"); }
|
||||
function return_std_string() { throw new Exception("bad std_string"); }
|
||||
function return_Bar() { throw new Exception("bad Bar"); }
|
||||
}
|
||||
|
||||
$bad = new Bad();
|
||||
|
||||
try {
|
||||
$bad->call_int();
|
||||
check::fail("Exception wasn't propagated from Bad::return_int()");
|
||||
} catch (Exception $e) {
|
||||
check::equal($e->getMessage(), "bad int", "propagated exception incorrect");
|
||||
}
|
||||
|
||||
try {
|
||||
$bad->call_double();
|
||||
check::fail("Exception wasn't propagated from Bad::return_double()");
|
||||
} catch (Exception $e) {
|
||||
check::equal($e->getMessage(), "bad double", "propagated exception incorrect");
|
||||
}
|
||||
|
||||
try {
|
||||
$bad->call_const_char_star();
|
||||
check::fail("Exception wasn't propagated from Bad::return_const_char_star()");
|
||||
} catch (Exception $e) {
|
||||
check::equal($e->getMessage(), "bad const_char_star", "propagated exception incorrect");
|
||||
}
|
||||
|
||||
try {
|
||||
$bad->call_std_string();
|
||||
check::fail("Exception wasn't propagated from Bad::return_std_string()");
|
||||
} catch (Exception $e) {
|
||||
check::equal($e->getMessage(), "bad std_string", "propagated exception incorrect");
|
||||
}
|
||||
|
||||
try {
|
||||
$bad->call_Bar();
|
||||
check::fail("Exception wasn't propagated from Bad::return_Bar()");
|
||||
} catch (Exception $e) {
|
||||
check::equal($e->getMessage(), "bad Bar", "propagated exception incorrect");
|
||||
}
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
require "tests.php";
|
||||
require "director_thread.php";
|
||||
|
||||
# Fails in a ZTS-build of PHP - see: https://github.com/swig/swig/pull/155
|
||||
exit(0);
|
||||
|
||||
// No new functions
|
||||
check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
|
||||
// No new classes
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
require "tests.php";
|
||||
require "exception_order.php";
|
||||
|
||||
check::functions(array(a_foo,a_bar,a_foobar,a_barfoo));
|
||||
check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
|
||||
check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
|
||||
check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ require "tests.php";
|
|||
require "import_nomodule.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array(create_foo,delete_foo,test1));
|
||||
check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
|
||||
// No new classes
|
||||
check::classes(array(import_nomodule,Bar));
|
||||
// now new vars
|
||||
|
|
|
|||
24
Examples/test-suite/php/php_iterator_runme.php
Normal file
24
Examples/test-suite/php/php_iterator_runme.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "php_iterator.php";
|
||||
|
||||
check::functions(array(myiterator_rewind,myiterator_key,myiterator_current,myiterator_next,myiterator_valid));
|
||||
check::classes(array(MyIterator));
|
||||
// No new global variables.
|
||||
check::globals(array());
|
||||
|
||||
$s = '';
|
||||
foreach (new MyIterator(1, 6) as $i) {
|
||||
$s .= $i;
|
||||
}
|
||||
check::equal($s, '12345', 'Simple iteration failed');
|
||||
|
||||
$s = '';
|
||||
foreach (new MyIterator(2, 5) as $k => $v) {
|
||||
$s .= "($k=>$v)";
|
||||
}
|
||||
check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed');
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -4,9 +4,9 @@ require "tests.php";
|
|||
require "threads_exception.php";
|
||||
|
||||
// Check functions
|
||||
check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi));
|
||||
check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
|
||||
// Check classes.
|
||||
check::classes(array(Exc,Test));
|
||||
check::classes(array(Exc,Test,threads_exception));
|
||||
// Chek globals.
|
||||
check::globals(array(exc_code,exc_msg));
|
||||
|
||||
|
|
|
|||
20
Examples/test-suite/php_iterator.i
Normal file
20
Examples/test-suite/php_iterator.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* php_iterator.i - PHP-specific testcase for wrapping to a PHP Iterator */
|
||||
%module php_iterator
|
||||
|
||||
%typemap("phpinterfaces") MyIterator "Iterator";
|
||||
|
||||
%inline %{
|
||||
|
||||
class MyIterator {
|
||||
int i, from, to;
|
||||
public:
|
||||
MyIterator(int from_, int to_)
|
||||
: i(from_), from(from_), to(to_) { }
|
||||
void rewind() { i = from; }
|
||||
bool valid() const { return i != to; }
|
||||
int key() const { return i - from; }
|
||||
int current() const { return i; }
|
||||
void next() { ++i; }
|
||||
};
|
||||
|
||||
%}
|
||||
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