Merge branch 'master' into gsoc2009-matevz
Conflicts: Examples/Makefile.in Examples/guile/Makefile.in Lib/php/php.swg Makefile.in Source/CParse/parser.y configure.ac
This commit is contained in:
commit
bcb7aee022
585 changed files with 9528 additions and 12959 deletions
|
|
@ -61,7 +61,6 @@ char* test_b(name a, const namea b) {
|
|||
return a;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int test_a(int a) {
|
||||
return a;
|
||||
}
|
||||
|
|
@ -70,7 +69,6 @@ int test_b(int a) {
|
|||
return a;
|
||||
}
|
||||
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
||||
|
|
|
|||
9
Examples/test-suite/bom_utf8.i
Normal file
9
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;
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ CPP_TEST_CASES =
|
|||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra cffi code)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <ext_test_wrap_hdr.h>
|
||||
#include <chicken/chicken_ext_test_wrap_hdr.h>
|
||||
#include <imports_a.h>
|
||||
|
||||
void test_create(C_word,C_word,C_word) C_noret;
|
||||
|
|
@ -7,16 +7,15 @@ void test_create(C_word argc, C_word closure, C_word continuation) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ CPP_TEST_CASES =
|
|||
# a file is found which has _runme.lisp appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra clisp code)
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ CPP_TEST_CASES += \
|
|||
kind \
|
||||
langobj \
|
||||
li_attribute \
|
||||
li_attribute_template \
|
||||
li_boost_shared_ptr \
|
||||
li_boost_shared_ptr_bits \
|
||||
li_boost_shared_ptr_template \
|
||||
|
|
@ -273,6 +274,7 @@ CPP_TEST_CASES += \
|
|||
nspace \
|
||||
nspace_extend \
|
||||
naturalvar \
|
||||
naturalvar_more \
|
||||
nested_class \
|
||||
nested_comment \
|
||||
nested_workaround \
|
||||
|
|
@ -284,8 +286,9 @@ CPP_TEST_CASES += \
|
|||
operbool \
|
||||
ordering \
|
||||
overload_copy \
|
||||
overload_method \
|
||||
overload_extend \
|
||||
overload_method \
|
||||
overload_numeric \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
overload_simple \
|
||||
|
|
@ -433,6 +436,7 @@ CPP_TEST_CASES += \
|
|||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_arrays \
|
||||
typemap_array_qualifiers \
|
||||
typemap_delete \
|
||||
typemap_directorout \
|
||||
typemap_global_scope \
|
||||
|
|
@ -546,12 +550,14 @@ endif
|
|||
# C test cases. (Can be run individually using: make testcase.ctest)
|
||||
C_TEST_CASES += \
|
||||
arrays \
|
||||
bom_utf8 \
|
||||
char_constant \
|
||||
const_const \
|
||||
constant_expr \
|
||||
empty \
|
||||
enums \
|
||||
enum_forward \
|
||||
enum_macro \
|
||||
extern_declaration \
|
||||
funcptr \
|
||||
function_typedef \
|
||||
|
|
|
|||
41
Examples/test-suite/csharp/director_smartptr_runme.cs
Normal file
41
Examples/test-suite/csharp/director_smartptr_runme.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using director_smartptrNamespace;
|
||||
|
||||
public class runme
|
||||
{
|
||||
|
||||
private class director_smartptr_MyBarFoo : Foo
|
||||
{
|
||||
public override string ping()
|
||||
{
|
||||
return "director_smartptr_MyBarFoo.ping();";
|
||||
}
|
||||
|
||||
public override string pong()
|
||||
{
|
||||
return "director_smartptr_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
public override string fooBar(FooBar fooBar)
|
||||
{
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
public override Foo makeFoo()
|
||||
{
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public override FooBar makeFooBar()
|
||||
{
|
||||
return new FooBar();
|
||||
}
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
director_smartptr_MyBarFoo myBarFoo =
|
||||
new director_smartptr_MyBarFoo();
|
||||
|
||||
myBarFoo.ping();
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,8 @@ public class runme {
|
|||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap")
|
||||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJames(name) != "SWIGTYPE_Name")
|
||||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJim(name) != "multiname num")
|
||||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ void main() {
|
|||
throw new Exception("test failed");
|
||||
}
|
||||
|
||||
if (testJames(name) != "SWIGTYPE_Name") {
|
||||
throw new Exception("test failed");
|
||||
}
|
||||
|
||||
if (testJim(name) != "multiname num") {
|
||||
throw new Exception("test failed");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ void main() {
|
|||
enforce(testJack(name) == "$specialname");
|
||||
enforce(testJill(name) == "jilly");
|
||||
enforce(testMary(name) == "SWIGTYPE_p_NameWrap");
|
||||
enforce(testJames(name) == "SWIGTYPE_Name");
|
||||
enforce(testJim(name) == "multiname num");
|
||||
|
||||
enforce(testJohn(new PairIntBool(10, false)) == 123);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
%module(directors="1") director_basic
|
||||
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
|
||||
%module(directors="1") director_basic
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// Tests classes passed by value, pointer and reference
|
||||
// Note: C# module has a large runtime test
|
||||
|
||||
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ref;
|
||||
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr;
|
||||
|
||||
%module(directors="1") director_classes
|
||||
|
||||
|
|
|
|||
|
|
@ -68,21 +68,6 @@ class DAbstractIgnores
|
|||
virtual double OverloadedProtectedMethod() = 0;
|
||||
};
|
||||
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreConstructor() {}
|
||||
DIgnoreConstructor(std::string s, int i) {}
|
||||
DIgnoreConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreOnlyConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreOnlyConstructor() {}
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
|
||||
template <typename T> class DTemplateAbstractIgnores
|
||||
{
|
||||
T t;
|
||||
|
|
@ -101,3 +86,37 @@ template <typename T> class DTemplateAbstractIgnores
|
|||
|
||||
%template(DTemplateAbstractIgnoresInt) DTemplateAbstractIgnores<int>;
|
||||
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreConstructor() {}
|
||||
DIgnoreConstructor(std::string s, int i) {}
|
||||
DIgnoreConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreOnlyConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreOnlyConstructor() {}
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
|
||||
%{
|
||||
class DIgnoreConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreConstructor() {}
|
||||
DIgnoreConstructor(std::string s, int i) {}
|
||||
private: // Hide constructor
|
||||
DIgnoreConstructor(bool b) {}
|
||||
};
|
||||
|
||||
class DIgnoreOnlyConstructor
|
||||
{
|
||||
public:
|
||||
virtual ~DIgnoreOnlyConstructor() {}
|
||||
private: // Hide constructor
|
||||
DIgnoreOnlyConstructor(bool b) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace TopLevel
|
|||
%nspace TopLevel::B::Foo;
|
||||
#else
|
||||
#warning nspace feature not yet supported in this target language
|
||||
%ignore TopLevel::B::Foo;
|
||||
#endif
|
||||
|
||||
%feature("director") TopLevel::A::Foo;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ public:
|
|||
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
|
||||
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
|
||||
#endif
|
||||
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%include <std_string.i>
|
||||
%include <boost_shared_ptr.i>
|
||||
|
||||
|
|
@ -60,4 +66,7 @@ public:
|
|||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
92
Examples/test-suite/enum_macro.i
Normal file
92
Examples/test-suite/enum_macro.i
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
%module enum_macro
|
||||
|
||||
%inline %{
|
||||
enum Greeks1
|
||||
{
|
||||
#define GREEK1 -1
|
||||
alpha1=1,
|
||||
beta1,
|
||||
theta1
|
||||
};
|
||||
|
||||
enum Greeks2
|
||||
{
|
||||
alpha2 = 2,
|
||||
#define GREEK2 -2
|
||||
beta2,
|
||||
theta2
|
||||
};
|
||||
|
||||
enum Greeks3
|
||||
{
|
||||
alpha3,
|
||||
beta3,
|
||||
#define GREEK3 -3
|
||||
theta3
|
||||
};
|
||||
|
||||
enum Greeks4
|
||||
{
|
||||
alpha4 = 4,
|
||||
beta4 = 5,
|
||||
theta4 = 6
|
||||
#define GREEK4 -4
|
||||
};
|
||||
|
||||
enum Greeks5
|
||||
{
|
||||
#define GREEK5 -5
|
||||
alpha5,
|
||||
beta5,
|
||||
};
|
||||
|
||||
enum Greeks6
|
||||
{
|
||||
alpha6,
|
||||
#define GREEK6 -6
|
||||
beta6,
|
||||
};
|
||||
|
||||
enum Greeks7
|
||||
{
|
||||
alpha7,
|
||||
beta7,
|
||||
#define GREEK7 -7
|
||||
};
|
||||
|
||||
enum Greeks8
|
||||
{
|
||||
#define GREEK8 -8
|
||||
theta8
|
||||
};
|
||||
|
||||
enum Greeks9
|
||||
{
|
||||
theta9
|
||||
#define GREEK9 -9
|
||||
};
|
||||
|
||||
enum Greeks10
|
||||
{
|
||||
#define GREEK10 -10
|
||||
theta10,
|
||||
};
|
||||
|
||||
enum Greeks11
|
||||
{
|
||||
theta11,
|
||||
#define GREEK11 -11
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
theta12 = 0
|
||||
#define GREEK12 -12
|
||||
} Greeks12;
|
||||
%}
|
||||
|
||||
|
||||
enum Greeks13
|
||||
{
|
||||
#define GREEK13 -13
|
||||
};
|
||||
|
||||
|
|
@ -188,6 +188,16 @@ pp_variable_args.i:6: Error: Variable length macro argument must be last paramet
|
|||
:::::::::::::::::::::::::::::::: swig_apply_nargs.i :::::::::::::::::::::::::::::::::::
|
||||
swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_extend.i :::::::::::::::::::::::::::::::::::
|
||||
swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name 'StructBName' should be used instead of the typedef name 'StructB'.
|
||||
swig_extend.i:45: Warning 326: Deprecated %extend name used - the struct name 'stru_struct' should be used instead of the typedef name 'stru'.
|
||||
swig_extend.i:56: Warning 326: Deprecated %extend name used - the union name 'uni_union' should be used instead of the typedef name 'uni'.
|
||||
swig_extend.i:34: Warning 303: %extend defined for an undeclared class StructDName.
|
||||
swig_extend.i:50: Warning 522: Use of an illegal constructor name 'stru' in %extend is deprecated, the constructor name should be 'stru_struct'.
|
||||
swig_extend.i:53: Warning 523: Use of an illegal destructor name 'stru' in %extend is deprecated, the destructor name should be 'stru_struct'.
|
||||
swig_extend.i:57: Warning 522: Use of an illegal constructor name 'uni' in %extend is deprecated, the constructor name should be 'uni_union'.
|
||||
swig_extend.i:58: Warning 523: Use of an illegal destructor name 'uni' in %extend is deprecated, the destructor name should be 'uni_union'.
|
||||
|
||||
:::::::::::::::::::::::::::::::: swig_identifier.i :::::::::::::::::::::::::::::::::::
|
||||
swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier.
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ pp_unterm_comment
|
|||
pp_unterm_string
|
||||
pp_variable_args
|
||||
swig_apply_nargs
|
||||
swig_extend
|
||||
swig_identifier
|
||||
swig_insert_bad
|
||||
swig_typemap_copy
|
||||
|
|
|
|||
60
Examples/test-suite/errors/swig_extend.i
Normal file
60
Examples/test-suite/errors/swig_extend.i
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
%module xxx
|
||||
|
||||
typedef struct {
|
||||
int myint;
|
||||
} StructA;
|
||||
|
||||
typedef struct StructBName {
|
||||
int myint;
|
||||
} StructB;
|
||||
|
||||
typedef struct StructC {
|
||||
int myint;
|
||||
} StructC;
|
||||
|
||||
%extend StructA {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
%extend StructB {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
%extend StructC {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
struct StructD {
|
||||
int myint;
|
||||
};
|
||||
typedef struct StructD StructDName;
|
||||
|
||||
%extend StructDName {
|
||||
void method() {}
|
||||
}
|
||||
|
||||
|
||||
typedef struct stru_struct {
|
||||
int bar;
|
||||
} stru;
|
||||
typedef union uni_union {
|
||||
int un1;
|
||||
double un2;
|
||||
} uni;
|
||||
|
||||
%extend stru {
|
||||
stru() {
|
||||
stru* s = (stru*)malloc(sizeof(stru));
|
||||
s->bar = 11;
|
||||
return s;
|
||||
}
|
||||
~stru() {
|
||||
free($self);
|
||||
}
|
||||
}
|
||||
|
||||
%extend uni {
|
||||
uni() { return 0; }
|
||||
~uni() { free($self); }
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,12 @@
|
|||
%module extend_constructor_destructor
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) Space::tagCStruct;
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagEStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) Space::tagCStruct::CStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) Space::tagCStruct::~CStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_CONSTRUCTOR) tagEStruct::EStruct;
|
||||
%warnfilter(SWIGWARN_LANG_EXTEND_DESTRUCTOR) tagEStruct::~EStruct;
|
||||
|
||||
%inline %{
|
||||
int globalVar = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
%module extend_typedef_class
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCClass;
|
||||
%warnfilter(SWIGWARN_PARSE_EXTEND_NAME) tagCStruct;
|
||||
|
||||
// classes in global namespace
|
||||
%inline %{
|
||||
typedef struct tagAClass {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"./constover"
|
||||
"fmt"
|
||||
"os"
|
||||
"./constover"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ func main() {
|
|||
if special_variable_macros.TestMary(name) != "SWIGTYPE_p_NameWrap" {
|
||||
panic("test failed")
|
||||
}
|
||||
if special_variable_macros.TestJames(name) != "SWIGTYPE_Name" {
|
||||
panic("test failed")
|
||||
}
|
||||
if special_variable_macros.TestJim(name) != "multiname num" {
|
||||
panic("test failed")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import . "./template_typedef_cplx3"
|
|||
func main() {
|
||||
// this is OK
|
||||
|
||||
|
||||
s := NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import . "./template_typedef_cplx4"
|
|||
func main() {
|
||||
// this is OK
|
||||
|
||||
|
||||
s := NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import "template_typedef_import"
|
|||
func main() {
|
||||
// this is OK
|
||||
|
||||
|
||||
s := template_typedef_import.NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@
|
|||
# Makefile for guile test-suite
|
||||
#######################################################################
|
||||
|
||||
EXTRA_TEST_CASES += guile_ext_test.externaltest
|
||||
|
||||
LANGUAGE = guile
|
||||
VARIANT = _gh
|
||||
VARIANT =
|
||||
SCRIPTSUFFIX = _runme.scm
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
GUILE = @GUILE@
|
||||
GUILE_RUNTIME=-runtime
|
||||
GUILE_RUNTIME=
|
||||
|
||||
C_TEST_CASES = long_long \
|
||||
list_vector \
|
||||
|
|
@ -20,7 +22,7 @@ C_TEST_CASES = long_long \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# none!
|
||||
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
%.multicpptest: SWIGOPT += $(GUILE_RUNTIME)
|
||||
|
|
@ -41,11 +43,16 @@ include $(srcdir)/../common.mk
|
|||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.externaltest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_external)
|
||||
$(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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts.so"))
|
||||
(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts"))
|
||||
(load "../schemerunme/casts.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant.so"))
|
||||
(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant"))
|
||||
(load "../schemerunme/char_constant.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore.so"))
|
||||
(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore"))
|
||||
(load "../schemerunme/class_ignore.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover.so"))
|
||||
(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover"))
|
||||
(load "../schemerunme/constover.scm")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract.so"))
|
||||
(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract"))
|
||||
(load "testsuite.scm")
|
||||
(load "../schemerunme/contract.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum.so"))
|
||||
(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum"))
|
||||
(load "../schemerunme/cpp_enum.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace.so"))
|
||||
(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace"))
|
||||
(load "../schemerunme/cpp_namespace.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast.so"))
|
||||
(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast"))
|
||||
(load "../schemerunme/dynamic_cast.scm")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include <ext_test_wrap_hdr.h>
|
||||
#include <guile_ext_test_wrap_hdr.h>
|
||||
#include <imports_a.h>
|
||||
|
||||
SCM test_create()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so"))
|
||||
(dynamic-call "scm_init_guile_ext_test_module" (dynamic-link "./libguile_ext_test"))
|
||||
|
||||
; This is a test for SF Bug 1573892
|
||||
; If IsPointer is called before TypeQuery, the test-is-pointer will fail
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule.so"))
|
||||
(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule"))
|
||||
(load "../schemerunme/import_nomodule.scm")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a.so"))
|
||||
(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b.so"))
|
||||
(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a"))
|
||||
(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b"))
|
||||
(load "../schemerunme/imports.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing.so"))
|
||||
(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing"))
|
||||
(load "../schemerunme/inherit_missing.scm")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers.so"))
|
||||
(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers"))
|
||||
|
||||
(define-macro (throws-exception? form)
|
||||
`(catch #t
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so"))
|
||||
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string"))
|
||||
(load "../schemerunme/li_std_string.scm")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so"))
|
||||
(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps"))
|
||||
(load "../schemerunme/li_typemaps.scm")
|
||||
|
||||
(let ((lst (inoutr-int2 3 -2)))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector.so"))
|
||||
(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector"))
|
||||
(load "../schemerunme/list_vector.scm")
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue.so"))
|
||||
(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue"))
|
||||
(load "../schemerunme/multivalue.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_name_module" (dynamic-link "./libname.so"))
|
||||
(dynamic-call "scm_init_name_module" (dynamic-link "./libname"))
|
||||
(load "../schemerunme/name.scm")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated.so"))
|
||||
(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated"))
|
||||
|
||||
(define-macro (check form)
|
||||
`(if (not ,form)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy.so"))
|
||||
(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy"))
|
||||
(load "../schemerunme/overload_copy.scm")
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend.so"))
|
||||
(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend"))
|
||||
(load "../schemerunme/overload_extend.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple.so"))
|
||||
(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple"))
|
||||
(load "../schemerunme/overload_simple.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype.so"))
|
||||
(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype"))
|
||||
(load "../schemerunme/overload_subtype.scm")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out.so"))
|
||||
(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out"))
|
||||
(load "../schemerunme/pointer_in_out.scm")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
; copied from python runme_.py
|
||||
(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars.so"))
|
||||
(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars"))
|
||||
(load "../schemerunme/reference_global_vars.scm")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so"))
|
||||
(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception"))
|
||||
|
||||
(define-macro (check-throw form)
|
||||
`(catch 'swig-exception
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit.so"))
|
||||
(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit"))
|
||||
(load "../schemerunme/typedef_inherit.scm")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename.so"))
|
||||
;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes.so"))
|
||||
(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename"))
|
||||
;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes"))
|
||||
(load "../schemerunme/typename.scm")
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions.so"))
|
||||
(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions"))
|
||||
(load "../schemerunme/unions.scm")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%module guilescm_ext_test
|
||||
%module guile_ext_test
|
||||
|
||||
/* just use the imports_a.h header... for this test we only need a class */
|
||||
%{
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#######################################################################
|
||||
# Makefile for guile test-suite (with SCM API)
|
||||
#######################################################################
|
||||
|
||||
EXTRA_TEST_CASES += guilescm_ext_test.externaltest
|
||||
|
||||
include ../guile/Makefile
|
||||
|
||||
# Overridden variables here
|
||||
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guilescm
|
||||
VARIANT =
|
||||
# Refer to the guile directory for the run scripts
|
||||
SCRIPTPREFIX = ../guile/
|
||||
GUILE_RUNTIME=
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
||||
# 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 $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
|
||||
fi
|
||||
|
||||
%.externaltest:
|
||||
$(local_setup)
|
||||
+$(swig_and_compile_external)
|
||||
$(local_run_testcase)
|
||||
|
||||
# Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory)
|
||||
local_setup = \
|
||||
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \
|
||||
fi
|
||||
|
||||
local_run_testcase = \
|
||||
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
|
@ -46,7 +46,6 @@
|
|||
Foo(double){ ii = 2;}
|
||||
explicit Foo(char *s){ii = 3;}
|
||||
Foo(const Foo& f){ ii = f.ii;}
|
||||
|
||||
};
|
||||
|
||||
struct Bar
|
||||
|
|
@ -57,11 +56,61 @@
|
|||
Bar(const Foo& ff){ ii = ff.ii;}
|
||||
};
|
||||
|
||||
|
||||
int get_b(const Bar&b) { return b.ii; }
|
||||
|
||||
Foo foo;
|
||||
|
||||
}
|
||||
|
||||
%template(A_int) A_T<int>;
|
||||
|
||||
|
||||
/****************** None handling *********************/
|
||||
|
||||
%inline
|
||||
{
|
||||
struct BB {};
|
||||
struct AA
|
||||
{
|
||||
int ii;
|
||||
AA(int i) { ii = 1; }
|
||||
AA(double d) { ii = 2; }
|
||||
AA(const B* b) { ii = 3; }
|
||||
explicit AA(char *s) { ii = 4; }
|
||||
AA(const BB& b) { ii = 5; }
|
||||
|
||||
int get() const { return ii; }
|
||||
};
|
||||
|
||||
int get_AA_val(AA a) { return a.ii; }
|
||||
int get_AA_ref(const AA& a) { return a.ii; }
|
||||
}
|
||||
|
||||
|
||||
/****************** Overloading priority *********************/
|
||||
|
||||
%inline %{
|
||||
class BBB {
|
||||
public:
|
||||
BBB(const B &) {}
|
||||
};
|
||||
|
||||
class CCC {
|
||||
public:
|
||||
CCC(const BBB &) : checkvalue(0) {}
|
||||
int xx(int i) { return 11; }
|
||||
int xx(const A& i) { return 22; }
|
||||
int yy(int i, int j) { return 111; }
|
||||
int yy(const A& i, const A& j) { return 222; }
|
||||
int checkvalue;
|
||||
};
|
||||
%}
|
||||
|
||||
// CCC(const BBB &) was being called instead of this constructor (independent of being added via %extend)
|
||||
%extend CCC {
|
||||
CCC(const B& b) {
|
||||
CCC* ccc = new CCC(b);
|
||||
ccc->checkvalue = 10;
|
||||
return ccc;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,16 @@
|
|||
unsigned long unsigned_long_identity(unsigned long x) { return x; }
|
||||
signed long long signed_long_long_identity(signed long long x) { return x; }
|
||||
unsigned long long unsigned_long_long_identity(unsigned long long x) { return x; }
|
||||
|
||||
size_t signed_char_size() { return sizeof (signed char); }
|
||||
size_t unsigned_char_size() { return sizeof (unsigned char); }
|
||||
size_t signed_short_size() { return sizeof (signed short); }
|
||||
size_t unsigned_short_size() { return sizeof (unsigned short); }
|
||||
size_t signed_int_size() { return sizeof (signed int); }
|
||||
size_t unsigned_int_size() { return sizeof (unsigned int); }
|
||||
size_t signed_long_size() { return sizeof (signed long); }
|
||||
size_t unsigned_long_size() { return sizeof (unsigned long); }
|
||||
size_t signed_long_long_size() { return sizeof (signed long long); }
|
||||
size_t unsigned_long_long_size() { return sizeof (unsigned long long); }
|
||||
%}
|
||||
|
||||
|
|
|
|||
93
Examples/test-suite/java/enum_macro_runme.java
Normal file
93
Examples/test-suite/java/enum_macro_runme.java
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
import enum_macro.*;
|
||||
|
||||
public class enum_macro_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("enum_macro");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
{
|
||||
Greeks1 a = Greeks1.alpha1;
|
||||
a = Greeks1.beta1;
|
||||
a = Greeks1.theta1;
|
||||
if (a.swigValue() != 3)
|
||||
throw new RuntimeException("Greeks1");
|
||||
}
|
||||
{
|
||||
Greeks2 a = Greeks2.alpha2;
|
||||
a = Greeks2.beta2;
|
||||
a = Greeks2.theta2;
|
||||
if (a.swigValue() != 4)
|
||||
throw new RuntimeException("Greeks2");
|
||||
}
|
||||
{
|
||||
Greeks3 a = Greeks3.alpha3;
|
||||
a = Greeks3.beta3;
|
||||
a = Greeks3.theta3;
|
||||
if (a.swigValue() != 2)
|
||||
throw new RuntimeException("Greeks3");
|
||||
}
|
||||
{
|
||||
Greeks4 a = Greeks4.alpha4;
|
||||
a = Greeks4.beta4;
|
||||
a = Greeks4.theta4;
|
||||
if (a.swigValue() != 6)
|
||||
throw new RuntimeException("Greeks4");
|
||||
}
|
||||
{
|
||||
Greeks5 a = Greeks5.alpha5;
|
||||
a = Greeks5.beta5;
|
||||
if (a.swigValue() != 1)
|
||||
throw new RuntimeException("Greeks5");
|
||||
}
|
||||
{
|
||||
Greeks6 a = Greeks6.alpha6;
|
||||
a = Greeks6.beta6;
|
||||
if (a.swigValue() != 1)
|
||||
throw new RuntimeException("Greeks6");
|
||||
}
|
||||
{
|
||||
Greeks7 a = Greeks7.alpha7;
|
||||
a = Greeks7.beta7;
|
||||
if (a.swigValue() != 1)
|
||||
throw new RuntimeException("Greeks7");
|
||||
}
|
||||
{
|
||||
Greeks8 a = Greeks8.theta8;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks8");
|
||||
}
|
||||
{
|
||||
Greeks9 a = Greeks9.theta9;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks9");
|
||||
}
|
||||
{
|
||||
Greeks10 a = Greeks10.theta10;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks10");
|
||||
}
|
||||
{
|
||||
Greeks11 a = Greeks11.theta11;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks11");
|
||||
}
|
||||
{
|
||||
Greeks12 a = Greeks12.theta12;
|
||||
if (a.swigValue() != 0)
|
||||
throw new RuntimeException("Greeks12");
|
||||
}
|
||||
{
|
||||
Greeks13 a = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -22,6 +22,8 @@ public class special_variable_macros_runme {
|
|||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testMary(name).equals("SWIGTYPE_p_NameWrap"))
|
||||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testJames(name).equals("SWIGTYPE_Name"))
|
||||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testJim(name).equals("multiname num"))
|
||||
throw new RuntimeException("test failed");
|
||||
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
%module(directors="1") java_director_assumeoverride
|
||||
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
|
||||
|
||||
%{
|
||||
class OverrideMe {
|
||||
|
|
|
|||
110
Examples/test-suite/li_attribute_template.i
Normal file
110
Examples/test-suite/li_attribute_template.i
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
%module li_attribute_template
|
||||
|
||||
%include <exception.i>
|
||||
|
||||
//#define SWIG_ATTRIBUTE_TEMPLATE
|
||||
%include <attribute.i>
|
||||
%include <std_string.i>
|
||||
|
||||
%inline
|
||||
{
|
||||
class Foo {
|
||||
public:
|
||||
Foo( int _value ) { value = _value; }
|
||||
int value;
|
||||
};
|
||||
|
||||
template< class T1, class T2>
|
||||
struct pair{
|
||||
pair( T1 t1, T2 t2 ):
|
||||
first(t1), second(t2) {;}
|
||||
|
||||
T1 first;
|
||||
T2 second;
|
||||
};
|
||||
|
||||
template< class T1, class T2>
|
||||
struct C
|
||||
{
|
||||
C(int a, int b, int c) :
|
||||
_a(a), _b(b), _c(c), _d(a), _e(b),
|
||||
_f(a,b), _g(b,c)
|
||||
{
|
||||
|
||||
/*
|
||||
_f.first = _a;
|
||||
_f.second = _b;
|
||||
|
||||
_g.first = _b;
|
||||
_g.second = _c;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
int get_value() const
|
||||
{
|
||||
return _a;
|
||||
}
|
||||
|
||||
void set_value(int aa)
|
||||
{
|
||||
_a = aa;
|
||||
}
|
||||
|
||||
/* only one ref method */
|
||||
int& get_ref()
|
||||
{
|
||||
return _b;
|
||||
}
|
||||
|
||||
Foo get_class_value() const { return _d; }
|
||||
void set_class_value( Foo foo) { _d = foo; }
|
||||
|
||||
const Foo& get_class_ref() const { return _e; }
|
||||
void set_class_ref( const Foo& foo ) { _e = foo; }
|
||||
|
||||
pair<T1,T2> get_template_value() const { return _f; }
|
||||
void set_template_value( const pair<T1,T2> f ) { _f = f; }
|
||||
|
||||
const pair<T1,T2>& get_template_ref() const { return _g; }
|
||||
void set_template_ref( const pair<T1,T2>& g ) { _g = g; }
|
||||
|
||||
std::string get_string() { return str; }
|
||||
void set_string(std::string other) { str = other; }
|
||||
|
||||
private:
|
||||
int _a;
|
||||
int _b;
|
||||
int _c;
|
||||
Foo _d;
|
||||
Foo _e;
|
||||
pair<T1,T2> _f;
|
||||
pair<T1,T2> _g;
|
||||
|
||||
std::string str;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
%define %instantiate_C( T1, T2 )
|
||||
%template (pair_ ## T1 ## T2 ) pair<T1,T2>;
|
||||
// Primitive types
|
||||
%attribute( %arg(C<T1,T2>), int, a, get_value, set_value );
|
||||
%attributeref( %arg(C<T1,T2>), int, b, get_ref );
|
||||
|
||||
// Strings
|
||||
%attributestring(%arg(C<T1,T2>), std::string, str, get_string, set_string);
|
||||
|
||||
// Class types
|
||||
%attributeval( %arg(C<T1,T2>), Foo, d, get_class_value, set_class_value );
|
||||
%attribute2( %arg(C<T1,T2>), Foo, e, get_class_ref, set_class_ref );
|
||||
|
||||
// Moderately templated types
|
||||
%attributeval( %arg(C<T1,T2>), %arg(pair<T1,T2>), f, get_template_value, set_template_value );
|
||||
%attribute2( %arg(C<T1,T2>), %arg(pair<T1,T2>), g, get_template_ref, set_template_ref );
|
||||
|
||||
%template (C ## T1 ## T2) C<T1,T2>;
|
||||
%enddef
|
||||
|
||||
|
||||
%instantiate_C(int,int);
|
||||
|
|
@ -13,9 +13,12 @@
|
|||
%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived;
|
||||
%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived;
|
||||
|
||||
%inline %{
|
||||
#include "boost/shared_ptr.hpp"
|
||||
#include "boost/intrusive_ptr.hpp"
|
||||
%{
|
||||
template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
|
||||
template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/detail/atomic_count.hpp>
|
||||
|
||||
// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
|
||||
|
|
@ -102,8 +105,6 @@
|
|||
|
||||
%ignore IgnoredRefCountingBase;
|
||||
%ignore *::operator=;
|
||||
%ignore intrusive_ptr_add_ref;
|
||||
%ignore intrusive_ptr_release;
|
||||
%newobject pointerownertest();
|
||||
%newobject smartpointerpointerownertest();
|
||||
|
||||
|
|
@ -430,10 +431,6 @@ template <class T1, class T2> struct Pair : Base<T1, T2> {
|
|||
Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
|
||||
SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
|
||||
|
||||
template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
|
||||
|
||||
template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
|
||||
|
||||
long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
|
||||
return sptr.use_count();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@
|
|||
* if there were also functions throwing 'std::logic_error' and
|
||||
* 'std::exception' then the bug would not be fully replicated */
|
||||
|
||||
%{
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
%}
|
||||
|
||||
%{
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
%feature("trackobjects");
|
||||
|
||||
%include std_pair.i
|
||||
%include std_map.i
|
||||
%include std_multimap.i
|
||||
|
||||
%inline %{
|
||||
|
|
@ -20,6 +19,5 @@ struct A{
|
|||
namespace std
|
||||
{
|
||||
%template(pairA) pair<int, A*>;
|
||||
%template(mapA) map<int, A*>;
|
||||
%template(multimapA) multimap<int, A*>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,14 @@ wchar_t* test_cvalue(wchar_t* x) {
|
|||
}
|
||||
|
||||
|
||||
wchar_t* test_wchar_overload() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
wchar_t* test_wchar_overload(wchar_t *x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
std::wstring test_value(std::wstring x) {
|
||||
return x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
%{
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
// Fix Tcl.h and Windows.h cat and mouse over definition of VOID
|
||||
#if defined(_TCL) && defined(__CYGWIN__)
|
||||
#ifdef VOID
|
||||
#undef VOID
|
||||
#endif
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
// Use equivalent types for non-windows systems
|
||||
|
|
|
|||
|
|
@ -42,16 +42,22 @@ assert(f3.num==32)
|
|||
f4=cb.Foo(6)
|
||||
cb.Bar_global_fptr=f4
|
||||
assert(cb.Bar_global_fptr.num==6)
|
||||
assert(cb.Bar.global_fptr.num==6)
|
||||
f4.num=8
|
||||
assert(cb.Bar_global_fptr.num==8)
|
||||
assert(cb.Bar.global_fptr.num==8)
|
||||
|
||||
assert(cb.Bar_global_fref.num==23)
|
||||
assert(cb.Bar.global_fref.num==23)
|
||||
cb.Bar_global_fref=cb.Foo(-7) -- this will set the value
|
||||
assert(cb.Bar_global_fref.num==-7)
|
||||
assert(cb.Bar.global_fref.num==-7)
|
||||
|
||||
assert(cb.Bar_global_fval.num==3)
|
||||
assert(cb.Bar.global_fval.num==3)
|
||||
cb.Bar_global_fval=cb.Foo(-34)
|
||||
assert(cb.Bar_global_fval.num==-34)
|
||||
assert(cb.Bar.global_fval.num==-34)
|
||||
|
||||
-- Now test member function pointers
|
||||
func1_ptr=cb.get_func1_ptr()
|
||||
|
|
|
|||
53
Examples/test-suite/naturalvar_more.i
Normal file
53
Examples/test-suite/naturalvar_more.i
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
%module naturalvar_more
|
||||
|
||||
// The instantiation of a template using an enum in the template parameter was not picking up %naturalvar.
|
||||
|
||||
// These typemaps will be used if %naturalvar is not working
|
||||
%typemap(out) T<Space::E> *te, T<Space::E> *const_te "_should_not_use_this_out_typemap_"
|
||||
%typemap(varout) T<Space::E> *te, T<Space::E> *const_te "_should_not_use_this_varout_typemap_"
|
||||
%typemap(out) Hidden *hidden "_should_not_use_this_out_typemap_"
|
||||
%typemap(varout) Hidden *hidden "_should_not_use_this_varout_typemap_"
|
||||
|
||||
%naturalvar T<Space::E>;
|
||||
%naturalvar Hidden;
|
||||
|
||||
%inline %{
|
||||
template <typename X> struct T {};
|
||||
struct K {};
|
||||
struct Hidden;
|
||||
namespace Ace {
|
||||
int glob;
|
||||
}
|
||||
%}
|
||||
%{
|
||||
struct Hidden {};
|
||||
namespace Ace {
|
||||
template<typename> struct NoIdea {};
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
enum E { E1, E2, E3 };
|
||||
}
|
||||
%}
|
||||
|
||||
%template(TE) T<Space::E>;
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%template(VectorString) std::vector<std::string>;
|
||||
|
||||
%inline {
|
||||
using namespace Space;
|
||||
struct S {
|
||||
T<E> te;
|
||||
const T<E> const_te;
|
||||
const std::vector<std::string>::value_type const_string_member; // check this resolves to std::string which has a naturalvar
|
||||
std::vector<std::string>::value_type string_member; // check this resolves to std::string which has a naturalvar
|
||||
Hidden hidden;
|
||||
Ace::NoIdea<Hidden> noidea;
|
||||
S() : const_te(), const_string_member("initial string value") {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#######################################################################
|
||||
|
||||
LANGUAGE = octave
|
||||
OCTAVE = @OCTAVE@ -qf
|
||||
OCTAVE = @OCTAVE@
|
||||
SCRIPTSUFFIX = _runme.m
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
# This is the import runtime testcase.
|
||||
|
||||
imports_b;
|
||||
imports_a;
|
||||
# Workaround seg fault occurring during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6
|
||||
if (compare_versions(version(), "3.3", ">="))
|
||||
imports_b;
|
||||
imports_a;
|
||||
|
||||
x = imports_b.B();
|
||||
x.hello();
|
||||
x = imports_b.B();
|
||||
x.hello();
|
||||
|
||||
a = imports_a.A();
|
||||
a = imports_a.A();
|
||||
|
||||
c = imports_b.C();
|
||||
a1 = c.get_a(c);
|
||||
a2 = c.get_a_type(c);
|
||||
c = imports_b.C();
|
||||
a1 = c.get_a(c);
|
||||
a2 = c.get_a_type(c);
|
||||
|
||||
a1.hello();
|
||||
a2.hello();
|
||||
assert(swig_this(a1)==swig_this(a2));
|
||||
assert(strcmp(swig_type(a1),swig_type(a2)));
|
||||
a1.hello();
|
||||
a2.hello();
|
||||
assert(swig_this(a1)==swig_this(a2));
|
||||
assert(strcmp(swig_type(a1),swig_type(a2)));
|
||||
endif
|
||||
|
||||
|
|
|
|||
51
Examples/test-suite/overload_numeric.i
Normal file
51
Examples/test-suite/overload_numeric.i
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
%module overload_numeric
|
||||
|
||||
// Tests overloading of integral and floating point types to verify the range checking required
|
||||
// for dispatch to the correct overloaded method
|
||||
|
||||
#ifdef SWIGLUA
|
||||
// lua only has one numeric type, so most of the overloads shadow each other creating warnings
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over;
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
struct Limits {
|
||||
signed char schar_min() { return SCHAR_MIN; }
|
||||
signed char schar_max() { return SCHAR_MAX; }
|
||||
short shrt_min() { return SHRT_MIN; }
|
||||
short shrt_max() { return SHRT_MAX; }
|
||||
int int_min() { return INT_MIN; }
|
||||
int int_max() { return INT_MAX; }
|
||||
float flt_min() { return FLT_MIN; }
|
||||
float flt_max() { return FLT_MAX; }
|
||||
double dbl_max() { return DBL_MAX; }
|
||||
};
|
||||
|
||||
struct Nums {
|
||||
const char * over(signed char v) {
|
||||
return "signed char";
|
||||
}
|
||||
const char * over(short v) {
|
||||
return "short";
|
||||
}
|
||||
const char * over(int v) {
|
||||
return "int";
|
||||
}
|
||||
const char * over(float v) {
|
||||
return "float";
|
||||
}
|
||||
const char * over(double v) {
|
||||
return "double";
|
||||
}
|
||||
double doublebounce(double v) {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -57,9 +57,9 @@ missingtests: missingcpptests missingctests
|
|||
# found, runs testcase.php, except for multicpptests.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \
|
||||
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \
|
||||
fi
|
||||
|
||||
# Clean: remove the generated .php file
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#ifdef SWIGGUILE
|
||||
/* A silly testing typemap for feeding a doubly indirect integer */
|
||||
%typemap(in) int *&XYZZY (int temp1, int *temp2) {
|
||||
temp1 = gh_scm2int($input); temp2 = &temp1; $1 = &temp2;
|
||||
temp1 = scm_to_int($input); temp2 = &temp1; $1 = &temp2;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
const double & ($basetype temp)
|
||||
%{ temp = ($basetype)$input; $1 = &temp; %}
|
||||
|
||||
the other tipical change is to add the enum SWIGTYPE to the
|
||||
the other typical change is to add the enum SWIGTYPE to the
|
||||
integer throws typemaps:
|
||||
|
||||
%typemap(throws) int,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ CPP_TEST_CASES += \
|
|||
li_std_wstream \
|
||||
li_std_wstring \
|
||||
primitive_types \
|
||||
python_abstractbase \
|
||||
python_abstractbase \
|
||||
python_append \
|
||||
python_director \
|
||||
python_nondynamic \
|
||||
|
|
@ -110,16 +110,19 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
|
|||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
|
@ -139,17 +142,17 @@ run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PY
|
|||
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
|
||||
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
|
||||
|
||||
ifeq (,$(PY3))
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(run_python);\
|
||||
fi
|
||||
|
||||
ifeq (,$(PY3))
|
||||
convert_testcase =
|
||||
else
|
||||
run_testcase = \
|
||||
convert_testcase = \
|
||||
if [ -f $(py2_runme) ]; then \
|
||||
$(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \
|
||||
elif [ -f $(py3_runme) ]; then \
|
||||
$(run_python); \
|
||||
$(MAKE) -f $(srcdir)/Makefile $(py3_runme); \
|
||||
fi
|
||||
endif
|
||||
|
||||
|
|
@ -162,6 +165,9 @@ endif
|
|||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
|
||||
rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
|
||||
rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
|
||||
rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
|
||||
rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py
|
||||
|
||||
cvsignore:
|
||||
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from autodoc import *
|
||||
import sys
|
||||
|
||||
def check(got, expected):
|
||||
if expected != got:
|
||||
|
|
@ -121,22 +122,24 @@ check(A.func3static.__doc__, "\n"
|
|||
" "
|
||||
)
|
||||
|
||||
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
|
||||
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
|
||||
check(A.variable_c.__doc__, "\n"
|
||||
"A_variable_c_get(self) -> int\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
" self: A *\n"
|
||||
"\n"
|
||||
)
|
||||
check(A.variable_d.__doc__, "\n"
|
||||
"A_variable_d_get(A self) -> int\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
" self: A *\n"
|
||||
"\n"
|
||||
)
|
||||
if sys.version_info[0:2] > (2, 4):
|
||||
# Python 2.4 does not seem to work
|
||||
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
|
||||
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
|
||||
check(A.variable_c.__doc__, "\n"
|
||||
"A_variable_c_get(self) -> int\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
" self: A *\n"
|
||||
"\n"
|
||||
)
|
||||
check(A.variable_d.__doc__, "\n"
|
||||
"A_variable_d_get(A self) -> int\n"
|
||||
"\n"
|
||||
"Parameters:\n"
|
||||
" self: A *\n"
|
||||
"\n"
|
||||
)
|
||||
|
||||
check(B.__doc__, "Proxy of C++ B class")
|
||||
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import sys
|
||||
import file_test
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
if sys.version_info[0:2] < (3, 0):
|
||||
file_test.nfile(sys.stdout)
|
||||
|
||||
cstdout = file_test.GetStdOut()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@ check(1, A(1).get())
|
|||
check(2, A(1.0).get())
|
||||
check(3, A(B()).get())
|
||||
check(4, A("hello").get())
|
||||
try:
|
||||
check(3, A(None).get())
|
||||
raise RuntimeError
|
||||
except ValueError:
|
||||
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
||||
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
||||
# references and pointers to different types, where pointers ought to be given a slightly higher precedence.
|
||||
pass
|
||||
|
||||
check(1, get(1))
|
||||
check(2, get(1.0))
|
||||
|
|
@ -71,3 +79,47 @@ try:
|
|||
except TypeError:
|
||||
pass
|
||||
|
||||
#### Class testing None ####
|
||||
|
||||
# No implicit conversion
|
||||
check(1, AA(1).get())
|
||||
check(2, AA(1.0).get())
|
||||
check(3, AA(B()).get())
|
||||
check(3, AA(None).get())
|
||||
check(4, AA("hello").get())
|
||||
check(5, AA(BB()).get())
|
||||
|
||||
check(1, get_AA_val(1))
|
||||
check(2, get_AA_val(1.0))
|
||||
check(3, get_AA_val(B()))
|
||||
check(3, get_AA_val(None))
|
||||
check(5, get_AA_val(BB()))
|
||||
|
||||
# Explicit constructor:
|
||||
try:
|
||||
check(4, get_AA_val("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
check(1, get_AA_ref(1))
|
||||
check(2, get_AA_ref(1.0))
|
||||
check(3, get_AA_ref(B()))
|
||||
check(3, get_AA_ref(None))
|
||||
check(5, get_AA_ref(BB()))
|
||||
|
||||
# Explicit constructor:
|
||||
try:
|
||||
check(4, get_AA_ref("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
### overloading priority test ###
|
||||
|
||||
ccc = CCC(B())
|
||||
check(ccc.checkvalue, 10)
|
||||
check(ccc.xx(123), 11)
|
||||
check(ccc.yy(123, 123), 111)
|
||||
|
||||
|
|
|
|||
67
Examples/test-suite/python/li_attribute_template_runme.py
Normal file
67
Examples/test-suite/python/li_attribute_template_runme.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# Check usage of template attributes
|
||||
|
||||
import li_attribute_template
|
||||
|
||||
chell = li_attribute_template.Cintint(1,2,3)
|
||||
|
||||
def rassert( what, master ):
|
||||
if what != master:
|
||||
print what
|
||||
raise RuntimeError
|
||||
|
||||
## Testing primitive by value attribute
|
||||
rassert( chell.a, 1 )
|
||||
|
||||
chell.a = 3
|
||||
rassert( chell.a, 3 )
|
||||
|
||||
## Testing primitive by ref attribute
|
||||
|
||||
rassert( chell.b, 2 )
|
||||
|
||||
chell.b = 5
|
||||
rassert( chell.b,5 )
|
||||
|
||||
## Testing string
|
||||
chell.str = "abc"
|
||||
rassert( chell.str, "abc" )
|
||||
|
||||
# Testing class by value
|
||||
|
||||
rassert( chell.d.value, 1 )
|
||||
|
||||
chell.d = li_attribute_template.Foo(2)
|
||||
rassert( chell.d.value, 2 )
|
||||
|
||||
# Testing class by reference
|
||||
|
||||
rassert( chell.e.value, 2 )
|
||||
|
||||
chell.e= li_attribute_template.Foo(3)
|
||||
rassert( chell.e.value, 3 )
|
||||
|
||||
chell.e.value = 4
|
||||
rassert( chell.e.value, 4 )
|
||||
|
||||
# Testing moderately complex template by value
|
||||
rassert( chell.f.first, 1 )
|
||||
rassert( chell.f.second, 2 )
|
||||
|
||||
pair = li_attribute_template.pair_intint(3,4)
|
||||
chell.f = pair
|
||||
rassert( chell.f.first, 3 )
|
||||
rassert( chell.f.second, 4 )
|
||||
|
||||
# Testing moderately complex template by ref
|
||||
rassert( chell.g.first, 2 )
|
||||
rassert( chell.g.second, 3 )
|
||||
|
||||
pair = li_attribute_template.pair_intint(4,5)
|
||||
chell.g = pair
|
||||
rassert( chell.g.first, 4 )
|
||||
rassert( chell.g.second, 5 )
|
||||
|
||||
chell.g.first = 6
|
||||
chell.g.second = 7
|
||||
rassert( chell.g.first, 6 )
|
||||
rassert( chell.g.second, 7 )
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# Check std::vector and std::list behaves the same as Python iterable types (list)
|
||||
|
||||
from li_std_containers_int import *
|
||||
import sys
|
||||
|
||||
def failed(a, b, msg):
|
||||
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
|
||||
|
|
@ -76,10 +77,13 @@ def container_insert_step(i, j, step, newval):
|
|||
except IndexError, e:
|
||||
il_error = e
|
||||
|
||||
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
||||
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
||||
# Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html
|
||||
skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6))
|
||||
if not(skip_check):
|
||||
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
||||
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
||||
|
||||
compare_containers(ps, iv, il)
|
||||
compare_containers(ps, iv, il)
|
||||
|
||||
|
||||
# Check std::vector and std::list delete behaves same as Python list delete including exceptions
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ if li_std_wstring.test_ccvalue(x) != x:
|
|||
if li_std_wstring.test_cvalue(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_wchar_overload(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_value(x) != x:
|
||||
print x, li_std_wstring.test_value(x)
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
|
|
|||
43
Examples/test-suite/python/overload_numeric_runme.py
Normal file
43
Examples/test-suite/python/overload_numeric_runme.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
from overload_numeric import *
|
||||
import math
|
||||
|
||||
nums = Nums()
|
||||
limits = Limits()
|
||||
|
||||
def check(got, expected):
|
||||
if got != expected:
|
||||
raise RuntimeError("got: " + got + " expected: " + expected)
|
||||
|
||||
check(nums.over(0), "signed char")
|
||||
check(nums.over(0.0), "float")
|
||||
|
||||
check(nums.over(limits.schar_min()), "signed char")
|
||||
check(nums.over(limits.schar_max()), "signed char")
|
||||
|
||||
check(nums.over(limits.schar_min()-1), "short")
|
||||
check(nums.over(limits.schar_max()+1), "short")
|
||||
check(nums.over(limits.shrt_min()), "short")
|
||||
check(nums.over(limits.shrt_max()), "short")
|
||||
|
||||
check(nums.over(limits.shrt_min()-1), "int")
|
||||
check(nums.over(limits.shrt_max()+1), "int")
|
||||
check(nums.over(limits.int_min()), "int")
|
||||
check(nums.over(limits.int_max()), "int")
|
||||
|
||||
check(nums.over(limits.flt_min()), "float")
|
||||
check(nums.over(limits.flt_max()), "float")
|
||||
|
||||
check(nums.over(limits.flt_max()*10), "double")
|
||||
check(nums.over(-limits.flt_max()*10), "double")
|
||||
check(nums.over(limits.dbl_max()), "double")
|
||||
check(nums.over(-limits.dbl_max()), "double")
|
||||
|
||||
check(nums.over(float("inf")), "float")
|
||||
check(nums.over(float("-inf")), "float")
|
||||
check(nums.over(float("nan")), "float")
|
||||
|
||||
# Just check if the following are accepted without exceptions being thrown
|
||||
nums.doublebounce(float("inf"))
|
||||
nums.doublebounce(float("-inf"))
|
||||
nums.doublebounce(float("nan"))
|
||||
|
|
@ -275,10 +275,22 @@ try:
|
|||
except TypeError:
|
||||
if a != t.var_char:
|
||||
error = 1
|
||||
pass
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad char typemap"
|
||||
|
||||
try:
|
||||
error = 0
|
||||
a = t.var_ushort
|
||||
t.var_ushort = -1
|
||||
error = 1
|
||||
except OverflowError:
|
||||
if a != t.var_ushort:
|
||||
error = 1
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad ushort typemap"
|
||||
|
||||
try:
|
||||
error = 0
|
||||
a = t.var_uint
|
||||
|
|
@ -287,10 +299,34 @@ try:
|
|||
except OverflowError:
|
||||
if a != t.var_uint:
|
||||
error = 1
|
||||
pass
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad uint typemap"
|
||||
|
||||
try:
|
||||
error = 0
|
||||
a = t.var_sizet
|
||||
t.var_sizet = -1
|
||||
error = 1
|
||||
except OverflowError:
|
||||
if a != t.var_sizet:
|
||||
error = 1
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad sizet typemap"
|
||||
|
||||
try:
|
||||
error = 0
|
||||
a = t.var_ulong
|
||||
t.var_ulong = -1
|
||||
error = 1
|
||||
except OverflowError:
|
||||
if a != t.var_ulong:
|
||||
error = 1
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad ulong typemap"
|
||||
|
||||
#
|
||||
#
|
||||
try:
|
||||
|
|
@ -301,7 +337,7 @@ try:
|
|||
except TypeError:
|
||||
if a != t.var_namet:
|
||||
error = 1
|
||||
pass
|
||||
pass
|
||||
if error:
|
||||
raise RuntimeError, "bad namet typemap"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,3 +2,10 @@ from python_append import *
|
|||
t=Test()
|
||||
t.func()
|
||||
t.static_func()
|
||||
|
||||
if grabpath() != os.path.dirname(mypath):
|
||||
raise RuntimeError
|
||||
|
||||
if grabstaticpath() != os.path.basename(mypath):
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
|||
|
|
@ -2,3 +2,6 @@ import python_varargs_typemap
|
|||
|
||||
if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") :
|
||||
raise RuntimeError("testfunc failed!")
|
||||
|
||||
if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") :
|
||||
raise RuntimeError("testfunc failed! {}")
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ if special_variable_macros.testJill(name) != "jilly":
|
|||
raise "test failed"
|
||||
if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
|
||||
raise "test failed"
|
||||
if special_variable_macros.testJames(name) != "SWIGTYPE_Name":
|
||||
raise "test failed"
|
||||
if special_variable_macros.testJim(name) != "multiname num":
|
||||
raise "test failed"
|
||||
if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123:
|
||||
|
|
|
|||
|
|
@ -23,10 +23,12 @@ except RuntimeError,e:
|
|||
try:
|
||||
t.hosed()
|
||||
except threads_exception.Exc,e:
|
||||
if e.code != 42:
|
||||
raise RuntimeError
|
||||
if e.msg != "Hosed":
|
||||
raise RuntimeError, "bad... msg: %s" % e.msg
|
||||
code = e.code
|
||||
if code != 42:
|
||||
raise RuntimeError, "bad... code: %d" % code
|
||||
msg = e.msg
|
||||
if msg != "Hosed":
|
||||
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
|
||||
|
||||
for i in range(1,4):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,25 +1,43 @@
|
|||
/*
|
||||
Testcase to test %pythonprepend and %pythonappend
|
||||
Testcase to test %pythonprepend and %pythonappend %pythoncode %pythonbegin
|
||||
*/
|
||||
|
||||
%module python_append
|
||||
|
||||
%pythoncode %{
|
||||
mypath = os.path.dirname("/a/b/c/d.txt")
|
||||
funcpath = None
|
||||
staticfuncpath = None
|
||||
def grabpath():
|
||||
return funcpath
|
||||
def grabstaticpath():
|
||||
return staticfuncpath
|
||||
%}
|
||||
|
||||
%pythonappend Test::func %{
|
||||
pass
|
||||
funcpath = os.path.dirname(funcpath)
|
||||
%}
|
||||
|
||||
%pythonprepend Test::func %{
|
||||
pass
|
||||
global funcpath
|
||||
funcpath = mypath
|
||||
%}
|
||||
|
||||
%pythonappend Test::static_func %{
|
||||
staticfuncpath = os.path.basename(staticfuncpath)
|
||||
pass
|
||||
%}
|
||||
|
||||
%pythonprepend Test::static_func {
|
||||
global staticfuncpath
|
||||
staticfuncpath = mypath
|
||||
pass
|
||||
}
|
||||
|
||||
%pythonbegin %{
|
||||
import os.path
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
class Test {
|
||||
|
|
|
|||
|
|
@ -4,13 +4,10 @@
|
|||
* chapter of the SWIG manual.
|
||||
*/
|
||||
|
||||
%{
|
||||
%}
|
||||
|
||||
%typemap(in) (...)(char *args[10]) {
|
||||
%typemap(in) (...)(char *vargs[10]) {
|
||||
int i;
|
||||
int argc;
|
||||
for (i = 0; i < 10; i++) args[i] = 0;
|
||||
for (i = 0; i < 10; i++) vargs[i] = 0;
|
||||
argc = PyTuple_Size(varargs);
|
||||
if (argc > 10) {
|
||||
PyErr_SetString(PyExc_ValueError, "Too many arguments");
|
||||
|
|
@ -26,7 +23,7 @@
|
|||
return NULL;
|
||||
}
|
||||
pystr = PyUnicode_AsUTF8String(pyobj);
|
||||
str = PyBytes_AsString(pystr);
|
||||
str = strdup(PyBytes_AsString(pystr));
|
||||
Py_XDECREF(pystr);
|
||||
%#else
|
||||
if (!PyString_Check(pyobj)) {
|
||||
|
|
@ -35,15 +32,24 @@
|
|||
}
|
||||
str = PyString_AsString(pyobj);
|
||||
%#endif
|
||||
args[i] = str;
|
||||
vargs[i] = str;
|
||||
}
|
||||
$1 = (void *) args;
|
||||
$1 = (void *)vargs;
|
||||
}
|
||||
|
||||
%feature("action") testfunc {
|
||||
char **args = (char **) arg3;
|
||||
result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
|
||||
args[5],args[6],args[7],args[8],args[9], NULL);
|
||||
char **vargs = (char **) arg3;
|
||||
result = testfunc(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
|
||||
vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
|
||||
}
|
||||
|
||||
%typemap(freearg) (...) {
|
||||
%#if PY_VERSION_HEX>=0x03000000
|
||||
int i;
|
||||
for (i = 0; i < 10; i++) {
|
||||
free(vargs$argnum[i]);
|
||||
}
|
||||
%#endif
|
||||
}
|
||||
|
||||
%inline {
|
||||
|
|
@ -51,10 +57,14 @@ char* testfunc (int arg1, double arg2, ...)
|
|||
{
|
||||
va_list ap;
|
||||
char *c;
|
||||
static char buffer[1024];
|
||||
buffer[0] = 0;
|
||||
va_start(ap, arg2);
|
||||
c = va_arg(ap, char*);
|
||||
while ((c = va_arg(ap, char *))) {
|
||||
strcat(buffer, c);
|
||||
}
|
||||
va_end(ap);
|
||||
return c;
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ C_TEST_CASES += \
|
|||
|
||||
CPP_TEST_CASES += \
|
||||
r_double_delete \
|
||||
r_overload_array
|
||||
r_overload_array \
|
||||
r_sexp
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
7
Examples/test-suite/r/r_sexp_runme.R
Normal file
7
Examples/test-suite/r/r_sexp_runme.R
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
source("unittest.R")
|
||||
dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep=""))
|
||||
source("r_sexp.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
obj <- return_sexp(1);
|
||||
unittest(obj, 1)
|
||||
10
Examples/test-suite/r_sexp.i
Normal file
10
Examples/test-suite/r_sexp.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module r_sexp
|
||||
|
||||
extern "C" SEXP return_sexp(SEXP x);
|
||||
|
||||
%inline %{
|
||||
SEXP return_sexp(SEXP x) {
|
||||
return x; //Rcpp NumericVector is automatically casted to SEXP
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ ruby_naming.cpptest: SWIGOPT += -autorename
|
|||
# a file is found which has _runme.rb appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I$(srcdir):. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ def _set(container)
|
|||
EOF
|
||||
end
|
||||
|
||||
def b_lessthan_a(b, a)
|
||||
res = b < a
|
||||
# print b, "<", a, "=", res
|
||||
return res
|
||||
end
|
||||
|
||||
def _map(container)
|
||||
swig_assert_each_line(<<EOF, binding)
|
||||
cont = #{container}.new
|
||||
|
|
@ -43,7 +49,7 @@ def _map(container)
|
|||
cont['w'] = 2
|
||||
cont.to_a == [['w',2],['x',8],['y',1],['z',9]]
|
||||
|
||||
cont = #{container}.new(proc { |a,b| b < a } )
|
||||
cont = #{container}.new(proc { |a,b| b_lessthan_a(b, a) } )
|
||||
cont['z'] = 9
|
||||
cont['y'] = 1
|
||||
cont['x'] = 8
|
||||
|
|
|
|||
|
|
@ -57,7 +57,14 @@ s = LanguageSet.new
|
|||
s.insert([1,2])
|
||||
s.insert(1)
|
||||
s.insert("hello")
|
||||
s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash}
|
||||
#s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash}
|
||||
# Test above is flawed as LanguageSet sorts by each element's hash, so the order will change from one invocation to the next. Sort a conversion to array instead.
|
||||
sa = s.to_a.sort { |x, y| x.to_s <=> y.to_s }
|
||||
sa == [1,[1,2],'hello']
|
||||
|
||||
EOF
|
||||
|
||||
iv = Set_int.new([0,1,2,3,4,5,6])
|
||||
iv.delete_if { |x| x == 0 || x == 3 || x == 6 }
|
||||
swig_assert_equal(iv.to_s, '1245', binding)
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,11 @@ y = average([1, 2, 3, 4])
|
|||
half([10, 10.5, 11, 11.5])
|
||||
EOF
|
||||
|
||||
iv = IntVector.new([0,1,2,3,4,5,6])
|
||||
iv.delete_if { |x| x == 0 || x == 3 || x == 6 }
|
||||
swig_assert_equal(iv.to_s, '1245', binding)
|
||||
|
||||
|
||||
dv = DoubleVector.new(10)
|
||||
|
||||
swig_assert( "dv.respond_to? :each_with_index", binding )
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue