Merge branch 'master' into C

Merge with the latest master before making more changes.
This commit is contained in:
Vadim Zeitlin 2021-10-04 16:03:36 +02:00
commit ac4f3c78be
1118 changed files with 15064 additions and 34376 deletions

View file

@ -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

View file

@ -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 {
/*

View file

@ -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 *}

View file

@ -183,3 +183,12 @@ const int PROCESS_DEFAULT_VALUE = 17;
typedef long int some_type;
int process_complex_defval(int val = PROCESS_DEFAULT_VALUE, int factor = some_type(-1)) { return val*factor; }
%}
// Test for empty docstring, which should be ignored.
%feature("docstring") ""
%inline %{
struct a_structure{
char my_array[1];
};
%}

View 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);
}
}

View file

@ -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

View file

@ -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.

View file

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

View file

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

View file

@ -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);
}

View file

@ -1,5 +0,0 @@
(load "chicken_ext_test.so")
(define a (test-create))
(A-hello a)

View file

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

View file

@ -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)

View file

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

View file

@ -1,3 +0,0 @@
(load "contract.so")
(include "testsuite.ss")
(include "../schemerunme/contract.scm")

View file

@ -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)

View file

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

View file

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

View file

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

View file

@ -1,2 +0,0 @@
(require 'global_vars)
(load "../schemerunme/global_vars.scm")

View file

@ -1,2 +0,0 @@
(require 'global_vars)
(load "../schemerunme/global_vars_proxy.scm")

View file

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

View file

@ -1,3 +0,0 @@
(load "imports_a.so")
(load "imports_b.so")
(include "../schemerunme/imports.scm")

View file

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

View file

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

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

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

View file

@ -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)))

View file

@ -1,2 +0,0 @@
(require 'multiple_inheritance)
(load "../schemerunme/multiple_inheritance_proxy.scm")

View file

@ -1,4 +0,0 @@
;; this doesn't work yet :(
(load "multivalue.so")
(include "../schemerunme/multivalue.scm")
(exit 0)

View file

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

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

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

View file

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

View file

@ -1,6 +0,0 @@
(load "./overload_copy.so")
(define f (make <Foo>))
(define g (make <Foo> f))
(exit 0)

View file

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

View file

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

View file

@ -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)

View file

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

View file

@ -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)

View file

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

View file

@ -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)

View file

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

View file

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

View file

@ -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))))

View file

@ -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)

View file

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

View file

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

View file

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

View file

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

View file

@ -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));
}
%}

View file

@ -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

View file

@ -159,6 +159,7 @@ CPP_TEST_CASES += \
cpp_enum \
cpp_namespace \
cpp_nodefault \
cpp_parameters \
cpp_static \
cpp_typedef \
cpp14_binary_integer_literals \
@ -183,6 +184,8 @@ CPP_TEST_CASES += \
director_classes \
director_classic \
director_constructor \
director_comparison_operators \
director_conversion_operators \
director_default \
director_detect \
director_enum \
@ -250,6 +253,7 @@ CPP_TEST_CASES += \
funcptr_cpp \
functors \
fvirtual \
global_immutable_vars_cpp \
global_namespace \
global_ns_arg \
global_scope_types \
@ -326,7 +330,7 @@ CPP_TEST_CASES += \
nested_ignore \
nested_inheritance_interface \
nested_in_template \
nested_scope \
nested_scope_flat \
nested_template_base \
nested_workaround \
newobject1 \
@ -414,6 +418,7 @@ CPP_TEST_CASES += \
struct_value \
swig_exception \
symbol_clash \
sym \
template_arg_replace \
template_arg_scope \
template_arg_typename \
@ -456,6 +461,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 \
@ -610,11 +616,14 @@ CPP11_TEST_BROKEN = \
# cpp11_reference_wrapper \ # No typemaps
# Doxygen support test cases: can only be used with languages supporting
# Doxygen comment translation, currently only Python and Java.
# Doxygen comment translation (currently Python and Java) and only if not
# disabled by configure via SKIP_DOXYGEN_TEST_CASES.
ifneq ($(SKIP_DOXYGEN_TEST_CASES),1)
python_HAS_DOXYGEN := 1
java_HAS_DOXYGEN := 1
$(eval HAS_DOXYGEN := $($(LANGUAGE)_HAS_DOXYGEN))
endif
ifdef HAS_DOXYGEN
DOXYGEN_TEST_CASES += \
@ -622,6 +631,8 @@ DOXYGEN_TEST_CASES += \
doxygen_basic_notranslate \
doxygen_basic_translate \
doxygen_basic_translate_style2 \
doxygen_basic_translate_style3 \
doxygen_code_blocks \
doxygen_ignore \
doxygen_misc_constructs \
doxygen_nested_class \
@ -643,6 +654,7 @@ CPP_STD_TEST_CASES += \
director_string \
ignore_template_constructor \
li_std_combinations \
li_std_containers_overload \
li_std_deque \
li_std_except \
li_std_except_as_class \
@ -665,7 +677,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
@ -688,6 +700,7 @@ C_TEST_CASES += \
funcptr \
function_typedef \
global_functions \
global_immutable_vars \
immutable_values \
inctest \
infinity \
@ -707,6 +720,7 @@ C_TEST_CASES += \
nested_extend_c \
nested_structs \
newobject2 \
not_c_keywords \
overload_extend_c \
overload_extend2 \
preproc \
@ -849,8 +863,6 @@ setup = \
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
fi
#######################################################################
# Clean
#######################################################################

View file

@ -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

View file

@ -14,6 +14,11 @@ struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
};
enum EnumType
{
EnumValue
};
EnumType enumValue = EnumValue;
/* Typedefs for const Type and its pointer */
typedef const Type1 Type1Const;
typedef const Type1* Type1Cptr;
@ -46,3 +51,4 @@ Type1 getType1Instance() { return Type1(111); }
%constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance;
/* Regular constant */
%constant int TYPE_INT = 0;
%constant enum EnumType newValue = enumValue;

View file

@ -138,3 +138,31 @@ void DerivedNoVirtualStruct::ef() {}
DerivedNoVirtualStruct::~DerivedNoVirtualStruct() {}
%}
%inline %{
namespace Outer {
namespace final {
template <typename T> struct smart_ptr {
typedef T type;
};
}
namespace override {
template <typename T> struct dumb_ptr {
typedef T type;
};
}
}
%}
%template(SmartPtrBaseStruct) Outer::final::smart_ptr<DerivedStruct>;
%inline %{
class ObjectDB
{
public:
static void smart1(typename Outer::final::smart_ptr<DerivedStruct>::type *objectT) {}
static void smart2(Outer::final::smart_ptr<DerivedStruct>::type *objectT) {}
static void dumb1(typename Outer::override::dumb_ptr<DerivedStruct>::type *objectT) {}
static void dumb2(Outer::override::dumb_ptr<DerivedStruct>::type *objectT) {}
static Outer::final::smart_ptr<DerivedStruct>::type get() { return DerivedStruct(); }
};
%}

View file

@ -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; };
}

View file

@ -0,0 +1,88 @@
%module cpp11_shared_ptr_template_upcast
%{
#include <memory>
#include <string>
%}
%include <std_shared_ptr.i>
%include <std_string.i>
%{
class Base {
public:
Base() : value(0) {}
Base(int v) : value(v) {}
virtual ~Base() {}
virtual int GetResult() = 0;
int value;
};
class Derived : public Base {
public:
Derived() : Base() {}
Derived(int v) : Base(v) {}
virtual ~Derived() {}
int GetResult() { return value*2; }
};
template <class T> class Printable : virtual public T {
public:
Printable(int param) : T(param) {}
~Printable() {}
std::string GetFormatted() { return std::string("The formatted result is: ").append(std::to_string(this->GetResult())); }
};
std::shared_ptr<Printable<Derived> > MakePrintableDerived(int param) {
return std::make_shared<Printable<Derived> >(param);
}
%}
%shared_ptr(Base);
%shared_ptr(Derived);
%shared_ptr(Printable<Derived>)
class Base {
public:
Base();
Base(int v);
virtual ~Base();
virtual int GetResult() = 0;
int value;
};
class Derived : public Base {
public:
Derived();
Derived(int v);
virtual ~Derived();
int GetResult();
};
/*
Virtual inheritance is contrived for this case, but exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type -
if the pointer type is incorrect, this will result in a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access members
inherited from T through a shared_ptr<Printable<T> >.
*/
template <class T> class Printable : virtual public T {
public:
Printable(int param);
~Printable();
std::string GetFormatted();
};
std::shared_ptr<Printable<Derived> > MakePrintableDerived(int param);
%template(PrintableDerived) Printable<Derived>;

View file

@ -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 */

View file

@ -0,0 +1,46 @@
%module cpp_parameters
%{
// For Perl
#ifdef Zero
#undef Zero
#endif
%}
%inline %{
// Zero arguments
struct Zero {
Zero() {}
int zero() { return 0; }
static int stat_zero() { return 0; }
};
// One mandatory argument
struct One {
One(int a) {}
int one(int a) { return a; }
static int stat_one(int a) { return a; }
};
// Two mandatory arguments
struct Two {
Two(int a, int b) {}
int two(int a, int b) { return a + b; }
static int stat_two(int a, int b) { return a + b; }
};
// Single optional argument
struct Single {
Single(int a=0) {}
int single(int a=0) { return a; }
static int stat_single(int a=0) { return a; }
};
int global_zero() { return 0; }
int global_one(int a) { return a; }
int global_two(int a, int b) { return a + b; }
int global_single(int a=0) { return a; }
#ifdef SWIGPYTHON_BUILTIN
bool is_python_builtin() { return true; }
#else
bool is_python_builtin() { return false; }
#endif
%}

View file

@ -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:

View file

@ -16,6 +16,7 @@ CPP_TEST_CASES = \
complextest \
csharp_attributes \
csharp_swig2_compatibility \
csharp_director_typemaps \
csharp_exceptions \
csharp_features \
csharp_lib_arrays \
@ -27,6 +28,7 @@ CPP_TEST_CASES = \
enum_thorough_typesafe \
exception_partial_info \
intermediary_classname \
nested_scope \
li_boost_intrusive_ptr \
li_std_list \
@ -34,6 +36,7 @@ CPP11_TEST_CASES = \
cpp11_shared_ptr_const \
cpp11_shared_ptr_nullptr_in_containers \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_template_upcast \
cpp11_shared_ptr_upcast \
cpp11_strongly_typed_enumerations_simple \

View file

@ -0,0 +1,15 @@
// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class.
// For this case, the expected behavior is: given a cptr with underlying type shared_ptr<Printable<Derived> >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with
// underlying type std::shared_ptr< Derived >, where Printable<Derived> inherits from Derived.
using System;
using cpp11_shared_ptr_template_upcastNamespace;
public class cpp11_shared_ptr_template_upcast_runme
{
static void Main()
{
PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20);
pd.GetResult();
pd.GetFormatted();
}
}

View file

@ -0,0 +1,53 @@
using System;
using System.Reflection;
using csharp_director_typemapsNamespace;
public class csharp_director_typemaps_runme {
class CSharpDirectorTypemaps_InStreamDerived : InStream
{
private int constant;
public CSharpDirectorTypemaps_InStreamDerived(int constant) { this.constant = constant; }
public override int Read(global::System.IntPtr buf, int len, out int readLen) {
readLen = (buf == global::System.IntPtr.Zero) ? -len - constant : len + constant;
return readLen;
}
public override int Write(global::System.IntPtr buf, int len, out int writeLen) {
writeLen = (buf == global::System.IntPtr.Zero) ? -len - constant : len + constant;
return writeLen;
}
}
public static void Main() {
int outLen = -1;
int k = 100;
int j = 23;
InStream instream = new CSharpDirectorTypemaps_InStreamDerived(k);
{
int ret = csharp_director_typemaps.callRead(instream, InStream.getCPtr(instream).Handle, j, out outLen);
Assert(outLen, j + k);
Assert(ret, j + k);
}
{
int ret = csharp_director_typemaps.callRead(instream, global::System.IntPtr.Zero, j, out outLen);
Assert(outLen, -j - k);
Assert(ret, -j - k);
}
{
int ret = csharp_director_typemaps.callWrite(instream, InStream.getCPtr(instream).Handle, j, out outLen);
Assert(outLen, j + k);
Assert(ret, j + k);
}
{
int ret = csharp_director_typemaps.callWrite(instream, global::System.IntPtr.Zero, j, out outLen);
Assert(outLen, -j - k);
Assert(ret, -j - k);
}
}
private static void Assert(int i1, int i2) {
if (i1 != i2)
throw new Exception("assertion failure. " + i1 + " != " + i2);
}
}

View file

@ -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;
}
}
}

View file

@ -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,7 +106,17 @@ public class runme
check_equal(received, expected);
}
/* Not working on Windows okay on Linux
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")]
* Needs a SWIG code change to support this
foreach (string test_string in test_strings)
{
foreach (char expected in test_string)

View file

@ -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");

View file

@ -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");

View file

@ -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");

View 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);
}
}

View file

@ -0,0 +1,37 @@
%module (directors="1") csharp_director_typemaps
// This tests that the csout typemap is handled correctly in the director code.
// The 'out' needs stripping in some parts of the generated director code.
%feature("director") InStream;
%apply void *VOID_INT_PTR { void * }
%typemap(ctype) int* readLen, int* writeLen "/*ctype*/ int*"
%typemap(imtype) int* readLen, int* writeLen "/*imtype*/ out int"
%typemap(cstype) int* readLen "/*cstype*/ out int"
// Note for below: 'out' used in typemap comment
%typemap(cstype) int* writeLen "/*out cstype out*/ out int"
%typemap(csin) int* readLen, int* writeLen "/*csin*/ out $csinput"
%typemap(in) int* readLen, int* writeLen %{/*in*/ $1 = ($1_ltype)$input; %}
%typemap(out) int* readLen, int* writeLen %{/*out*/ $result = (void *)$1; %}
%typemap(csdirectorin) int* readLen, int* writeLen "/*csdirectorin*/ out $iminput"
%typemap(csdirectorout) int* readLen, int* writeLen "/*csdirectorout*/ $cscall"
%typemap(directorin) int* readLen, int* writeLen "/*directorin*/ $input = $1;"
%typemap(directorout) int* readLen, int* writeLen %{/*directorout*/ $result = ($1_ltype)$input; %}
%inline %{
class InStream
{
public:
virtual int Read(void* buf, int len, int* readLen) = 0;
virtual int Write(void* buf, int len, int* writeLen) = 0;
virtual ~InStream() {}
};
int callRead(InStream* stream, void* buf, int len, int* readLen) {
return stream->Read(buf, len, readLen);
}
int callWrite(InStream* stream, void* buf, int len, int* writeLen) {
return stream->Write(buf, len, writeLen);
}
%}

View file

@ -5,6 +5,7 @@
#endif
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) ConstPtrClass::getConstPtr;
%{
#include <string>
@ -174,7 +175,19 @@ public:
}
};
%}
%}
%template(MyClassT_i) MyClassT<int>;
%feature("director") ConstPtrClass;
%inline %{
class ConstPtrClass {
public:
virtual ~ConstPtrClass() {}
virtual int *const getConstPtr() = 0;
};
%}

View file

@ -0,0 +1,23 @@
%module(directors="1") director_comparison_operators
%include "std_string.i"
%feature("director");
#if !defined(SWIGLUA) && !defined(SWIGR)
%rename(EqualEqual) operator ==;
%rename(NotEqual) operator !=;
%rename(LessThanEqual) operator <=;
%rename(GreaterThanEqual) operator >=;
#endif
%inline %{
class Foo {
public:
virtual ~Foo() { }
virtual bool operator==(const Foo&) const = 0;
virtual bool operator>=(const Foo&) const = 0;
virtual bool operator<=(const Foo&) const = 0;
virtual bool operator!=(const Foo&) const = 0;
virtual std::string test(const char *foo="a=1,b=2") { return foo; }
};
%}

View file

@ -0,0 +1,35 @@
%module(directors="1") director_conversion_operators
%feature("director");
%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Bar;
%rename(toFoo) Bar::operator Foo();
%rename(toFooPtr) Bar::operator Foo *();
%rename(toFooRef) Bar::operator Foo &();
%rename(toFooPtrRef) Bar::operator Foo *&();
%rename(toOtherFoo) Bar::operator OtherFoo();
%rename(toOtherFooPtr) Bar::operator OtherFoo *();
%rename(toOtherFooRef) Bar::operator OtherFoo &();
%rename(toOtherFooPtrRef) Bar::operator OtherFoo *&();
%inline %{
struct Foo {
};
struct OtherFoo {
};
struct Bar {
Foo myFoo;
Foo *myFooPtr;
virtual ~Bar() { }
virtual operator Foo () { return Foo(); }
virtual operator Foo *() { return &myFoo; }
virtual operator Foo &() { return myFoo; }
virtual operator Foo *&() { return myFooPtr; }
virtual operator OtherFoo () = 0;
virtual operator OtherFoo *() = 0;
virtual operator OtherFoo &() = 0;
virtual operator OtherFoo *&() = 0;
};
%}

View file

@ -18,22 +18,7 @@ namespace Swig {
%include "std_string.i"
#ifdef SWIGPHP
%feature("director:except") {
if ($error == FAILURE) {
Swig::DirectorMethodException::raise("$symname");
}
}
%exception {
try { $action }
catch (Swig::DirectorException &) { SWIG_fail; }
}
#endif
#ifdef SWIGPYTHON
#if defined SWIGPHP || defined SWIGPYTHON
%feature("director:except") {
if ($error != NULL) {

View file

@ -15,7 +15,6 @@ namespace TopLevel
class FooBar {
public:
FooBar() {}
FooBar(const FooBar&) {}
virtual ~FooBar() {}
std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
@ -56,7 +55,6 @@ namespace TopLevel
class FooBar {
public:
FooBar();
FooBar(const FooBar&);
virtual ~FooBar();
std::string FooBarDo();

View file

@ -47,5 +47,14 @@ public:
virtual void notover(int *p) const {}
};
%}
class OverloadedGetSet
{
int v;
public:
OverloadedGetSet() : v(42) { }
virtual ~OverloadedGetSet() { }
virtual int rw() const { return v; }
virtual void rw(int new_v) { v = new_v; }
};
%}

View file

@ -14,11 +14,15 @@ struct OverloadDerived1 : OverloadBase {
virtual void nnn(int vvv) {}
#if defined(__SUNPRO_CC)
virtual void nnn() {}
#elif defined(SWIGPHP) // FIXME: Hack to stop director_overload2 failing for PHP8
virtual void nnn() {}
#endif
};
struct OverloadDerived2 : OverloadBase {
#if defined(__SUNPRO_CC)
virtual void nnn(int vvv) {}
#elif defined(SWIGPHP) // FIXME: Hack to stop director_overload2 failing for PHP8
virtual void nnn(int vvv) {}
#endif
virtual void nnn() {}
};

View file

@ -11,13 +11,6 @@
%newobject *::create();
#ifdef SWIGPHP
// TODO: Currently we do not track the dynamic type of returned objects
// in PHP, so we need the factory helper.
%include factory.i
%factory(Foo *Bar::create, Bar);
#endif
%rename(a) Bar::hello;
%rename(s) Foo::p;
%rename(q) Foo::r;

View file

@ -17,11 +17,7 @@
%feature("director") Foo;
%feature("director:except") {
#ifndef SWIGPHP
if ($error != NULL) {
#else
if ($error == FAILURE) {
#endif
throw Swig::DirectorMethodException();
}
}

View file

@ -43,5 +43,9 @@ struct Caller {
return *(int *)p;
}
};
struct MemberVoid {
void *memberVariable;
};
%}

View file

@ -107,6 +107,23 @@ double Atan2(double y, double x)
return 0;
}
/* Regression test for crash with empty comment: */
/**/
/**
* @brief Test variadic function
* @param ... extra args
*/
void function8(...) {
}
/**
* @brief Test unnamed argument
* @param baz Description of baz
*/
void function9(int) {
}
/**
* Comment at the end of file should be ignored.
*/

View file

@ -0,0 +1,102 @@
%module doxygen_basic_translate_style3
%include "doxygen_basic_translate.h"
%inline %{
/// \brief
/// Brief description.
///
/// The comment text.
///
/// \author Some author
///
/// \return Some number
///
/// \sa function2
int function()
{
return 0;
}
/// A test of a very very very very very very very very very very very very very very very very
/// very very very very very long comment string.
void function2()
{
}
/// A test for overloaded functions
/// This is function \b one
void function3(int a)
{
}
/// A test for overloaded functions
/// This is function \b two
void function3(int a, int b)
{
}
/// A test of some mixed tag usage
/// \if CONDITION
/// This \a code fragment shows us something \.
/// \par Minuses:
/// \arg it's senseless
/// \arg it's stupid
/// \arg it's null
///
/// \warning This may not work as expected
/// \code
/// int main() { while(true); }
///
/// int testBlankLine() {}
/// \endcode
/// \endif
void function4()
{
// Note: a comment in the above code block will not get processed
// correctly with this doxygen comment style, because
// DoxygenParser::tokenizeDoxygenComment strips out the leading
// comment characters. Whereas it works in the other doxygen
// comment styles (as shown in the other variations of
// doxygen_basic_translate), this test is modified to remove the
// comment within the code block.
}
void function5(int a)
{
}
///< This is a post comment.
/// Test for default args
/// @param a Some parameter, default is 42
void function6(int a=42)
{
}
class Shape
{
public:
typedef Shape* superType;
};
/// Test for a parameter with difficult type
/// (mostly for python)
/// @param a Very strange param
void function7(Shape::superType *a[10])
{
}
/// Multiple parameters test.
///
/// @param y Vertical coordinate.
/// @param x Horizontal coordinate.
/// @return Arc tangent of @c y/x.
double Atan2(double y, double x)
{
return 0;
}
/// Comment at the end of file should be ignored.
%}

View file

@ -0,0 +1,62 @@
%module doxygen_code_blocks
// This test is only used with Python
%inline %{
/**
* \brief Test for code blocks
*
* \code
* simple code block
* \endcode
*
* More advanced usage with C++ characters:
* \code
* std::vector<int> first; // empty vector of ints
* std::vector<int> second (4,100); // four ints with value 100
* std::vector<int> third (second.begin(),second.end()); // iterating through second
* std::vector<int> fourth (third); // a copy of third
* // the iterator constructor can also be used to construct from arrays:
* int myints[] = {16,2,77,29};
* std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
*
* std::cout << "The contents of fifth are:";
* for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
* std::cout << ' ' << *it;
* std::cout << '\n';
* \endcode
*
* A code block for C:
* \code{.c}
* printf("hello world");
* \endcode
*
* A code block for Java:
* \code{.java}
* public class HelloWorld {
* public static void main(String[] args) {
* // Prints "Hello, World" to the terminal window.
* System.out.println("Hello, World");
* }
* }
* \endcode
*
* A code block for python:
* \code{.py}
* print('hello world')
* \endcode
*
* A python doctest example:
* \code{.py}
* >>> 1 + 1
* 2
* \endcode
*/
int function()
{
return 0;
}
%}

View file

@ -91,4 +91,12 @@ void backslashC()
void cycle(int id, char *fileName)
{}
/// This doc comment ends with a quote: "and that's ok"
void doc_ends_with_quote() {}
/**
This comment contains embedded triple-quoted string:
"""How quaint"""
*/
void doc_with_triple_quotes() {}

View file

@ -36,7 +36,7 @@
* @param line line number
* @param isGetSize if set, for every object location both address and size are returned
*
* @link Connection::getId() @endlink <br>
* @link Connection::getId() @endlink<br>
*/
void getAddress(int &fileName,
int line,
@ -62,7 +62,7 @@
* used for unspecified parameters.
* <p>
*
* @link advancedWinIDEALaunching.py Python example.@endlink <br>
* @link advancedWinIDEALaunching.py Python example.@endlink<br>
*/
class CConnectionConfig
{

View file

@ -29,6 +29,7 @@ enum SomeEnum
*/
struct SomeStruct
{
int width; ///< \**immutable** image width in pixels
};
/**

View file

@ -210,7 +210,7 @@ void func05(int a)
*
* \line example
*
* \link someMember Some description follows \endlink
* \link someMember Some description follows\endlink with text after
*
* \mainpage Some title
*
@ -262,6 +262,9 @@ void func06(int a)
* \paragraph someParagraph Paragraph title
*
* \param a the first param
* \param[in] b parameter with intent(in)
* \param[out] c parameter with intent(out)
* \param[in,out] d parameter with intent(in,out)
*
* \post Some description
*
@ -273,7 +276,7 @@ void func06(int a)
*
* \property someVar
*/
void func07(int a)
void func07(int a, int b, int c, int d)
{
}

View file

@ -45,6 +45,11 @@ include $(srcdir)/../common.mk
# whatever we do here.
$(DOXYGEN_ERROR_TEST_CASES): SWIGOPT += -doxygen
# Unique module names are obtained from the .i file name (required for parallel make).
# Note: -module overrides %module in the .i file.
MODULE_OPTION=-module $*
nomodule.ctest: MODULE_OPTION =
# Portable dos2unix / todos for stripping CR
TODOS = tr -d '\r'
#TODOS = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//'
@ -55,12 +60,12 @@ STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
# Rules for the different types of tests
%.cpptest:
echo "$(ACTION)ing errors testcase $*"
-$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
-$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.ctest:
echo "$(ACTION)ing errors testcase $*"
-$(SWIGINVOKE) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
-$(SWIGINVOKE) -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
%.clean:

View file

@ -1,4 +1,4 @@
%module cpp_extra_brackets
%module xxx
// Extra brackets was segfaulting in SWIG-3.0.0
struct ABC {

View file

@ -1,4 +1,4 @@
%module cpp_extra_brackets
%module xxx
// Extra brackets was segfaulting in SWIG-3.0.0
struct ABC {

View file

@ -1,4 +1,4 @@
%module cpp_invalid_qualifiers
%module xxx
// Constructors, destructors and static methods cannot have qualifiers
struct A {

View file

@ -1,4 +1,4 @@
%module cpp_invalid_scope
%module xxx
%template(abc) SSS::AAA<int>;

View file

@ -1,4 +1,4 @@
%module namespace_template
%module xxx
namespace test {
template<typename T> T max(T a, T b) { return (a > b) ? a : b; }

View file

@ -1,4 +1,4 @@
%module cpp_nested_namespace_alias
%module xxx
// C++17 nested namespaces

View file

@ -1,4 +1,4 @@
%module cpp_recursive_typedef
%module xxx
typedef std::set<pds> pds;

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