update swig on windows
This commit is contained in:
52
winx64/bin/swigwin-4.0.0/Examples/test-suite/README
Normal file
52
winx64/bin/swigwin-4.0.0/Examples/test-suite/README
Normal file
@@ -0,0 +1,52 @@
|
||||
SWIG testsuite README file
|
||||
--------------------------
|
||||
|
||||
This testsuite is here to ensure SWIG can handle a wide range of c/c++
|
||||
syntax. The testsuite comprises many testcases in this directory. Each
|
||||
test case is tested under each of the language modules thereby
|
||||
thoroughly testing all of SWIG. It ensures that each of the language
|
||||
modules are at a similar standard.
|
||||
|
||||
Those modules that support shadow classes run the tests producing
|
||||
shadow classes to test the full language module functionality.
|
||||
|
||||
Some test cases need a runtime test. These need implementing in each
|
||||
of the language modules. The language modules look for a file in the
|
||||
language specific test-suite directory which has _runme appended after
|
||||
the testcase name. If one is found it will be run as part of the test.
|
||||
|
||||
Some language modules add to this common set of test cases for
|
||||
language specific tests. These can be found in the appropriate
|
||||
language test-suite directory. There is also a README in each of the
|
||||
language module directories.
|
||||
|
||||
For each testcase a message showing which testcase is being tested is
|
||||
displayed. Nothing else is printed unless the test fails.
|
||||
|
||||
|
||||
Some Developer Guidelines
|
||||
-------------------------
|
||||
|
||||
Note that the whole test suite need not be run each time a testcase is
|
||||
modified. An individual testcase may be run by going to the language
|
||||
module test-suite directory and using make testcasename.xxx where xxx
|
||||
is the type of test (eg cpptest). See common.mk. make -s doesn't print
|
||||
any junk on the screen and is useful for emulating the way make check
|
||||
works from the SWIG root directory.
|
||||
|
||||
If there are runtime tests needed, don't print anything unless there
|
||||
is an error in which case stderr is suggested.
|
||||
|
||||
Please set the name of the module to the same name as the testcase,
|
||||
otherwise modules will not be found.
|
||||
|
||||
There is a special directory called testdir for testcases requiring
|
||||
inputs from subdirectories or multiple directories. See the
|
||||
testdir/README file.
|
||||
|
||||
Further Documentation
|
||||
---------------------
|
||||
|
||||
There is documentation about the test-suite and how to use it in
|
||||
the SWIG documentation - Doc/Manual/Extending.html#Extending_test_suite.
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
%module abstract_access
|
||||
|
||||
%warnfilter(SWIGWARN_LANG_DIRECTOR_ABSTRACT) A;
|
||||
|
||||
%inline %{
|
||||
class A {
|
||||
public:
|
||||
virtual ~A()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
virtual int x() = 0;
|
||||
protected:
|
||||
virtual int y() = 0;
|
||||
public:
|
||||
virtual int z() = 0;
|
||||
int do_x() { return x(); }
|
||||
};
|
||||
|
||||
class B : public A {
|
||||
private:
|
||||
virtual int x() { return y(); }
|
||||
};
|
||||
|
||||
class C : public B {
|
||||
protected:
|
||||
virtual int y() { return z(); }
|
||||
};
|
||||
|
||||
class D : public C {
|
||||
private:
|
||||
virtual int z() { return 1; }
|
||||
};
|
||||
|
||||
%}
|
||||
@@ -0,0 +1,62 @@
|
||||
%module abstract_inherit
|
||||
|
||||
%warnfilter(SWIGWARN_TYPE_ABSTRACT) Spam;
|
||||
%warnfilter(SWIGWARN_TYPE_ABSTRACT) Bar;
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int blah() = 0;
|
||||
};
|
||||
|
||||
class Bar : public Foo { };
|
||||
|
||||
class Spam: public Foo {
|
||||
public:
|
||||
Spam() { }
|
||||
};
|
||||
|
||||
|
||||
template <class Type>
|
||||
class NRFilter {
|
||||
public:
|
||||
virtual ~NRFilter()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void do_filter() = 0;
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
class NRRCFilter : public NRFilter<Type>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template <class Type>
|
||||
class NRRCFilterpro : protected NRFilter<Type>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template <class Type>
|
||||
class NRRCFilterpri : private NRFilter<Type>
|
||||
{
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%template(NRFilter_i) NRFilter<int>;
|
||||
|
||||
%template(NRRCFilter_i) NRRCFilter<int>;
|
||||
|
||||
%template(NRRCFilterpro_i) NRRCFilterpro<int>;
|
||||
|
||||
%template(NRRCFilterpri_i) NRRCFilterpri<int>;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
%module abstract_inherit_ok
|
||||
|
||||
%feature("notabstract") Spam;
|
||||
%warnfilter(SWIGWARN_TYPE_ABSTRACT) Spam;
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() { }
|
||||
virtual int blah() = 0;
|
||||
};
|
||||
|
||||
class Spam: public Foo {
|
||||
public:
|
||||
Spam() { }
|
||||
#ifndef SWIG
|
||||
int blah() { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
%}
|
||||
@@ -0,0 +1,26 @@
|
||||
%module abstract_signature
|
||||
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) abstract_foo; // Ruby, wrong class name
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) abstract_bar; // Ruby, wrong class name
|
||||
|
||||
%inline %{
|
||||
class abstract_foo
|
||||
{
|
||||
public:
|
||||
abstract_foo() { };
|
||||
virtual ~abstract_foo() { };
|
||||
virtual int meth(int meth_param) = 0;
|
||||
};
|
||||
|
||||
|
||||
class abstract_bar : public abstract_foo
|
||||
{
|
||||
public:
|
||||
abstract_bar() { };
|
||||
|
||||
virtual ~abstract_bar() { };
|
||||
virtual int meth(int meth_param) = 0;
|
||||
int meth(int meth_param_1, int meth_param_2) { return 0; }
|
||||
};
|
||||
|
||||
%}
|
||||
@@ -0,0 +1,56 @@
|
||||
%module abstract_typedef
|
||||
|
||||
|
||||
%inline %{
|
||||
struct Engine
|
||||
{
|
||||
};
|
||||
|
||||
struct AbstractBaseClass
|
||||
{
|
||||
virtual ~AbstractBaseClass()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool write(Engine& archive) const = 0;
|
||||
};
|
||||
|
||||
typedef Engine PersEngine;
|
||||
typedef AbstractBaseClass PersClassBase;
|
||||
|
||||
|
||||
class A : public PersClassBase
|
||||
{
|
||||
// This works always
|
||||
// bool write(Engine& archive) const;
|
||||
|
||||
// This doesn't with Swig 1.3.17.
|
||||
// But it works fine with 1.3.16
|
||||
bool write(PersEngine& archive) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Problem related to the direct comparison of strings
|
||||
in the file allocate.cxx (line 55)
|
||||
|
||||
......
|
||||
String *local_decl = Getattr(dn,"decl");
|
||||
if (local_decl && !Strcmp(local_decl, base_decl)) {
|
||||
......
|
||||
|
||||
with the direct string comparison, no equivalent types
|
||||
are checked and the two 'write' functions appear to be
|
||||
different because
|
||||
|
||||
"q(const).f(r.bss::PersEngine)." != "q(const).f(r.bss::Engine)."
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,60 @@
|
||||
%module abstract_typedef2
|
||||
|
||||
/*
|
||||
After the fix for abstract_typedef, this simpler
|
||||
example got broken.
|
||||
*/
|
||||
|
||||
%inline %{
|
||||
|
||||
enum FieldDim {
|
||||
UnaryField,
|
||||
BinaryField
|
||||
};
|
||||
|
||||
template <FieldDim Dim>
|
||||
struct Facet;
|
||||
|
||||
|
||||
template <FieldDim Dim>
|
||||
struct Base
|
||||
{
|
||||
virtual ~Base() {}
|
||||
|
||||
typedef unsigned int size_type;
|
||||
typedef Facet<Dim>* facet_ptr;
|
||||
|
||||
// This works
|
||||
// virtual Facet<Dim>* set(size_type) = 0;
|
||||
|
||||
// This doesn't
|
||||
virtual facet_ptr set(size_type) = 0;
|
||||
};
|
||||
|
||||
|
||||
template <FieldDim Dim>
|
||||
struct Facet
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template <FieldDim Dim>
|
||||
struct A : Base<Dim>
|
||||
{
|
||||
typedef Base<Dim> base;
|
||||
typedef typename base::size_type size_type;
|
||||
|
||||
A(int a = 0)
|
||||
{
|
||||
}
|
||||
|
||||
Facet<Dim>* set(size_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
%template(Base_UF) Base<UnaryField>;
|
||||
%template(A_UF) A<UnaryField>;
|
||||
@@ -0,0 +1,69 @@
|
||||
%module(ruby_minherit="1") abstract_virtual
|
||||
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, D, Java, PHP multiple inheritance */
|
||||
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_D_MULTIPLE_INHERITANCE,
|
||||
SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
|
||||
|
||||
%inline %{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4250) // warning C4250: 'D' : inherits 'B::B::foo' via dominance
|
||||
#endif
|
||||
struct A
|
||||
{
|
||||
virtual ~A()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int foo() = 0;
|
||||
};
|
||||
|
||||
struct B : virtual A
|
||||
{
|
||||
int foo()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct C: virtual A
|
||||
{
|
||||
protected:
|
||||
C()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// This case works
|
||||
//
|
||||
struct D : B, C
|
||||
{
|
||||
D()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// This case doesn't work.
|
||||
// It seems the is_abstract function doesn't
|
||||
// navigate the entire set of base classes,
|
||||
// and therefore, it doesn't detect B::foo()
|
||||
//
|
||||
#ifdef SWIG
|
||||
// Uncommenting this line, of course, make it works
|
||||
// %feature("notabstract") E;
|
||||
#endif
|
||||
//
|
||||
struct E : C, B
|
||||
{
|
||||
E()
|
||||
{
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
51
winx64/bin/swigwin-4.0.0/Examples/test-suite/access_change.i
Normal file
51
winx64/bin/swigwin-4.0.0/Examples/test-suite/access_change.i
Normal file
@@ -0,0 +1,51 @@
|
||||
%module access_change
|
||||
|
||||
// test access changing from protected to public
|
||||
|
||||
%inline %{
|
||||
|
||||
template<typename T> class Base {
|
||||
public:
|
||||
virtual ~Base() {}
|
||||
virtual int *PublicProtectedPublic1() { return 0; }
|
||||
int *PublicProtectedPublic2() { return 0; }
|
||||
virtual int *PublicProtectedPublic3() { return 0; }
|
||||
int *PublicProtectedPublic4() { return 0; }
|
||||
protected:
|
||||
virtual int * WasProtected1() { return 0; }
|
||||
int * WasProtected2() { return 0; }
|
||||
virtual int * WasProtected3() { return 0; }
|
||||
int * WasProtected4() { return 0; }
|
||||
};
|
||||
|
||||
template<typename T> class Derived : public Base<T> {
|
||||
public:
|
||||
int * WasProtected1() { return 0; }
|
||||
int * WasProtected2() { return 0; }
|
||||
using Base<T>::WasProtected3;
|
||||
using Base<T>::WasProtected4;
|
||||
protected:
|
||||
virtual int *PublicProtectedPublic1() { return 0; }
|
||||
int *PublicProtectedPublic2() { return 0; }
|
||||
using Base<T>::PublicProtectedPublic3;
|
||||
using Base<T>::PublicProtectedPublic4;
|
||||
};
|
||||
|
||||
template<typename T> class Bottom : public Derived<T> {
|
||||
public:
|
||||
int * WasProtected1() { return 0; }
|
||||
int * WasProtected2() { return 0; }
|
||||
using Base<T>::WasProtected3;
|
||||
using Base<T>::WasProtected4;
|
||||
int *PublicProtectedPublic1() { return 0; }
|
||||
int *PublicProtectedPublic2() { return 0; }
|
||||
int *PublicProtectedPublic3() { return 0; }
|
||||
int *PublicProtectedPublic4() { return 0; }
|
||||
};
|
||||
%}
|
||||
|
||||
%template(BaseInt) Base<int>;
|
||||
%template(DerivedInt) Derived<int>;
|
||||
%template(BottomInt) Bottom<int>;
|
||||
|
||||
|
||||
20
winx64/bin/swigwin-4.0.0/Examples/test-suite/add_link.i
Normal file
20
winx64/bin/swigwin-4.0.0/Examples/test-suite/add_link.i
Normal file
@@ -0,0 +1,20 @@
|
||||
%module add_link
|
||||
|
||||
%extend Foo {
|
||||
Foo *blah() {
|
||||
return new Foo();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
Foo() { };
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
37
winx64/bin/swigwin-4.0.0/Examples/test-suite/aggregate.i
Normal file
37
winx64/bin/swigwin-4.0.0/Examples/test-suite/aggregate.i
Normal file
@@ -0,0 +1,37 @@
|
||||
/* This file tests a few new contract features.
|
||||
First it checks to make sure the constant aggregation macro
|
||||
%aggregate_check() works. This is defined in swig.swg.
|
||||
|
||||
Next, it checks to make sure a simple contract works.
|
||||
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
|
||||
|
||||
Note: It is used like this:
|
||||
SWIG_contract_assert(x == 1, "Some kind of error message");
|
||||
|
||||
Note: Contracts are still experimental. The runtime interface may
|
||||
change in future versions.
|
||||
*/
|
||||
|
||||
%module aggregate
|
||||
|
||||
%include <exception.i>
|
||||
%aggregate_check(int, check_direction, UP, DOWN, LEFT, RIGHT)
|
||||
|
||||
%contract move(int x) {
|
||||
require:
|
||||
check_direction(x);
|
||||
}
|
||||
|
||||
%inline %{
|
||||
#define UP 1
|
||||
#define DOWN 2
|
||||
#define LEFT 3
|
||||
#define RIGHT 4
|
||||
|
||||
int move(int direction) {
|
||||
return direction;
|
||||
}
|
||||
%}
|
||||
@@ -0,0 +1,126 @@
|
||||
#######################################################################
|
||||
# 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
|
||||
73
winx64/bin/swigwin-4.0.0/Examples/test-suite/allowexcept.i
Normal file
73
winx64/bin/swigwin-4.0.0/Examples/test-suite/allowexcept.i
Normal file
@@ -0,0 +1,73 @@
|
||||
// Test allowexcept feature
|
||||
|
||||
%module allowexcept
|
||||
|
||||
// First make sure %exception is not used by default for variable wrappers
|
||||
|
||||
%nodefaultctor;
|
||||
%nodefaultdtor;
|
||||
%exception {
|
||||
This will not compile
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct UVW {};
|
||||
UVW uvw_global_variable;
|
||||
struct Bar {
|
||||
UVW member_variable;
|
||||
static UVW static_member_variable;
|
||||
};
|
||||
UVW Bar::static_member_variable;
|
||||
%}
|
||||
|
||||
|
||||
// Now test the allowexcept feature by making the usual $action uncompilable and ensuring the %exception is picked up
|
||||
|
||||
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() {}
|
||||
private:
|
||||
XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
|
||||
XYZ* operator&(); // prevent dereferencing used in normally generated get method
|
||||
};
|
||||
%}
|
||||
#endif
|
||||
#if defined(SWIGUTL)
|
||||
%exception {
|
||||
/*
|
||||
$action
|
||||
*/
|
||||
SWIG_fail;
|
||||
}
|
||||
#else
|
||||
%exception {
|
||||
/*
|
||||
$action
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
%allowexception;
|
||||
|
||||
%inline %{
|
||||
XYZ global_variable;
|
||||
struct Foo {
|
||||
XYZ member_variable;
|
||||
static XYZ static_member_variable;
|
||||
};
|
||||
XYZ Foo::static_member_variable;
|
||||
%}
|
||||
|
||||
87
winx64/bin/swigwin-4.0.0/Examples/test-suite/allprotected.i
Normal file
87
winx64/bin/swigwin-4.0.0/Examples/test-suite/allprotected.i
Normal file
@@ -0,0 +1,87 @@
|
||||
// Tests for the allprotected option
|
||||
|
||||
%module(directors="1", allprotected="1") allprotected
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
|
||||
#ifdef SWIGSCILAB
|
||||
%rename(ProcBase) ProtectedBase;
|
||||
%rename(PubBase) PublicBase;
|
||||
#endif
|
||||
|
||||
%feature("director") PublicBase;
|
||||
%feature("director") ProtectedBase;
|
||||
|
||||
// protected types not supported (ProtectedEnum, IntegerType). Make sure they can be ignored.
|
||||
%ignore ProtectedBase::protectedenum;
|
||||
%ignore ProtectedBase::typedefs;
|
||||
|
||||
%inline %{
|
||||
class Klass {
|
||||
std::string name;
|
||||
public:
|
||||
Klass(const std::string& n) : name(n) {}
|
||||
std::string getName() { return name; }
|
||||
};
|
||||
|
||||
class PublicBase {
|
||||
std::string str;
|
||||
public:
|
||||
enum AnEnum { EnumVal1, EnumVal2 };
|
||||
public:
|
||||
PublicBase(const char* s): str(s), instanceMemberVariable(0), anEnum(EnumVal1), stringMember(0) {}
|
||||
virtual ~PublicBase() { }
|
||||
virtual std::string virtualMethod() const { return "PublicBase"; }
|
||||
Klass instanceMethod(Klass k) const { return k; }
|
||||
Klass *instanceOverloaded(Klass *k) const { return k; }
|
||||
Klass *instanceOverloaded(Klass *k, std::string name) const { return new Klass(name); }
|
||||
static Klass staticMethod(Klass k) { return k; }
|
||||
static Klass *staticOverloaded(Klass *k) { return k; }
|
||||
static Klass *staticOverloaded(Klass *k, std::string name) { return new Klass(name); }
|
||||
int instanceMemberVariable;
|
||||
static int staticMemberVariable;
|
||||
static const int staticConstMemberVariable = 20;
|
||||
AnEnum anEnum;
|
||||
char *stringMember;
|
||||
};
|
||||
int PublicBase::staticMemberVariable = 10;
|
||||
|
||||
class ProtectedBase {
|
||||
std::string str;
|
||||
public:
|
||||
enum AnEnum { EnumVal1, EnumVal2 };
|
||||
std::string getName() { return str; }
|
||||
protected:
|
||||
ProtectedBase(const char* s): str(s), instanceMemberVariable(0), anEnum(EnumVal1), stringMember(0), protectedenum(ProtEnumVal1) {}
|
||||
virtual ~ProtectedBase() { }
|
||||
virtual std::string virtualMethod() const { return "ProtectedBase"; }
|
||||
Klass instanceMethod(Klass k) const { return k; }
|
||||
Klass *instanceOverloaded(Klass *k) const { return k; }
|
||||
Klass *instanceOverloaded(Klass *k, std::string name) const { return new Klass(name); }
|
||||
static Klass staticMethod(Klass k) { return k; }
|
||||
static Klass *staticOverloaded(Klass *k) { return k; }
|
||||
static Klass *staticOverloaded(Klass *k, std::string name) { return new Klass(name); }
|
||||
int instanceMemberVariable;
|
||||
static int staticMemberVariable;
|
||||
static const int staticConstMemberVariable = 20;
|
||||
AnEnum anEnum;
|
||||
char *stringMember;
|
||||
|
||||
// unsupported: types defined with protected access and thus methods/variables which use them
|
||||
enum ProtectedEnum { ProtEnumVal1, ProtEnumVal2 };
|
||||
typedef int IntegerType;
|
||||
ProtectedEnum protectedenum;
|
||||
IntegerType typedefs(IntegerType it) { return it; }
|
||||
};
|
||||
int ProtectedBase::staticMemberVariable = 10;
|
||||
|
||||
class ProtectedDerived : public ProtectedBase {
|
||||
public:
|
||||
ProtectedDerived(const char *s) : ProtectedBase(s) {}
|
||||
};
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Tests directors and allprotected option when the class does not have the "director" feature
|
||||
// Was previously crashing and/or generating uncompilable code.
|
||||
|
||||
%module(directors="1", allprotected="1") allprotected_not
|
||||
|
||||
//%feature("director") AllProtectedNot;
|
||||
%feature("director") AllProtectedNot::ProtectedMethod;
|
||||
%feature("director") AllProtectedNot::StaticNonVirtualProtectedMethod;
|
||||
%feature("director") AllProtectedNot::NonVirtualProtectedMethod;
|
||||
%feature("director") AllProtectedNot::ProtectedVariable;
|
||||
%feature("director") AllProtectedNot::StaticProtectedVariable;
|
||||
%feature("director") AllProtectedNot::PublicMethod;
|
||||
|
||||
%inline %{
|
||||
class AllProtectedNot {
|
||||
public:
|
||||
virtual ~AllProtectedNot() {}
|
||||
virtual void PublicMethod() {}
|
||||
protected:
|
||||
virtual void ProtectedMethod() {}
|
||||
static void StaticNonVirtualProtectedMethod() {}
|
||||
void NonVirtualProtectedMethod() {}
|
||||
int ProtectedVariable;
|
||||
static int StaticProtectedVariable;
|
||||
};
|
||||
int AllProtectedNot::StaticProtectedVariable = 0;
|
||||
%}
|
||||
@@ -0,0 +1,17 @@
|
||||
%module anonymous_bitfield
|
||||
|
||||
%inline %{
|
||||
|
||||
struct Foo {
|
||||
int x : 4;
|
||||
int y : 4;
|
||||
int : 2;
|
||||
unsigned int f : 1;
|
||||
unsigned int : 5;
|
||||
int z : 15;
|
||||
unsigned int : 8+6;
|
||||
unsigned seq : (sizeof(unsigned)*8 - 6);
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Test %apply for char */
|
||||
|
||||
%module(directors="1") apply_signed_char
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest;
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(DirTest) DirectorTest;
|
||||
#endif
|
||||
|
||||
%apply signed char {char, const char};
|
||||
%apply const signed char & {const char &};
|
||||
|
||||
%inline %{
|
||||
char CharValFunction(char number) { return number; }
|
||||
const char CCharValFunction(const char number) { return number; }
|
||||
const char & CCharRefFunction(const char & number) { return number; }
|
||||
char globalchar = -109;
|
||||
const char globalconstchar = -110;
|
||||
%}
|
||||
|
||||
// Director test
|
||||
%feature("director");
|
||||
|
||||
%inline %{
|
||||
struct DirectorTest {
|
||||
|
||||
DirectorTest() : memberchar(-111), memberconstchar(-112) {}
|
||||
|
||||
virtual char CharValFunction(char number) { return number; }
|
||||
virtual const char CCharValFunction(const char number) { return number; }
|
||||
virtual const char & CCharRefFunction(const char & number) { return number; }
|
||||
|
||||
char memberchar;
|
||||
const char memberconstchar;
|
||||
|
||||
virtual ~DirectorTest() {}
|
||||
private:
|
||||
DirectorTest& operator=(const DirectorTest &);
|
||||
};
|
||||
%}
|
||||
87
winx64/bin/swigwin-4.0.0/Examples/test-suite/apply_strings.i
Normal file
87
winx64/bin/swigwin-4.0.0/Examples/test-suite/apply_strings.i
Normal file
@@ -0,0 +1,87 @@
|
||||
/* Test %apply for char *, signed char *, unsigned char *
|
||||
This won't work in all situations, so does not necessarily have to be implemented. See
|
||||
http://groups.google.com.ai/group/comp.lang.c++.moderated/browse_thread/thread/ad5873ce25d49324/0ae94552452366be?lnk=raot */
|
||||
%module(directors="1") apply_strings
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) DigitsGlobalB;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) DigitsGlobalC;
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(TNum) TNumber;
|
||||
%rename(DirTest) DirectorTest;
|
||||
#endif
|
||||
|
||||
%apply char * {UCharPtr};
|
||||
%apply char * {SCharPtr};
|
||||
%apply const char * {CUCharPtr};
|
||||
%apply const char * {CSCharPtr};
|
||||
|
||||
%inline %{
|
||||
typedef unsigned char* UCharPtr;
|
||||
typedef signed char* SCharPtr;
|
||||
typedef const unsigned char* CUCharPtr;
|
||||
typedef const signed char* CSCharPtr;
|
||||
|
||||
UCharPtr UCharFunction(UCharPtr str) { return str; }
|
||||
SCharPtr SCharFunction(SCharPtr str) { return str; }
|
||||
CUCharPtr CUCharFunction(CUCharPtr str) { return str; }
|
||||
CSCharPtr CSCharFunction(CSCharPtr str) { return str; }
|
||||
%}
|
||||
|
||||
%typemap(freearg) SWIGTYPE * ""
|
||||
%apply SWIGTYPE* {CharPtr};
|
||||
%apply SWIGTYPE* {CCharPtr};
|
||||
|
||||
%inline %{
|
||||
typedef char* CharPtr;
|
||||
typedef const char* CCharPtr;
|
||||
|
||||
CharPtr CharFunction(CharPtr buffer) { return buffer; }
|
||||
CCharPtr CCharFunction(CCharPtr buffer) { return buffer; }
|
||||
%}
|
||||
|
||||
// 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 *}
|
||||
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
typedef unsigned char TAscii;
|
||||
typedef struct {
|
||||
TAscii DigitsMemberA[20];
|
||||
TAscii *DigitsMemberB;
|
||||
} TNumber;
|
||||
|
||||
TAscii DigitsGlobalA[20];
|
||||
TAscii DigitsGlobalB[] = {(unsigned char)'A', (unsigned char)'B', 0};
|
||||
TAscii *DigitsGlobalC;
|
||||
|
||||
%}
|
||||
|
||||
// Director test
|
||||
%feature("director");
|
||||
|
||||
#if defined(SWIGGO)
|
||||
%typemap(godirectorout) CharPtr, CCharPtr ""
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
struct DirectorTest {
|
||||
virtual UCharPtr UCharFunction(UCharPtr str) { return str; }
|
||||
virtual SCharPtr SCharFunction(SCharPtr str) { return str; }
|
||||
virtual CUCharPtr CUCharFunction(CUCharPtr str) { return str; }
|
||||
virtual CSCharPtr CSCharFunction(CSCharPtr str) { return str; }
|
||||
virtual CharPtr CharFunction(CharPtr buffer) { return buffer; }
|
||||
virtual CCharPtr CCharFunction(CCharPtr buffer) { return buffer; }
|
||||
virtual ~DirectorTest() {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
23
winx64/bin/swigwin-4.0.0/Examples/test-suite/argcargvtest.i
Normal file
23
winx64/bin/swigwin-4.0.0/Examples/test-suite/argcargvtest.i
Normal file
@@ -0,0 +1,23 @@
|
||||
%module argcargvtest
|
||||
|
||||
%include <argcargv.i>
|
||||
|
||||
%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
|
||||
|
||||
%inline %{
|
||||
|
||||
int mainc(size_t argc, const char **argv)
|
||||
{
|
||||
return (int)argc;
|
||||
}
|
||||
|
||||
const char* mainv(size_t argc, const char **argv, int idx)
|
||||
{
|
||||
return argv[idx];
|
||||
}
|
||||
|
||||
void initializeApp(size_t argc, const char **argv, bool setPGid = true, bool isMakeline = false)
|
||||
{
|
||||
}
|
||||
|
||||
%}
|
||||
37
winx64/bin/swigwin-4.0.0/Examples/test-suite/argout.i
Normal file
37
winx64/bin/swigwin-4.0.0/Examples/test-suite/argout.i
Normal file
@@ -0,0 +1,37 @@
|
||||
/* This interface file checks how well SWIG handles passing data back
|
||||
through arguments WITHOUT returning it separately; for the cases where
|
||||
maybe multiple values are passed by reference and all want changing */
|
||||
|
||||
%module argout
|
||||
|
||||
%include cpointer.i
|
||||
%pointer_functions(int,intp);
|
||||
|
||||
%inline %{
|
||||
// returns old value
|
||||
int incp(int *value) {
|
||||
return (*value)++;
|
||||
}
|
||||
|
||||
// returns old value
|
||||
int incr(int &value) {
|
||||
return value++;
|
||||
}
|
||||
|
||||
typedef int & IntRef;
|
||||
// returns old value
|
||||
int inctr(IntRef value) {
|
||||
return value++;
|
||||
}
|
||||
|
||||
// example of the old DB login type routines where you keep
|
||||
// a void* which it points to its opaque struct when you login
|
||||
// So login function takes a void**
|
||||
void voidhandle(void** handle) {
|
||||
*handle=(void*)"Here it is";
|
||||
}
|
||||
char * handle(void* handle) {
|
||||
return (char *)handle;
|
||||
}
|
||||
|
||||
%}
|
||||
78
winx64/bin/swigwin-4.0.0/Examples/test-suite/array_member.i
Normal file
78
winx64/bin/swigwin-4.0.0/Examples/test-suite/array_member.i
Normal file
@@ -0,0 +1,78 @@
|
||||
%module array_member
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(RayPkt) RayPacketData;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
typedef struct Foo {
|
||||
char text[8];
|
||||
int data[8];
|
||||
} Foo;
|
||||
|
||||
int global_data[8] = { 0,1,2,3,4,5,6,7 };
|
||||
|
||||
void set_value(int *x, int i, int v) {
|
||||
x[i] = v;
|
||||
}
|
||||
|
||||
int get_value(int *x, int i) {
|
||||
return x[i];
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
%inline
|
||||
{
|
||||
|
||||
struct Material
|
||||
{
|
||||
};
|
||||
|
||||
class RayPacketData {
|
||||
public:
|
||||
enum {
|
||||
Size = 32
|
||||
};
|
||||
|
||||
const Material * chitMat[Size];
|
||||
Material hitMat_val[Size];
|
||||
Material *hitMat[Size];
|
||||
|
||||
const Material * chitMat2[Size][Size];
|
||||
Material hitMat_val2[Size][Size];
|
||||
Material *hitMat2[Size][Size];
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
%inline %{
|
||||
#define BUFF_LEN 12
|
||||
|
||||
typedef unsigned char BUFF[BUFF_LEN];
|
||||
|
||||
typedef BUFF MY_BUFF;
|
||||
|
||||
typedef struct _m {
|
||||
int i;
|
||||
MY_BUFF x;
|
||||
} MyBuff;
|
||||
|
||||
|
||||
typedef char SBUFF[BUFF_LEN];
|
||||
typedef SBUFF MY_SBUFF;
|
||||
typedef struct _sm {
|
||||
int i;
|
||||
MY_SBUFF x;
|
||||
} MySBuff;
|
||||
|
||||
%}
|
||||
@@ -0,0 +1,49 @@
|
||||
%module array_typedef_memberin
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(ExDetail) ExampleDetail;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4351) // new behavior: elements of array 'xyz' will be default initialized
|
||||
#endif
|
||||
|
||||
typedef short Eight[8];
|
||||
typedef const short ConstEight[8];
|
||||
namespace ArrayExample
|
||||
{
|
||||
class ExampleDetail
|
||||
{
|
||||
public:
|
||||
Eight node_list;
|
||||
const Eight node_list2;
|
||||
ConstEight node_list3;
|
||||
|
||||
void fn1(Eight a) {}
|
||||
void fn2(const Eight a) {}
|
||||
void fn3(ConstEight a) {}
|
||||
|
||||
void fn4(Eight* a) {}
|
||||
void fn5(ConstEight* a) {}
|
||||
void fn6(const ConstEight* a) {}
|
||||
|
||||
void fn7(Eight*& a) {}
|
||||
void fn8(ConstEight*& a) {}
|
||||
void fn9(const ConstEight*& a) {}
|
||||
|
||||
ExampleDetail() : node_list(), node_list2(), node_list3() {}
|
||||
};
|
||||
}
|
||||
|
||||
typedef int Four[4];
|
||||
typedef const int ConstFour[4];
|
||||
|
||||
void test_1(int (*v)[4]) {}
|
||||
void test_2(Four *v) {}
|
||||
void test_3(const Four *v) {}
|
||||
void test_4(ConstFour *v) {}
|
||||
void test_5(const int (*v)[4]) {}
|
||||
void test_3r(const Four *&v) {}
|
||||
void test_4r(ConstFour *&v) {}
|
||||
%}
|
||||
14
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrayref.i
Normal file
14
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrayref.i
Normal file
@@ -0,0 +1,14 @@
|
||||
// A function that passes arrays by reference
|
||||
|
||||
%module arrayref
|
||||
|
||||
%inline %{
|
||||
|
||||
void foo(const int (&x)[10]) {
|
||||
}
|
||||
|
||||
void bar(int (&x)[10]) {
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
76
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrays.i
Normal file
76
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrays.i
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
This test case tests that various types of arrays are working.
|
||||
*/
|
||||
|
||||
%module arrays
|
||||
%{
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(ArrSt) ArrayStruct;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
#define ARRAY_LEN 2
|
||||
|
||||
typedef enum {One, Two, Three, Four, Five} finger;
|
||||
|
||||
typedef struct {
|
||||
double double_field;
|
||||
} SimpleStruct;
|
||||
|
||||
typedef struct {
|
||||
char array_c [ARRAY_LEN];
|
||||
signed char array_sc[ARRAY_LEN];
|
||||
unsigned char array_uc[ARRAY_LEN];
|
||||
short array_s [ARRAY_LEN];
|
||||
unsigned short array_us[ARRAY_LEN];
|
||||
int array_i [ARRAY_LEN];
|
||||
unsigned int array_ui[ARRAY_LEN];
|
||||
long array_l [ARRAY_LEN];
|
||||
unsigned long array_ul[ARRAY_LEN];
|
||||
long long array_ll[ARRAY_LEN];
|
||||
float array_f [ARRAY_LEN];
|
||||
double array_d [ARRAY_LEN];
|
||||
SimpleStruct array_struct[ARRAY_LEN];
|
||||
SimpleStruct* array_structpointers[ARRAY_LEN];
|
||||
int* array_ipointers [ARRAY_LEN];
|
||||
finger array_enum[ARRAY_LEN];
|
||||
finger* array_enumpointers[ARRAY_LEN];
|
||||
const int array_const_i[ARRAY_LEN];
|
||||
} ArrayStruct;
|
||||
|
||||
void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN]) {}
|
||||
|
||||
/* Pointer helper functions used in the Java run test */
|
||||
int* newintpointer() {
|
||||
return (int*)malloc(sizeof(int));
|
||||
}
|
||||
void setintfrompointer(int* intptr, int value) {
|
||||
*intptr = value;
|
||||
}
|
||||
int getintfrompointer(int* intptr) {
|
||||
return *intptr;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
// This tests wrapping of function that involves pointer to array
|
||||
|
||||
|
||||
%inline %{
|
||||
void array_pointer_func(int (*x)[10]) {}
|
||||
%}
|
||||
|
||||
|
||||
%inline %{
|
||||
typedef float FLOAT;
|
||||
|
||||
typedef FLOAT cartPosition_t[3];
|
||||
|
||||
typedef struct {
|
||||
cartPosition_t p;
|
||||
} CartPoseData_t;
|
||||
|
||||
%}
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
%module arrays_dimensionless
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) globalints; /* Unable to set variable of type int [] */
|
||||
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) ints; /* Unable to set variable of type int [] */
|
||||
|
||||
%inline %{
|
||||
|
||||
int globalints[] = {100, 200, 300};
|
||||
const int constglobalints[] = {400, 500, 600};
|
||||
|
||||
struct Bar {
|
||||
static int ints[];
|
||||
};
|
||||
int Bar::ints[] = {700, 800, 900};
|
||||
|
||||
double arr_bool(bool array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]=!array[i]; } return sum; }
|
||||
double arr_char(char array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_schar(signed char array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_uchar(unsigned char array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_short(short array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_ushort(unsigned short array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_int(int array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_uint(unsigned int array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_long(long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_ulong(unsigned long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_ll(long long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_ull(unsigned long long array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_float(float array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
double arr_double(double array[], int length) { double sum=0.0; int i=0; for(; i<length; i++) { sum += array[i]; array[i]*=2; } return sum; }
|
||||
|
||||
%}
|
||||
|
||||
%apply SWIGTYPE[] {
|
||||
bool *,
|
||||
char *,
|
||||
signed char *,
|
||||
unsigned char *,
|
||||
short *,
|
||||
unsigned short *,
|
||||
int *,
|
||||
unsigned int *,
|
||||
long *,
|
||||
unsigned long *,
|
||||
long *,
|
||||
unsigned long long *,
|
||||
float *,
|
||||
double *
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
double ptr_bool(bool *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_char(char *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_schar(signed char *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_uchar(unsigned char *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_short(short *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_ushort(unsigned short *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_int(int *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_uint(unsigned int *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_long(long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_ulong(unsigned long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_ll(long long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_ull(unsigned long long *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_float(float *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
double ptr_double(double *array, int length) { double sum=0.0; int i=0; for(; i<length; i++) sum += array[i]; return sum; }
|
||||
|
||||
%}
|
||||
|
||||
93
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrays_global.i
Normal file
93
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrays_global.i
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This test case tests that various types of arrays are working.
|
||||
*/
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK,SWIGWARN_TYPEMAP_VARIN_UNDEF);
|
||||
|
||||
%module arrays_global
|
||||
|
||||
%inline %{
|
||||
#define ARRAY_LEN 2
|
||||
|
||||
typedef enum {One, Two, Three, Four, Five} finger;
|
||||
|
||||
typedef struct {
|
||||
double double_field;
|
||||
} SimpleStruct;
|
||||
|
||||
char array_c [ARRAY_LEN];
|
||||
signed char array_sc[ARRAY_LEN];
|
||||
unsigned char array_uc[ARRAY_LEN];
|
||||
short array_s [ARRAY_LEN];
|
||||
unsigned short array_us[ARRAY_LEN];
|
||||
int array_i [ARRAY_LEN];
|
||||
unsigned int array_ui[ARRAY_LEN];
|
||||
long array_l [ARRAY_LEN];
|
||||
unsigned long array_ul[ARRAY_LEN];
|
||||
long long array_ll[ARRAY_LEN];
|
||||
float array_f [ARRAY_LEN];
|
||||
double array_d [ARRAY_LEN];
|
||||
SimpleStruct array_struct[ARRAY_LEN];
|
||||
SimpleStruct* array_structpointers[ARRAY_LEN];
|
||||
int* array_ipointers [ARRAY_LEN];
|
||||
finger array_enum[ARRAY_LEN];
|
||||
finger* array_enumpointers[ARRAY_LEN];
|
||||
const int array_const_i[ARRAY_LEN] = {10, 20};
|
||||
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
const char BeginString_FIX44a[8] = "FIX.a.a";
|
||||
char BeginString_FIX44b[8] = "FIX.b.b";
|
||||
|
||||
const char BeginString_FIX44c[] = "FIX.c.c";
|
||||
char BeginString_FIX44d[] = "FIX.d.d";
|
||||
|
||||
const char* BeginString_FIX44e = "FIX.e.e";
|
||||
const char* const BeginString_FIX44f = "FIX.f.f";
|
||||
|
||||
typedef char name[8];
|
||||
typedef char namea[];
|
||||
|
||||
char* test_a(char hello[8],
|
||||
char hi[],
|
||||
const char chello[8],
|
||||
const char chi[]) {
|
||||
return hi;
|
||||
}
|
||||
|
||||
char* test_b(name a, const namea b) {
|
||||
return a;
|
||||
}
|
||||
|
||||
int test_a(int a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
int test_b(int a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
%inline
|
||||
{
|
||||
|
||||
struct Material
|
||||
{
|
||||
};
|
||||
|
||||
enum {
|
||||
Size = 32
|
||||
};
|
||||
|
||||
const Material * chitMat[Size];
|
||||
Material hitMat_val[Size];
|
||||
Material *hitMat[Size];
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Two dimension arrays
|
||||
*/
|
||||
|
||||
%module arrays_global_twodim
|
||||
|
||||
%inline %{
|
||||
#define ARRAY_LEN_X 2
|
||||
#define ARRAY_LEN_Y 4
|
||||
|
||||
typedef enum {One, Two, Three, Four, Five} finger;
|
||||
|
||||
typedef struct {
|
||||
double double_field;
|
||||
} SimpleStruct;
|
||||
|
||||
char array_c [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
signed char array_sc[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
unsigned char array_uc[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
short array_s [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
int array_i [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
unsigned int array_ui[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
long array_l [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
unsigned long array_ul[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
long long array_ll[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
float array_f [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
double array_d [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
SimpleStruct* array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
int* array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
finger array_enum[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
finger* array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
|
||||
const int array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} };
|
||||
|
||||
void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {}
|
||||
|
||||
int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
|
||||
return array[x][y];
|
||||
}
|
||||
%}
|
||||
|
||||
#ifdef __cplusplus
|
||||
%inline
|
||||
{
|
||||
|
||||
struct Material
|
||||
{
|
||||
};
|
||||
|
||||
enum {
|
||||
Size = 32
|
||||
};
|
||||
|
||||
const Material * chitMat[Size][Size];
|
||||
Material hitMat_val[Size][Size];
|
||||
Material *hitMat[Size][Size];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
19
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrays_scope.i
Normal file
19
winx64/bin/swigwin-4.0.0/Examples/test-suite/arrays_scope.i
Normal file
@@ -0,0 +1,19 @@
|
||||
%module arrays_scope
|
||||
|
||||
%inline %{
|
||||
|
||||
enum { ASIZE = 256 };
|
||||
namespace foo {
|
||||
enum { BBSIZE = 512 };
|
||||
class Bar {
|
||||
public:
|
||||
enum { CCSIZE = 768 };
|
||||
int adata[ASIZE];
|
||||
int bdata[BBSIZE];
|
||||
int cdata[CCSIZE];
|
||||
void blah(int x[ASIZE], int y[BBSIZE], int z[CCSIZE]) { };
|
||||
};
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
185
winx64/bin/swigwin-4.0.0/Examples/test-suite/autodoc.i
Normal file
185
winx64/bin/swigwin-4.0.0/Examples/test-suite/autodoc.i
Normal file
@@ -0,0 +1,185 @@
|
||||
%module(docstring="hello.") autodoc
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) inout;
|
||||
|
||||
%feature("autodoc");
|
||||
|
||||
// special typemap and its docs
|
||||
%typemap(in) (int c, int d) "$1 = 0; $2 = 0;";
|
||||
%typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
|
||||
|
||||
// testing for different documentation levels
|
||||
%feature("autodoc","0") A::func0; // names
|
||||
%feature("autodoc","1") A::func1; // names + types
|
||||
%feature("autodoc","2") A::func2; // extended
|
||||
%feature("autodoc","3") A::func3; // extended + types
|
||||
|
||||
%feature("autodoc","0") A::func0default; // names
|
||||
%feature("autodoc","1") A::func1default; // names + types
|
||||
%feature("autodoc","2") A::func2default; // extended
|
||||
%feature("autodoc","3") A::func3default; // extended + types
|
||||
|
||||
%feature("autodoc","0") A::func0static; // names
|
||||
%feature("autodoc","1") A::func1static; // names + types
|
||||
%feature("autodoc","2") A::func2static; // extended
|
||||
%feature("autodoc","3") A::func3static; // extended + types
|
||||
|
||||
%feature("autodoc","0") A::variable_a; // names
|
||||
%feature("autodoc","1") A::variable_b; // names + types
|
||||
%feature("autodoc","2") A::variable_c; // extended
|
||||
%feature("autodoc","3") A::variable_d; // extended + types
|
||||
|
||||
%feature("autodoc","just a string.") A::funk; // names
|
||||
|
||||
%inline {
|
||||
|
||||
enum Hola {
|
||||
hi, hello
|
||||
};
|
||||
|
||||
struct A {
|
||||
A(int a, short b, Hola h) {}
|
||||
int funk(int a) { return a; }
|
||||
|
||||
int func0(short, int c, int d) { return c; }
|
||||
int func1(short, int c, int d) { return c; }
|
||||
int func2(short, int c, int d) { return c; }
|
||||
int func3(short, int c, int d) { return c; }
|
||||
|
||||
int func0default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
int func1default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
int func2default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
int func3default(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
|
||||
static int func0static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
static int func1static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
static int func2static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
static int func3static(A *e, short, int c, int d, double f = 2) { return 0; }
|
||||
|
||||
int variable_a;
|
||||
int variable_b;
|
||||
int variable_c;
|
||||
int variable_d;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// deleting typemaps and docs
|
||||
%typemap(in) (int c, int d) ;
|
||||
%typemap(doc) (int c, int d);
|
||||
|
||||
// docs for some parameters
|
||||
%typemap(doc) int a "a: special comment for parameter a";
|
||||
%typemap(doc) int b "b: another special comment for parameter b";
|
||||
|
||||
%feature("autodoc","0") C::C(int a, int b, Hola h); // names
|
||||
%feature("autodoc","1") D::D(int a, int b, Hola h); // names + types
|
||||
%feature("autodoc","2") E::E(int a, int b, Hola h); // extended
|
||||
%feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types
|
||||
%feature("autodoc","0") C::~C(); // names
|
||||
%feature("autodoc","1") D::~D(); // names + types
|
||||
%feature("autodoc","2") E::~E(); // extended
|
||||
%feature("autodoc","3") F::~F(); // extended + types
|
||||
|
||||
%inline {
|
||||
|
||||
struct B {
|
||||
B(int a, int b, Hola h) {}
|
||||
int funk(int c, int d) { return c; }
|
||||
};
|
||||
|
||||
struct C {
|
||||
C(int a, int b, Hola h) {}
|
||||
};
|
||||
struct D {
|
||||
D(int a, int b, Hola h) {}
|
||||
};
|
||||
struct E {
|
||||
E(int a, int b, Hola h) {}
|
||||
};
|
||||
struct F {
|
||||
F(int a, int b, Hola h) {}
|
||||
};
|
||||
|
||||
int funk(A *e, short, int c, int d) { return c; }
|
||||
int funkdefaults(A *e, short, int c, int d, double f = 2) { return c; }
|
||||
}
|
||||
|
||||
%include <typemaps.i>
|
||||
%inline %{
|
||||
int func_input(int *INPUT) {
|
||||
return 1;
|
||||
}
|
||||
int func_output(int *OUTPUT) {
|
||||
*OUTPUT = 2;
|
||||
return 1;
|
||||
}
|
||||
int func_inout(int *INOUT) {
|
||||
*INOUT += 1;
|
||||
return 1;
|
||||
}
|
||||
%}
|
||||
|
||||
%callback("%(uppercase)s_CALLBACK") func_cb;
|
||||
|
||||
%inline {
|
||||
int func_cb(int c, int d) { return c; }
|
||||
}
|
||||
|
||||
// Bug 3310528
|
||||
%feature("autodoc","1") banana; // names + types
|
||||
%inline %{
|
||||
typedef struct tagS {
|
||||
int a;
|
||||
char b;
|
||||
} S;
|
||||
|
||||
typedef int Integer;
|
||||
|
||||
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
||||
%}
|
||||
|
||||
// Check docs for a template type
|
||||
%inline %{
|
||||
template<typename X> struct T {
|
||||
T inout(T t) { return t; }
|
||||
};
|
||||
%}
|
||||
%template(TInteger) T<int>;
|
||||
|
||||
%inline %{
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
||||
// Autodoc language keywords
|
||||
%feature(autodoc,1) process;
|
||||
%feature(autodoc,1) process2;
|
||||
%feature("compactdefaultargs") process;
|
||||
%feature("compactdefaultargs") process2;
|
||||
%inline %{
|
||||
int process(int from, int in, int var) { return from; }
|
||||
int process2(int from = 0, int _in = 1, int var = 2) { return from; }
|
||||
%}
|
||||
|
||||
%feature(autodoc,1) process3;
|
||||
%feature(autodoc,1) process4;
|
||||
%feature("kwargs") process3;
|
||||
%feature("kwargs") process4;
|
||||
%inline %{
|
||||
int process3(int from, int _in, int var) { return from; }
|
||||
int process4(int from = 0, int _in = 1, int var = 2) { return from; }
|
||||
%}
|
||||
|
||||
// Autodoc for methods with default arguments not directly representable in
|
||||
// target language.
|
||||
%feature(autodoc,0) process_complex_defval;
|
||||
%feature("compactdefaultargs") process_complex_defval;
|
||||
%inline %{
|
||||
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; }
|
||||
%}
|
||||
22
winx64/bin/swigwin-4.0.0/Examples/test-suite/bloody_hell.i
Normal file
22
winx64/bin/swigwin-4.0.0/Examples/test-suite/bloody_hell.i
Normal file
@@ -0,0 +1,22 @@
|
||||
%module bloody_hell
|
||||
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) kMaxIOCTLSpaceParmsSize;
|
||||
|
||||
#ifdef SWIGSCILAB
|
||||
%rename(Parms) sm_channel_ix_dump_parms;
|
||||
#endif
|
||||
|
||||
#define kMaxIOCTLSpaceParmsSize 128
|
||||
|
||||
%{
|
||||
#define kMaxIOCTLSpaceParmsSize 128
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
typedef struct sm_channel_ix_dump_parms {
|
||||
unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
|
||||
} SM_CHANNEL_IX_DUMP_PARMS;
|
||||
%}
|
||||
|
||||
|
||||
|
||||
9
winx64/bin/swigwin-4.0.0/Examples/test-suite/bom_utf8.i
Normal file
9
winx64/bin/swigwin-4.0.0/Examples/test-suite/bom_utf8.i
Normal file
@@ -0,0 +1,9 @@
|
||||
%module bom_utf8
|
||||
|
||||
/* Test for UTF8 BOM at start of file */
|
||||
%inline %{
|
||||
struct NotALotHere {
|
||||
int n;
|
||||
};
|
||||
%}
|
||||
|
||||
69
winx64/bin/swigwin-4.0.0/Examples/test-suite/bools.i
Normal file
69
winx64/bin/swigwin-4.0.0/Examples/test-suite/bools.i
Normal file
@@ -0,0 +1,69 @@
|
||||
// bool typemaps check
|
||||
%module bools
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%rename(BoolSt) BoolStructure;
|
||||
#endif
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool; /* Ruby, wrong class name */
|
||||
|
||||
// bool constant
|
||||
%constant bool constbool=false;
|
||||
|
||||
%inline %{
|
||||
|
||||
// bool variables
|
||||
bool bool1 = true;
|
||||
bool bool2 = false;
|
||||
bool* pbool = &bool1;
|
||||
bool& rbool = bool2;
|
||||
const bool* const_pbool = pbool;
|
||||
const bool& const_rbool = rbool;
|
||||
|
||||
static int eax()
|
||||
{
|
||||
return 1024; // NOTE: any number > 255 should do
|
||||
}
|
||||
|
||||
// bool functions
|
||||
bool bo(bool b) {
|
||||
return b;
|
||||
}
|
||||
bool& rbo(bool& b) {
|
||||
return b;
|
||||
}
|
||||
bool* pbo(bool* b) {
|
||||
return b;
|
||||
}
|
||||
const bool& const_rbo(const bool& b) {
|
||||
return b;
|
||||
}
|
||||
const bool* const_pbo(const bool* b) {
|
||||
return b;
|
||||
}
|
||||
|
||||
// helper function
|
||||
bool value(bool* b) {
|
||||
return *b;
|
||||
}
|
||||
|
||||
struct BoolStructure {
|
||||
bool m_bool1;
|
||||
bool m_bool2;
|
||||
bool* m_pbool;
|
||||
bool& m_rbool;
|
||||
const bool* m_const_pbool;
|
||||
const bool& m_const_rbool;
|
||||
BoolStructure() :
|
||||
m_bool1(true),
|
||||
m_bool2(false),
|
||||
m_pbool(&m_bool1),
|
||||
m_rbool(m_bool2),
|
||||
m_const_pbool(m_pbool),
|
||||
m_const_rbool(m_rbool) {}
|
||||
private:
|
||||
BoolStructure& operator=(const BoolStructure &);
|
||||
};
|
||||
%}
|
||||
|
||||
20
winx64/bin/swigwin-4.0.0/Examples/test-suite/c_delete.i
Normal file
20
winx64/bin/swigwin-4.0.0/Examples/test-suite/c_delete.i
Normal file
@@ -0,0 +1,20 @@
|
||||
%module c_delete
|
||||
|
||||
/* check C++ delete keyword is okay in C wrappers */
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) delete;
|
||||
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */
|
||||
|
||||
%inline %{
|
||||
struct delete {
|
||||
int delete;
|
||||
};
|
||||
%}
|
||||
|
||||
%rename(DeleteGlobalVariable) delete;
|
||||
%inline %{
|
||||
int delete = 0;
|
||||
%}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
%module c_delete_function
|
||||
|
||||
/* check C++ delete keyword is okay in C wrappers */
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_KEYWORD) delete;
|
||||
|
||||
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8) /* Octave and Javascript/v8 compiles wrappers as C++ */
|
||||
|
||||
%inline %{
|
||||
double delete(double d) { return d; }
|
||||
%}
|
||||
|
||||
#endif
|
||||
96
winx64/bin/swigwin-4.0.0/Examples/test-suite/callback.i
Normal file
96
winx64/bin/swigwin-4.0.0/Examples/test-suite/callback.i
Normal file
@@ -0,0 +1,96 @@
|
||||
%module callback
|
||||
|
||||
// Not specifying the callback name is only possible in Python.
|
||||
#ifdef SWIGPYTHON
|
||||
%callback(1) foo;
|
||||
%callback(1) foof;
|
||||
%callback(1) A::bar;
|
||||
%callback(1) A::foom;
|
||||
#else
|
||||
%callback("%s") foo;
|
||||
%callback("%s") foof;
|
||||
%callback("%s") A::bar;
|
||||
%callback("%s") A::foom;
|
||||
#endif
|
||||
%callback("%(uppercase)s_Cb_Ptr") foo_T; // this works in Python too
|
||||
|
||||
%inline %{
|
||||
|
||||
int foo(int a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
int foof(int a) {
|
||||
return 3*a;
|
||||
}
|
||||
|
||||
struct A
|
||||
{
|
||||
static int bar(int a) {
|
||||
return 2*a;
|
||||
}
|
||||
|
||||
int foom(int a)
|
||||
{
|
||||
return -a;
|
||||
}
|
||||
|
||||
//friend int foof(int a);
|
||||
};
|
||||
|
||||
|
||||
extern "C" int foobar(int a, int (*pf)(int a)) {
|
||||
return pf(a);
|
||||
}
|
||||
|
||||
extern "C" int foobarm(int a, A ap, int (A::*pf)(int a)) {
|
||||
return (ap.*pf)(a);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T foo_T(T a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T foo_T(T a, T b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T foobar_T(T a, T (*pf)(T a)) {
|
||||
return pf(a);
|
||||
}
|
||||
|
||||
#if defined(__SUNPRO_CC)
|
||||
// workaround for: Error: Could not find a match for foobar_T<T>(int, extern "C" int(*)(int)).
|
||||
extern "C" {
|
||||
typedef int (*foobar_int_int)(int a);
|
||||
typedef double (*foobar_double_double)(double a);
|
||||
};
|
||||
template <class T>
|
||||
int foobar_T(int a, foobar_int_int pf) {
|
||||
return pf(a);
|
||||
}
|
||||
template <class T>
|
||||
double foobar_T(double a, foobar_double_double pf) {
|
||||
return pf(a);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
const T& ident(const T& x) {
|
||||
return x;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(foo_i) foo_T<int>;
|
||||
%template(foobar_i) foobar_T<int>;
|
||||
|
||||
%template(foo_d) foo_T<double>;
|
||||
%template(foobar_d) foobar_T<double>;
|
||||
|
||||
%template(ident_d) ident<double>;
|
||||
20
winx64/bin/swigwin-4.0.0/Examples/test-suite/cast_operator.i
Normal file
20
winx64/bin/swigwin-4.0.0/Examples/test-suite/cast_operator.i
Normal file
@@ -0,0 +1,20 @@
|
||||
%module cast_operator
|
||||
|
||||
%rename(tochar) A::operator char*() const;
|
||||
%inline %{
|
||||
#include <string.h>
|
||||
struct A
|
||||
{
|
||||
operator char*() const;
|
||||
};
|
||||
|
||||
inline
|
||||
A::operator char*() const
|
||||
{
|
||||
static char hi[16];
|
||||
strcpy(hi, "hi");
|
||||
return hi;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
21
winx64/bin/swigwin-4.0.0/Examples/test-suite/casts.i
Normal file
21
winx64/bin/swigwin-4.0.0/Examples/test-suite/casts.i
Normal file
@@ -0,0 +1,21 @@
|
||||
%module casts
|
||||
|
||||
%inline %{
|
||||
|
||||
class A {
|
||||
public:
|
||||
A() {}
|
||||
|
||||
void hello()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class B : public A
|
||||
{
|
||||
public:
|
||||
B() {}
|
||||
|
||||
};
|
||||
|
||||
%}
|
||||
33
winx64/bin/swigwin-4.0.0/Examples/test-suite/catches.i
Normal file
33
winx64/bin/swigwin-4.0.0/Examples/test-suite/catches.i
Normal file
@@ -0,0 +1,33 @@
|
||||
%module catches
|
||||
|
||||
// throw is invalid in C++17 and later, only SWIG to use it
|
||||
#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3)
|
||||
%{
|
||||
#define TESTCASE_THROW3(T1, T2, T3)
|
||||
%}
|
||||
|
||||
%include <exception.i> // for throws(...) typemap
|
||||
|
||||
%catches(int, const char *, const ThreeException&) test_catches(int i);
|
||||
%catches(int, ...) test_exception_specification(int i); // override the exception specification
|
||||
%catches(...) test_catches_all(int i);
|
||||
|
||||
%inline %{
|
||||
struct ThreeException {};
|
||||
void test_catches(int i) {
|
||||
if (i == 1) {
|
||||
throw int(1);
|
||||
} else if (i == 2) {
|
||||
throw (const char *)"two";
|
||||
} else if (i == 3) {
|
||||
throw ThreeException();
|
||||
}
|
||||
}
|
||||
void test_exception_specification(int i) TESTCASE_THROW3(int, const char *, const ThreeException&) {
|
||||
test_catches(i);
|
||||
}
|
||||
void test_catches_all(int i) {
|
||||
test_catches(i);
|
||||
}
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#######################################################################
|
||||
# Makefile for cffi test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = cffi
|
||||
CFFI = @CFFIBIN@
|
||||
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) $(CFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra cffi code)
|
||||
%.clean:
|
||||
@exit 0
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' cffi_clean
|
||||
33
winx64/bin/swigwin-4.0.0/Examples/test-suite/char_binary.i
Normal file
33
winx64/bin/swigwin-4.0.0/Examples/test-suite/char_binary.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
A test case for testing non null terminated char pointers.
|
||||
*/
|
||||
|
||||
%module char_binary
|
||||
|
||||
%apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) }
|
||||
%apply (char *STRING, size_t LENGTH) { (const unsigned char *str, size_t len) }
|
||||
|
||||
%inline %{
|
||||
struct Test {
|
||||
size_t strlen(const char *str, size_t len) {
|
||||
return len;
|
||||
}
|
||||
size_t ustrlen(const unsigned char *str, size_t len) {
|
||||
return len;
|
||||
}
|
||||
};
|
||||
|
||||
typedef char namet[5];
|
||||
namet var_namet;
|
||||
|
||||
typedef char* pchar;
|
||||
pchar var_pchar;
|
||||
%}
|
||||
|
||||
// Remove string handling typemaps and treat as pointer
|
||||
%typemap(freearg) SWIGTYPE * ""
|
||||
%apply SWIGTYPE * { char * }
|
||||
|
||||
%include "carrays.i"
|
||||
%array_functions(char, pchar);
|
||||
|
||||
50
winx64/bin/swigwin-4.0.0/Examples/test-suite/char_constant.i
Normal file
50
winx64/bin/swigwin-4.0.0/Examples/test-suite/char_constant.i
Normal file
@@ -0,0 +1,50 @@
|
||||
/* This interface file tests whether character constants are correctly
|
||||
wrapped as procedures returning Scheme characters (rather than
|
||||
Scheme strings).
|
||||
*/
|
||||
|
||||
%module char_constant
|
||||
|
||||
#define CHAR_CONSTANT 'x'
|
||||
|
||||
#define STRING_CONSTANT "xyzzy"
|
||||
|
||||
#define ESC_CONST '\1'
|
||||
#define NULL_CONST '\0'
|
||||
#define SPECIALCHAR 'á'
|
||||
#define SPECIALCHAR2 '\n'
|
||||
#define SPECIALCHARA 'A'
|
||||
#define SPECIALCHARB '\102' // B
|
||||
#define SPECIALCHARC '\x43' // C
|
||||
#define SPECIALCHARD 0x44 // D
|
||||
#define SPECIALCHARE 69 // E
|
||||
#define SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
|
||||
#define SPECIALCHARAE2 '\306' // AE (latin1 encoded)
|
||||
#define SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
%javaconst(1);
|
||||
#elif SWIGCSHARP
|
||||
%csconst(1);
|
||||
#elif SWIGD
|
||||
%dmanifestconst;
|
||||
#endif
|
||||
|
||||
#define X_ESC_CONST '\1'
|
||||
#define X_NULL_CONST '\0'
|
||||
#define X_SPECIALCHAR 'á'
|
||||
#define X_SPECIALCHAR2 '\n'
|
||||
#define X_SPECIALCHARA 'A'
|
||||
#define X_SPECIALCHARB '\102' // B
|
||||
#define X_SPECIALCHARC '\x43' // C
|
||||
#define X_SPECIALCHARD 0x44 // D
|
||||
#define X_SPECIALCHARE 69 // E
|
||||
#define X_SPECIALCHARAE1 'Æ' // AE (latin1 encoded)
|
||||
#define X_SPECIALCHARAE2 '\306' // AE (latin1 encoded)
|
||||
#define X_SPECIALCHARAE3 '\xC6' // AE (latin1 encoded)
|
||||
|
||||
%inline
|
||||
{
|
||||
const int ia = (int)'a';
|
||||
const int ib = 'b';
|
||||
}
|
||||
191
winx64/bin/swigwin-4.0.0/Examples/test-suite/char_strings.i
Normal file
191
winx64/bin/swigwin-4.0.0/Examples/test-suite/char_strings.i
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
A test case for testing char based strings. Useful for runtime testing,
|
||||
there were some runtime crashes and leaks in the C# module in some of the scenarios
|
||||
below.
|
||||
*/
|
||||
|
||||
%module char_strings
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
|
||||
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
|
||||
|
||||
%{
|
||||
#include <stdio.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."
|
||||
static char *global_str = NULL;
|
||||
const int UINT_DIGITS = 10; // max unsigned int is 4294967295
|
||||
|
||||
bool check(const char *const str, unsigned int number) {
|
||||
static char expected[256];
|
||||
sprintf(expected, "%s%d", OTHERLAND_MSG, number);
|
||||
bool matches = (strcmp(str, expected) == 0);
|
||||
if (!matches) printf("Failed: [%s][%s]\n", str, expected);
|
||||
return matches;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%immutable global_const_char;
|
||||
|
||||
%inline %{
|
||||
// get functions
|
||||
char *GetCharHeapString() {
|
||||
global_str = new char[sizeof(CPLUSPLUS_MSG)+1];
|
||||
strcpy(global_str, CPLUSPLUS_MSG);
|
||||
return global_str;
|
||||
}
|
||||
|
||||
const char *GetConstCharProgramCodeString() {
|
||||
return CPLUSPLUS_MSG;
|
||||
}
|
||||
|
||||
void DeleteCharHeapString() {
|
||||
delete[] global_str;
|
||||
global_str = NULL;
|
||||
}
|
||||
|
||||
char *GetCharStaticString() {
|
||||
static char str[sizeof(CPLUSPLUS_MSG)+1];
|
||||
strcpy(str, CPLUSPLUS_MSG);
|
||||
return str;
|
||||
}
|
||||
|
||||
char *GetCharStaticStringFixed() {
|
||||
static char str[] = CPLUSPLUS_MSG;
|
||||
return str;
|
||||
}
|
||||
|
||||
const char *GetConstCharStaticStringFixed() {
|
||||
static const char str[] = CPLUSPLUS_MSG;
|
||||
return str;
|
||||
}
|
||||
|
||||
// set functions
|
||||
bool SetCharHeapString(char *str, unsigned int number) {
|
||||
delete[] global_str;
|
||||
global_str = new char[strlen(str)+UINT_DIGITS+1];
|
||||
strcpy(global_str, str);
|
||||
return check(global_str, number);
|
||||
}
|
||||
|
||||
bool SetCharStaticString(char *str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetCharArrayStaticString(char str[], unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetConstCharHeapString(const char *str, unsigned int number) {
|
||||
delete[] global_str;
|
||||
global_str = new char[strlen(str)+UINT_DIGITS+1];
|
||||
strcpy(global_str, str);
|
||||
return check(global_str, number);
|
||||
}
|
||||
|
||||
bool SetConstCharStaticString(const char *str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetConstCharArrayStaticString(const char str[], unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetCharConstStaticString(char *const str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetConstCharConstStaticString(const char *const str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
// get set function
|
||||
char *CharPingPong(char *str) {
|
||||
return str;
|
||||
}
|
||||
char *CharArrayPingPong(char abcstr[]) {
|
||||
return abcstr;
|
||||
}
|
||||
char *CharArrayDimsPingPong(char abcstr[16]) {
|
||||
return abcstr;
|
||||
}
|
||||
|
||||
// variables
|
||||
char *global_char = NULL;
|
||||
char global_char_array1[] = CPLUSPLUS_MSG;
|
||||
char global_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
|
||||
|
||||
const char *global_const_char = CPLUSPLUS_MSG;
|
||||
const char global_const_char_array1[] = CPLUSPLUS_MSG;
|
||||
const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG;
|
||||
|
||||
%}
|
||||
|
||||
|
||||
%typemap(newfree) char *GetNewCharString() { /* hello */ delete[] $1; }
|
||||
%newobject GetNewCharString();
|
||||
|
||||
%inline {
|
||||
char *GetNewCharString() {
|
||||
char *nstr = new char[sizeof(CPLUSPLUS_MSG)+1];
|
||||
strcpy(nstr, CPLUSPLUS_MSG);
|
||||
return nstr;
|
||||
}
|
||||
}
|
||||
|
||||
%inline {
|
||||
struct Formatpos;
|
||||
struct OBFormat;
|
||||
|
||||
static int GetNextFormat(Formatpos& itr, const char*& str,OBFormat*& pFormat) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
// char *& tests
|
||||
char *&GetCharPointerRef() {
|
||||
static char str[] = CPLUSPLUS_MSG;
|
||||
static char *ptr = str;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
bool SetCharPointerRef(char *&str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
const char *&GetConstCharPointerRef() {
|
||||
static const char str[] = CPLUSPLUS_MSG;
|
||||
static const char *ptr = str;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
bool SetConstCharPointerRef(const char *&str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
84
winx64/bin/swigwin-4.0.0/Examples/test-suite/chartest.i
Normal file
84
winx64/bin/swigwin-4.0.0/Examples/test-suite/chartest.i
Normal file
@@ -0,0 +1,84 @@
|
||||
%module chartest
|
||||
|
||||
%inline %{
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
// Suppress: illegal character encoding in character literal
|
||||
#pragma clang diagnostic ignored "-Winvalid-source-encoding"
|
||||
#endif
|
||||
char printable_global_char = 'a';
|
||||
char unprintable_global_char = 0x7F;
|
||||
|
||||
char GetPrintableChar() {
|
||||
return 'a';
|
||||
}
|
||||
|
||||
char GetUnprintableChar() {
|
||||
return 0x7F;
|
||||
}
|
||||
|
||||
static const char globchar0 = '\0';
|
||||
static const char globchar1 = '\1';
|
||||
static const char globchar2 = '\n';
|
||||
static const char globcharA = 'A';
|
||||
static const char globcharB = '\102'; // B
|
||||
static const char globcharC = '\x43'; // C
|
||||
static const char globcharD = 0x44; // D
|
||||
static const char globcharE = 69; // E
|
||||
static const char globcharAE1 = 'Æ'; // AE (latin1 encoded)
|
||||
static const char globcharAE2 = '\306'; // AE (latin1 encoded)
|
||||
static const char globcharAE3 = '\xC6'; // AE (latin1 encoded)
|
||||
|
||||
struct CharTestClass {
|
||||
static const char memberchar0 = '\0';
|
||||
static const char memberchar1 = '\1';
|
||||
static const char memberchar2 = '\n';
|
||||
static const char membercharA = 'A';
|
||||
static const char membercharB = '\102'; // B
|
||||
static const char membercharC = '\x43'; // C
|
||||
static const char membercharD = 0x44; // D
|
||||
static const char membercharE = 69; // E
|
||||
static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
|
||||
static const char membercharAE2 = '\306'; // AE (latin1 encoded)
|
||||
static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
|
||||
};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
%javaconst(1);
|
||||
#elif SWIGCSHARP
|
||||
%csconst(1);
|
||||
#elif SWIGD
|
||||
%dmanifestconst;
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
static const char x_globchar0 = '\0';
|
||||
static const char x_globchar1 = '\1';
|
||||
static const char x_globchar2 = '\n';
|
||||
static const char x_globcharA = 'A';
|
||||
static const char x_globcharB = '\102'; // B
|
||||
static const char x_globcharC = '\x43'; // C
|
||||
static const char x_globcharD = 0x44; // D
|
||||
static const char x_globcharE = 69; // E
|
||||
static const char x_globcharAE1 = 'Æ'; // AE (latin1 encoded)
|
||||
static const char x_globcharAE2 = '\306'; // AE (latin1 encoded)
|
||||
static const char x_globcharAE3 = '\xC6'; // AE (latin1 encoded)
|
||||
|
||||
struct X_CharTestClass {
|
||||
static const char memberchar0 = '\0';
|
||||
static const char memberchar1 = '\1';
|
||||
static const char memberchar2 = '\n';
|
||||
static const char membercharA = 'A';
|
||||
static const char membercharB = '\102'; // B
|
||||
static const char membercharC = '\x43'; // C
|
||||
static const char membercharD = 0x44; // D
|
||||
static const char membercharE = 69; // E
|
||||
static const char membercharAE1 = 'Æ'; // AE (latin1 encoded)
|
||||
static const char membercharAE2 = '\306'; // AE (latin1 encoded)
|
||||
static const char membercharAE3 = '\xC6'; // AE (latin1 encoded)
|
||||
};
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
%}
|
||||
101
winx64/bin/swigwin-4.0.0/Examples/test-suite/chicken/Makefile.in
Normal file
101
winx64/bin/swigwin-4.0.0/Examples/test-suite/chicken/Makefile.in
Normal file
@@ -0,0 +1,101 @@
|
||||
#######################################################################
|
||||
# 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
|
||||
11
winx64/bin/swigwin-4.0.0/Examples/test-suite/chicken/README
Normal file
11
winx64/bin/swigwin-4.0.0/Examples/test-suite/chicken/README
Normal file
@@ -0,0 +1,11 @@
|
||||
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.
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "casts.so")
|
||||
(include "../schemerunme/casts.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "char_constant.so")
|
||||
(include "../schemerunme/char_constant.scm")
|
||||
@@ -0,0 +1,21 @@
|
||||
#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);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
(load "chicken_ext_test.so")
|
||||
|
||||
(define a (test-create))
|
||||
|
||||
(A-hello a)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "class_ignore.so")
|
||||
(include "../schemerunme/class_ignore.scm")
|
||||
@@ -0,0 +1,95 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "constover.so")
|
||||
(include "../schemerunme/constover.scm")
|
||||
@@ -0,0 +1,3 @@
|
||||
(load "contract.so")
|
||||
(include "testsuite.ss")
|
||||
(include "../schemerunme/contract.scm")
|
||||
@@ -0,0 +1,64 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "cpp_enum.so")
|
||||
(include "../schemerunme/cpp_enum.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "cpp_namespace.so")
|
||||
(include "../schemerunme/cpp_namespace.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "dynamic_cast.so")
|
||||
(include "../schemerunme/dynamic_cast.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(require 'global_vars)
|
||||
(load "../schemerunme/global_vars.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(require 'global_vars)
|
||||
(load "../schemerunme/global_vars_proxy.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "import_nomodule.so")
|
||||
(include "../schemerunme/import_nomodule.scm")
|
||||
@@ -0,0 +1,3 @@
|
||||
(load "imports_a.so")
|
||||
(load "imports_b.so")
|
||||
(include "../schemerunme/imports.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "inherit_missing.so")
|
||||
(include "../schemerunme/inherit_missing.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "li_std_string.so")
|
||||
(include "../schemerunme/li_std_string.scm")
|
||||
@@ -0,0 +1,47 @@
|
||||
(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)
|
||||
@@ -0,0 +1,12 @@
|
||||
(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)
|
||||
@@ -0,0 +1,13 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "list_vector.so")
|
||||
(include "../schemerunme/list_vector.scm")
|
||||
@@ -0,0 +1,28 @@
|
||||
(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)))
|
||||
@@ -0,0 +1,2 @@
|
||||
(require 'multiple_inheritance)
|
||||
(load "../schemerunme/multiple_inheritance_proxy.scm")
|
||||
@@ -0,0 +1,4 @@
|
||||
;; this doesn't work yet :(
|
||||
(load "multivalue.so")
|
||||
(include "../schemerunme/multivalue.scm")
|
||||
(exit 0)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "name.so")
|
||||
(include "../schemerunme/name.scm")
|
||||
@@ -0,0 +1,30 @@
|
||||
(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)
|
||||
@@ -0,0 +1,29 @@
|
||||
(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)
|
||||
@@ -0,0 +1,29 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "overload_complicated.so")
|
||||
(include "../schemerunme/overload_complicated.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "overload_copy.so")
|
||||
(include "../schemerunme/overload_copy.scm")
|
||||
@@ -0,0 +1,6 @@
|
||||
(load "./overload_copy.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define g (make <Foo> f))
|
||||
|
||||
(exit 0)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "overload_extend_c.so")
|
||||
(include "../schemerunme/overload_extend_c.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "overload_extend.so")
|
||||
(include "../schemerunme/overload_extend.scm")
|
||||
@@ -0,0 +1,14 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "overload_simple.so")
|
||||
(include "../schemerunme/overload_simple.scm")
|
||||
@@ -0,0 +1,56 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "overload_subtype.so")
|
||||
(include "../schemerunme/overload_subtype.scm")
|
||||
@@ -0,0 +1,12 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "pointer_in_out.so")
|
||||
(include "../schemerunme/pointer_in_out.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "reference_global_vars.so")
|
||||
(include "../schemerunme/reference_global_vars.scm")
|
||||
@@ -0,0 +1,12 @@
|
||||
(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))))
|
||||
@@ -0,0 +1,29 @@
|
||||
(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)
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "typedef_inherit.so")
|
||||
(include "../schemerunme/typedef_inherit.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "typename.so")
|
||||
(include "../schemerunme/typename.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "unions.so")
|
||||
(include "../schemerunme/unions.scm")
|
||||
@@ -0,0 +1,2 @@
|
||||
(load "unions.so")
|
||||
(include "../schemerunme/unions_proxy.scm")
|
||||
@@ -0,0 +1,21 @@
|
||||
%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));
|
||||
}
|
||||
%}
|
||||
|
||||
10
winx64/bin/swigwin-4.0.0/Examples/test-suite/class_forward.i
Normal file
10
winx64/bin/swigwin-4.0.0/Examples/test-suite/class_forward.i
Normal file
@@ -0,0 +1,10 @@
|
||||
%module class_forward
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
class B;
|
||||
};
|
||||
class C : public A {
|
||||
};
|
||||
%}
|
||||
|
||||
47
winx64/bin/swigwin-4.0.0/Examples/test-suite/class_ignore.i
Normal file
47
winx64/bin/swigwin-4.0.0/Examples/test-suite/class_ignore.i
Normal file
@@ -0,0 +1,47 @@
|
||||
%module class_ignore
|
||||
|
||||
%ignore Foo;
|
||||
%ignore *::Bar::foo;
|
||||
%ignore Far::away() const;
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() { }
|
||||
virtual char *blah() = 0;
|
||||
};
|
||||
|
||||
namespace hi
|
||||
{
|
||||
namespace hello
|
||||
{
|
||||
class Bar : public Foo {
|
||||
public:
|
||||
void foo(void) {};
|
||||
|
||||
virtual char *blah() { return (char *) "Bar::blah"; }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
struct Boo {
|
||||
virtual ~Boo() {}
|
||||
virtual void away() const {}
|
||||
};
|
||||
struct Far : Boo {
|
||||
virtual void away() const {}
|
||||
};
|
||||
struct Hoo : Far {
|
||||
virtual void away() const {}
|
||||
};
|
||||
|
||||
char *do_blah(Foo *f) {
|
||||
return f->blah();
|
||||
}
|
||||
|
||||
class ForwardClass;
|
||||
template <class C> class ForwardClassT;
|
||||
template<typename T1, typename T2> class PatchList;
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
// Test a mix of forward class declarations, class definitions, using declarations and using directives.
|
||||
|
||||
%module class_scope_namespace
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) H::HH;
|
||||
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Space8::I_::II;
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
namespace Space1 {
|
||||
namespace SubSpace1 {
|
||||
struct A {
|
||||
void aa(Space1::SubSpace1::A, SubSpace1::A, A) {}
|
||||
};
|
||||
void aaa(Space1::SubSpace1::A, SubSpace1::A, A) {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Space2 {
|
||||
struct B;
|
||||
}
|
||||
using Space2::B;
|
||||
#ifdef __clang__
|
||||
namespace Space2 {
|
||||
struct B {
|
||||
void bb(Space2::B, B) {}
|
||||
};
|
||||
}
|
||||
#else
|
||||
struct B {
|
||||
void bb(Space2::B, B) {}
|
||||
};
|
||||
#endif
|
||||
void bbb(Space2::B, B) {}
|
||||
|
||||
namespace Space3 {
|
||||
namespace SubSpace3 {
|
||||
struct C;
|
||||
struct D;
|
||||
}
|
||||
}
|
||||
struct C;
|
||||
struct D;
|
||||
namespace Space3 {
|
||||
struct C;
|
||||
struct SubSpace3::C {
|
||||
void cc(Space3::SubSpace3::C, SubSpace3::C) {}
|
||||
};
|
||||
using SubSpace3::D;
|
||||
struct SubSpace3::D {
|
||||
void dd(Space3::SubSpace3::D, SubSpace3::D, D) {}
|
||||
};
|
||||
void ccc(Space3::SubSpace3::C, SubSpace3::C) {}
|
||||
void ddd(Space3::SubSpace3::D, SubSpace3::D, D) {}
|
||||
}
|
||||
|
||||
namespace Space4 {
|
||||
namespace SubSpace4 {
|
||||
struct E;
|
||||
}
|
||||
}
|
||||
using namespace Space4;
|
||||
using SubSpace4::E;
|
||||
// Was added to incorrect namespace in swig-3.0.12
|
||||
struct SubSpace4::E {
|
||||
void ee(Space4::SubSpace4::E, SubSpace4::E, E) {}
|
||||
};
|
||||
void eee(Space4::SubSpace4::E, SubSpace4::E, E) {}
|
||||
|
||||
namespace Space5 {
|
||||
namespace SubSpace5 {
|
||||
namespace SubSubSpace5 {
|
||||
struct F;
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Space5 {
|
||||
using namespace SubSpace5;
|
||||
using SubSubSpace5::F;
|
||||
// Was added to incorrect namespace in swig-3.0.12
|
||||
struct SubSubSpace5::F {
|
||||
void ff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
|
||||
};
|
||||
void fff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
|
||||
}
|
||||
|
||||
namespace Space6 {
|
||||
struct G;
|
||||
namespace SubSpace6 {
|
||||
struct G;
|
||||
}
|
||||
}
|
||||
namespace Space6 {
|
||||
struct SubSpace6::G {
|
||||
void gg(Space6::SubSpace6::G, SubSpace6::G) {}
|
||||
};
|
||||
void ggg(Space6::SubSpace6::G, SubSpace6::G) {}
|
||||
}
|
||||
|
||||
struct HH;
|
||||
struct H {
|
||||
struct HH {
|
||||
void hh(H::HH) {}
|
||||
};
|
||||
};
|
||||
void hhh(H::HH) {}
|
||||
|
||||
namespace Space8 {
|
||||
struct II;
|
||||
struct I_ {
|
||||
struct II {
|
||||
void ii(Space8::I_::II, I_::II) {}
|
||||
};
|
||||
};
|
||||
void iii(Space8::I_::II, I_::II) {}
|
||||
}
|
||||
|
||||
struct J;
|
||||
namespace Space9 {
|
||||
namespace SubSpace9 {
|
||||
struct J {
|
||||
void jj(Space9::SubSpace9::J, SubSpace9::J, J) {}
|
||||
};
|
||||
void jjj(Space9::SubSpace9::J, SubSpace9::J, J) {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Space10 {
|
||||
struct K;
|
||||
}
|
||||
namespace Space10 {
|
||||
namespace SubSpace10 {
|
||||
struct K {
|
||||
void kk(Space10::SubSpace10::K, SubSpace10::K, K) {}
|
||||
};
|
||||
void kkk(Space10::SubSpace10::K, SubSpace10::K, K) {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace OtherSpace {
|
||||
struct L;
|
||||
struct M;
|
||||
}
|
||||
using OtherSpace::L;
|
||||
namespace Space11 {
|
||||
using OtherSpace::M;
|
||||
namespace SubSpace11 {
|
||||
struct L {
|
||||
void ll(Space11::SubSpace11::L, SubSpace11::L, L) {}
|
||||
};
|
||||
void lll(Space11::SubSpace11::L, SubSpace11::L, L) {}
|
||||
struct M {
|
||||
void mm(Space11::SubSpace11::M, SubSpace11::M, M) {}
|
||||
};
|
||||
void mmm(Space11::SubSpace11::M, SubSpace11::M, M) {}
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
%module class_scope_weird
|
||||
|
||||
// Use this version with extra qualifiers to test SWIG as some compilers accept this
|
||||
class Foo {
|
||||
public:
|
||||
Foo::Foo(void) {}
|
||||
Foo::Foo(int) {}
|
||||
int Foo::bar(int x) {
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
// Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards)
|
||||
%{
|
||||
class Foo {
|
||||
public:
|
||||
Foo(void) {}
|
||||
Foo(int) {}
|
||||
int bar(int x) {
|
||||
return x;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
class Quat;
|
||||
class matrix4;
|
||||
class tacka3;
|
||||
%}
|
||||
|
||||
// Use this version with extra qualifiers to test SWIG as some compilers accept this
|
||||
class Quat {
|
||||
public:
|
||||
Quat::Quat(void){}
|
||||
Quat::Quat(float in_w, float x, float y, float z){}
|
||||
Quat::Quat(const tacka3& axis, float angle){}
|
||||
Quat::Quat(const matrix4& m){}
|
||||
};
|
||||
|
||||
// Remove extra qualifiers for the compiler as some compilers won't compile the extra qaulification (eg gcc-4.1 onwards)
|
||||
%{
|
||||
class Quat {
|
||||
public:
|
||||
Quat(void){}
|
||||
Quat(float in_w, float x, float y, float z){}
|
||||
Quat(const tacka3& axis, float angle){}
|
||||
Quat(const matrix4& m){}
|
||||
};
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
clientdata_prop_a
|
||||
clientdata_prop_b
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
class A {
|
||||
public:
|
||||
void fA() {}
|
||||
};
|
||||
|
||||
typedef A tA;
|
||||
|
||||
void test_A(A *a) {}
|
||||
void test_tA(tA *a) {}
|
||||
|
||||
tA *new_tA() { return new tA(); }
|
||||
@@ -0,0 +1,12 @@
|
||||
/* This file tests the clientdata propagation at swig wrapper
|
||||
generation. It tests a bug in the TCL module where the
|
||||
clientdata was not propagated correctly to all classes */
|
||||
|
||||
%module clientdata_prop_a
|
||||
%{
|
||||
#include "clientdata_prop_a.h"
|
||||
%}
|
||||
|
||||
%include "clientdata_prop_a.h"
|
||||
|
||||
%newobject new_tA;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user