Merge branch 'master' into director-unwrap-result
This commit is contained in:
commit
deb7cbf741
1099 changed files with 14845 additions and 34359 deletions
20
Examples/test-suite/abstract_basecast.i
Normal file
20
Examples/test-suite/abstract_basecast.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module abstract_basecast
|
||||
|
||||
%inline %{
|
||||
class BaseClass {
|
||||
public:
|
||||
virtual ~BaseClass() { }
|
||||
|
||||
virtual void g() = 0;
|
||||
};
|
||||
|
||||
class DerivedClass : public BaseClass {
|
||||
public:
|
||||
|
||||
virtual void g() { }
|
||||
|
||||
BaseClass& f() {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
class abstract_foo
|
||||
{
|
||||
public:
|
||||
abstract_foo() { };
|
||||
virtual ~abstract_foo() { };
|
||||
abstract_foo() { }
|
||||
virtual ~abstract_foo() { }
|
||||
virtual int meth(int meth_param) = 0;
|
||||
};
|
||||
|
||||
|
|
@ -16,9 +16,9 @@ public:
|
|||
class abstract_bar : public abstract_foo
|
||||
{
|
||||
public:
|
||||
abstract_bar() { };
|
||||
abstract_bar() { }
|
||||
|
||||
virtual ~abstract_bar() { };
|
||||
virtual ~abstract_bar() { }
|
||||
virtual int meth(int meth_param) = 0;
|
||||
int meth(int meth_param_1, int meth_param_2) { return 0; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
To support contracts, you need to add a macro to the runtime.
|
||||
For Python, it looks like this:
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg #expr ); goto fail; } else
|
||||
#define SWIG_contract_assert(expr, msg) do { if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg #expr ); goto fail; } } while (0)
|
||||
|
||||
Note: It is used like this:
|
||||
SWIG_contract_assert(x == 1, "Some kind of error message");
|
||||
|
|
|
|||
|
|
@ -1,126 +0,0 @@
|
|||
#######################################################################
|
||||
# Makefile for allegrocl test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = allegrocl
|
||||
ALLEGROCL = @ALLEGROCLBIN@
|
||||
SCRIPTSUFFIX = _runme.lisp
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
|
||||
# these cpp tests generate warnings/errors when compiling
|
||||
# the wrapper .cxx file.
|
||||
CPP_TEST_BROKEN_CXX =
|
||||
# the error is wrap:action code generated by swig. \
|
||||
# error: can't convert [std::string] 'b' to 'bool' \
|
||||
# might just need a bool overload op for std::string. \
|
||||
global_vars \
|
||||
# same as w/ global_vars but with more errors in cxx file \
|
||||
naturalvar \
|
||||
|
||||
# these cpp tests aren't working. Fix 'em
|
||||
# need to further separate these into tests requiring
|
||||
# std libraries, or the $ldestructor problem.
|
||||
CPP_TEST_BROKEN_ACL = \
|
||||
contract \
|
||||
allprotected \
|
||||
# 'throws' typemap entries. \
|
||||
cplusplus_throw \
|
||||
# 'throws' typemap entries. \
|
||||
default_args \
|
||||
# missing typemaps. suspect module support needed \
|
||||
dynamic_cast \
|
||||
extend_variable \
|
||||
# cdata.i support needed \
|
||||
li_cdata_cpp \
|
||||
# warning generated. otherwise all good. \
|
||||
operator_overload \
|
||||
# std_common.i support \
|
||||
sizet \
|
||||
# std_vector.i support. \
|
||||
template_default \
|
||||
# *** line 31. can't copy typemap?? \
|
||||
typemap_namespace \
|
||||
|
||||
# these aren't working due to longlong support. (low hanging fruit)
|
||||
CPP_TEST_BROKEN_LONGLONG = \
|
||||
arrays_dimensionless \
|
||||
arrays_global \
|
||||
arrays_global_twodim \
|
||||
li_typemaps \
|
||||
li_windows \
|
||||
long_long_apply \
|
||||
primitive_ref \
|
||||
reference_global_vars \
|
||||
template_default_arg
|
||||
|
||||
# These are currently unsupported.
|
||||
CPP_TEST_CASES_ACL_UNSUPPORTED = \
|
||||
# contract support \
|
||||
aggregate \
|
||||
# directors support \
|
||||
apply_signed_char \
|
||||
# contract support \
|
||||
contract \
|
||||
director_exception \
|
||||
director_protected \
|
||||
exception_order \
|
||||
# 'throws' typemap support \
|
||||
extern_throws \
|
||||
throw_exception \
|
||||
using_pointers \
|
||||
|
||||
C_TEST_CASES_ACL_BROKEN = \
|
||||
# 'cdate.i' module support \
|
||||
li_cdata \
|
||||
# adding an existing type defnition... \
|
||||
typedef_struct \
|
||||
# swigrun.swg support. \
|
||||
typemap_subst
|
||||
|
||||
C_TEST_BROKEN_LONGLONG = \
|
||||
long_long
|
||||
|
||||
|
||||
# std lib support hasn't been done yet.
|
||||
SKIP_CPP_STD_CASES = Yes
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# SWIGOPT += -debug-module 4
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
%.clean:
|
||||
@rm -f $*.cl
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" allegrocl_clean
|
||||
|
|
@ -26,17 +26,6 @@ UVW Bar::static_member_variable;
|
|||
struct XYZ {
|
||||
};
|
||||
|
||||
// The operator& trick doesn't work for SWIG/PHP because the generated code
|
||||
// takes the address of the variable in the code in the "vinit" section.
|
||||
#ifdef SWIGPHP
|
||||
%{
|
||||
struct XYZ {
|
||||
void foo() {}
|
||||
private:
|
||||
XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
|
||||
};
|
||||
%}
|
||||
#else
|
||||
%{
|
||||
struct XYZ {
|
||||
void foo() {}
|
||||
|
|
@ -45,7 +34,6 @@ private:
|
|||
XYZ* operator&(); // prevent dereferencing used in normally generated get method
|
||||
};
|
||||
%}
|
||||
#endif
|
||||
#if defined(SWIGUTL)
|
||||
%exception {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -35,7 +35,5 @@
|
|||
const char memberconstchar;
|
||||
|
||||
virtual ~DirectorTest() {}
|
||||
private:
|
||||
DirectorTest& operator=(const DirectorTest &);
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@
|
|||
// unsigned char* as strings
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
|
||||
/* Note: Chicken does not allow unsigned char * in strings */
|
||||
|
||||
%apply char [ANY] {TAscii[ANY]}
|
||||
%apply char [] {TAscii []}
|
||||
%apply char * {TAscii *}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,6 @@ struct BoolStructure {
|
|||
m_rbool(m_bool2),
|
||||
m_const_pbool(m_pbool),
|
||||
m_const_rbool(m_rbool) {}
|
||||
private:
|
||||
BoolStructure& operator=(const BoolStructure &);
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
%callback("%s") A::foom;
|
||||
#endif
|
||||
%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too
|
||||
%callback("%s_cb") identity_finger;
|
||||
|
||||
%inline %{
|
||||
|
||||
|
|
@ -85,6 +86,15 @@
|
|||
const T& ident(const T& x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
// Test callbacks for enum types
|
||||
typedef enum {One, Two, Three, Four, Five} finger;
|
||||
typedef finger (*finger_finger)(finger);
|
||||
finger identity_finger(finger f) { return f; }
|
||||
finger apply_finger_cb(finger f, finger_finger cb) {
|
||||
return cb(f);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(foo_i) foo_T<int>;
|
||||
|
|
|
|||
81
Examples/test-suite/ccomplextest.i
Normal file
81
Examples/test-suite/ccomplextest.i
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
%module ccomplextest
|
||||
|
||||
%include <complex.i>
|
||||
|
||||
%{
|
||||
#include <complex.h>
|
||||
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199001L
|
||||
#define HAS_C99_COMPLEX_FOR_TESTING 1
|
||||
#else
|
||||
/* c99 complex not supported - super hack tests to just test plain floating point numbers */
|
||||
/* some pre c99 compilers (gcc-4.x) don't define _Complex but do define complex */
|
||||
#define _Complex
|
||||
#if !defined(complex)
|
||||
# define complex
|
||||
#endif
|
||||
#define conj
|
||||
#define conjf
|
||||
#define creal
|
||||
#define cimag
|
||||
#if defined(I)
|
||||
# undef I
|
||||
# define I 1
|
||||
#endif
|
||||
#define HAS_C99_COMPLEX_FOR_TESTING 0
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline
|
||||
{
|
||||
int has_c99_complex(void) {
|
||||
return HAS_C99_COMPLEX_FOR_TESTING;
|
||||
}
|
||||
|
||||
complex double Conj(complex double a)
|
||||
{
|
||||
return conj(a);
|
||||
}
|
||||
|
||||
|
||||
complex float Conjf(complex float a)
|
||||
{
|
||||
return conjf(a);
|
||||
}
|
||||
|
||||
|
||||
double complex Conj1(double complex a)
|
||||
{
|
||||
return conj(a);
|
||||
}
|
||||
|
||||
|
||||
float complex Conjf1(float complex a)
|
||||
{
|
||||
return conjf(a);
|
||||
}
|
||||
|
||||
|
||||
_Complex double Conj2(_Complex double a)
|
||||
{
|
||||
return conj(a);
|
||||
}
|
||||
|
||||
|
||||
_Complex float Conjf2(_Complex float a)
|
||||
{
|
||||
return conjf(a);
|
||||
}
|
||||
|
||||
|
||||
double _Complex Conj3(double _Complex a)
|
||||
{
|
||||
return conj(a);
|
||||
}
|
||||
|
||||
|
||||
float _Complex Conjf3(float _Complex a)
|
||||
{
|
||||
return conjf(a);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ run_testcase = \
|
|||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra cffi code)
|
||||
# Clean: (does nothing, we don't generate extra cffi code)
|
||||
%.clean:
|
||||
@exit 0
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ below.
|
|||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OTHERLAND_MSG "Little message from the safe world."
|
||||
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
|
||||
|
|
@ -150,11 +151,11 @@ const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
|
|||
%inline {
|
||||
struct Formatpos;
|
||||
struct OBFormat;
|
||||
|
||||
|
||||
static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,101 +0,0 @@
|
|||
#######################################################################
|
||||
# Makefile for chicken test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = chicken
|
||||
VARIANT =
|
||||
SCRIPTSUFFIX = _runme.ss
|
||||
PROXYSUFFIX = _runme_proxy.ss
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
CHICKEN_CSI = @CHICKEN_CSI@ -quiet -batch -no-init
|
||||
SO = @SO@
|
||||
|
||||
#C_TEST_CASES = long_long list_vector pointer_in_out multivalue
|
||||
|
||||
# Skip the STD cases for now, except for li_std_string.i
|
||||
SKIP_CPP_STD_CASES = Yes
|
||||
|
||||
CPP_TEST_CASES += li_std_string
|
||||
|
||||
EXTRA_TEST_CASES += chicken_ext_test.externaltest
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SWIGOPT += -nounit
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# If there exists a PROXYSUFFIX runme file, we also generate the wrapper
|
||||
# with the -proxy argument
|
||||
%.cppproxy: SWIGOPT += -proxy
|
||||
%.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
|
||||
|
||||
%.cproxy: SWIGOPT += -proxy
|
||||
%.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
|
||||
|
||||
%.multiproxy: SWIGOPT += -proxy -noclosuses
|
||||
%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
$(MAKE) $*.cppproxy; \
|
||||
fi
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
$(MAKE) $*.cproxy; \
|
||||
fi
|
||||
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
|
||||
$(MAKE) $*.multiproxy; \
|
||||
fi
|
||||
|
||||
%.externaltest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_external)
|
||||
$(run_testcase)
|
||||
|
||||
%.cppproxy:
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy"
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.cproxy:
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy"
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multiproxy:
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test) with -proxy"
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.scm appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean
|
||||
%.clean:
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
|
||||
rm -f *.scm
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
See ../README for common README file.
|
||||
|
||||
Any testcases which have _runme.ss appended after the testcase name will be detected and run.
|
||||
NOTE: I had to use _runme.ss because otherwise it would be hard to implement make clean
|
||||
Since when SWIG runs it generates an example.scm file for every test, to clean those files
|
||||
I needed to add a rm -f *.scm to make clean. But we don't want the runme scripts to
|
||||
disappear as well!
|
||||
|
||||
Any testcases which have _runme_proxy.ss appended after the testcase name will be detected
|
||||
and run with the -proxy argument passed to SWIG. SWIG will not be run with the -unhide-primitive
|
||||
option, so the _runme_proxy.ss file must use only the tinyclos exported interface.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "casts.so")
|
||||
(include "../schemerunme/casts.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "char_constant.so")
|
||||
(include "../schemerunme/char_constant.scm")
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#include <chicken/chicken_ext_test_wrap_hdr.h>
|
||||
#include <imports_a.h>
|
||||
|
||||
void test_create(C_word,C_word,C_word) C_noret;
|
||||
void test_create(C_word argc, C_word closure, C_word continuation) {
|
||||
C_word resultobj;
|
||||
swig_type_info *type;
|
||||
A *newobj;
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
|
||||
C_trace("test-create");
|
||||
if (argc!=2) C_bad_argc(argc,2);
|
||||
|
||||
|
||||
newobj = new A();
|
||||
|
||||
type = SWIG_TypeQuery("A *");
|
||||
resultobj = SWIG_NewPointerObj(newobj, type, 1);
|
||||
|
||||
C_kontinue(continuation, resultobj);
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
(load "chicken_ext_test.so")
|
||||
|
||||
(define a (test-create))
|
||||
|
||||
(A-hello a)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "class_ignore.so")
|
||||
(include "../schemerunme/class_ignore.scm")
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
(require 'clientdata_prop_a)
|
||||
(require 'clientdata_prop_b)
|
||||
|
||||
(define a (make <A>))
|
||||
(test-A a)
|
||||
(test-tA a)
|
||||
(test-t2A a)
|
||||
(test-t3A a)
|
||||
(fA a)
|
||||
|
||||
(define b (make <B>))
|
||||
(test-A b)
|
||||
(test-tA b)
|
||||
(test-t2A b)
|
||||
(test-t3A b)
|
||||
(test-B b)
|
||||
(fA b)
|
||||
(fB b)
|
||||
|
||||
(define c (make <C>))
|
||||
(test-A c)
|
||||
(test-tA c)
|
||||
(test-t2A c)
|
||||
(test-t3A c)
|
||||
(test-C c)
|
||||
(fA c)
|
||||
(fC c)
|
||||
|
||||
(define d (make <D>))
|
||||
(test-A d)
|
||||
(test-tA d)
|
||||
(test-t2A d)
|
||||
(test-t3A d)
|
||||
(test-D d)
|
||||
(test-tD d)
|
||||
(test-t2D d)
|
||||
(fA d)
|
||||
(fD d)
|
||||
|
||||
;; here are the real tests... if the clientdata is correctly
|
||||
;; propegated, new-tA, new-t2A, should all return wrapped proxy's
|
||||
;; of class <A>
|
||||
|
||||
(define a2 (new-tA))
|
||||
(if (not (eq? (class-of a2) <A>))
|
||||
(error "Error 1"))
|
||||
(test-A a2)
|
||||
(test-tA a2)
|
||||
(test-t2A a2)
|
||||
(test-t3A a2)
|
||||
(fA a2)
|
||||
|
||||
(define a3 (new-t2A))
|
||||
(if (not (eq? (class-of a3) <A>))
|
||||
(error "Error 2"))
|
||||
(test-A a3)
|
||||
(test-tA a3)
|
||||
(test-t2A a3)
|
||||
(test-t3A a3)
|
||||
(fA a3)
|
||||
|
||||
(define a4 (new-t3A))
|
||||
(if (not (eq? (class-of a4) <A>))
|
||||
(error "Error 3"))
|
||||
(test-A a4)
|
||||
(test-tA a4)
|
||||
(test-t2A a4)
|
||||
(test-t3A a4)
|
||||
(fA a4)
|
||||
|
||||
(define d2 (new-tD))
|
||||
(if (not (eq? (class-of d2) <D>))
|
||||
(error "Error 4"))
|
||||
(test-A d2)
|
||||
(test-tA d2)
|
||||
(test-t2A d2)
|
||||
(test-t3A d2)
|
||||
(test-D d2)
|
||||
(test-tD d2)
|
||||
(fA d2)
|
||||
(fD d2)
|
||||
|
||||
(define d3 (new-t2D))
|
||||
(if (not (eq? (class-of d3) <D>))
|
||||
(error "Error 5"))
|
||||
(test-A d3)
|
||||
(test-tA d3)
|
||||
(test-t2A d3)
|
||||
(test-t3A d3)
|
||||
(test-D d3)
|
||||
(test-tD d3)
|
||||
(fA d3)
|
||||
(fD d3)
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "constover.so")
|
||||
(include "../schemerunme/constover.scm")
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
(load "contract.so")
|
||||
(include "testsuite.ss")
|
||||
(include "../schemerunme/contract.scm")
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
(require 'cpp_basic)
|
||||
|
||||
(define-macro (check test)
|
||||
`(if (not ,test) (error "Error in test " ',test)))
|
||||
|
||||
(define f (make <Foo> 4))
|
||||
(check (= (slot-ref f 'num) 4))
|
||||
(slot-set! f 'num -17)
|
||||
(check (= (slot-ref f 'num) -17))
|
||||
|
||||
(define b (make <Bar>))
|
||||
|
||||
(slot-set! b 'fptr f)
|
||||
(check (= (slot-ref (slot-ref b 'fptr) 'num) -17))
|
||||
(check (= (test b -3 (slot-ref b 'fptr)) -5))
|
||||
(slot-set! f 'num 12)
|
||||
(check (= (slot-ref (slot-ref b 'fptr) 'num) 12))
|
||||
|
||||
(check (= (slot-ref (slot-ref b 'fref) 'num) -4))
|
||||
(check (= (test b 12 (slot-ref b 'fref)) 23))
|
||||
;; references don't take ownership, so if we didn't define this here it might get garbage collected
|
||||
(define f2 (make <Foo> 23))
|
||||
(slot-set! b 'fref f2)
|
||||
(check (= (slot-ref (slot-ref b 'fref) 'num) 23))
|
||||
(check (= (test b -3 (slot-ref b 'fref)) 35))
|
||||
|
||||
(check (= (slot-ref (slot-ref b 'fval) 'num) 15))
|
||||
(check (= (test b 3 (slot-ref b 'fval)) 33))
|
||||
(slot-set! b 'fval (make <Foo> -15))
|
||||
(check (= (slot-ref (slot-ref b 'fval) 'num) -15))
|
||||
(check (= (test b 3 (slot-ref b 'fval)) -27))
|
||||
|
||||
(define f3 (testFoo b 12 (slot-ref b 'fref)))
|
||||
(check (= (slot-ref f3 'num) 32))
|
||||
|
||||
;; now test global
|
||||
(define f4 (make <Foo> 6))
|
||||
(Bar-global-fptr f4)
|
||||
(check (= (slot-ref (Bar-global-fptr) 'num) 6))
|
||||
(slot-set! f4 'num 8)
|
||||
(check (= (slot-ref (Bar-global-fptr) 'num) 8))
|
||||
|
||||
(check (= (slot-ref (Bar-global-fref) 'num) 23))
|
||||
(Bar-global-fref (make <Foo> -7))
|
||||
(check (= (slot-ref (Bar-global-fref) 'num) -7))
|
||||
|
||||
(check (= (slot-ref (Bar-global-fval) 'num) 3))
|
||||
(Bar-global-fval (make <Foo> -34))
|
||||
(check (= (slot-ref (Bar-global-fval) 'num) -34))
|
||||
|
||||
;; Now test function pointers
|
||||
(define func1ptr (get-func1-ptr))
|
||||
(define func2ptr (get-func2-ptr))
|
||||
|
||||
(slot-set! f 'num 4)
|
||||
(check (= (func1 f 2) 16))
|
||||
(check (= (func2 f 2) -8))
|
||||
|
||||
(slot-set! f 'func-ptr func1ptr)
|
||||
(check (= (test-func-ptr f 2) 16))
|
||||
(slot-set! f 'func-ptr func2ptr)
|
||||
(check (= (test-func-ptr f 2) -8))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "cpp_enum.so")
|
||||
(include "../schemerunme/cpp_enum.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "cpp_namespace.so")
|
||||
(include "../schemerunme/cpp_namespace.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "dynamic_cast.so")
|
||||
(include "../schemerunme/dynamic_cast.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(require 'global_vars)
|
||||
(load "../schemerunme/global_vars.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(require 'global_vars)
|
||||
(load "../schemerunme/global_vars_proxy.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "import_nomodule.so")
|
||||
(include "../schemerunme/import_nomodule.scm")
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
(load "imports_a.so")
|
||||
(load "imports_b.so")
|
||||
(include "../schemerunme/imports.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "inherit_missing.so")
|
||||
(include "../schemerunme/inherit_missing.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "li_std_string.so")
|
||||
(include "../schemerunme/li_std_string.scm")
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
(load "li_std_string.so")
|
||||
|
||||
(define x "hello")
|
||||
|
||||
(if (not (string=? (test-value x) x))
|
||||
(begin (error "Error 1") (exit 1)))
|
||||
|
||||
(if (not (string=? (test-const-reference x) x))
|
||||
(begin (error "Error 2") (exit 1)))
|
||||
|
||||
(define y (test-pointer-out))
|
||||
(test-pointer y)
|
||||
(define z (test-const-pointer-out))
|
||||
(test-const-pointer z)
|
||||
|
||||
(define a (test-reference-out))
|
||||
(test-reference a)
|
||||
|
||||
;; test global variables
|
||||
(GlobalString "whee")
|
||||
(if (not (string=? (GlobalString) "whee"))
|
||||
(error "Error 3"))
|
||||
(if (not (string=? (GlobalString2) "global string 2"))
|
||||
(error "Error 4"))
|
||||
|
||||
(define struct (make <Structure>))
|
||||
|
||||
;; MemberString should be a wrapped class
|
||||
(if (not (string=? (slot-ref struct 'MemberString) ""))
|
||||
(error "Error 4.5"))
|
||||
;(slot-set! (slot-ref struct 'MemberString) "and how")
|
||||
;;(if (not (string=? (slot-ref struct 'MemberString) "and how"))
|
||||
;; (error "Error 5"))
|
||||
(if (not (string=? (slot-ref struct 'MemberString2) "member string 2"))
|
||||
(error "Error 6"))
|
||||
(Structure-StaticMemberString "static str")
|
||||
(if (not (string=? (Structure-StaticMemberString) "static str"))
|
||||
(error "Error 7"))
|
||||
(if (not (string=? (Structure-StaticMemberString2) "static member string 2"))
|
||||
(error "Error 8"))
|
||||
|
||||
;(if (not (string=? (Structure-ConstMemberString-get struct) "const member string"))
|
||||
; (error "Error 9"))
|
||||
(if (not (string=? (Structure-ConstStaticMemberString) "const static member string"))
|
||||
(error "Error 10"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
(require 'li_typemaps)
|
||||
(load "../schemerunme/li_typemaps.scm")
|
||||
|
||||
(call-with-values (lambda () (inoutr-int2 3 -2))
|
||||
(lambda (a b)
|
||||
(if (not (and (= a 3) (= b -2)))
|
||||
(error "Error in inoutr-int2"))))
|
||||
(call-with-values (lambda () (out-foo 4))
|
||||
(lambda (a b)
|
||||
(if (not (and (= (Foo-a-get a) 4) (= b 8)))
|
||||
(error "Error in out-foo"))))
|
||||
(exit 0)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
(require 'li_typemaps)
|
||||
(load "../schemerunme/li_typemaps_proxy.scm")
|
||||
|
||||
(call-with-values (lambda () (inoutr-int2 3 -2))
|
||||
(lambda (a b)
|
||||
(if (not (and (= a 3) (= b -2)))
|
||||
(error "Error in inoutr-int2"))))
|
||||
(call-with-values (lambda () (out-foo 4))
|
||||
(lambda (a b)
|
||||
(if (not (and (= (slot-ref a 'a) 4) (= b 8)))
|
||||
(error "Error in out-foo"))))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "list_vector.so")
|
||||
(include "../schemerunme/list_vector.scm")
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
(require 'member_pointer)
|
||||
|
||||
(define (check-eq? msg expected actual)
|
||||
(if (not (= expected actual))
|
||||
(error "Error " msg ": expected " expected " got " actual)))
|
||||
|
||||
(define area-pt (areapt))
|
||||
(define perim-pt (perimeterpt))
|
||||
|
||||
(define s (new-Square 10))
|
||||
|
||||
(check-eq? "Square area" 100.0 (do-op s area-pt))
|
||||
(check-eq? "Square perim" 40.0 (do-op s perim-pt))
|
||||
|
||||
(check-eq? "Square area" 100.0 (do-op s (areavar)))
|
||||
(check-eq? "Square perim" 40.0 (do-op s (perimetervar)))
|
||||
|
||||
;; Set areavar to return value of function
|
||||
(areavar perim-pt)
|
||||
(check-eq? "Square perim" 40 (do-op s (areavar)))
|
||||
|
||||
(check-eq? "Square area" 100.0 (do-op s (AREAPT)))
|
||||
(check-eq? "Square perim" 40.0 (do-op s (PERIMPT)))
|
||||
|
||||
(define test (NULLPT))
|
||||
|
||||
(perimetervar (AREAPT))
|
||||
(check-eq? "Square area" 100.0 (do-op s (perimetervar)))
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(require 'multiple_inheritance)
|
||||
(load "../schemerunme/multiple_inheritance_proxy.scm")
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
;; this doesn't work yet :(
|
||||
(load "multivalue.so")
|
||||
(include "../schemerunme/multivalue.scm")
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "name.so")
|
||||
(include "../schemerunme/name.scm")
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
(require 'newobject1)
|
||||
|
||||
(define-macro (check-count val)
|
||||
`(if (not (= (Foo-fooCount) ,val)) (error "Error checking val " ,val " != " ,(Foo-fooCount))))
|
||||
|
||||
(define f (Foo-makeFoo))
|
||||
|
||||
(check-count 1)
|
||||
|
||||
(define f2 (makeMore f))
|
||||
|
||||
(check-count 2)
|
||||
|
||||
(set! f #f)
|
||||
(gc #t)
|
||||
|
||||
(check-count 1)
|
||||
|
||||
(define f3 (makeMore f2))
|
||||
|
||||
(check-count 2)
|
||||
|
||||
(set! f3 #f)
|
||||
(set! f2 #f)
|
||||
|
||||
(gc #t)
|
||||
|
||||
(check-count 0)
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
(load "newobject2.so")
|
||||
|
||||
(define f (new-Foo))
|
||||
|
||||
(Foo-dummy-set f 14)
|
||||
(if (not (= (Foo-dummy-get f) 14))
|
||||
(error "Bad dummy value"))
|
||||
|
||||
(if (not (= (fooCount) 0))
|
||||
(error "Bad foo count 1"))
|
||||
|
||||
(define f2 (makeFoo))
|
||||
|
||||
(if (not (= (fooCount) 1))
|
||||
(error "Bad foo count 2"))
|
||||
|
||||
(Foo-dummy-set f2 16)
|
||||
(if (not (= (Foo-dummy-get f2) 16))
|
||||
(error "Bad dummy value for f2"))
|
||||
|
||||
(set! f #f)
|
||||
(set! f2 #f)
|
||||
|
||||
(gc #t)
|
||||
|
||||
(if (not (= (fooCount) -1))
|
||||
(error "Bad foo count 3"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
(load "newobject2.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
|
||||
(slot-set! f 'dummy 14)
|
||||
(if (not (= (slot-ref f 'dummy) 14))
|
||||
(error "Bad dummy value"))
|
||||
|
||||
(if (not (= (fooCount) 0))
|
||||
(error "Bad foo count 1"))
|
||||
|
||||
(define f2 (makeFoo))
|
||||
|
||||
(if (not (= (fooCount) 1))
|
||||
(error "Bad foo count 2"))
|
||||
|
||||
(slot-set! f2 'dummy 16)
|
||||
(if (not (= (slot-ref f2 'dummy) 16))
|
||||
(error "Bad dummy value for f2"))
|
||||
|
||||
(set! f #f)
|
||||
(set! f2 #f)
|
||||
|
||||
(gc #t)
|
||||
|
||||
(if (not (= (fooCount) -1))
|
||||
(error "Bad foo count 3"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "overload_complicated.so")
|
||||
(include "../schemerunme/overload_complicated.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "overload_copy.so")
|
||||
(include "../schemerunme/overload_copy.scm")
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
(load "./overload_copy.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define g (make <Foo> f))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "overload_extend_c.so")
|
||||
(include "../schemerunme/overload_extend_c.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "overload_extend.so")
|
||||
(include "../schemerunme/overload_extend.scm")
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
(load "./overload_extend.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
|
||||
(if (not (= (test f 3) 1))
|
||||
(error "test integer bad"))
|
||||
|
||||
(if (not (= (test f "hello") 2))
|
||||
(error "test string bad"))
|
||||
|
||||
(if (not (= (test f 3.5 2.5) 6.0))
|
||||
(error "test reals bad"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "overload_simple.so")
|
||||
(include "../schemerunme/overload_simple.scm")
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
(load "overload_simple.so")
|
||||
|
||||
(define-macro (check test)
|
||||
`(if (not ,test) (error ',test)))
|
||||
|
||||
(check (string=? (foo) "foo:"))
|
||||
(check (string=? (foo 3) "foo:int"))
|
||||
(check (string=? (foo 3.01) "foo:double"))
|
||||
(check (string=? (foo "hey") "foo:char *"))
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define b (make <Bar>))
|
||||
(define b2 (make <Bar> 3))
|
||||
|
||||
(check (= (slot-ref b 'num) 0))
|
||||
(check (= (slot-ref b2 'num) 3))
|
||||
|
||||
(check (string=? (foo f) "foo:Foo *"))
|
||||
(check (string=? (foo b) "foo:Bar *"))
|
||||
(check (string=? (foo f 3) "foo:Foo *,int"))
|
||||
(check (string=? (foo 3.2 b) "foo:double,Bar *"))
|
||||
|
||||
;; now check blah
|
||||
(check (string=? (blah 2.01) "blah:double"))
|
||||
(check (string=? (blah "hey") "blah:char *"))
|
||||
|
||||
;; now check spam member functions
|
||||
(define s (make <Spam>))
|
||||
(define s2 (make <Spam> 3))
|
||||
(define s3 (make <Spam> 3.2))
|
||||
(define s4 (make <Spam> "whee"))
|
||||
(define s5 (make <Spam> f))
|
||||
(define s6 (make <Spam> b))
|
||||
|
||||
(check (string=? (slot-ref s 'type) "none"))
|
||||
(check (string=? (slot-ref s2 'type) "int"))
|
||||
(check (string=? (slot-ref s3 'type) "double"))
|
||||
(check (string=? (slot-ref s4 'type) "char *"))
|
||||
(check (string=? (slot-ref s5 'type) "Foo *"))
|
||||
(check (string=? (slot-ref s6 'type) "Bar *"))
|
||||
|
||||
;; now check Spam member functions
|
||||
(check (string=? (foo s 2) "foo:int"))
|
||||
(check (string=? (foo s 2.1) "foo:double"))
|
||||
(check (string=? (foo s "hey") "foo:char *"))
|
||||
(check (string=? (foo s f) "foo:Foo *"))
|
||||
(check (string=? (foo s b) "foo:Bar *"))
|
||||
|
||||
;; check static member funcs
|
||||
(check (string=? (Spam-bar 3) "bar:int"))
|
||||
(check (string=? (Spam-bar 3.2) "bar:double"))
|
||||
(check (string=? (Spam-bar "hey") "bar:char *"))
|
||||
(check (string=? (Spam-bar f) "bar:Foo *"))
|
||||
(check (string=? (Spam-bar b) "bar:Bar *"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "overload_subtype.so")
|
||||
(include "../schemerunme/overload_subtype.scm")
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
(load "./overload_subtype.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define b (make <Bar>))
|
||||
|
||||
(if (not (= (spam f) 1))
|
||||
(error "Error in foo"))
|
||||
|
||||
(if (not (= (spam b) 2))
|
||||
(error "Error in bar"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "pointer_in_out.so")
|
||||
(include "../schemerunme/pointer_in_out.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "reference_global_vars.so")
|
||||
(include "../schemerunme/reference_global_vars.scm")
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
(define (lookup-ext-tag tag)
|
||||
(cond
|
||||
((equal? tag '(quote swig-contract-assertion-failed))
|
||||
'( ((exn type) #f)) )
|
||||
(#t '())))
|
||||
|
||||
(define-macro (expect-throw tag-form form)
|
||||
`(if (condition-case (begin ,form #t)
|
||||
,@(lookup-ext-tag tag-form)
|
||||
((exn) (print "The form threw a different error than expected: " ',form) (exit 1))
|
||||
(var () (print "The form did not error as expected: " ',form) (exit 1)))
|
||||
(begin (print "The form returned normally when it was expected to throw an error: " ',form) (exit 1))))
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
(load "throw_exception.so")
|
||||
|
||||
(define-macro (check-throw expr check)
|
||||
`(if (handle-exceptions exvar (if ,check #f (begin (print "Error executing: " ',expr " " exvar) (exit 1))) ,expr #t)
|
||||
(print "Expression did not throw an error: " ',expr)))
|
||||
|
||||
(define f (new-Foo))
|
||||
|
||||
(check-throw (Foo-test-int f) (= exvar 37))
|
||||
(check-throw (Foo-test-msg f) (string=? exvar "Dead"))
|
||||
(check-throw (Foo-test-cls f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ptr f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ref f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-td f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ptr-td f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ref-td f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-enum f) (= exvar (enum2)))
|
||||
|
||||
; don't know how to test this... it is returning a SWIG wrapped int *
|
||||
;(check-throw (Foo-test-array f) (equal? exvar '(0 1 2 3 4 5 6 7 8 9)))
|
||||
|
||||
(check-throw (Foo-test-multi f 1) (= exvar 37))
|
||||
(check-throw (Foo-test-multi f 2) (string=? exvar "Dead"))
|
||||
(check-throw (Foo-test-multi f 3) (test-is-Error exvar))
|
||||
|
||||
(set! f #f)
|
||||
(gc #t)
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "typedef_inherit.so")
|
||||
(include "../schemerunme/typedef_inherit.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "typename.so")
|
||||
(include "../schemerunme/typename.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "unions.so")
|
||||
(include "../schemerunme/unions.scm")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
(load "unions.so")
|
||||
(include "../schemerunme/unions_proxy.scm")
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
%module chicken_ext_test
|
||||
|
||||
/* just use the imports_a.h header... for this test we only need a class */
|
||||
%{
|
||||
#include "imports_a.h"
|
||||
%}
|
||||
|
||||
%include "imports_a.h"
|
||||
|
||||
%{
|
||||
void test_create(C_word,C_word,C_word) C_noret;
|
||||
%}
|
||||
|
||||
%init %{
|
||||
{
|
||||
C_word *space = C_alloc(2 + C_SIZEOF_INTERNED_SYMBOL(11));
|
||||
sym = C_intern (&space, 11, "test-create");
|
||||
C_mutate ((C_word*)sym+1, (*space=C_CLOSURE_TYPE|1, space[1]=(C_word)test_create, tmp=(C_word)space, space+=2, tmp));
|
||||
}
|
||||
%}
|
||||
|
||||
18
Examples/test-suite/class_case.i
Normal file
18
Examples/test-suite/class_case.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
%module class_case
|
||||
|
||||
// Regression test for SWIG/Go bug #676
|
||||
|
||||
%inline %{
|
||||
|
||||
class ClassA {};
|
||||
|
||||
class classB {};
|
||||
class classB2 : public classB {};
|
||||
|
||||
int Test1(ClassA* a) { return 1; }
|
||||
int Test1(int i) { return 0; }
|
||||
|
||||
int Test2(classB* a) { return 1; }
|
||||
int Test2(int i) { return 0; }
|
||||
|
||||
%}
|
||||
|
|
@ -15,6 +15,7 @@ namespace Space1 {
|
|||
void aaa(Space1::SubSpace1::A, SubSpace1::A, A) {}
|
||||
}
|
||||
}
|
||||
void global_namespace_a(A*) {}
|
||||
|
||||
namespace Space2 {
|
||||
struct B;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class A {
|
|||
|
||||
typedef A tA;
|
||||
|
||||
void test_A(A *a) {}
|
||||
void test_tA(tA *a) {}
|
||||
inline void test_A(A *a) {}
|
||||
inline void test_tA(tA *a) {}
|
||||
|
||||
tA *new_tA() { return new tA(); }
|
||||
inline tA *new_tA() { return new tA(); }
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
#######################################################################
|
||||
# Makefile for clisp test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = clisp
|
||||
CLISP = @CLISPBIN@
|
||||
SCRIPTSUFFIX = _runme.lisp
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# no C++ tests for now
|
||||
CPP_TEST_CASES =
|
||||
#C_TEST_CASES +=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra clisp code)
|
||||
%.clean:
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' clisp_clean
|
||||
7
Examples/test-suite/command_line_define.i
Normal file
7
Examples/test-suite/command_line_define.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module command_line_define
|
||||
|
||||
// Test handling of -D without a value specified.
|
||||
|
||||
#if FOO-0 != 1
|
||||
# error "-DFOO didn't set FOO to 1"
|
||||
#endif
|
||||
|
|
@ -102,6 +102,7 @@ C_TEST_BROKEN += \
|
|||
# C++ test cases. (Can be run individually using: make testcase.cpptest)
|
||||
CPP_TEST_CASES += \
|
||||
abstract_access \
|
||||
abstract_basecast \
|
||||
abstract_inherit \
|
||||
abstract_inherit_ok \
|
||||
abstract_signature \
|
||||
|
|
@ -134,6 +135,7 @@ CPP_TEST_CASES += \
|
|||
char_binary \
|
||||
char_strings \
|
||||
chartest \
|
||||
class_case \
|
||||
class_scope_namespace \
|
||||
class_forward \
|
||||
class_ignore \
|
||||
|
|
@ -141,6 +143,7 @@ CPP_TEST_CASES += \
|
|||
compactdefaultargs \
|
||||
const_const_2 \
|
||||
constant_directive \
|
||||
constant_expr \
|
||||
constant_pointers \
|
||||
constover \
|
||||
constructor_copy \
|
||||
|
|
@ -184,6 +187,7 @@ CPP_TEST_CASES += \
|
|||
director_classes \
|
||||
director_classic \
|
||||
director_constructor \
|
||||
director_comparison_operators \
|
||||
director_conversion_operators \
|
||||
director_default \
|
||||
director_detect \
|
||||
|
|
@ -210,6 +214,7 @@ CPP_TEST_CASES += \
|
|||
director_protected_overloaded \
|
||||
director_redefined \
|
||||
director_ref \
|
||||
director_simple \
|
||||
director_smartptr \
|
||||
director_thread \
|
||||
director_unroll \
|
||||
|
|
@ -232,6 +237,7 @@ CPP_TEST_CASES += \
|
|||
evil_diamond_ns \
|
||||
evil_diamond_prop \
|
||||
exception_classname \
|
||||
exception_memory_leak \
|
||||
exception_order \
|
||||
extend \
|
||||
extend_constructor_destructor \
|
||||
|
|
@ -313,6 +319,7 @@ CPP_TEST_CASES += \
|
|||
namespace_forward_declaration \
|
||||
namespace_nested \
|
||||
namespace_spaces \
|
||||
namespace_struct \
|
||||
namespace_template \
|
||||
namespace_typedef_class \
|
||||
namespace_typemap \
|
||||
|
|
@ -330,7 +337,7 @@ CPP_TEST_CASES += \
|
|||
nested_ignore \
|
||||
nested_inheritance_interface \
|
||||
nested_in_template \
|
||||
nested_scope \
|
||||
nested_scope_flat \
|
||||
nested_template_base \
|
||||
nested_workaround \
|
||||
newobject1 \
|
||||
|
|
@ -418,6 +425,7 @@ CPP_TEST_CASES += \
|
|||
struct_value \
|
||||
swig_exception \
|
||||
symbol_clash \
|
||||
sym \
|
||||
template_arg_replace \
|
||||
template_arg_scope \
|
||||
template_arg_typename \
|
||||
|
|
@ -460,6 +468,7 @@ CPP_TEST_CASES += \
|
|||
template_using_directive_and_declaration_forward \
|
||||
template_using_directive_typedef \
|
||||
template_nested \
|
||||
template_nested_flat \
|
||||
template_nested_typemaps \
|
||||
template_ns \
|
||||
template_ns2 \
|
||||
|
|
@ -545,6 +554,7 @@ CPP_TEST_CASES += \
|
|||
using_directive_and_declaration_forward \
|
||||
using_extend \
|
||||
using_inherit \
|
||||
using_member \
|
||||
using_namespace \
|
||||
using_namespace_loop \
|
||||
using_pointers \
|
||||
|
|
@ -675,7 +685,7 @@ ifndef SKIP_CPP_STD_CASES
|
|||
CPP_TEST_CASES += ${CPP_STD_TEST_CASES}
|
||||
endif
|
||||
|
||||
ifneq (,$(HAVE_CXX11_COMPILER))
|
||||
ifeq (1,$(HAVE_CXX11))
|
||||
CPP_TEST_CASES += $(CPP11_TEST_CASES)
|
||||
endif
|
||||
|
||||
|
|
@ -686,8 +696,10 @@ C_TEST_CASES += \
|
|||
c_delete \
|
||||
c_delete_function \
|
||||
char_constant \
|
||||
command_line_define \
|
||||
const_const \
|
||||
constant_expr \
|
||||
constant_expr_c \
|
||||
contract_c \
|
||||
default_args_c \
|
||||
empty_c \
|
||||
enums \
|
||||
|
|
@ -718,6 +730,7 @@ C_TEST_CASES += \
|
|||
nested_extend_c \
|
||||
nested_structs \
|
||||
newobject2 \
|
||||
not_c_keywords \
|
||||
overload_extend_c \
|
||||
overload_extend2 \
|
||||
preproc \
|
||||
|
|
@ -754,6 +767,7 @@ MULTI_CPP_TEST_CASES += \
|
|||
# Custom tests - tests with additional commandline options
|
||||
wallkw.cpptest: SWIGOPT += -Wallkw
|
||||
preproc_include.ctest: SWIGOPT += -includeall
|
||||
command_line_define.ctest: SWIGOPT += -DFOO
|
||||
|
||||
# Allow modules to define temporarily failing tests.
|
||||
C_TEST_CASES := $(filter-out $(FAILING_C_TESTS),$(C_TEST_CASES))
|
||||
|
|
@ -858,8 +872,6 @@ setup = \
|
|||
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#######################################################################
|
||||
# Clean
|
||||
#######################################################################
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
%include <complex.i>
|
||||
|
||||
#ifdef __cplusplus
|
||||
%{
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
|
@ -10,9 +9,7 @@
|
|||
%}
|
||||
%include <std_vector.i>
|
||||
|
||||
#if 1
|
||||
%template(VectorStdCplx) std::vector<std::complex<double> >;
|
||||
#endif
|
||||
|
||||
%inline
|
||||
{
|
||||
|
|
@ -63,26 +60,3 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
%{
|
||||
%}
|
||||
|
||||
%inline
|
||||
{
|
||||
complex Conj(complex a)
|
||||
{
|
||||
return conj(a);
|
||||
}
|
||||
|
||||
|
||||
complex float Conjf(float complex a)
|
||||
{
|
||||
return conj(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,11 +1,26 @@
|
|||
%module constant_expr;
|
||||
/* Tests of constant expressions. */
|
||||
/* Tests of constant expressions (C++ version). */
|
||||
|
||||
%include "constant_expr_c.i"
|
||||
|
||||
%inline %{
|
||||
|
||||
/* % didn't work in SWIG 1.3.40 and earlier. */
|
||||
const int X = 123%7;
|
||||
#define FOO 12 % 9
|
||||
double d_array[12 % 9];
|
||||
// Testcase from https://sourceforge.net/p/swig/bugs/1139/
|
||||
template<typename Tp>
|
||||
struct SizeInfo {
|
||||
enum {
|
||||
isLarge = (sizeof(Tp)>sizeof(void*)),
|
||||
isPointer = false
|
||||
};
|
||||
};
|
||||
|
||||
/* Regression test for #300, fixed in 4.1.0.
|
||||
*
|
||||
* Now `a%b` without a space after the `%` is handled as a modulus operator,
|
||||
* but it gave a cryptic `Syntax error in input(1)` before SWIG 3.0.4, and from
|
||||
* SWIG 3.0.4 until 4.1.0, `Unknown directive '%a'`.
|
||||
*/
|
||||
int a;
|
||||
int test2(int b = 9%a) { return b; }
|
||||
|
||||
%}
|
||||
|
|
|
|||
56
Examples/test-suite/constant_expr_c.i
Normal file
56
Examples/test-suite/constant_expr_c.i
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
%module constant_expr_c;
|
||||
/* Tests of constant expressions (C version). */
|
||||
|
||||
%inline %{
|
||||
|
||||
/* % didn't work in SWIG 1.3.40 and earlier. */
|
||||
const int X = 123%7;
|
||||
#define FOO 12 % 9
|
||||
double d_array[12 % 9];
|
||||
|
||||
/* `<` and `>` in constant expressions caused parse errors before SWIG 4.1.0.
|
||||
* They're now supported if inside parentheses (and with some restrictions
|
||||
* on the LHS of `<`.
|
||||
*/
|
||||
|
||||
// Testcase from https://github.com/swig/swig/issues/635
|
||||
#define TEST_A 1
|
||||
#define TEST_B 2
|
||||
#define TEST_C (TEST_A < TEST_B)
|
||||
#define TEST_D (TEST_A > TEST_B)
|
||||
// These have been supported since 1.3.41.
|
||||
#define TEST_E (TEST_A <= TEST_B)
|
||||
#define TEST_F (TEST_A >= TEST_B)
|
||||
// For completeness
|
||||
#define TEST_G (TEST_A == TEST_B)
|
||||
#define TEST_H (TEST_A != TEST_B)
|
||||
|
||||
// No warning
|
||||
#if (TEST_A < TEST_B)
|
||||
#define TEST_I 1
|
||||
#else
|
||||
#define TEST_I 0
|
||||
#endif
|
||||
|
||||
/* sizeof didn't work on an expression before SWIG 4.1.0 except for cases where
|
||||
* the expression was in parentheses and looked syntactically like a type (so
|
||||
* sizeof(X) worked because X could be a type syntactically).
|
||||
*/
|
||||
const int s1a = sizeof(X); /* worked before 4.1.0 */
|
||||
//const int s1b = sizeof X; /* not currently supported */
|
||||
const int s2a = sizeof("a string" );
|
||||
const int s2b = sizeof "a string";
|
||||
const int s3a = sizeof('c');
|
||||
const int s3b = sizeof('c');
|
||||
const int s4a = sizeof(L"a wstring");
|
||||
const int s4b = sizeof L"a wstring";
|
||||
const int s5a = sizeof(L'C');
|
||||
const int s5b = sizeof L'C';
|
||||
const int s6a = sizeof(sizeof(X));
|
||||
const int s6b = sizeof sizeof(X);
|
||||
const int s7a = sizeof(3.14);
|
||||
const int s7b = sizeof 3.14;
|
||||
const int s8a = sizeof(2.1e-6);
|
||||
const int s8b = sizeof 2.1e-6;
|
||||
|
||||
%}
|
||||
|
|
@ -53,8 +53,6 @@ public:
|
|||
int* array_member1[ARRAY_SIZE];
|
||||
ParametersTest* array_member2[ARRAY_SIZE];
|
||||
MemberVariablesTest() : member3(NULL), member4(NULL) {}
|
||||
private:
|
||||
MemberVariablesTest& operator=(const MemberVariablesTest&);
|
||||
};
|
||||
void foofunction(const int *const i) {}
|
||||
|
||||
|
|
@ -80,8 +78,6 @@ public:
|
|||
void ret8(int*const& a) {}
|
||||
int*const& ret9() {return GlobalIntPtr;}
|
||||
ReturnValuesTest() : int3(NULL) {}
|
||||
private:
|
||||
ReturnValuesTest& operator=(const ReturnValuesTest&);
|
||||
};
|
||||
|
||||
const int* globalRet1() {return &GlobalInt;}
|
||||
|
|
@ -113,8 +109,6 @@ int* const globalRet2() {return &GlobalInt;}
|
|||
A* ap;
|
||||
const A* cap;
|
||||
Acptr acptr;
|
||||
private:
|
||||
B& operator=(const B&);
|
||||
};
|
||||
|
||||
const B* bar(const B* b) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ int test_prepost(int x, int y) {
|
|||
}
|
||||
%}
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Class tests */
|
||||
|
||||
%contract Foo::test_preassert(int x, int y) {
|
||||
|
|
@ -235,4 +236,4 @@ class myClass
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
5
Examples/test-suite/contract_c.i
Normal file
5
Examples/test-suite/contract_c.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%module contract_c;
|
||||
|
||||
%include <exception.i>
|
||||
|
||||
%include "contract.i"
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
%module cpp11_alternate_function_syntax
|
||||
|
||||
%inline %{
|
||||
struct Hello {};
|
||||
|
||||
struct SomeStruct {
|
||||
int addNormal(int x, int y);
|
||||
auto addAlternate(int x, int y) -> int;
|
||||
|
|
@ -12,6 +14,9 @@ struct SomeStruct {
|
|||
auto addAlternateMemberPtrParm(int x, int (SomeStruct::*mp)(int, int)) -> int;
|
||||
auto addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const -> int;
|
||||
|
||||
// Returning a reference didn't parse in SWIG < 4.1.0 (#231)
|
||||
auto output() -> Hello&;
|
||||
|
||||
virtual auto addFinal(int x, int y) const noexcept -> int final { return x + y; }
|
||||
virtual ~SomeStruct() = default;
|
||||
};
|
||||
|
|
@ -27,5 +32,6 @@ auto SomeStruct::addAlternateMemberPtrParm(int x, int (SomeStruct::*mp)(int, int
|
|||
auto SomeStruct::addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const -> int {
|
||||
return 1000*x + (this->*mp)(x, x);
|
||||
}
|
||||
auto SomeStruct::output() -> Hello& { static Hello h; return h; }
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -53,3 +53,12 @@ int Array300[ConstExpressions::LLL];
|
|||
//int Array400[ConstExpressions::MMM()];
|
||||
//int Array500[ConstExpressions::NNN()];
|
||||
%}
|
||||
|
||||
%{
|
||||
// Test handling of ID PERIOD ID in constant expressions (supported since 4.1.0).
|
||||
struct A {
|
||||
int i;
|
||||
};
|
||||
constexpr A a{42};
|
||||
constexpr int N = a.i;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ struct FinalOverrideMethods {
|
|||
virtual void override(int) {}
|
||||
virtual ~FinalOverrideMethods() = default;
|
||||
};
|
||||
struct FinalOverrideVariables {
|
||||
struct FinalOverrideVars {
|
||||
int final;
|
||||
double override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ auto lambda4 = [](int x, int y) { return x+y; };
|
|||
auto lambda5 = []() { return thing; };
|
||||
#endif
|
||||
|
||||
void fn() {
|
||||
void fn1() {
|
||||
int stuff = 0;
|
||||
auto lambdaxxxx = [=,&stuff]() { return thing; };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@
|
|||
%include <std_wstring.i>
|
||||
#endif
|
||||
|
||||
#if defined(SWIGLUA)
|
||||
// Lua uses a parameter called L in every wrapper function
|
||||
%ignore L;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -24,19 +24,19 @@ void takeit3(Thing const*&& t) {}
|
|||
void takeit4(Thing *const&& t) {}
|
||||
void takeit5(Thing const*const&& t) {}
|
||||
|
||||
struct Containing {
|
||||
Thing && member_rvalue_ref;
|
||||
Thing *&& member_rvalue_ref_ptr1;
|
||||
Thing const*&& member_rvalue_ref_ptr2;
|
||||
Thing *const&& member_rvalue_ref_ptr3;
|
||||
Thing const*const &&member_rvalue_ref_ptr4;
|
||||
struct Contain {
|
||||
Thing && m_ref;
|
||||
Thing *&& m_ref_ptr1;
|
||||
Thing const*&& m_ref_ptr2;
|
||||
Thing *const&& m_ref_ptr3;
|
||||
Thing const*const &&m_ref_ptr4;
|
||||
|
||||
Containing(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) :
|
||||
member_rvalue_ref(std::move(r)),
|
||||
member_rvalue_ref_ptr1(std::move(r1)),
|
||||
member_rvalue_ref_ptr2(std::move(r2)),
|
||||
member_rvalue_ref_ptr3(std::move(r3)),
|
||||
member_rvalue_ref_ptr4(std::move(r4))
|
||||
Contain(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) :
|
||||
m_ref(std::move(r)),
|
||||
m_ref_ptr1(std::move(r1)),
|
||||
m_ref_ptr2(std::move(r2)),
|
||||
m_ref_ptr3(std::move(r3)),
|
||||
m_ref_ptr4(std::move(r4))
|
||||
{}
|
||||
};
|
||||
%}
|
||||
|
|
@ -61,19 +61,19 @@ void int_takeit3(int const*&& t) {}
|
|||
void int_takeit4(int *const&& t) {}
|
||||
void int_takeit5(int const*const&& t) {}
|
||||
|
||||
struct IntContaining {
|
||||
int && member_rvalue_ref;
|
||||
int *&& member_rvalue_ref_ptr1;
|
||||
int const*&& member_rvalue_ref_ptr2;
|
||||
int *const&& member_rvalue_ref_ptr3;
|
||||
int const*const &&member_rvalue_ref_ptr4;
|
||||
struct IContain {
|
||||
int && m_ref;
|
||||
int *&& m_ref_ptr1;
|
||||
int const*&& m_ref_ptr2;
|
||||
int *const&& m_ref_ptr3;
|
||||
int const*const &&m_ref_ptr4;
|
||||
|
||||
IntContaining(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) :
|
||||
member_rvalue_ref(std::move(r)),
|
||||
member_rvalue_ref_ptr1(std::move(r1)),
|
||||
member_rvalue_ref_ptr2(std::move(r2)),
|
||||
member_rvalue_ref_ptr3(std::move(r3)),
|
||||
member_rvalue_ref_ptr4(std::move(r4))
|
||||
IContain(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) :
|
||||
m_ref(std::move(r)),
|
||||
m_ref_ptr1(std::move(r1)),
|
||||
m_ref_ptr2(std::move(r2)),
|
||||
m_ref_ptr3(std::move(r3)),
|
||||
m_ref_ptr4(std::move(r4))
|
||||
{}
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
%module cpp11_std_array
|
||||
|
||||
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO)
|
||||
|
||||
%{
|
||||
#include <array>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* This interface checks whether SWIG supports the new double angled brackets
|
||||
in the template syntax without having a space inbetween. This feature was
|
||||
in the template syntax without having a space in between. This feature was
|
||||
introduced in new C++11 standard.
|
||||
*/
|
||||
%module cpp11_template_double_brackets
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
*/
|
||||
%module cpp11_template_explicit
|
||||
|
||||
/* Suppress SWIG warnings related to explicit template instantiation and extern templates */
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_EXPLICIT_TEMPLATE
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_EXTERN_TEMPLATE
|
||||
|
||||
%inline %{
|
||||
|
||||
|
|
@ -33,6 +35,30 @@ extern template class Temper<B*>;
|
|||
|
||||
template class Temper<int>;
|
||||
extern template class Temper<short>;
|
||||
|
||||
/* Templated function to check support for extern template functions */
|
||||
template <typename T>
|
||||
T my_templated_function(int a, double b)
|
||||
{
|
||||
return T();
|
||||
}
|
||||
|
||||
/* Explicit extern function template instantiation with simple type */
|
||||
extern template int my_templated_function<int>(int, double);
|
||||
template int my_templated_function<int>(int, double);
|
||||
|
||||
/* Explicit extern function template instantiation with more complex types */
|
||||
extern template A my_templated_function<A>(int, double);
|
||||
template A my_templated_function<A>(int, double);
|
||||
|
||||
extern template Temper<int> my_templated_function<Temper<int>>(int, double);
|
||||
template Temper<int> my_templated_function<Temper<int>>(int, double);
|
||||
|
||||
%}
|
||||
|
||||
%template(TemperInt) Temper<int>;
|
||||
|
||||
/* Enable several versions of the templated function */
|
||||
%template(my_templated_function_int ) my_templated_function<int>;
|
||||
%template(my_templated_function_A ) my_templated_function<A>;
|
||||
%template(my_templated_function_TemperInt) my_templated_function<Temper<int>>;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ thread_local static int tsval;
|
|||
extern thread_local int etval;
|
||||
thread_local extern int teval;
|
||||
extern "C" thread_local int ectval;
|
||||
extern "C" { thread_local int ectval2 = 56; }
|
||||
extern "C++" thread_local int ecpptval;
|
||||
extern "C++" { thread_local int ecpptval2 = 67; }
|
||||
|
||||
thread_local int ThreadLocals::stval = 11;
|
||||
thread_local int ThreadLocals::tsval = 22;
|
||||
|
|
@ -30,6 +32,10 @@ thread_local const int ThreadLocals::tscval99;
|
|||
// externs
|
||||
thread_local int etval = 33;
|
||||
thread_local int teval = 44;
|
||||
extern "C" {
|
||||
thread_local int ectval = 55;
|
||||
}
|
||||
extern "C++" {
|
||||
thread_local int ecpptval = 66;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -63,12 +63,14 @@ using IntArray = Int[];
|
|||
|
||||
// Test that SWIG understands these new types
|
||||
|
||||
%{
|
||||
Int mult2(Int x) { return x * 2; }
|
||||
%}
|
||||
%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; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* This is a basic test of proxy classes, used by chicken */
|
||||
/* This is a basic test of proxy classes */
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
|
||||
|
||||
|
|
@ -45,6 +45,9 @@ class FooSubSub : public FooSub {
|
|||
const char* __str__() const { return "FooSubSub"; }
|
||||
};
|
||||
|
||||
Foo& get_reference(Foo& other) { return other; }
|
||||
const Foo& get_const_reference(const Foo& other) { return other; }
|
||||
|
||||
%}
|
||||
|
||||
%{
|
||||
|
|
@ -74,8 +77,16 @@ class Bar {
|
|||
Foo *testFoo(int a, Foo *f) {
|
||||
return new Foo(2 * a + (f ? f->num : 0) + fval.num);
|
||||
}
|
||||
/* Const member data and references mean this class can't be assigned.
|
||||
private:
|
||||
Bar& operator=(const Bar&);
|
||||
*/
|
||||
};
|
||||
|
||||
// This class is valid C++ but cannot be assigned to because it has const member data.
|
||||
struct JustConst {
|
||||
explicit JustConst(int i_inp) : i(i_inp) {}
|
||||
const int i;
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
%module cpp_typedef
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 5208) // warning C5208: unnamed class used in typedef name cannot declare members other than non-static data members, member enumerations, or member classes
|
||||
#endif
|
||||
|
||||
class Bar {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ CPP_TEST_CASES = \
|
|||
enum_thorough_typesafe \
|
||||
exception_partial_info \
|
||||
intermediary_classname \
|
||||
nested_scope \
|
||||
li_boost_intrusive_ptr \
|
||||
li_std_list \
|
||||
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public class CSharpDerived : Base
|
|||
// Note the following method can never be called from unmanaged code.
|
||||
// It is here only for code that calls it directly from managed code.
|
||||
// But should always be defined to ensure behaviour is consistent
|
||||
// independent of where DefaultParsms is called from (managed or unmanaged code).
|
||||
// independent of where DefaultParams is called from (managed or unmanaged code).
|
||||
// Note this method can never be called from unmanaged code
|
||||
public override String DefaultParms(int x)
|
||||
{
|
||||
|
|
|
|||
58
Examples/test-suite/csharp/director_default_runme.cs
Normal file
58
Examples/test-suite/csharp/director_default_runme.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
|
||||
namespace director_defaultNamespace {
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
{
|
||||
MyFoo a = new MyFoo();
|
||||
a = new MyFoo(10);
|
||||
a.Dispose();
|
||||
}
|
||||
|
||||
{
|
||||
MyFoo a = new MyFoo();
|
||||
if (a.GetMsg() != "MyFoo-default") {
|
||||
throw new Exception( "Test 1 failed" );
|
||||
}
|
||||
if (a.GetMsg("boo") != "MyFoo-boo") {
|
||||
throw new Exception( "Test 2 failed" );
|
||||
}
|
||||
a.Dispose();
|
||||
}
|
||||
|
||||
{
|
||||
Foo b = new Foo();
|
||||
if (b.GetMsg() != "Foo-default") {
|
||||
throw new Exception( "Test 1 failed" );
|
||||
}
|
||||
if (b.GetMsg("boo") != "Foo-boo") {
|
||||
throw new Exception( "Test 2 failed" );
|
||||
}
|
||||
b.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MyFoo : Foo
|
||||
{
|
||||
public MyFoo()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public MyFoo(int i)
|
||||
: base(i)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Msg(string msg)
|
||||
{
|
||||
return "MyFoo-" + msg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
64
Examples/test-suite/csharp/director_property_runme.cs
Normal file
64
Examples/test-suite/csharp/director_property_runme.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
|
||||
namespace director_propertyNamespace {
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
{
|
||||
Foo a = new MyFoo();
|
||||
if (a.getA() != "") {
|
||||
throw new Exception( "Test failed" );
|
||||
}
|
||||
a.setA("Hello");
|
||||
if (a.getA() != "Hello set from MyFoo") {
|
||||
throw new Exception( "Test failed" );
|
||||
}
|
||||
a.setAByRef("Hello");
|
||||
if (a.getA() != "Hello setAByRef from MyFoo") {
|
||||
throw new Exception( "Test failed" );
|
||||
}
|
||||
a.Dispose();
|
||||
}
|
||||
|
||||
{
|
||||
Foo a_original = new MyFoo();
|
||||
Foo a = Foo.get_self(a_original);
|
||||
if (a.getA() != "") {
|
||||
throw new Exception( "Test failed" );
|
||||
}
|
||||
a.setA("Hello");
|
||||
if (a.getA() != "Hello set from MyFoo") {
|
||||
throw new Exception( "Test failed" );
|
||||
}
|
||||
a.setAByRef("Hello");
|
||||
if (a.getA() != "Hello setAByRef from MyFoo") {
|
||||
throw new Exception( "Test failed" );
|
||||
}
|
||||
a.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MyFoo : Foo
|
||||
{
|
||||
public MyFoo()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override void setA(string a)
|
||||
{
|
||||
base.setA(a + " set from MyFoo");
|
||||
}
|
||||
|
||||
public override void setAByRef(string a)
|
||||
{
|
||||
base.setA(a + " setAByRef from MyFoo");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -67,6 +67,12 @@ public class runme
|
|||
if (x != 1334)
|
||||
throw new Exception("Bad4 should be 1334, got " + x);
|
||||
}
|
||||
{
|
||||
MemberVoid mv = new MemberVoid();
|
||||
global::System.IntPtr zero = global::System.IntPtr.Zero;
|
||||
mv.memberVariable = zero;
|
||||
zero = mv.memberVariable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,13 @@ public class runme
|
|||
check_equal(li_std_wstring.test_ccvalue(x), "abc");
|
||||
check_equal(li_std_wstring.test_wchar_overload(x), "abc");
|
||||
|
||||
// Member variables
|
||||
var s = new wchar_test_struct();
|
||||
s.wchar_t_member = h;
|
||||
check_equal(s.wchar_t_member, h);
|
||||
s.wchar_t_ptr_member = x;
|
||||
check_equal(s.wchar_t_ptr_member, "abc");
|
||||
|
||||
{
|
||||
// Unicode strings
|
||||
string[] test_strings = {
|
||||
|
|
@ -99,6 +106,13 @@ public class runme
|
|||
check_equal(received, expected);
|
||||
}
|
||||
|
||||
foreach (string expected in test_strings)
|
||||
{
|
||||
s.wchar_t_ptr_member = expected;
|
||||
string received = s.wchar_t_ptr_member;
|
||||
check_equal(received, expected);
|
||||
}
|
||||
|
||||
/* Not working for Japanese and Russian characters on Windows, okay on Linux
|
||||
* Is fixed by adding CharSet=CharSet.Unicode to the DllImport, so change to:
|
||||
* [global::System.Runtime.InteropServices.DllImport("li_std_wstring", CharSet=global::System.Runtime.InteropServices.CharSet.Unicode, EntryPoint="CSharp_li_std_wstringNamespace_test_wcvalue")]
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ public class multiple_inheritance_abstract_runme {
|
|||
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");
|
||||
|
|
@ -234,6 +235,15 @@ public class multiple_inheritance_abstract_runme {
|
|||
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
|
||||
|
||||
// Return const pointer references
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_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");
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ public class multiple_inheritance_nspace_runme {
|
|||
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");
|
||||
|
|
@ -235,6 +236,15 @@ public class multiple_inheritance_nspace_runme {
|
|||
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
|
||||
|
||||
// Return const pointer references
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_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");
|
||||
|
|
|
|||
|
|
@ -301,6 +301,15 @@ public class multiple_inheritance_shared_ptr_runme {
|
|||
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 const pointer references
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
|
||||
check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_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");
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ public class runme {
|
|||
assert( typeof(int) == preproc_constants_c.EXPR_MINUS.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_LSHIFT.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_RSHIFT.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_LT.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_GT.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_LTE.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_GTE.GetType() );
|
||||
assert( typeof(int) == preproc_constants_c.EXPR_INEQUALITY.GetType() );
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class runme {
|
|||
assert( typeof(int) == preproc_constants.EXPR_MINUS.GetType() );
|
||||
assert( typeof(int) == preproc_constants.EXPR_LSHIFT.GetType() );
|
||||
assert( typeof(int) == preproc_constants.EXPR_RSHIFT.GetType() );
|
||||
assert( typeof(bool) == preproc_constants.EXPR_LT.GetType() );
|
||||
assert( typeof(bool) == preproc_constants.EXPR_GT.GetType() );
|
||||
assert( typeof(bool) == preproc_constants.EXPR_LTE.GetType() );
|
||||
assert( typeof(bool) == preproc_constants.EXPR_GTE.GetType() );
|
||||
assert( typeof(bool) == preproc_constants.EXPR_INEQUALITY.GetType() );
|
||||
|
|
|
|||
25
Examples/test-suite/csharp/template_nested_flat_runme.cs
Normal file
25
Examples/test-suite/csharp/template_nested_flat_runme.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using template_nested_flatNamespace;
|
||||
#pragma warning disable 219
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
new T_NormalTemplateNormalClass().tmethod(new NormalClass());
|
||||
new OuterClass().T_OuterTMethodNormalClass(new NormalClass());
|
||||
|
||||
TemplateFuncs tf = new TemplateFuncs();
|
||||
if (tf.T_TemplateFuncs1Int(-10) != -10)
|
||||
throw new Exception("it failed");
|
||||
if (tf.T_TemplateFuncs2Double(-12.3) != -12.3)
|
||||
throw new Exception("it failed");
|
||||
|
||||
T_NestedOuterTemplateDouble tn = new T_NestedOuterTemplateDouble();
|
||||
if (tn.hohum(-12.3) != -12.3)
|
||||
throw new Exception("it failed");
|
||||
T_OuterClassInner1Int inner1 = new OuterClass().useInner1(new T_OuterClassInner1Int());
|
||||
T_OuterClassInner2NormalClass inner2 = new T_OuterClassInner2NormalClass();
|
||||
inner2.embeddedVar = 2;
|
||||
T_OuterClassInner2NormalClass inner22 = new OuterClass().useInner2Again(inner2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ void main() {
|
|||
enforce(countUntil(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
|
||||
}
|
||||
|
||||
enforce(countUntil(vector[], 42) == -1, "non-existant item indexOf test failed");
|
||||
enforce(countUntil(vector[], 42) == -1, "non-existent item indexOf test failed");
|
||||
|
||||
vector.clear();
|
||||
enforce(vector.length == 0, "clear test failed");
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue