Merge branch 'master' into doxygen

The way Python docstrings are indented has changed on master, so use the
standard inspect module in Python autodoc unit test to ignore the differences
in their indentation level between -builtin and non-builtin cases to make the
test still pass with the branch version, which avoids the use of different
(but almost identical) values in the test itself.
This commit is contained in:
Vadim Zeitlin 2016-12-05 02:14:51 +01:00
commit e668c47b70
1094 changed files with 39390 additions and 11483 deletions

View file

@ -35,7 +35,7 @@ CPP_TEST_BROKEN_ACL = \
dynamic_cast \
extend_variable \
# cdata.i support needed \
li_cdata \
li_cdata_cpp \
# warning generated. otherwise all good. \
operator_overload \
# std_common.i support \

View file

@ -68,6 +68,10 @@ TAscii *DigitsGlobalC;
// Director test
%feature("director");
#if defined(SWIGGO)
%typemap(godirectorout) CharPtr, CCharPtr ""
#endif
%inline %{
struct DirectorTest {
virtual UCharPtr UCharFunction(UCharPtr str) { return str; }

View file

@ -5,6 +5,10 @@
#endif
%inline %{
#if defined(_MSC_VER)
#pragma warning(disable: 4351) // new behavior: elements of array 'xyz' will be default initialized
#endif
typedef short Eight[8];
typedef const short ConstEight[8];
namespace ArrayExample

View file

@ -1,4 +1,4 @@
%module(docstring="hello") autodoc
%module(docstring="hello.") autodoc
%feature("autodoc");
@ -27,7 +27,7 @@
%feature("autodoc","2") A::variable_c; // extended
%feature("autodoc","3") A::variable_d; // extended + types
%feature("autodoc","just a string") A::funk; // names
%feature("autodoc","just a string.") A::funk; // names
%inline {

View file

@ -1,10 +1,18 @@
%module callback
// Not specifying the callback name is only possible in Python.
#ifdef SWIGPYTHON
%callback(1) foo;
%callback(1) foof;
%callback(1) A::bar;
%callback(1) A::foom;
%callback("%s_Cb_Ptr") foo_T; // old style, still works.
#else
%callback("%s") foo;
%callback("%s") foof;
%callback("%s") A::bar;
%callback("%s") A::foom;
#endif
%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too
%inline %{

View file

@ -48,4 +48,4 @@ run_testcase = \
@exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" cffi_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' cffi_clean

View file

@ -5,12 +5,16 @@ A test case for testing non null terminated char pointers.
%module char_binary
%apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) }
%apply (char *STRING, size_t LENGTH) { (const unsigned char *str, size_t len) }
%inline %{
struct Test {
size_t strlen(const char *str, size_t len) {
return len;
}
size_t ustrlen(const unsigned char *str, size_t len) {
return len;
}
};
typedef char namet[5];

View file

@ -12,6 +12,36 @@
#define ESC_CONST '\1'
#define NULL_CONST '\0'
#define SPECIALCHAR 'á'
#define SPECIALCHAR2 '\n'
#define SPECIALCHARA 'A'
#define SPECIALCHARB '\102' // B
#define SPECIALCHARC '\x43' // C
#define SPECIALCHARD 0x44 // D
#define SPECIALCHARE 69 // E
#define SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
#define SPECIALCHARAE2 '\306' // AE (latin1 encoded)
#define SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
#if defined(SWIGJAVA)
%javaconst(1);
#elif SWIGCSHARP
%csconst(1);
#elif SWIGD
%dmanifestconst;
#endif
#define X_ESC_CONST '\1'
#define X_NULL_CONST '\0'
#define X_SPECIALCHAR 'á'
#define X_SPECIALCHAR2 '\n'
#define X_SPECIALCHARA 'A'
#define X_SPECIALCHARB '\102' // B
#define X_SPECIALCHARC '\x43' // C
#define X_SPECIALCHARD 0x44 // D
#define X_SPECIALCHARE 69 // E
#define X_SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
#define X_SPECIALCHARAE2 '\306' // AE (latin1 encoded)
#define X_SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
%inline
{

View file

@ -1,6 +1,11 @@
%module chartest
%inline %{
#if defined(__clang__)
#pragma clang diagnostic push
// Suppress: illegal character encoding in character literal
#pragma clang diagnostic ignored "-Winvalid-source-encoding"
#endif
char printable_global_char = 'a';
char unprintable_global_char = 0x7F;
@ -12,4 +17,68 @@ char GetUnprintableChar() {
return 0x7F;
}
static const char globchar0 = '\0';
static const char globchar1 = '\1';
static const char globchar2 = '\n';
static const char globcharA = 'A';
static const char globcharB = '\102'; // B
static const char globcharC = '\x43'; // C
static const char globcharD = 0x44; // D
static const char globcharE = 69; // E
static const char globcharAE1 = 'Æ'; // AE (latin1 encoded)
static const char globcharAE2 = '\306'; // AE (latin1 encoded)
static const char globcharAE3 = '\xC6'; // AE (latin1 encoded)
struct CharTestClass {
static const char memberchar0 = '\0';
static const char memberchar1 = '\1';
static const char memberchar2 = '\n';
static const char membercharA = 'A';
static const char membercharB = '\102'; // B
static const char membercharC = '\x43'; // C
static const char membercharD = 0x44; // D
static const char membercharE = 69; // E
static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
static const char membercharAE2 = '\306'; // AE (latin1 encoded)
static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
};
%}
#if defined(SWIGJAVA)
%javaconst(1);
#elif SWIGCSHARP
%csconst(1);
#elif SWIGD
%dmanifestconst;
#endif
%inline %{
static const char x_globchar0 = '\0';
static const char x_globchar1 = '\1';
static const char x_globchar2 = '\n';
static const char x_globcharA = 'A';
static const char x_globcharB = '\102'; // B
static const char x_globcharC = '\x43'; // C
static const char x_globcharD = 0x44; // D
static const char x_globcharE = 69; // E
static const char x_globcharAE1 = 'Æ'; // AE (latin1 encoded)
static const char x_globcharAE2 = '\306'; // AE (latin1 encoded)
static const char x_globcharAE3 = '\xC6'; // AE (latin1 encoded)
struct X_CharTestClass {
static const char memberchar0 = '\0';
static const char memberchar1 = '\1';
static const char memberchar2 = '\n';
static const char membercharA = 'A';
static const char membercharB = '\102'; // B
static const char membercharC = '\x43'; // C
static const char membercharD = 0x44; // D
static const char membercharE = 69; // E
static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
static const char membercharAE2 = '\306'; // AE (latin1 encoded)
static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
};
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
%}

View file

@ -97,5 +97,5 @@ run_testcase = \
@exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" chicken_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
rm -f *.scm

View file

@ -0,0 +1,2 @@
(load "overload_extend_c.so")
(include "../schemerunme/overload_extend_c.scm")

View file

@ -48,4 +48,4 @@ run_testcase = \
@exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" clisp_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' clisp_clean

View file

@ -33,9 +33,7 @@
# can be used for memory checking of the runtime tests using:
# make RUNTOOL="valgrind --leak-check=full"
# and valgrind can be used when invoking SWIG using:
# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
# Note: trace-children needed because of preinst-swig shell wrapper
# to the swig executable.
# make SWIGTOOL="valgrind --tool=memcheck"
#
# An individual test run can be debugged easily:
# make director_string.cpptest RUNTOOL="gdb --args"
@ -56,8 +54,8 @@ endif
COMPILETOOL=
SWIGTOOL =
SWIG = $(SWIGTOOL) $(top_builddir)/preinst-swig
SWIG_LIB = $(top_srcdir)/Lib
SWIGEXE = $(top_builddir)/swig
SWIG_LIB_DIR = $(top_srcdir)/Lib
TEST_SUITE = test-suite
EXAMPLES = Examples
CXXSRCS =
@ -89,7 +87,6 @@ CPP_TEST_BROKEN += \
director_nested_class \
exception_partial_info \
extend_variable \
li_std_vector_ptr \
li_boost_shared_ptr_template \
nested_private \
overload_complicated \
@ -176,7 +173,6 @@ CPP_TEST_CASES += \
director_abstract \
director_alternating \
director_basic \
director_property \
director_binary_string \
director_classes \
director_classic \
@ -191,12 +187,14 @@ CPP_TEST_CASES += \
director_ignore \
director_keywords \
director_namespace_clash \
director_nested \
director_nspace \
director_nspace_director_name_collision \
director_nested \
director_overload \
director_overload2 \
director_pass_by_value \
director_primitives \
director_property \
director_protected \
director_protected_overloaded \
director_redefined \
@ -205,6 +203,7 @@ CPP_TEST_CASES += \
director_thread \
director_unroll \
director_using \
director_void \
director_wombat \
disown \
dynamic_cast \
@ -220,6 +219,7 @@ CPP_TEST_CASES += \
evil_diamond \
evil_diamond_ns \
evil_diamond_prop \
exception_classname \
exception_order \
extend \
extend_constructor_destructor \
@ -264,9 +264,9 @@ CPP_TEST_CASES += \
li_boost_shared_ptr_bits \
li_boost_shared_ptr_template \
li_boost_shared_ptr_attribute \
li_carrays \
li_cdata \
li_cpointer \
li_carrays_cpp \
li_cdata_cpp \
li_cpointer_cpp \
li_std_auto_ptr \
li_stdint \
li_swigtype_inout \
@ -282,6 +282,10 @@ CPP_TEST_CASES += \
minherit2 \
mixed_types \
multiple_inheritance \
multiple_inheritance_abstract \
multiple_inheritance_interfaces \
multiple_inheritance_nspace \
multiple_inheritance_shared_ptr \
name_cxx \
name_warnings \
namespace_class \
@ -303,6 +307,7 @@ CPP_TEST_CASES += \
nested_class \
nested_directors \
nested_comment \
nested_ignore \
nested_scope \
nested_template_base \
nested_workaround \
@ -341,12 +346,14 @@ CPP_TEST_CASES += \
rename2 \
rename3 \
rename4 \
rename_rstrip_encoder \
rename_scope \
rename_simple \
rename_strip_encoder \
rename_pcre_encoder \
rename_pcre_enum \
rename_predicates \
rename_wildcard \
restrict_cplusplus \
return_const_value \
return_value_scope \
@ -357,6 +364,7 @@ CPP_TEST_CASES += \
smart_pointer_const2 \
smart_pointer_const_overload \
smart_pointer_extend \
smart_pointer_ignore \
smart_pointer_member \
smart_pointer_multi \
smart_pointer_multi_typedef \
@ -374,12 +382,15 @@ CPP_TEST_CASES += \
smart_pointer_templatevariables \
smart_pointer_typedef \
special_variables \
special_variable_attributes \
special_variable_macros \
static_array_member \
static_const_member \
static_const_member_2 \
string_constants \
struct_initialization_cpp \
struct_value \
swig_exception \
symbol_clash \
template_arg_replace \
template_arg_scope \
@ -394,6 +405,8 @@ CPP_TEST_CASES += \
template_default \
template_default2 \
template_default_arg \
template_default_arg_overloaded \
template_default_arg_overloaded_extend \
template_default_arg_virtual_destructor \
template_default_class_parms \
template_default_class_parms_typedef \
@ -469,12 +482,13 @@ CPP_TEST_CASES += \
typedef_reference \
typedef_scope \
typedef_sizet \
typedef_struct \
typedef_struct_cpp \
typedef_typedef \
typemap_arrays \
typemap_array_qualifiers \
typemap_delete \
typemap_directorout \
typemap_documentation \
typemap_global_scope \
typemap_manyargs \
typemap_namespace \
@ -508,6 +522,7 @@ CPP_TEST_CASES += \
valuewrapper_opaque \
varargs \
varargs_overload \
variable_replacement \
virtual_destructor \
virtual_poly \
virtual_vs_nonvirtual_base \
@ -531,6 +546,7 @@ CPP11_TEST_CASES = \
cpp11_initializer_list \
cpp11_initializer_list_extend \
cpp11_lambda_functions \
cpp11_li_std_array \
cpp11_noexcept \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \
@ -597,7 +613,7 @@ CPP_STD_TEST_CASES += \
li_std_vector \
li_std_vector_enum \
li_std_vector_member_var\
naturalvar \
li_std_vector_ptr \
smart_pointer_inherit \
template_typedef_fnc \
template_type_namespace \
@ -622,7 +638,7 @@ C_TEST_CASES += \
char_constant \
const_const \
constant_expr \
empty \
empty_c \
enums \
enum_forward \
enum_macro \
@ -635,7 +651,7 @@ C_TEST_CASES += \
inctest \
infinity \
integers \
keyword_rename \
keyword_rename_c \
lextype \
li_carrays \
li_cdata \
@ -650,8 +666,8 @@ C_TEST_CASES += \
nested_extend_c \
nested_structs \
newobject2 \
overload_extend \
overload_extendc \
overload_extend_c \
overload_extend2 \
preproc \
preproc_constants_c \
preproc_defined \
@ -684,6 +700,11 @@ MULTI_CPP_TEST_CASES += \
wallkw.cpptest: SWIGOPT += -Wallkw
preproc_include.ctest: SWIGOPT += -includeall
# Allow modules to define temporarily failing tests.
C_TEST_CASES := $(filter-out $(FAILING_C_TESTS),$(C_TEST_CASES))
CPP_TEST_CASES := $(filter-out $(FAILING_CPP_TESTS),$(CPP_TEST_CASES))
MULTI_CPP_TEST_CASES := $(filter-out $(FAILING_MULTI_CPP_TESTS),$(MULTI_CPP_TEST_CASES))
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
$(C_TEST_CASES:=.ctest) \
@ -714,6 +735,7 @@ all: $(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES)
broken: $(BROKEN_TEST_CASES)
check: $(NOT_BROKEN_TEST_CASES)
@echo $(words $^) $(LANGUAGE) tests passed
check-c: $(C_TEST_CASES:=.ctest)
@ -725,6 +747,13 @@ ifdef HAS_DOXYGEN
check-doxygen: $(DOXYGEN_TEST_CASES:=.cpptest)
endif
check-failing-test = \
$(MAKE) -s $1.$2 >/dev/null 2>/dev/null && echo "Failing test $1 passed."
check-failing:
+-$(foreach t,$(FAILING_C_TESTS),$(call check-failing-test,$t,ctest);)
+-$(foreach t,$(FAILING_CPP_TESTS),$(call check-failing-test,$t,cpptest);)
+-$(foreach t,$(FAILING_MULTI_CPP_TESTS),$(call check-failing-test,$t,multicpptest);)
endif
# partialcheck target runs SWIG only, ie no compilation or running of tests (for a subset of languages)
@ -732,37 +761,37 @@ partialcheck:
$(MAKE) check CC=true CXX=true LDSHARED=true CXXSHARED=true RUNTOOL=true COMPILETOOL=true
swig_and_compile_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_c = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
$(LANGUAGE)$(VARIANT)
swig_and_compile_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
swig_and_compile_external = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
TARGET="$*_wrap_hdr.h" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$*_wrap_hdr.h' \
$(LANGUAGE)$(VARIANT)_externalhdr; \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS) $*_external.cxx" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS) $*_external.cxx' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_runtime = \

View file

@ -30,6 +30,7 @@ public:
static const double PUBLIC_DEFAULT;
Defaults2(int a = PRIVATE_DEFAULT) {}
double ret(double d = PUBLIC_DEFAULT) { return d; }
double nodefault(int x) { return x; }
};
%}

View file

@ -1,28 +1,44 @@
%module constant_directive
// %constant and struct
%inline %{
#if defined(_MSC_VER)
#pragma warning(disable : 4190) // warning C4190: 'result' has C-linkage specified, but returns UDT 'Type1' which is incompatible with C
#endif
struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
};
/* Typedefs for const Type and its pointer */
typedef const Type1 Type1Const;
typedef const Type1* Type1Cptr;
/* Typedefs for function pointers returning Type1 */
typedef Type1 (*Type1Fptr)();
typedef Type1 (* const Type1Cfptr)();
/* Function returning an instance of Type1 */
Type1 getType1Instance() { return Type1(111); }
%}
%{
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;
/* Typedef'ed types */
%constant Type1Const* TYPE1CONST_CONSTANT1 = &TYPE1_CONSTANT1;
%constant Type1Cptr TYPE1CPTR_CONSTANT1 = &TYPE1_CONSTANT1;
/* Function pointers */
%constant Type1 (*TYPE1FPTR1_CONSTANT1)() = getType1Instance;
%constant Type1 (* const TYPE1CFPTR1_CONSTANT1)() = getType1Instance;
/* Typedef'ed function pointers */
%constant Type1Fptr TYPE1FPTR1DEF_CONSTANT1 = getType1Instance;
%constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance;
/* Regular constant */
%constant int TYPE_INT = 0;

View file

@ -0,0 +1,62 @@
%module cpp11_li_std_array
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP)
%{
#include <array>
%}
%include <std_array.i>
%template(ArrayInt6) std::array<int, 6>;
%inline %{
std::array<int, 6> arrayOutVal() {
return { -2, -1, 0, 0, 1, 2 };
}
std::array<int, 6> & arrayOutRef() {
static std::array<int, 6> a = { -2, -1, 0, 0, 1, 2 };
return a;
}
const std::array<int, 6> & arrayOutConstRef() {
static std::array<int, 6> a = { -2, -1, 0, 0, 1, 2 };
return a;
}
std::array<int, 6> * arrayOutPtr() {
static std::array<int, 6> a = { -2, -1, 0, 0, 1, 2 };
return &a;
}
std::array<int, 6> arrayInVal(std::array<int, 6> myarray) {
std::array<int, 6> a = myarray;
for (auto& val : a) {
val *= 10;
}
return a;
}
const std::array<int, 6> & arrayInConstRef(const std::array<int, 6> & myarray) {
static std::array<int, 6> a = myarray;
for (auto& val : a) {
val *= 10;
}
return a;
}
void arrayInRef(std::array<int, 6> & myarray) {
for (auto& val : myarray) {
val *= 10;
}
}
void arrayInPtr(std::array<int, 6> * myarray) {
for (auto& val : *myarray) {
val *= 10;
}
}
%}
#endif

View file

@ -214,5 +214,12 @@ Enum1 globalTest1(Enum1 e) { return e; }
Class1::Enum12 globalTest2(Class1::Enum12 e) { return e; }
Class1::Struct1::Enum12 globalTest3(Class1::Struct1::Enum12 e) { return e; }
class PrivateEnumClass {
private:
enum class Enum {
PrivateEnum1,
PrivateEnum2
};
};
%}

View file

@ -1,56 +1,86 @@
/* This testcase checks whether SWIG correctly parses alias templates. */
/* This testcase checks whether SWIG correctly handles alias templates. */
%module cpp11_template_typedefs
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefName;
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) TypedefNamePtr;
%warnfilter(SWIGWARN_CPP11_ALIAS_TEMPLATE) MyIntKeyClass;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) PF;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator1;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) BucketAllocator2;
// This warning should go away when type aliasing is supported
#pragma SWIG nowarn=SWIGWARN_PARSE_USING_UNDEF // Nothing known about 'p.SomeType< char *,T2,4 >'.
%inline %{
template< typename T1, typename T2, int >
template<typename T>
using ptr_t = T*;
namespace ns {
template<typename T1, typename T2, int N>
class SomeType {
public:
using type1_t = T1;
using type2_t = T2;
T1 a;
T2 b;
int c;
constexpr int get_n() { return N; }
};
// template aliasing
template< typename T2 >
using TypedefName = SomeType<char*, T2, 5>;
template< typename T2 >
using TypedefNamePtr = SomeType<char*, T2, 4>*;
// type aliasing
typedef void (*PFD)(double); // Old style
using PF = void (*)(double); // New introduced syntax
// use of template aliasing
template<typename Key,typename Val>
class MyCPP11Class {
// Specialization for T1=const char*, T2=bool
template<int N>
class SomeType<const char*, bool, N> {
public:
using type1_t = const char*;
using type2_t = bool;
type1_t a;
type2_t b;
constexpr int get_n() { return 3 * N; }
};
template<typename VAL> using MyIntKeyClass = MyCPP11Class<int,VAL>;
MyIntKeyClass<char> intchar;
TypedefName<int> alias1(TypedefName<int> a) { return a; }
TypedefNamePtr<int> alias1(TypedefNamePtr<int> a = nullptr) { return a; }
%}
// alias templates
template<typename T2>
using TypedefName = SomeType<const char*, T2, 5>;
template<typename T2>
using TypedefNamePtr = ptr_t<SomeType<const char*, T2, 4>>;
// alias template that returns T2 for a SomeType<T1,T2,N> class
template<typename T>
using T2_of = typename T::type2_t;
T2_of<TypedefName<int>> get_SomeType_b(const SomeType<const char*, int, 5>& x) { return x.b; }
template<typename T>
T2_of<TypedefName<T>> get_SomeType_b2(const TypedefName<T>& x) { return x.b; }
} // namespace ns
ns::TypedefName<int> create_TypedefName() { return { "hello", 10}; }
ns::TypedefName<bool> create_TypedefNameBool() { return { "hello", true}; }
ns::TypedefNamePtr<int> identity(ns::TypedefNamePtr<int> a = nullptr) { return a; }
%inline %{
typedef double Val;
template<typename T> struct ListBucket {
};
namespace Alloc {
template<typename T> struct rebind {
typedef int other;
using other = int;
};
}
using BucketAllocator1 = typename Alloc::template rebind<ListBucket<Val>>::other;
using BucketAllocator2 = typename Alloc::template rebind<::template ListBucket<double>>::other;
BucketAllocator1 get_bucket_allocator1() { return 1; }
BucketAllocator2 get_bucket_allocator2() { return 2; }
%}
%immutable ns::SomeType::a;
// %template() directives
%template(SomeTypeInt5) ns::SomeType<const char*, int, 5>;
%template(SomeTypeInt4) ns::SomeType<const char*, int, 4>;
%template(SomeTypeBool5) ns::SomeType<const char*, bool, 5>;
%template(ListBucketDouble) ListBucket<Val>;
%template(RebindListBucketDouble) Alloc::rebind<ListBucket<Val>>;
%template() ptr_t<ns::SomeType<const char*, int, 4>>;
%template() ns::TypedefName<int>;
%template() ns::TypedefName<bool>;
%template() ns::TypedefNamePtr<int>;
%template() ns::T2_of<ns::TypedefName<int>>;
%template(get_SomeType_b2) ns::get_SomeType_b2<int>;

View file

@ -2,15 +2,6 @@
// Type aliasing seg fault : Github issue #424
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
%inline %{
namespace Halide {
@ -53,14 +44,69 @@ public:
%inline %{
using Int = int;
using IntRef = int&;
using IntPtrRef = int*&;
using IntRValueRef = int&&;
using IntArray = int[];
using HalideTargetPtr1 = Halide::Target*;
namespace Halide {
using HalideTargetPtr2 = Target*;
}
%}
// Define some types
%inline %{
using Int = int;
using IntPtr = Int*;
using IntRef = Int&;
using IntPtrRef = Int*&;
using IntRValueRef = Int&&;
using IntArray = Int[];
%}
// Test that SWIG understands these new types
%callback("%s_cb");
Int mult2(Int x);
%nocallback;
%inline %{
Int mult2(Int x) { return x * 2; }
IntPtr allocate_int() { return new Int(12); }
void free_int(int* ptr) { delete ptr; }
void inplace_mult2(IntRef x) { x *= 2; }
Int read_int(IntPtr ptr) { return *ptr; }
template <typename T> class Pair {
public:
using data_t = T;
data_t a, b;
Pair() : a(), b() { }
Pair(data_t a, data_t b) : a(a), b(b) { }
data_t first() { return a; }
data_t second() { return b; }
};
%}
%template(int_pair) Pair<Int>;
%inline %{
using PairInt = Pair<Int>;
class PairSubclass : public PairInt {
public:
PairSubclass(data_t a, data_t b) : PairInt(a, b) { }
using const_ref_data_t = const data_t&;
};
PairSubclass::data_t plus1(PairSubclass::const_ref_data_t x) { return x + 1; }
%}
// Test function pointers
%inline %{
using callback_t = int(*)(int);
callback_t get_callback() { return mult2; }
int call(callback_t func, int param) { return func(param); }
%}

View file

@ -6,6 +6,12 @@ The primary purpose of this testcase is to ensure that enums used along with the
%inline %{
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/* for anonymous enums */
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
enum SOME_ENUM {ENUM_ONE, ENUM_TWO};
struct StructWithEnums {

View file

@ -22,5 +22,28 @@ public:
%}
%{
int StaticMemberTest::static_int;
int StaticMemberTest::static_int = 99;
%}
%inline %{
struct StaticBase {
static int statty;
virtual ~StaticBase() {}
};
struct StaticDerived : StaticBase {
static int statty;
};
%}
%{
int StaticBase::statty = 11;
int StaticDerived::statty = 111;
%}
%inline %{
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
bool is_python_builtin() { return false; }
#endif
%}

View file

@ -73,7 +73,7 @@ setup = \
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
# DYLD_FALLBACK_LIBRARY_PATH is cleared for Mac OS X.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \

View file

@ -0,0 +1,82 @@
// This test tests all the methods in the C# collection wrapper
using System;
using cpp11_li_std_arrayNamespace;
public class cpp11_li_std_array_runme
{
private static ArrayInt6 ToArray6(int[] a)
{
if (a.Length != 6)
throw new Exception("a is incorrect size");
return new ArrayInt6(a);
}
private static void compareContainers(ArrayInt6 actual, int[] expected)
{
if (actual.Count != expected.Length)
throw new Exception("Sizes are different: " + actual.Count + " " + expected.Length);
for (int i=0; i<actual.Count; ++i)
{
int actualValue = actual[i];
int expectedValue = expected[i];
if (actualValue != expectedValue)
throw new Exception("Value is wrong for element " + i + ". Expected " + expectedValue + " got: " + actualValue);
}
if (actual.IsEmpty)
throw new Exception("ai should not be empty");
}
static void Main()
{
ArrayInt6 ai = new ArrayInt6();
compareContainers(ai, new int[] { 0, 0, 0, 0, 0, 0 });
int[] vals = { 10, 20, 30, 40, 50, 60 };
for (int i = 0; i < ai.Count; ++i)
ai[i] = vals[i];
compareContainers(ai, vals);
// Check return
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 });
// Check passing arguments
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
cpp11_li_std_array.arrayInRef(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
cpp11_li_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
// fill
ai.Fill(111);
compareContainers(ai, new int[] { 111, 111, 111, 111, 111, 111 });
// out of range errors
try
{
ai[ai.Count] = 0;
throw new Exception("Out of range exception not caught");
}
catch (ArgumentOutOfRangeException)
{
}
try
{
ai[-1] = 0;
throw new Exception("Out of range exception not caught");
}
catch (ArgumentOutOfRangeException)
{
}
}
}

View file

@ -0,0 +1,43 @@
using System;
using director_pass_by_valueNamespace;
public class runme
{
private static void WaitForGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(10);
}
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
Caller caller = new Caller();
caller.call_virtualMethod(new director_pass_by_value_Derived());
{
int countdown = 5;
while (true) {
WaitForGC();
if (--countdown == 0)
break;
};
}
// bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
int ret = runme.passByVal.getVal();
if (ret != 0x12345678)
throw new Exception("Bad return value, got " + ret.ToString("x"));
}
public static PassedByValue passByVal;
}
class director_pass_by_value_Derived : DirectorPassByValueAbstractBase {
public override void virtualMethod(PassedByValue pbv) {
runme.passByVal = pbv;
}
}

View file

@ -1,13 +1,13 @@
using director_smartptrNamespace;
using System;
public class runme
{
private class director_smartptr_MyBarFoo : Foo
{
public override string ping()
{
return "director_smartptr_MyBarFoo.ping();";
return "director_smartptr_MyBarFoo.ping()";
}
public override string pong()
@ -15,27 +15,39 @@ public class runme
return "director_smartptr_MyBarFoo.pong();" + ping();
}
public override string fooBar(FooBar fooBar)
public override string upcall(FooBar fooBarPtr)
{
return fooBar.FooBarDo();
return "override;" + fooBarPtr.FooBarDo();
}
public override Foo makeFoo()
{
return new Foo();
}
}
public override FooBar makeFooBar()
{
return new FooBar();
}
private static void check(string got, string expected)
{
if (got != expected)
throw new ApplicationException("Failed, got: " + got + " expected: " + expected);
}
static void Main()
{
director_smartptr_MyBarFoo myBarFoo =
new director_smartptr_MyBarFoo();
FooBar fooBar = new FooBar();
myBarFoo.ping();
Foo myBarFoo = new director_smartptr_MyBarFoo();
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");
Foo myFoo = myBarFoo.makeFoo();
check(myFoo.pong(), "Foo::pong();Foo::ping()");
check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
check(myFoo.upcall(new FooBar()), "Bar::Foo2::Foo2Bar()");
Foo myFoo2 = new Foo().makeFoo();
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
}
}

View file

@ -0,0 +1,83 @@
using System;
using director_voidNamespace;
public class runme
{
private static void WaitForGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(10);
}
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
Caller caller = new Caller();
{
DirectorVoidPointer dvp = new DirectorVoidPointer(5);
int x = caller.callVirtualIn(dvp, 6);
if (x != 106)
throw new Exception("Fail1 should be 106, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = Caller.VoidToInt(ptr);
if (x != 106)
throw new Exception("Fail2 should be 106, got " + x);
x = Caller.VoidToInt(dvp.voidPtrOut());
if (x != 106)
throw new Exception("Fail3 should be 106, got " + x);
}
{
DirectorVoidPointer dvp = new director_void_VoidPointer(5);
int x = caller.callVirtualIn(dvp, 6);
if (x != 12)
throw new Exception("Fail1 should be 12, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = Caller.VoidToInt(ptr);
if (x != 25)
throw new Exception("Fail2 should be 25, got " + x);
x = Caller.VoidToInt(dvp.voidPtrOut());
if (x != 1234)
throw new Exception("Fail3 should be 1234, got " + x);
}
{
DirectorVoidPointer dvp = new DirectorVoidPointer(10);
int x = caller.callVirtualOut(dvp);
if (x != 10)
throw new Exception("Bad1 should be 10, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = dvp.nonVirtualVoidPtrIn(ptr);
if (x != 110)
throw new Exception("Bad2 should be 110, got " + x);
}
{
DirectorVoidPointer dvp = new director_void_VoidPointer(10);
int x = caller.callVirtualOut(dvp);
if (x != 1234)
throw new Exception("Bad3 should be 1234, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = dvp.nonVirtualVoidPtrIn(ptr);
if (x != 1334)
throw new Exception("Bad4 should be 1334, got " + x);
}
}
}
class director_void_VoidPointer : DirectorVoidPointer {
public director_void_VoidPointer(int num) : base(num*num) {
}
public override int voidPtrIn(global::System.IntPtr p) {
return Caller.VoidToInt(p) * 2;
}
public override global::System.IntPtr voidPtrOut() {
setNewValue(1234);
return nonVirtualVoidPtrOut();
}
}

View file

@ -405,6 +405,10 @@ public class runme {
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
}
{
if (enum_thorough_typesafe.enumWithMacroTest(enumWithMacro.ABCD).swigValue != (('A' << 24) | ('B' << 16) | ('C' << 8) | 'D')) throw new Exception("enumWithMacroTest 1 failed");
if (enum_thorough_typesafe.enumWithMacroTest(enumWithMacro.ABCD2).swigValue != enum_thorough_typesafe.enumWithMacroTest(enumWithMacro.ABCD).swigValue) throw new Exception("enumWithMacroTest 2 failed");
}
// different types
{
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
@ -413,6 +417,8 @@ public class runme {
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typecharcompound).swigValue != (int)'A' + 1) throw new Exception("differentTypes 7 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typecharcompound2).swigValue != (int)'B' << 2) throw new Exception("differentTypes 8 failed");
int global_enum = enum_thorough_typesafe.global_typeint;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
@ -426,6 +432,10 @@ public class runme {
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough_typesafe.global_typedefaultint;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
global_enum = enum_thorough_typesafe.global_typecharcompound;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != (int)'A' + 1) throw new Exception("global differentTypes 7 failed");
global_enum = enum_thorough_typesafe.global_typecharcompound2;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != (int)'B' << 2) throw new Exception("global differentTypes 8 failed");
}
}
}

View file

@ -7,6 +7,7 @@ public class li_std_except_runme {
public static void Main() {
Test test = new Test();
try { test.throw_bad_cast(); throw new Exception("throw_bad_cast failed"); } catch (InvalidCastException) {}
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}

View file

@ -0,0 +1,245 @@
using System;
using multiple_inheritance_abstractNamespace;
public class multiple_inheritance_abstract_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using multiple_inheritance_interfacesNamespace;
public class multiple_inheritance_interfaces_runme {
static string SortArrayToString(string[] types) {
Array.Sort<string>(types);
return string.Join(" ", types);
}
static string SortArrayToString(Type[] types) {
List<string> stypes = new List<string>();
foreach (Type t in types)
stypes.Add(t.Name);
return SortArrayToString(stypes.ToArray());
}
private static void checkBaseAndInterfaces(Type cls, bool interfaceExpected, string baseClass, string[] interfaces) {
string[] expectedInterfaces = new string[interfaces.Length + (interfaceExpected ? 0 : 1)];
for (int i=0; i<interfaces.Length; ++i)
expectedInterfaces[i] = interfaces[i];
if (!interfaceExpected)
expectedInterfaces[interfaces.Length] = "IDisposable";
Type[] actualInterfaces = cls.GetInterfaces();
string expectedInterfacesString = SortArrayToString(expectedInterfaces);
string actualInterfacesString = SortArrayToString(actualInterfaces);
if (expectedInterfacesString != actualInterfacesString)
throw new Exception("Expected interfaces for " + cls.Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
string expectedBaseString = null;
if (interfaceExpected) {
// expecting an interface
if (!cls.IsInterface)
throw new Exception(cls.Name + " should be an interface but is not");
expectedBaseString = string.IsNullOrEmpty(baseClass) ? "" : "multiple_inheritance_interfacesNamespace." + baseClass;
} else {
// expecting a class
if (cls.IsInterface)
throw new Exception(cls.Name + " is an interface but it should not be");
expectedBaseString = string.IsNullOrEmpty(baseClass) ? "Object" : baseClass;
}
string actualBaseString = cls.BaseType == null ? "" : cls.BaseType.Name;
if (expectedBaseString != actualBaseString)
throw new Exception("Expected base for " + cls.Name + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
}
public static void Main() {
// Note that we can't get just the immediate interface
// Type.GetInterfaces() returns all interfaces up the inheritance hierarchy
checkBaseAndInterfaces(typeof(IA), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IB), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IC), true, "", new string[] {"IA", "IB"});
checkBaseAndInterfaces(typeof(A), false, "", new string[] {"IA"});
checkBaseAndInterfaces(typeof(B), false, "", new string[] {"IB"});
checkBaseAndInterfaces(typeof(C), false, "", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(D), false, "", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(E), false, "D", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(IJ), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IK), true, "", new string[] {"IJ"});
checkBaseAndInterfaces(typeof(IL), true, "", new string[] {"IJ", "IK"});
checkBaseAndInterfaces(typeof(J), false, "", new string[] {"IJ"});
checkBaseAndInterfaces(typeof(K), false, "", new string[] {"IJ", "IK"});
checkBaseAndInterfaces(typeof(L), false, "", new string[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(typeof(M), false, "", new string[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(typeof(P), false, "", new string[] {});
checkBaseAndInterfaces(typeof(IQ), true, "", new string[] {});
checkBaseAndInterfaces(typeof(Q), false, "", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(R), false, "P", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(S), false, "P", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(T), false, "", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(U), false, "R", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(V), false, "S", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(W), false, "T", new string[] {"IQ"});
// overloaded methods check
D d = new D();
d.ia();
d.ia(10);
d.ia("bye");
d.ia("bye", false);
}
}

View file

@ -0,0 +1,246 @@
using System;
using multiple_inheritance_nspaceNamespace;
using multiple_inheritance_nspaceNamespace.Space;
public class multiple_inheritance_nspace_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1SwigInterface cb1){
return cb1.cbase1y();
}
int jabase1(ABase1SwigInterface ab1){
return ab1.abase1();
}
int jcbase2(CBase2SwigInterface cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1SwigInterface cb1=new CBase1();
CBase2SwigInterface cb2=new CBase2();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test nspace class as return value
ABase1SwigInterface ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1SwigInterface cb6=d2.cloneit();
CBase2SwigInterface cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1SwigInterface cb3=new Derived1();
CBase1SwigInterface cb4=new Derived3();
CBase2SwigInterface cb5=new Derived3();
ABase1SwigInterface ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,329 @@
using System;
using multiple_inheritance_shared_ptrNamespace;
public class multiple_inheritance_shared_ptr_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Shared pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
//Shared pointer reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,30 @@
using System;
using special_variable_attributesNamespace;
public class special_variable_attributes_runme {
public static void Main() {
if (special_variable_attributes.getNumber1() != 111)
throw new ApplicationException("getNumber1 failed");
if (special_variable_attributes.getNumber2() != 222)
throw new ApplicationException("getNumber2 failed");
if (special_variable_attributes.getNumber3() != 333)
throw new ApplicationException("getNumber3 failed");
if (special_variable_attributes.bounceNumber1(10) != 110)
throw new ApplicationException("bounceNumber1 failed");
if (special_variable_attributes.bounceNumber2(10) != 220)
throw new ApplicationException("bounceNumber2 failed");
if (special_variable_attributes.bounceNumber3(10) != 330)
throw new ApplicationException("bounceNumber3 failed");
if (special_variable_attributes.multi1(12.34) != 12+34)
throw new ApplicationException("multi1 failed");
if (special_variable_attributes.multi2(12.34) != 12+34+55)
throw new ApplicationException("multi2 failed");
if (special_variable_attributes.multi3(12.34) != 12+34+77)
throw new ApplicationException("multi3 failed");
}
}

View file

@ -77,6 +77,10 @@
// char
char chartest1(char c = 'x') { return c; }
char chartest2(char c = '\0') { return c; }
char chartest3(char c = '\1') { return c; }
char chartest4(char c = '\n') { return c; }
char chartest5(char c = '\102') { return c; } // 'B'
char chartest6(char c = '\x43') { return c; } // 'C'
// namespaces
namespace AType {

View file

@ -0,0 +1,14 @@
%module default_args_c
/* Default arguments for C code */
int foo1(int x = 42 || 3);
int foo43(int x = 42 | 3);
%{
int foo1(int x) {
return x;
}
int foo43(int x) {
return x;
}
%}

View file

@ -113,6 +113,10 @@ public:
void bar(F *) { }
#if defined(_MSC_VER)
#pragma warning(disable: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted
#endif
// Single inheritance, base has private destructor
class FFF : public F {
};
@ -123,6 +127,10 @@ class GGG : public A, public F {
class HHH : public F, public A {
};
#if defined(_MSC_VER)
#pragma warning(default: 4624) // destructor could not be generated because a base class destructor is inaccessible or deleted
#endif
/* A class with a protected destructor */
class G {
protected:

View file

@ -28,6 +28,21 @@ class DirectorMethodException: public Swig::DirectorException {};
%include "std_string.i"
#ifdef SWIGPHP
%feature("director:except") {
if ($error == FAILURE) {
throw Swig::DirectorMethodException();
}
}
%exception {
try { $action }
catch (Swig::DirectorException &) { SWIG_fail; }
}
#endif
#ifdef SWIGPYTHON
%feature("director:except") {

View file

@ -0,0 +1,30 @@
%module(directors="1") director_pass_by_value
%director DirectorPassByValueAbstractBase;
%inline %{
class PassedByValue {
int val;
public:
PassedByValue() { val = 0x12345678; }
int getVal() { return val; }
};
int doSomething(int x) {
int yy[256];
yy[0] =0x9876;
return yy[0];
}
class DirectorPassByValueAbstractBase {
public:
virtual void virtualMethod(PassedByValue pbv) = 0;
virtual ~DirectorPassByValueAbstractBase () {}
};
class Caller {
public:
void call_virtualMethod(DirectorPassByValueAbstractBase &f) {
f.virtualMethod(PassedByValue());
}
};
%}

View file

@ -23,16 +23,18 @@ public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
virtual std::string fooBar(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
virtual std::string upcall(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
virtual Foo makeFoo() { return Foo(); }
virtual FooBar makeFooBar() { return FooBar(); }
static std::string callPong(Foo &foo) { return foo.pong(); }
static std::string callUpcall(Foo &foo, FooBar* fooBarPtr) { return foo.upcall(fooBarPtr); }
static Foo* get_self(Foo *self_) {return self_;}
};
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
@ -61,10 +63,12 @@ public:
virtual ~Foo();
virtual std::string ping();
virtual std::string pong();
virtual std::string fooBar(FooBar* fooBarPtr);
virtual std::string upcall(FooBar* fooBarPtr);
virtual Foo makeFoo();
virtual FooBar makeFooBar();
static std::string callPong(Foo &foo);
static std::string callUpcall(Foo &foo, FooBar* fooBarPtr);
static Foo* get_self(Foo *self_);
};

View file

@ -0,0 +1,47 @@
%module(directors="1") director_void
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) voidPtrOut;
%feature("director") DirectorVoidPointer;
#if defined(SWIGCSHARP)
%apply void *VOID_INT_PTR { void * }
#endif
%inline %{
class DirectorVoidPointer {
int *ptr;
public:
DirectorVoidPointer(int val) : ptr(new int(val)) {}
virtual ~DirectorVoidPointer() { delete ptr; }
virtual void * voidPtrOut() { return ptr; }
virtual int voidPtrIn(void *p) {
return nonVirtualVoidPtrIn(p);
}
void setNewValue(int val) {
delete ptr;
ptr = new int(val);
}
void *nonVirtualVoidPtrOut() { return ptr; }
int nonVirtualVoidPtrIn(void *p) {
int val = *(int *)p;
setNewValue(val + 100);
return *ptr;
}
};
struct Caller {
int callVirtualIn(DirectorVoidPointer *d, int num) {
return d->voidPtrIn(&num);
}
int callVirtualOut(DirectorVoidPointer *d) {
return *(int *)d->voidPtrOut();
}
static int VoidToInt(void *p) {
return *(int *)p;
}
};
%}

View file

@ -0,0 +1 @@
%module empty_c

View file

@ -47,6 +47,12 @@
%inline %{
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/* for anonymous enums */
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
enum { AnonEnum1, AnonEnum2 = 100 };
enum { ReallyAnInteger = 200 };
//enum { AnonEnum3, AnonEnum4 } instance;
@ -563,6 +569,17 @@ repeat repeatTest(repeat e) { return e; }
}
%}
%inline %{
namespace EnumWithMacro {
#define PACK(C1,C2,C3,C4) ((C1<<24)|(C2<<16)|(C3<<8)|C4)
typedef enum {
ABCD = PACK('A','B','C','D'),
ABCD2 = ABCD
} enumWithMacro;
enumWithMacro enumWithMacroTest(enumWithMacro e) { return e; }
}
%}
%inline %{
namespace DifferentSpace {
enum DifferentTypes {
@ -571,7 +588,9 @@ enum DifferentTypes {
typebooltrue = true,
typebooltwo,
typechar = 'C',
typedefaultint
typedefaultint,
typecharcompound='A'+1,
typecharcompound2='B' << 2
};
DifferentTypes differentTypesTest(DifferentTypes n) { return n; }
@ -581,11 +600,68 @@ enum {
global_typebooltrue = true,
global_typebooltwo,
global_typechar = 'C',
global_typedefaultint
global_typedefaultint,
global_typecharcompound='A'+1,
global_typecharcompound2='B' << 2
};
int globalDifferentTypesTest(int n) { return n; }
}
%}
#if defined(SWIGCSHARP)
%csconstvalue("1") globalenumchar1;
%csconstvalue("'B'") globalenumcharB;
%csconstvalue("1") enumchar1;
%csconstvalue("'B'") enumcharB;
#endif
%inline %{
#if defined(__clang__)
#pragma clang diagnostic push
// Suppress: illegal character encoding in character literal
#pragma clang diagnostic ignored "-Winvalid-source-encoding"
#endif
enum {
globalenumchar0 = '\0',
globalenumchar1 = '\1',
globalenumchar2 = '\n',
globalenumcharA = 'A',
globalenumcharB = '\102', // B
globalenumcharC = '\x43', // C
globalenumcharD = 0x44, // D
globalenumcharE = 69, // E
globalenumcharAE1 = 'Æ', // AE (latin1 encoded)
globalenumcharAE2 = '\306', // AE (latin1 encoded)
globalenumcharAE3 = '\xC6' // AE (latin1 encoded)
};
enum EnumChar {
enumchar0 = '\0',
enumchar1 = '\1',
enumchar2 = '\n',
enumcharA = 'A',
enumcharB = '\102', // B
enumcharC = '\x43', // C
enumcharD = 0x44, // D
enumcharE = 69, // E
enumcharAE1 = 'Æ', // AE (latin1 encoded)
enumcharAE2 = '\306', // AE (latin1 encoded)
enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
struct EnumCharStruct {
enum EnumChar {
enumchar0 = '\0',
enumchar1 = '\1',
enumchar2 = '\n',
enumcharA = 'A',
enumcharB = '\102', // B
enumcharC = '\x43', // C
enumcharD = 0x44, // D
enumcharE = 69, // E
enumcharAE1 = 'Æ', // AE (latin1 encoded)
enumcharAE2 = '\306', // AE (latin1 encoded)
enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
};
%}
#if defined(SWIGJAVA)
@ -594,6 +670,53 @@ int globalDifferentTypesTest(int n) { return n; }
%csconst(0);
#endif
%inline %{
enum {
x_globalenumchar0 = '\0',
x_globalenumchar1 = '\1',
x_globalenumchar2 = '\n',
x_globalenumcharA = 'A',
x_globalenumcharB = '\102', // B
x_globalenumcharC = '\x43', // C
x_globalenumcharD = 0x44, // D
x_globalenumcharE = 69, // E
x_globalenumcharAE1 = 'Æ', // AE (latin1 encoded)
x_globalenumcharAE2 = '\306', // AE (latin1 encoded)
x_globalenumcharAE3 = '\xC6' // AE (latin1 encoded)
};
enum X_EnumChar {
x_enumchar0 = '\0',
x_enumchar1 = '\1',
x_enumchar2 = '\n',
x_enumcharA = 'A',
x_enumcharB = '\102', // B
x_enumcharC = '\x43', // C
x_enumcharD = 0x44, // D
x_enumcharE = 69, // E
x_enumcharAE1 = 'Æ', // AE (latin1 encoded)
x_enumcharAE2 = '\306', // AE (latin1 encoded)
x_enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
struct X_EnumCharStruct {
enum X_EnumChar {
enumchar0 = '\0',
enumchar1 = '\1',
enumchar2 = '\n',
enumcharA = 'A',
enumcharB = '\102', // B
enumcharC = '\x43', // C
enumcharD = 0x44, // D
enumcharE = 69, // E
enumcharAE1 = 'Æ', // AE (latin1 encoded)
enumcharAE2 = '\306', // AE (latin1 encoded)
enumcharAE3 = '\xC6' // AE (latin1 encoded)
};
};
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
%}
%inline %{
namespace DifferentSpace {
enum DifferentTypesNoConst {
@ -614,5 +737,4 @@ enum {
global_typedefaultint_noconst
};
}
%}

View file

@ -12,6 +12,12 @@
%inline %{
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/* for anonymous enums */
/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
typedef enum {
CSP_ITERATION_FWD,
CSP_ITERATION_BWD = 11

View file

@ -1,4 +0,0 @@
*.newerr
cpp_recursive_typedef.py
cpp_shared_ptr.py
xxx.py

View file

@ -20,6 +20,9 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SWIG_LIB_SET = @SWIG_LIB_SET@
SWIGINVOKE = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE)
# All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input
ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i)))
CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES))
@ -44,7 +47,7 @@ $(DOXYGEN_ERROR_TEST_CASES): SWIGOPT += -doxygen
# Portable dos2unix / todos for stripping CR
TODOS = tr -d '\r'
#TODOS = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
#TODOS = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//'
# strip source directory from output, so that diffs compare
STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
@ -52,17 +55,17 @@ STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
# Rules for the different types of tests
%.cpptest:
echo "$(ACTION)ing errors testcase $*"
-$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
-$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.ctest:
echo "$(ACTION)ing errors testcase $*"
-$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
-$(SWIGINVOKE) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.clean:
@exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean
@rm -f *.$(ERROR_EXT) *.py

View file

@ -1,4 +0,0 @@
%module xxx
int foo(int x = 42 || 3);

View file

@ -1,3 +0,0 @@
%module xxx
int foo(int x, ...);

View file

@ -0,0 +1,19 @@
%module xxx
// Only non-ignored classes should warn about Ignored base classes
%ignore ActualClass;
%ignore ActualClassNoTemplates;
%{
struct BaseClassNoTemplates {};
%}
%inline %{
template<typename T>
class TemplateClass {};
class ActualClass : public TemplateClass<int> {};
class AktuelKlass : public TemplateClass<int> {};
class ActualClassNoTemplates : public BaseClassNoTemplates {};
class AktuelKlassNoTemplates : public BaseClassNoTemplates {};
%}

View file

@ -0,0 +1,3 @@
cpp_inherit_ignored.i:15: Warning 401: Nothing known about base class 'TemplateClass< int >'. Ignored.
cpp_inherit_ignored.i:15: Warning 401: Maybe you forgot to instantiate 'TemplateClass< int >' using %template.
cpp_inherit_ignored.i:18: Warning 401: Nothing known about base class 'BaseClassNoTemplates'. Ignored.

View file

@ -1,15 +0,0 @@
%module xxx
int foo(int x);
int foo(double x);
class Foo {
public:
int bar(int);
int bar(double);
};
class Spam {
public:
Spam();
Spam(int);
};

View file

@ -1,7 +0,0 @@
%module xxx
class foo {
static const int BAR = 42;
public:
int blah(int x = BAR);
};

View file

@ -1,8 +0,0 @@
%module xxx
template<T> T blah(T x);

View file

@ -4,4 +4,4 @@ template<class T> T blah(T x) { };
%template(iblah) blah<int>;
%template(iiblah) blah<int>;
// The second %template instantiation above should surely be ignored with a warning, but doesn't atm

View file

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

View file

@ -1,7 +0,0 @@
%module xxx
#define foo(a,x) a x
#if foo
#endif

View file

@ -1 +1 @@
swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of pythoncode)
swig_pythoncode_bad.i:7: Error: Line indented less than expected (line 2 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1

View file

@ -1 +1 @@
swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of pythoncode)
swig_pythoncode_bad2.i:13: Error: Line indented less than expected (line 3 of %pythoncode or %insert("python") block) as no line should be indented less than the indentation in line 1

View file

@ -0,0 +1,7 @@
%module xxx
%pythoncode %{
def extra():
print "extra a" # indentation is 2 spaces then tab
print "extra b" # indentation is tab then 2 spaces
%}

View file

@ -0,0 +1 @@
swig_pythoncode_bad3.i:7: Warning 740: Whitespace indentation is inconsistent compared to earlier lines (line 3 of %pythoncode or %insert("python") block)

View file

@ -0,0 +1,13 @@
%module exception_classname
%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
#if defined(SWIGPHP) || defined(SWIGD)
%rename(ExceptionClass) Exception;
#endif
%inline %{
class Exception {
public:
int testfunc() { return 42; }
};
%}

View file

@ -23,6 +23,9 @@ struct Base {
virtual int method(int v) {
return v;
}
#if !defined(SWIG)
virtual ~Base() {}
#endif
};
struct Derived : Base {
double actualval;

View file

@ -20,7 +20,7 @@ int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
%constant int (* const ADD_BY_VALUE_C)(const int &, int) = addByValue;
%inline %{
typedef int AddByValueTypedef(const int &a, int b);

View file

@ -11,6 +11,8 @@ GO12 = @GO12@
GO13 = @GO13@
GO15 = @GO15@
GOC = @GOC@
GOVERSIONOPTION = @GOVERSIONOPTION@
host = @host@
SCRIPTSUFFIX = _runme.go
GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1); then echo tool $(GOC:c=g); fi`
@ -20,6 +22,8 @@ GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi`
OSXOLDGOLINKFLAGS = `if [ -n "\`$(GO) $(GOVERSIONOPTION) | grep -E 'go1($|.0|.1|.2|.3)'\`" ] && [ -n "\`echo $(host) | grep darwin\`" ]; then echo "-Wl,-U,__cgo_topofstack"; fi`
SO = @SO@
srcdir = @srcdir@
@ -46,11 +50,11 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+$(swig_and_compile_cpp)
$(run_testcase_cpp)
if ! $(GO15); then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp_nocgo; \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
$(LANGUAGE)$(VARIANT)_cpp_nocgo && \
$(run_testcase_cpp); \
fi
@ -59,11 +63,11 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+$(swig_and_compile_c)
$(run_testcase)
if ! $(GO15); then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_nocgo; \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \
$(LANGUAGE)$(VARIANT)_nocgo && \
$(run_testcase); \
fi
@ -79,10 +83,10 @@ li_windows.cpptest:
multi_import.multicpptest:
$(setup)
for f in multi_import_b multi_import_a; do \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
$(run_multi_testcase)
@ -91,18 +95,18 @@ go_subdir_import.multicpptest:
$(setup)
mkdir -p testdir/go_subdir_import/
mkdir -p gopath/src/testdir/go_subdir_import/
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INTERFACEPATH="$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) -outdir ." NOLINK=true \
TARGET="$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" \
INTERFACE="testdir/go_subdir_import/go_subdir_import_b.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INTERFACEPATH='$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i' \
INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT) -outdir .' NOLINK=true \
TARGET='$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' \
INTERFACE='testdir/go_subdir_import/go_subdir_import_b.i' \
$(LANGUAGE)$(VARIANT)_cpp;
for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
if $(GOGCC); then \
@ -121,7 +125,7 @@ run_testcase = \
$(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
@ -136,7 +140,7 @@ run_testcase_cpp = \
$(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a -lstdc++; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
@ -152,7 +156,7 @@ run_multi_testcase = \
$(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.a; done` -lstdc++; \
elif $(GO12) || $(GO13) || $(GO15); then \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
else \
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
@ -164,7 +168,7 @@ run_multi_testcase = \
@rm -rf $*.go $*_gc.c $*_wrap.* $*_runme $*.gox $*.a
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" go_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' go_clean
rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox
rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox
rm -f clientdata_prop_a.go clientdata_prop_a.gox

View file

@ -0,0 +1,6 @@
package main
import _ "./empty_c"
func main() {
}

View file

@ -40,4 +40,14 @@ func main() {
fmt.Println("got", a, "want", dwant)
panic(a)
}
c2 := go_inout.NewC2()
pm := c2.M()
want = map[string]interface{}{
"ID": float64(1),
}
if !reflect.DeepEqual(*pm, want) {
fmt.Println("for c2.M got", pm, "want", want)
panic(pm)
}
}

View file

@ -0,0 +1,8 @@
package main
import "./keyword_rename_c"
func main() {
keyword_rename_c.Xgo(1)
keyword_rename_c.Xchan(1)
}

View file

@ -0,0 +1,14 @@
package main
import . "./li_carrays_cpp"
func main() {
d := NewDoubleArray(10)
d.Setitem(0, 7)
d.Setitem(5, d.Getitem(0)+3)
if d.Getitem(5)+d.Getitem(0) != 17 {
panic(0)
}
}

View file

@ -0,0 +1,13 @@
package main
import . "./li_cdata_cpp"
func main() {
s := "ABC abc"
m := Malloc(256)
Memmove(m, s, len(s))
ss := Cdata(m, 7)
if string(ss) != "ABC abc" {
panic("failed")
}
}

View file

@ -0,0 +1,14 @@
package main
import . "./li_cpointer_cpp"
func main() {
p := New_intp()
Intp_assign(p, 3)
if Intp_value(p) != 3 {
panic(0)
}
Delete_intp(p)
}

View file

@ -1,12 +1,19 @@
package main
import . "./li_std_vector_ptr"
import "fmt"
func check(val1 int, val2 int) {
if val1 != val2 {
panic(fmt.Sprintf("Values are not the same %d %d", val1, val2))
}
}
func main() {
ip1 := MakeIntPtr(11)
ip2 := MakeIntPtr(22)
vi := NewIntPtrVector()
vi.Add(ip1)
vi.Add(ip2)
DisplayVector(vi)
check(GetValueFromVector(vi, 0), 11)
check(GetValueFromVector(vi, 1), 22)
}

View file

@ -1,9 +1,9 @@
package main
import "./overload_extendc"
import "./overload_extend2"
func main() {
f := overload_extendc.NewFoo()
f := overload_extend2.NewFoo()
if f.Test(3) != 1 {
panic(0)
}

View file

@ -0,0 +1,22 @@
package main
import "./overload_extend_c"
func main() {
f := overload_extend_c.NewFoo()
if f.Test().(int) != 0 {
panic(0)
}
if f.Test(3).(int) != 1 {
panic(0)
}
if f.Test("hello").(int) != 2 {
panic(0)
}
if f.Test(float64(3), float64(2)).(float64) != 5 {
panic(0)
}
if f.Test(3.0).(float64) != 1003 {
panic(0)
}
}

View file

@ -23,7 +23,7 @@ struct RetStruct {
// Write a typemap that calls C++ by converting in and out of JSON.
%go_import("encoding/json", "bytes", "encoding/binary")
%go_import("encoding/json", "bytes", "encoding/binary", "reflect", "unsafe")
%insert(go_header)
%{
@ -68,6 +68,26 @@ type In json.Marshaler
}
%}
%typemap(gotype) RetStruct* "*map[string]interface{}"
%typemap(imtype) RetStruct* "*string"
%typemap(out,fragment="AllocateString") RetStruct*
%{
$result = (_gostring_*)malloc(sizeof(_gostring_));
*$result = Swig_AllocateString($1->str.data(), $1->str.length());
%}
%typemap(goout,fragment="CopyString") RetStruct*
%{
defer Swig_free(uintptr(unsafe.Pointer($1)))
var rm map[string]interface{}
if err := json.Unmarshal([]byte(swigCopyString(*$1)), &rm); err != nil {
panic(err)
}
$result = &rm
%}
%inline
%{
@ -87,6 +107,10 @@ struct MyArray {
std::vector<std::string> strings;
};
void* Allocate(int n) {
return new char[n];
}
static uint64_t getuint64(const char* s) {
uint64_t ret = 0;
for (int i = 0; i < 8; i++, s++) {
@ -121,7 +145,12 @@ static void putuint64(std::string *s, size_t off, uint64_t v) {
buf.Write(b[:])
buf.WriteString(s)
}
str := buf.String()
bb := buf.Bytes()
p := Allocate(len(bb))
copy((*[1<<15]byte)(unsafe.Pointer(p))[:len(bb)], bb)
var str string
(*reflect.StringHeader)(unsafe.Pointer(&str)).Data = uintptr(unsafe.Pointer(p))
(*reflect.StringHeader)(unsafe.Pointer(&str)).Len = len(bb)
$result = &str
}
%}
@ -197,3 +226,18 @@ void DoubleArray(MyArray* v) {
}
}
%}
%inline
%{
class C1 {
public:
RetStruct* M() {
RetStruct* r = new RetStruct;
r->str = "{\"ID\":1}";
return r;
}
};
class C2 : public C1 {
};
%}

View file

@ -62,4 +62,4 @@ run_testcase = \
@rm -f $*-guile
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" guile_clean
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' guile_clean

View file

@ -25,7 +25,7 @@
(if (not (try-set-locale "C.UTF-8")) ; Linux
(if (not (try-set-locale "en_US.utf8")) ; Linux
(if (not (try-set-locale "en_US.UTF-8")) ; Mac OSX
(if (not (try-set-locale "en_US.UTF-8")) ; Mac OS X
(error "Failed to set any UTF-8 locale")
)))

View file

@ -0,0 +1,2 @@
(dynamic-call "scm_init_overload_extend_c_module" (dynamic-link "./liboverload_extend_c"))
(load "../schemerunme/overload_extend_c.scm")

View file

@ -34,5 +34,5 @@ int inserted_wrapper(int i) { return inserted_header3(i); }
%init %{
// %inserted code %init
int inserted_init_value = inserted_wrapper(0);
int SWIGUNUSED inserted_init_value = inserted_wrapper(0);
%}

View file

@ -5,7 +5,7 @@
LANGUAGE = java
JAVA = @JAVA@
JAVAC = @JAVAC@
JAVAFLAGS = -Xcheck:jni
JAVAFLAGS = @JAVAFLAGS@
JAVA_CLASSPATH_SEP := @JAVA_CLASSPATH_SEP@
SCRIPTSUFFIX = _runme.java
@ -28,6 +28,7 @@ CPP_TEST_CASES = \
java_director_assumeoverride \
java_director_exception_feature \
java_director_exception_feature_nspace \
java_director_ptrclass \
java_enums \
java_jnitypes \
java_lib_arrays_dimensionless \
@ -38,7 +39,7 @@ CPP_TEST_CASES = \
java_prepost \
java_throws \
java_typemaps_proxy \
java_typemaps_typewrapper
java_typemaps_typewrapper \
# li_boost_intrusive_ptr
CPP11_TEST_CASES = \
@ -59,12 +60,13 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT)
# Custom tests - tests with additional commandline options
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
multiple_inheritance_nspace.%: JAVA_PACKAGE = $*Package
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
doxygen_misc_constructs.%: INCLUDES = -I../$(srcdir)/..
# Rules for the different types of tests

View file

@ -20,5 +20,11 @@ public class char_binary_runme {
if (t.strlen(hil0) != 4)
throw new RuntimeException("bad multi-arg typemap");
if (t.ustrlen(hile) != 4)
throw new RuntimeException("bad multi-arg typemap");
if (t.ustrlen(hil0) != 4)
throw new RuntimeException("bad multi-arg typemap");
}
}

View file

@ -18,5 +18,9 @@ public class constant_directive_runme {
throw new RuntimeException("fail");
if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
throw new RuntimeException("fail");
if (constant_directive.TYPE1CONST_CONSTANT1.getVal() != 1)
throw new RuntimeException("fail");
if (constant_directive.TYPE1CPTR_CONSTANT1.getVal() != 1)
throw new RuntimeException("fail");
}
}

View file

@ -0,0 +1,82 @@
import cpp11_li_std_array.*;
public class cpp11_li_std_array_runme {
static {
try {
System.loadLibrary("cpp11_li_std_array");
} 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);
}
}
private static ArrayInt6 ToArray6(int [] a) {
ArrayInt6 ai = new ArrayInt6();
if (a.length != 6)
throw new RuntimeException("a is incorrect size");
for (int i=0; i<6; ++i)
ai.set(i, a[i]);
return ai;
}
private static void compareContainers(ArrayInt6 actual, int[] expected) {
if (actual.size() != expected.length)
throw new RuntimeException("Sizes are different: " + actual.size() + " " + expected.length);
for (int i=0; i<actual.size(); ++i) {
int actualValue = actual.get(i);
int expectedValue = expected[i];
if (actualValue != expectedValue)
throw new RuntimeException("Value is wrong for element " + i + ". Expected " + expectedValue + " got: " + actualValue);
}
if (actual.isEmpty())
throw new RuntimeException("ai should not be empty");
}
public static void main(String argv[]) {
ArrayInt6 ai = new ArrayInt6();
compareContainers(ai, new int[] {0, 0, 0, 0, 0, 0});
int[] vals = {10, 20, 30, 40, 50, 60};
for (int i=0; i<ai.size(); ++i)
ai.set(i, vals[i]);
compareContainers(ai, vals);
// Check return
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
// Check passing arguments
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
cpp11_li_std_array.arrayInRef(ai);
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
cpp11_li_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
// fill
ai.fill(111);
compareContainers(ai, new int[] {111, 111, 111, 111, 111, 111});
// out of range errors
try {
ai.set((int)ai.size(), 0);
throw new RuntimeException("Out of range exception not caught");
} catch(IndexOutOfBoundsException e) {
}
try {
ai.set(-1, 0);
throw new RuntimeException("Out of range exception not caught");
} catch(IndexOutOfBoundsException e) {
}
}
}

View file

@ -140,7 +140,7 @@ public class director_classes_runme {
Package packag = klass.getPackage();
String simpleName = null;
if (packag != null)
simpleName = fullName.replaceAll(packag.getName() + ".", "");
simpleName = fullName.replaceAll(packag.getName() + "\\.", "");
else
simpleName = fullName;
return simpleName;

View file

@ -0,0 +1,48 @@
import director_pass_by_value.*;
public class director_pass_by_value_runme {
static {
try {
System.loadLibrary("director_pass_by_value");
} 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);
}
}
private static void WaitForGC() {
System.gc();
System.runFinalization();
try {
java.lang.Thread.sleep(10);
} catch (java.lang.InterruptedException e) {
}
}
public static void main(String argv[]) {
Caller caller = new Caller();
caller.call_virtualMethod(new director_pass_by_value_Derived());
{
int countdown = 5;
while (true) {
WaitForGC();
if (--countdown == 0)
break;
};
}
// bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
int ret = director_pass_by_value_runme.passByVal.getVal();
if (ret != 0x12345678)
throw new RuntimeException("Bad return value, got " + Integer.toHexString(ret));
}
static PassedByValue passByVal;
}
class director_pass_by_value_Derived extends DirectorPassByValueAbstractBase {
public void virtualMethod(PassedByValue pbv) {
director_pass_by_value_runme.passByVal = pbv;
}
}

View file

@ -12,18 +12,35 @@ public class director_smartptr_runme {
}
}
public static void main(String argv[]) {
director_smartptr_MyBarFoo myBarFoo =
new director_smartptr_MyBarFoo();
private static void check(String got, String expected) {
if (!got.equals(expected))
throw new RuntimeException("Failed, got: " + got + " expected: " + expected);
}
public static void main(String argv[]) {
director_smartptr.FooBar fooBar = new director_smartptr.FooBar();
director_smartptr.Foo myBarFoo = new director_smartptr_MyBarFoo();
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
check(director_smartptr.Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
check(director_smartptr.Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");
director_smartptr.Foo myFoo = myBarFoo.makeFoo();
check(myFoo.pong(), "Foo::pong();Foo::ping()");
check(director_smartptr.Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
check(myFoo.upcall(fooBar), "Bar::Foo2::Foo2Bar()");
director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo();
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
}
}
class director_smartptr_MyBarFoo extends director_smartptr.Foo {
@Override
public String ping() {
return "director_smartptr_MyBarFoo.ping();";
return "director_smartptr_MyBarFoo.ping()";
}
@Override
@ -32,17 +49,12 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo {
}
@Override
public String fooBar(director_smartptr.FooBar fooBar) {
return fooBar.FooBarDo();
public String upcall(director_smartptr.FooBar fooBarPtr) {
return "override;" + fooBarPtr.FooBarDo();
}
@Override
public director_smartptr.Foo makeFoo() {
return new director_smartptr.Foo();
}
@Override
public director_smartptr.FooBar makeFooBar() {
return new director_smartptr.FooBar();
}
}
}

View file

@ -0,0 +1,47 @@
import java_director_ptrclass.*;
public class java_director_ptrclass_runme {
static {
try {
System.loadLibrary("java_director_ptrclass");
} 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[]) {
Foo f = new Foo();
Foo ft = new TouchingFoo();
Baz b = new Baz();
if (b.GetTouched()) {
throw new RuntimeException ( "Baz should not have been touched yet." );
}
Baz b2 = f.FinalMaybeTouch(b);
if (b2.GetTouched() || b.GetTouched()) {
throw new RuntimeException ( "Baz should not have been touched by Foo." );
}
Baz b3 = ft.FinalMaybeTouch(b);
if (!b.GetTouched() || !b3.GetTouched() || !b2.GetTouched()) {
throw new RuntimeException ( "Baz was not touched by TouchingFoo. This" +
" might mean the directorin typemap is not" +
" parsing the typemap(jstype, Bar) in its" +
" 'descriptor' kwarg correctly." );
}
}
}
class TouchingFoo extends Foo {
@Override
public Baz MaybeTouch(Baz baz_ptr) {
baz_ptr.SetTouched();
return baz_ptr;
}
}

View file

@ -0,0 +1,88 @@
import li_carrays_cpp.*;
public class li_carrays_cpp_runme {
static {
try {
System.loadLibrary("li_carrays_cpp");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) throws Throwable
{
// array_class
{
int length = 5;
XYArray xyArray = new XYArray(length);
for (int i=0; i<length; i++) {
XY xy = xyArray.getitem(i);
xy.setX(i*10);
xy.setY(i*100);
xyArray.setitem(i, xy);
}
for (int i=0; i<length; i++) {
Assert(xyArray.getitem(i).getX(), i*10);
Assert(xyArray.getitem(i).getY(), i*100);
}
}
{
// global array variable
int length = 3;
XY xyArrayPointer = li_carrays_cpp.getGlobalXYArray();
XYArray xyArray = XYArray.frompointer(xyArrayPointer);
for (int i=0; i<length; i++) {
XY xy = xyArray.getitem(i);
xy.setX(i*10);
xy.setY(i*100);
xyArray.setitem(i, xy);
}
for (int i=0; i<length; i++) {
Assert(xyArray.getitem(i).getX(), i*10);
Assert(xyArray.getitem(i).getY(), i*100);
}
}
// array_functions
{
int length = 5;
AB abArray = li_carrays_cpp.new_ABArray(length);
for (int i=0; i<length; i++) {
AB ab = li_carrays_cpp.ABArray_getitem(abArray, i);
ab.setA(i*10);
ab.setB(i*100);
li_carrays_cpp.ABArray_setitem(abArray, i, ab);
}
for (int i=0; i<length; i++) {
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getA(), i*10);
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getB(), i*100);
}
li_carrays_cpp.delete_ABArray(abArray);
}
{
// global array variable
int length = 3;
AB abArray = li_carrays_cpp.getGlobalABArray();
for (int i=0; i<length; i++) {
AB ab = li_carrays_cpp.ABArray_getitem(abArray, i);
ab.setA(i*10);
ab.setB(i*100);
li_carrays_cpp.ABArray_setitem(abArray, i, ab);
}
for (int i=0; i<length; i++) {
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getA(), i*10);
Assert(li_carrays_cpp.ABArray_getitem(abArray, i).getB(), i*100);
}
}
}
private static void Assert(int val1, int val2) {
// System.out.println("val1=" + val1 + " val2=" + val2);
if (val1 != val2)
throw new RuntimeException("Mismatch. val1=" + val1 + " val2=" + val2);
}
}

View file

@ -0,0 +1,24 @@
import li_cdata_cpp.*;
public class li_cdata_cpp_runme {
static {
try {
System.loadLibrary("li_cdata_cpp");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) throws Throwable
{
byte[] s = "ABC abc".getBytes();
SWIGTYPE_p_void m = li_cdata_cpp.malloc(256);
li_cdata_cpp.memmove(m, s);
byte[] ss = li_cdata_cpp.cdata(m, 7);
String ss_string = new String(ss);
if (!ss_string.equals("ABC abc"))
throw new RuntimeException("failed got: " + ss_string);
}
}

View file

@ -3,7 +3,8 @@
// unsigned long long types map correctly to long and BigInteger respectively.
import long_long.*;
import java.math.*;
import java.math.BigInteger;
import java.util.ArrayList;
public class long_long_runme {
@ -54,12 +55,57 @@ public class long_long_runme {
check_ull(testNumber);
testNumber = testNumber.add(BigInteger.ONE);
}
try {
long_long.setUll(null);
throw new RuntimeException("null check failed");
} catch (NullPointerException e) {
}
// UnsignedToSigned - checks that a cast from unsigned long long to long long in C
// gives expected value (including -ve numbers)
long[] nums = {
0x00,
0xFF, 0x80, 0x7F, 0x01,
-0xFF, -0x80, -0x7F, -0x01,
0x100, 0x10000,
-0x100, -0x10000,
0xFFFF, 0xFF80, 0xFF7F, 0xFF01, 0xFF00,
-0xFFFF, -0xFF80, -0xFF7F, -0xFF01, -0xFF00,
0x7FFF, 0x7F80, 0x7F7F, 0x7F01, 0x7F00,
-0x7FFF, -0x7F80, -0x7F7F, -0x7F01, -0x7F00,
0x80FF, 0x8080, 0x807F, 0x8001, 0x8000,
-0x80FF, -0x8080, -0x807F, -0x8001, -0x8000,
Integer.MAX_VALUE, Integer.MIN_VALUE,
Integer.MAX_VALUE+1, Integer.MIN_VALUE-1,
Long.MAX_VALUE, Long.MIN_VALUE,
};
ArrayList<BigInteger> bigIntegers = new ArrayList<BigInteger>();
for (int i=0; i<nums.length; ++i) {
BigInteger bi = new BigInteger(new Long(nums[i]).toString());
bigIntegers.add(bi);
}
{
BigInteger bi = new BigInteger(new Long(Long.MAX_VALUE).toString());
bigIntegers.add(bi.add(BigInteger.ONE));
bi = new BigInteger(new Long(Long.MIN_VALUE).toString());
bigIntegers.add(bi.subtract(BigInteger.ONE));
}
boolean failed = false;
for (int i=0; i<bigIntegers.size(); ++i) {
BigInteger bi = (BigInteger)bigIntegers.get(i);
long longReturn = long_long.UnsignedToSigned(bi);
if (bi.longValue() != longReturn) {
System.err.println("Conversion to long failed, in:" + bi + " out:" + longReturn);
failed = true;
}
}
if (failed)
throw new RuntimeException("There were UnsignedToSigned failures");
}
public static void check_ll(long ll) {

View file

@ -0,0 +1,253 @@
import multiple_inheritance_abstract.*;
public class multiple_inheritance_abstract_runme {
static {
try {
System.loadLibrary("multiple_inheritance_abstract");
} 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);
}
}
//Test base class as a parameter in java
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(boolean fail, String msg) {
if (fail)
throw new RuntimeException(msg);
}
public static void main(String argv[]) {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in java
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,78 @@
import multiple_inheritance_interfaces.*;
import java.util.Arrays;
public class multiple_inheritance_interfaces_runme {
static {
try {
System.loadLibrary("multiple_inheritance_interfaces");
} 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);
}
}
private static void checkBaseAndInterfaces(Class cls, boolean interfaceExpected, String base, String[] interfaces) {
String[] expectedInterfaces = new String[interfaces.length];
for (int i=0; i<interfaces.length; ++i)
expectedInterfaces[i] = "interface multiple_inheritance_interfaces." + interfaces[i];
Class[] actualInterfaces = cls.getInterfaces();
String expectedInterfacesString = Arrays.toString(expectedInterfaces);
String actualInterfacesString = Arrays.toString(actualInterfaces);
if (!expectedInterfacesString.equals(actualInterfacesString))
throw new RuntimeException("Expected interfaces for " + cls.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
String expectedBaseString = null;
if (interfaceExpected) {
// expecting an interface
if (!cls.isInterface())
throw new RuntimeException(cls.getName() + " should be an interface but is not");
expectedBaseString = base.isEmpty() ? "" : "multiple_inheritance_interfaces." + base;
} else {
// expecting a class
if (cls.isInterface())
throw new RuntimeException(cls.getName() + " is an interface but it should not be");
expectedBaseString = base.isEmpty() ? "java.lang.Object" : "multiple_inheritance_interfaces." + base;
}
String actualBaseString = cls.getSuperclass() == null ? "" : cls.getSuperclass().getName();
if (!expectedBaseString.equals(actualBaseString))
throw new RuntimeException("Expected base for " + cls.getName() + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
}
public static void main(String argv[]) {
checkBaseAndInterfaces(IA.class, true, "", new String[] {});
checkBaseAndInterfaces(IB.class, true, "", new String[] {});
checkBaseAndInterfaces(IC.class, true, "", new String[] {"IA", "IB"});
checkBaseAndInterfaces(A.class, false, "", new String[] {"IA"});
checkBaseAndInterfaces(B.class, false, "", new String[] {"IB"});
checkBaseAndInterfaces(C.class, false, "", new String[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(D.class, false, "", new String[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(E.class, false, "D", new String[] {});
checkBaseAndInterfaces(IJ.class, true, "", new String[] {});
checkBaseAndInterfaces(IK.class, true, "", new String[] {"IJ"});
checkBaseAndInterfaces(IL.class, true, "", new String[] {"IK"});
checkBaseAndInterfaces(J.class, false, "", new String[] {"IJ"});
checkBaseAndInterfaces(K.class, false, "", new String[] {"IJ", "IK"});
checkBaseAndInterfaces(L.class, false, "", new String[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(M.class, false, "", new String[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(P.class, false, "", new String[] {});
checkBaseAndInterfaces(IQ.class, true, "", new String[] {});
checkBaseAndInterfaces(Q.class, false, "", new String[] {"IQ"});
checkBaseAndInterfaces(R.class, false, "P", new String[] {"IQ"});
checkBaseAndInterfaces(S.class, false, "P", new String[] {"IQ"});
checkBaseAndInterfaces(T.class, false, "", new String[] {"IQ"});
checkBaseAndInterfaces(U.class, false, "R", new String[] {});
checkBaseAndInterfaces(V.class, false, "S", new String[] {});
checkBaseAndInterfaces(W.class, false, "T", new String[] {});
// overloaded methods check
D d = new D();
d.ia();
d.ia(10);
d.ia("bye");
d.ia("bye", false);
}
}

View file

@ -0,0 +1,255 @@
import multiple_inheritance_nspacePackage.multiple_inheritance_nspace;
import multiple_inheritance_nspacePackage.multiple_inheritance_nspaceJNI;
import multiple_inheritance_nspacePackage.Space.*;
public class multiple_inheritance_nspace_runme {
static {
try {
System.loadLibrary("multiple_inheritance_nspace");
} 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);
}
}
//Test base class as a parameter in java
int jcbase1b(CBase1SwigInterface cb1){
return cb1.cbase1y();
}
int jabase1(ABase1SwigInterface ab1){
return ab1.abase1();
}
int jcbase2(CBase2SwigInterface cb2){
return cb2.cbase2();
}
public static void check(boolean fail, String msg) {
if (fail)
throw new RuntimeException(msg);
}
public static void main(String argv[]) {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1SwigInterface cb1=new CBase1();
CBase2SwigInterface cb2=new CBase2();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test nspace class as return value
ABase1SwigInterface ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1SwigInterface cb6=d2.cloneit();
CBase2SwigInterface cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1SwigInterface cb3=new Derived1();
CBase1SwigInterface cb4=new Derived3();
CBase2SwigInterface cb5=new Derived3();
ABase1SwigInterface ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in java
multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,337 @@
import multiple_inheritance_shared_ptr.*;
public class multiple_inheritance_shared_ptr_runme {
static {
try {
System.loadLibrary("multiple_inheritance_shared_ptr");
} 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);
}
}
//Test base class as a parameter in java
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(boolean fail, String msg) {
if (fail)
throw new RuntimeException(msg);
}
public static void main(String argv[]) {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in java
multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Shared pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
//Shared pointer reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
// Return smart pointers references
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
}
}

View file

@ -0,0 +1,90 @@
import rename_wildcard.*;
public class rename_wildcard_runme {
static {
try {
System.loadLibrary("rename_wildcard");
} 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[]) {
// Wildcard check
{
new GlobalWildStruct().mm1();
new GlobalWildTemplateStructInt().mm1();
new SpaceWildStruct().mm1();
new SpaceWildTemplateStructInt().mm1();
}
// No declaration
{
new GlobalWildStruct().mm2a();
new GlobalWildTemplateStructInt().mm2b();
new SpaceWildStruct().mm2c();
new SpaceWildTemplateStructInt().mm2d();
new GlobalWildTemplateStructInt().tt2b();
new SpaceWildTemplateStructInt().tt2d();
}
// With declaration
{
new GlobalWildStruct().mm3a();
new GlobalWildTemplateStructInt().mm3b();
new SpaceWildStruct().mm3c();
new SpaceWildTemplateStructInt().mm3d();
new GlobalWildTemplateStructInt().tt3b();
new SpaceWildTemplateStructInt().tt3d();
}
// Global override too
{
new GlobalWildStruct().mm4a();
new GlobalWildTemplateStructInt().mm4b();
new SpaceWildStruct().mm4c();
new SpaceWildTemplateStructInt().mm4d();
new GlobalWildTemplateStructInt().tt4b();
new SpaceWildTemplateStructInt().tt4d();
}
// %extend renames
{
new GlobalWildStruct().mm5a();
new GlobalWildTemplateStructInt().mm5b();
new SpaceWildStruct().mm5c();
new SpaceWildTemplateStructInt().mm5d();
new GlobalWildTemplateStructInt().tt5b();
new SpaceWildTemplateStructInt().tt5d();
}
// operators
{
new GlobalWildStruct().opinta();
new GlobalWildTemplateStructInt().opintb();
new SpaceWildStruct().opintc();
new SpaceWildTemplateStructInt().opintd();
new GlobalWildTemplateStructInt().opdoubleb();
new SpaceWildTemplateStructInt().opdoubled();
}
// Wildcard renames expected for these
{
new NoChangeStruct().mm1();
new NoChangeStruct().mm2();
new NoChangeStruct().mm3();
new NoChangeStruct().mm4();
new NoChangeStruct().mm5();
new NoChangeStruct().opint();
new SpaceNoChangeStruct().mm1();
new SpaceNoChangeStruct().mm2();
new SpaceNoChangeStruct().mm3();
new SpaceNoChangeStruct().mm4();
new SpaceNoChangeStruct().mm5();
new SpaceNoChangeStruct().opint();
}
}
}

View file

@ -0,0 +1,19 @@
import smart_pointer_ignore.*;
public class smart_pointer_ignore_runme {
static {
try {
System.loadLibrary("smart_pointer_ignore");
} 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[]) {
DerivedPtr d = smart_pointer_ignore.makeDerived();
d.baseMethod();
d.derivedMethod();
}
}

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