Another merge with master.

Change Doxygen error codes to start at 740 instead of at 720 as the latter was
taken by Scilab in the meanwhile.

Resolve conflicts in autodoc_runme.py once again.
This commit is contained in:
Vadim Zeitlin 2015-02-16 23:46:39 +01:00
commit 300ccce46c
419 changed files with 18675 additions and 1315 deletions

View file

@ -8,6 +8,11 @@
%include "std_string.i"
#ifdef SWIGSCILAB
%rename(ProcBase) ProtectedBase;
%rename(PubBase) PublicBase;
#endif
%feature("director") PublicBase;
%feature("director") ProtectedBase;

View file

@ -4,6 +4,10 @@
%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 &};

View file

@ -1,5 +1,5 @@
/* Test %apply for char *, signed char *, unsigned char *
This won't work in all situations, so does not necessarily have to be implemented. See
/* 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
@ -7,6 +7,11 @@
%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};
@ -53,12 +58,12 @@ 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");

View file

@ -1,5 +1,9 @@
%module array_member
#if defined(SWIGSCILAB)
%rename(RayPkt) RayPacketData;
#endif
%inline %{
typedef struct Foo {

View file

@ -1,4 +1,9 @@
%module array_typedef_memberin
#if defined(SWIGSCILAB)
%rename(ExDetail) ExampleDetail;
#endif
%inline %{
typedef short Eight[8];
typedef const short ConstEight[8];

View file

@ -7,6 +7,10 @@ This test case tests that various types of arrays are working.
#include <stdlib.h>
%}
#if defined(SWIGSCILAB)
%rename(ArrSt) ArrayStruct;
#endif
%inline %{
#define ARRAY_LEN 2

View file

@ -2,16 +2,20 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) kMaxIOCTLSpaceParmsSize;
#define kMaxIOCTLSpaceParmsSize 128
#ifdef SWIGSCILAB
%rename(Parms) sm_channel_ix_dump_parms;
#endif
#define kMaxIOCTLSpaceParmsSize 128
%{
#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;
typedef struct sm_channel_ix_dump_parms {
unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
} SM_CHANNEL_IX_DUMP_PARMS;
%}

View file

@ -1,5 +1,10 @@
// 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 */

View file

@ -57,6 +57,22 @@
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;

View file

@ -9,13 +9,9 @@ below.
%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.
#ifdef SWIG_ALLEGRO_CL
%{
#include <stdio.h>
%}
#endif
%{
#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;

View file

@ -143,6 +143,7 @@ CPP_TEST_CASES += \
class_scope_weird \
compactdefaultargs \
const_const_2 \
constant_directive \
constant_pointers \
constover \
constructor_copy \
@ -298,6 +299,7 @@ CPP_TEST_CASES += \
nested_directors \
nested_comment \
nested_scope \
nested_template_base \
nested_workaround \
newobject1 \
null_pointer \
@ -306,6 +308,7 @@ CPP_TEST_CASES += \
operator_pointer_ref \
operbool \
ordering \
overload_arrays \
overload_bool \
overload_copy \
overload_extend \
@ -514,6 +517,7 @@ CPP11_TEST_CASES = \
cpp11_decltype \
cpp11_default_delete \
cpp11_delegating_constructors \
cpp11_director_enums \
cpp11_explicit_conversion_operators \
cpp11_final_override \
cpp11_function_objects \

View file

@ -0,0 +1,28 @@
%module constant_directive
// %constant and struct
%{
struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
};
static Type1 TYPE1_CONSTANT1(1);
static Type1 TYPE1_CONST2(2);
static Type1 TYPE1_CONST3(3);
%}
struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
};
%inline %{
Type1 getType1Instance() { return Type1(111); }
%}
%constant Type1 TYPE1_CONSTANT1;
%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
%constant int TYPE_INT = 0;

View file

@ -4,6 +4,11 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%module constant_pointers
#if defined(SWIGSCILAB)
%rename(MbrVar) MemberVariablesTest;
%rename(RetVal) ReturnValuesTest;
#endif
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */

View file

@ -5,13 +5,13 @@
%nocopyctor Bar<double>;
%inline %{
struct Foo1 {
int x;
Foo1(int _x = 2) : x(_x)
{
}
}
};
struct Foo2 {
@ -25,7 +25,7 @@ struct Foo3 {
struct Foo4 {
Foo4() { }
protected:
Foo4(const Foo4& ) { }
};
@ -33,7 +33,7 @@ protected:
struct Foo4a {
Foo4a() { }
private:
Foo4a(const Foo4a& ) { }
};
@ -53,7 +53,7 @@ struct Foo8 {
};
template <class T>
class Bar
class Bar
{
public:
int x;
@ -73,7 +73,7 @@ public:
%include "std_vector.i"
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT)
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB)
#define SWIG_GOOD_VECTOR
%ignore std::vector<Space::Flow>::vector(size_type);
%ignore std::vector<Space::Flow>::resize(size_type);
@ -126,7 +126,7 @@ public:
template <class T>
struct ModelUtils_T {};
}
}
}
%}
@ -144,13 +144,13 @@ namespace Space1 {
class TotalReturnSwap {
public:
TotalReturnSwap() {}
};
};
template <class T>
class TotalReturnSwap_T {
public:
TotalReturnSwap_T() {}
};
};
}
}

View file

@ -1,14 +1,14 @@
%module constructor_exception
%inline %{
class Error {
class MyError {
};
class SomeClass {
public:
SomeClass(int x) {
if (x < 0) {
throw Error();
throw MyError();
}
}
};
@ -17,7 +17,7 @@ class Test {
SomeClass o;
public:
Test(int x) try : o(x) { }
catch (Error &) {
catch (MyError &) {
}
catch (int) {
}

View file

@ -20,9 +20,13 @@
Bar(){ }
Bar(int){ }
#if !defined(__SUNPRO_CC)
operator int() { return 0; }
#endif
operator int&() { static int num = 0; return num; }
#if !defined(__SUNPRO_CC)
operator Foo<T>() { return Foo<T>(); }
#endif
operator Foo<T>&() { return *(new Foo<T>()); }
};
}

View file

@ -18,6 +18,12 @@ struct ConstExpressions {
static const int LLL = 300;
constexpr int MMM() { return 400; }
constexpr const int NNN() { return 500; }
// Regression tests for support added in SWIG 3.0.4:
static constexpr const int JJJ1 = 101;
constexpr static int KKK1 = 201;
// Regression tests for https://github.com/swig/swig/issues/284 :
explicit constexpr ConstExpressions(int) { }
constexpr explicit ConstExpressions(double) { }
};
%}

View file

@ -0,0 +1,14 @@
%module(directors="1") cpp11_director_enums
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Cpp11DirectorEnumsCallback::g;
%director Cpp11DirectorEnumsCallback;
%inline %{
enum class Color { Red, Green, Blue=10 };
struct Cpp11DirectorEnumsCallback {
virtual Color f(Color c) = 0;
virtual const Color & g(const Color &c) = 0;
virtual ~Cpp11DirectorEnumsCallback() {}
};
%}

View file

@ -198,7 +198,7 @@ enum UnmanagedExceptions {
UnmanagedSystemException,
UnmanagedArgumentException,
UnmanagedArgumentNullException,
UnmanagedArgumentOutOfRangeException,
UnmanagedArgumentOutOfRangeException
};
void check_exception(UnmanagedExceptions e) {

View file

@ -77,17 +77,17 @@ public:
Number quadruple(Number n) {
n.Value *= 4;
return n;
};
}
Number times8(const Number& num) {
Number n(num);
n.Value *= 8;
return n;
};
}
Number times12(const Number* num) {
Number n(*num);
n.Value *= 12;
return n;
};
}
%}
// Test $csinput expansion

View file

@ -13,6 +13,27 @@
%inline %{
#include <string>
// All kinds of numbers: hex, octal (which pose special problems to Python), negative...
void trickyvalue1(int first, int pos = -1) {}
void trickyvalue2(int first, unsigned rgb = 0xabcdef) {}
void trickyvalue3(int first, int mode = 0644) {}
void doublevalue1(int first, double num = 0.0e-1) {}
void doublevalue2(int first, double num = -0.0E2) {}
// Long long arguments are not handled at Python level currently but still work.
void seek(long long offset = 0LL) {}
void seek2(unsigned long long offset = 0ULL) {}
void seek3(long offset = 0L) {}
void seek4(unsigned long offset = 0UL) {}
void seek5(unsigned long offset = 0U) {}
void seek6(unsigned long offset = 02U) {}
void seek7(unsigned long offset = 00U) {}
void seek8(unsigned long offset = 1U) {}
void seek9(long offset = 1L) {}
void seekA(long long offset = 1LL) {}
void seekB(unsigned long long offset = 1ULL) {}
// Anonymous arguments
int anonymous(int = 7771);
int anonymous(int x) { return x; }
@ -29,6 +50,12 @@
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
};
// using base class enum in a derived class
class DerivedEnumClass : public EnumClass {
public:
void accelerate(speed s = SLOW) { }
};
// casts
const char * casts1(const char *m = (const char *) NULL) {
char *ret = NULL;
@ -199,6 +226,7 @@ namespace Space {
struct Klass {
int val;
Klass(int val = -1) : val(val) {}
static Klass inc(int n = 1, const Klass& k = Klass()) { return Klass(k.val + n); }
};
Klass constructorcall(const Klass& k = Klass()) { return k; }

View file

@ -1,6 +1,12 @@
%module(directors="1") director_frob;
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
#ifdef SWIGSCILAB
%rename(cb) coreCallbacks;
%rename(On3dEngRedrawn) coreCallbacksOn3dEngineRedrawnData;
%rename (_On3dEngRedrawn) coreCallbacks_On3dEngineRedrawnData;
#endif
%header %{
#include <iostream>
%}
@ -17,7 +23,7 @@
virtual ~Alpha() { };
virtual const char* abs_method() = 0;
};
struct Bravo : Alpha
{
const char* abs_method()
@ -26,14 +32,14 @@
}
};
struct Charlie : Bravo
struct Charlie : Bravo
{
const char* abs_method()
{
return "Charlie::abs_method()";
}
};
struct Delta : Charlie
{
};
@ -50,7 +56,9 @@
public:
Ops() : num(0) {}
virtual ~Ops() {}
#if !defined(__SUNPRO_CC)
virtual operator int() { return 0; }
#endif
virtual operator int **() const {
return (int **) 0;
}

View file

@ -12,10 +12,14 @@ struct OverloadBase {
};
struct OverloadDerived1 : OverloadBase {
virtual void nnn(int vvv) {}
// virtual void nnn() {}
#if defined(__SUNPRO_CC)
virtual void nnn() {}
#endif
};
struct OverloadDerived2 : OverloadBase {
// virtual void nnn(int vvv) {}
#if defined(__SUNPRO_CC)
virtual void nnn(int vvv) {}
#endif
virtual void nnn() {}
};
%}

View file

@ -7,13 +7,13 @@
class Foo {
private:
std::string a;
std::string a_;
public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
virtual std::string getA() { return this->a; }
virtual void setA(std::string a) { this->a = a; }
virtual std::string getA() { return this->a_; }
virtual void setA(std::string a) { this->a_ = a; }
static Foo* get_self(Foo *slf) {return slf;}

View file

@ -8,7 +8,20 @@ enum ForwardEnum2 { CCC, DDD };
%}
%inline %{
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/* ISO C forbids forward references to ‘enum’ types [-Werror=pedantic] */
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#if !defined(__SUNPRO_C)
enum ForwardEnum1;
enum ForwardEnum2;
enum ForwardEnum2;
enum ForwardEnum3;
#endif
%}
%inline %{
enum ForwardEnum1 get_enum1() { return AAA; }
enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
return e;
@ -16,22 +29,25 @@ enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
%}
%inline %{
enum ForwardEnum2;
enum ForwardEnum2;
enum ForwardEnum2 get_enum2() { return CCC; }
enum ForwardEnum2 test_function2(enum ForwardEnum2 e) {
return e;
}
enum ForwardEnum2;
%}
%inline %{
enum ForwardEnum3;
enum ForwardEnum3 { EEE, FFF };
enum ForwardEnum3 get_enum3() { return EEE; }
enum ForwardEnum3 test_function3(enum ForwardEnum3 e) {
return e;
}
enum ForwardEnum3;
%}
%inline %{
#if !defined(__SUNPRO_C)
enum ForwardEnum2;
enum ForwardEnum3;
#endif
%}
#endif

View file

@ -1,6 +1,13 @@
%module enum_macro
%inline %{
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/* comma at end of enumerator list [-Werror=pedantic] */
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
enum Greeks1
{
#define GREEK1 -1

View file

@ -14,10 +14,10 @@ enum AVPixelFormat2 {
%}
%inline %{
typedef struct AVCodecContext {
typedef struct AVCodecCtx {
enum AVPixelFormat pix_fmt;
enum AVPixelFormat2 pix_fmt2;
} AVCodecContext;
} AVCodecCtx;
enum AVPixelFormat global_fmt;
enum AVPixelFormat2 global_fmt2;
@ -29,7 +29,7 @@ enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) {
return px;
}
const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
return px;
}
const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) {

4
Examples/test-suite/errors/.gitignore vendored Normal file
View file

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

View file

@ -1 +1 @@
c_extra_rblock.i:5: Error: Syntax error in input(1).
c_extra_rblock.i:5: Error: Syntax error. Extraneous '%}'

View file

@ -1 +1 @@
c_missing_semi.i:3: Error: Syntax error in input(1).
c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon.

View file

@ -1 +1 @@
cpp_extra_brackets.i:5: Error: Syntax error in input(3).
cpp_extra_brackets.i:5: Error: Unexpected ')'.

View file

@ -1 +1 @@
doxygen_unknown_command.i:4: Warning 720: Doxygen parser warning: unknown command "unknown".
doxygen_unknown_command.i:4: Warning 740: Doxygen parser warning: unknown command "unknown".

View file

@ -1 +1 @@
pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here

View file

@ -1 +1 @@
pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
pp_missing_endif.i:3: Error: Missing #endif for conditional starting here

View file

@ -0,0 +1,7 @@
%module xxx
/* %beginfile and %endoffile are internal directives inserted when %include is
* used. Users should never use them directly, but test coverage for this
* error message still seems useful to have.
*/
%includefile "dummy.i" %beginfile

View file

@ -0,0 +1 @@
pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here

View file

@ -1 +1 @@
pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block

View file

@ -0,0 +1,7 @@
%module xxx
/* This used to give the rather cryptic "Syntax error in input(1)." prior to
* SWIG 3.0.4. This testcase checks that the improved message is actually
* issued.
*/
%remane("typo") tyop;

View file

@ -0,0 +1 @@
pp_unknowndirective.i:7: Error: Unknown directive '%remane'.

View file

@ -0,0 +1,11 @@
%module xxx
#ifdef FOO
long long i;
/* Check we get an error for an unknown directive (this should be #elif).
* Unknown directives were silently ignored by SWIG < 3.0.3. */
#elsif defined(BAR)
long i;
#else
int i;
#endif

View file

@ -0,0 +1 @@
pp_unknowndirective2.i:7: Error: Unknown SWIG preprocessor directive: elsif (if this is a block of target language code, delimit it with %{ and %})

View file

@ -1 +1 @@
pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
pp_unterm_char.i:4: Error: Unterminated character constant

View file

@ -1 +1 @@
pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
pp_unterm_comment.i:3: Error: Unterminated comment

View file

@ -1 +1 @@
pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
pp_unterm_string.i:4: Error: Unterminated string constant

View file

@ -0,0 +1,5 @@
%module xxx
%{
int foo(int x);

View file

@ -0,0 +1 @@
pp_unterminated_block.i:3: Error: Unterminated %{ ... %} block

View file

@ -28,7 +28,10 @@ namespace Space {
%extend Space::ExtendTemplate
{
void extending() { $parentclassname tmp; }
void extending() {
$parentclassname tmp;
(void)tmp;
}
}
%template(ExtendTemplateInt) Space::ExtendTemplate<int>;

View file

@ -196,13 +196,13 @@ func main() {
}()
//Namespace
my := contract.NewMyClass(1)
contract.NewMyClass(1)
func() {
defer func() {
if recover() == nil {
panic("Failed! constructor preassertion")
}
}()
my = contract.NewMyClass(0)
contract.NewMyClass(0)
}()
}

View file

@ -0,0 +1,22 @@
import constant_directive.*;
public class constant_directive_runme {
static {
try {
System.loadLibrary("constant_directive");
} 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[]) {
if (constant_directive.TYPE1_CONSTANT1.getVal() != 1)
throw new RuntimeException("fail");
if (constant_directive.TYPE1_CONSTANT2.getVal() != 2)
throw new RuntimeException("fail");
if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
throw new RuntimeException("fail");
}
}

View file

@ -0,0 +1,27 @@
import nested_template_base.*;
public class nested_template_base_runme {
static {
try {
System.loadLibrary("nested_template_base");
} 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[]) {
OuterC.InnerS ois = new OuterC.InnerS(123);
OuterC.InnerC oic = new OuterC.InnerC();
// Check base method is available
if (oic.outer(ois).getVal() != 123)
throw new RuntimeException("Wrong value calling outer");
// Check non-derived class using base class
if (oic.innerc().outer(ois).getVal() != 123)
throw new RuntimeException("Wrong value calling innerc");
}
}

View file

@ -63,7 +63,7 @@ public class preproc_line_file_runme {
if (SillyMacroClass.LINE_NUM != 56)
throw new RuntimeException("preproc failure");
if (SillyMultipleMacroStruct.LINE_NUM != 81)
if (SillyMulMacroStruc.LINE_NUM != 81)
throw new RuntimeException("preproc failure");
if (preproc_line_file.INLINE_LINE != 87)

View file

@ -41,7 +41,7 @@ public class smart_pointer_const_overload_runme {
Assert(f.getAccess() == MUTABLE_ACCESS);
// Test static method
b.stat();
b.statMethod();
Assert(f.getAccess() == CONST_ACCESS);

View file

@ -45,6 +45,11 @@ public class template_default_class_parms_runme {
foo.setTType(a);
a = foo.method(a);
}
{
MapDefaults md = new MapDefaults();
md.test_func(10, 20, new DefaultNodeType());
}
}
}

View file

@ -6,6 +6,8 @@ LANGUAGE = javascript
NODEGYP = @NODEGYP@
NODEJS = @NODEJS@
SCRIPTSUFFIX = _runme.js
OBJEXT = @OBJEXT@
SO = @SO@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@ -116,10 +118,10 @@ endif
%.clean:
@rm -rf $*
@rm -f $*_wrap.* $*.so $*.o
@rm -f $*_wrap.* $*$(SO) $*.$(OBJEXT)
clean:
for ext in _wrap.cxx _wrap.o .so; do \
for ext in _wrap.cxx _wrap.$(OBJEXT) $(SO); do \
rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \
rm -f imports_a$${ext} imports_b$${ext}; \
rm -f import_stl_a$${ext} import_stl_b$${ext}; \

View file

@ -79,9 +79,9 @@
static const size_type hello = 3;
};
int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
int rfoo( int n = 0, const size_type& x = Hello::hello, const Hello& y = Hello() )
{
return x;
return n - x;
}
%}
%{

View file

@ -27,38 +27,38 @@
struct C
{
C(int a, int b, int c) :
_a(a), _b(b), _c(c), _d(a), _e(b),
a(a), b(b), c(c), d(a), _e(b),
_f(a,b), _g(b,c)
{
/*
_f.first = _a;
_f.second = _b;
_f.first = a;
_f.second = b;
_g.first = _b;
_g.second = _c;
_g.first = b;
_g.second = c;
*/
}
int get_value() const
{
return _a;
return a;
}
void set_value(int aa)
{
_a = aa;
a = aa;
}
/* only one ref method */
int& get_ref()
{
return _b;
return b;
}
Foo get_class_value() const { return _d; }
void set_class_value( Foo foo) { _d = foo; }
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; }
@ -73,10 +73,10 @@
void set_string(std::string other) { str = other; }
private:
int _a;
int _b;
int _c;
Foo _d;
int a;
int b;
int c;
Foo d;
Foo _e;
pair<T1,T2> _f;
pair<T1,T2> _g;

View file

@ -1,7 +1,7 @@
// This tests shared_ptr is working okay. It also checks that there are no memory leaks in the
// class that shared_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
// In order to test that there are no leaks of the shared_ptr class itself (as it is created on the heap)
// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
// like 'top'. There is a wrapper for shared_ptr in shared_ptr_wrapper.h which enables one to
// count the instances of shared_ptr. Uncomment the SHARED_PTR_WRAPPER macro to turn this on.
//
@ -11,6 +11,16 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
#if defined(SWIGSCILAB)
%rename(MbrVar) MemberVariables;
%rename(MbrVal) MemberVariables::MemberValue;
%rename(MbrPtr) MemberVariables::MemberPointer;
%rename(MbrRef) MemberVariables::MemberReference;
%rename(SmartMbrVal) MemberVariables::SmartMemberValue;
%rename(SmartMbrPtr) MemberVariables::SmartMemberPointer;
%rename(SmartMbrRef) MemberVariables::SmartMemberReference;
#endif
%inline %{
#include "boost/shared_ptr.hpp"
#include "swig_examples_lock.h"
@ -34,7 +44,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
@ -93,7 +103,7 @@ struct Klass {
static int getTotal_count() { return total_count; }
private:
// lock increment and decrement as a destructor could be called at the same time as a
// lock increment and decrement as a destructor could be called at the same time as a
// new object is being created - C# / Java, at least, have finalizers run in a separate thread
static SwigExamples::CriticalSection critical_section;
static void increment() { SwigExamples::Lock lock(critical_section); total_count++; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
@ -104,15 +114,15 @@ private:
};
SwigExamples::CriticalSection Space::Klass::critical_section;
struct IgnoredMultipleInheritBase {
struct IgnoredMultipleInheritBase {
IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
virtual ~IgnoredMultipleInheritBase() {}
double d;
virtual ~IgnoredMultipleInheritBase() {}
double d;
double e;
virtual void AVirtualMethod() {}
virtual void AVirtualMethod() {}
};
// For most compilers, this use of multiple inheritance results in different derived and base class
// For most compilers, this use of multiple inheritance results in different derived and base class
// pointer values ... for some more challenging tests :)
struct KlassDerived : IgnoredMultipleInheritBase, Klass {
KlassDerived() : Klass() {}
@ -254,7 +264,7 @@ long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) {
long use_count(const SwigBoost::shared_ptr<Klass>& sptr) {
return sptr.use_count();
}
const SwigBoost::shared_ptr<Klass>& ref_1() {
const SwigBoost::shared_ptr<Klass>& ref_1() {
static SwigBoost::shared_ptr<Klass> sptr;
return sptr;
}
@ -334,7 +344,11 @@ template <class T1, class T2> struct Base {
};
%}
#if !defined(SWIGSCILAB)
%template(BaseIntDouble) Base<int, double>;
#else
%template(BaseIDbl) Base<int, double>;
#endif
%inline %{
template <class T1, class T2> struct Pair : Base<T1, T2> {
@ -356,9 +370,9 @@ SwigBoost::shared_ptr< Pair<int, double> > pair_id1(SwigBoost::shared_ptr< Pair<
%inline %{
namespace SwigBoost {
const int NOT_COUNTING = -123456;
int shared_ptr_wrapper_count() {
int shared_ptr_wrapper_count() {
#ifdef SHARED_PTR_WRAPPER
return SwigBoost::SharedPtrWrapper::getTotalCount();
return SwigBoost::SharedPtrWrapper::getTotalCount();
#else
return NOT_COUNTING;
#endif

View file

@ -1,7 +1,7 @@
%module li_std_auto_ptr
%{
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation
#endif
%}

View file

@ -9,15 +9,23 @@
%template(PairIntString) std::pair<int, std::string>;
%template(VectorPairIntString) std::vector< std::pair<int, std::string> >;
%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
%template(VectorVectorString) std::vector< std::vector<std::string> >;
#if !defined(SWIGSCILAB)
%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;
#else
%template(PairIntVecStr) std::pair< int, std::vector<std::string> >;
%template(PairIntPairIntStr) std::pair< int, std::pair<int, std::string> >;
#endif
#if defined(SWIGCSHARP) || defined(SWIGD)
// Checks macro containing a type with a comma
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
#endif
%template(PairDoubleString) std::pair< double, std::string >;
%template(VectorPairDoubleString) std::vector< std::pair<double, std::string> >;

View file

@ -0,0 +1,132 @@
%module li_std_container_typemaps
%include stl.i
%include std_list.i
%include std_deque.i
%include std_set.i
%include std_multiset.i
%{
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <numeric>
using namespace std;
%}
%inline %{
class ClassA
{
public:
ClassA() : a(0) {}
ClassA(int _a) : a(_a) {}
ClassA(const ClassA& c) : a(c.a) {}
int a;
};
typedef ClassA* ClassAPtr;
enum _Color { RED=1, GREEN=10, YELLOW=11, BLUE=100, MAGENTA=101, CYAN=111 };
typedef enum _Color Color;
namespace std {
template<typename T> T binaryOperation(T x, T y) {
return static_cast<T>(x + y);
}
template<> bool binaryOperation(bool x, bool y) {
return x | y;
}
template<> ClassAPtr binaryOperation(ClassAPtr x, ClassAPtr y) {
if (x)
y->a += x->a;
return y;
}
template<typename SeqCont>
struct sequence_container {
typedef typename SeqCont::value_type value_type;
static SeqCont ret_container(const value_type value1, const value_type value2) {
SeqCont s;
s.insert(s.end(), value1);
s.insert(s.end(), value2);
return s;
}
static value_type val_container(const SeqCont container) {
return std::accumulate(container.begin(), container.end(), value_type(),
binaryOperation<value_type>);
}
static value_type ref_container(const SeqCont& container) {
return std::accumulate(container.begin(), container.end(), value_type(),
binaryOperation<value_type>);
}
};
template<typename T, class Container>
Container ret_container(const T value1, const T value2) {
return sequence_container<Container>::ret_container(value1, value2);
}
template<typename T, class Container>
T val_container(const Container container) {
return sequence_container<Container >::val_container(container);
}
template<typename T, class Container>
T ref_container(const Container& container) {
return sequence_container<Container >::ref_container(container);
}
}
%}
%define %instantiate_containers_templates(TYPE...)
namespace std
{
%template(TYPE ## _vector) std::vector<TYPE>;
%template(TYPE ## _list) std::list<TYPE>;
%template(TYPE ## _deque) std::deque<TYPE>;
%template(TYPE ## _set) std::set<TYPE>;
%template(TYPE ## _multiset) std::multiset<TYPE>;
}
%enddef
%define %instantiate_containers_functions(TYPE...)
namespace std
{
%template(ret_ ## TYPE ## _vector) ret_container<TYPE, std::vector<TYPE> >;
%template(val_ ## TYPE ## _vector) val_container<TYPE, std::vector<TYPE> >;
%template(ref_ ## TYPE ## _vector) ref_container<TYPE, std::vector<TYPE> >;
%template(ret_ ## TYPE ## _list) ret_container<TYPE, std::list<TYPE> >;
%template(val_ ## TYPE ## _list) val_container<TYPE, std::list<TYPE> >;
%template(ref_ ## TYPE ## _list) ref_container<TYPE, std::list<TYPE> >;
%template(ret_ ## TYPE ## _deque) ret_container<TYPE, std::deque<TYPE> >;
%template(val_ ## TYPE ## _deque) val_container<TYPE, std::deque<TYPE> >;
%template(ref_ ## TYPE ## _deque) ref_container<TYPE, std::deque<TYPE> >;
%template(ret_ ## TYPE ## _set) ret_container<TYPE, std::set<TYPE> >;
%template(val_ ## TYPE ## _set) val_container<TYPE, std::set<TYPE> >;
%template(ref_ ## TYPE ## _set) ref_container<TYPE, std::set<TYPE> >;
%template(ret_ ## TYPE ## _multiset) ret_container<TYPE, std::multiset<TYPE> >;
%template(val_ ## TYPE ## _multiset) val_container<TYPE, std::multiset<TYPE> >;
%template(ref_ ## TYPE ## _multiset) ref_container<TYPE, std::multiset<TYPE> >;
}
%enddef
%define %instantiate_containers_templates_and_functions(TYPE...)
%instantiate_containers_templates(TYPE);
%instantiate_containers_functions(TYPE);
%enddef
%instantiate_containers_templates_and_functions(int);
%instantiate_containers_templates_and_functions(double);
%instantiate_containers_templates_and_functions(float);
%instantiate_containers_templates_and_functions(bool);
%instantiate_containers_templates_and_functions(string);
%instantiate_containers_templates_and_functions(ClassAPtr);

View file

@ -83,6 +83,16 @@ void test_const_pointer_throw() throw(const std::string *) {
std::string *Structure::StaticMemberString2 };
*/
#ifdef SWIGSCILAB
%rename(St) MemberString;
%rename(Str) MemberString;
%rename(Str2) MemberString2;
%rename(StaticStr) StaticMemberString;
%rename(StaticStr2) StaticMemberString2;
%rename(ConstStr) ConstMemberString;
%rename(ConstStaticStr) ConstStaticMemberString;
#endif
%inline %{
std::string GlobalString;
std::string GlobalString2 = "global string 2";

View file

@ -12,6 +12,17 @@
#include <algorithm>
#include <functional>
#include <numeric>
#if defined(__clang__)
// Suppress:
// warning: destination for this 'memset' call is a pointer to dynamic class
// 'Test::B'; vtable pointer will be overwritten [-Wdynamic-class-memaccess]
// memset(v_def,0,sizeof(Type));
// Better generated code is probably needed though
#pragma clang diagnostic ignored "-Wdynamic-class-memaccess"
#endif
%}
namespace std {

View file

@ -3,7 +3,7 @@
%include <stdint.i>
%inline %{
struct StdInts {
struct StdI {
int8_t int8_member;
int16_t int16_member;
int32_t int32_member;
@ -23,7 +23,7 @@
uint32_t uint32_td(int32_t i) { return i; }
uint64_t uint64_td(int64_t i) { return i; }
struct StdIntFasts {
struct StdIf {
int_fast8_t int_fast8_member;
int_fast16_t int_fast16_member;
int_fast32_t int_fast32_member;
@ -43,7 +43,7 @@
uint_fast32_t uint_fast32_td(int_fast32_t i) { return i; }
uint_fast64_t uint_fast64_td(int_fast64_t i) { return i; }
struct StdIntLeasts {
struct StdIl {
int_least8_t int_least8_member;
int_least16_t int_least16_member;
int_least32_t int_least32_member;

View file

@ -13,28 +13,28 @@
#include <iostream>
struct XXX {
XXX(int v) : value(v) {
if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl;
if (debugging) std::cout << "Default Constructor " << value << " " << this << std::endl;
count++;
}
XXX(const XXX &other) {
value = other.value;
if (debug) std::cout << "Copy Constructor " << value << " " << this << std::endl;
if (debugging) std::cout << "Copy Constructor " << value << " " << this << std::endl;
count++;
}
XXX& operator=(const XXX &other) {
value = other.value;
if (debug) std::cout << "Assignment operator " << value << " " << this << std::endl;
if (debugging) std::cout << "Assignment operator " << value << " " << this << std::endl;
return *this;
}
~XXX() {
if (debug) std::cout << "Destructor " << value << " " << this << std::endl;
if (debugging) std::cout << "Destructor " << value << " " << this << std::endl;
count--;
}
void showInfo() {
if (debug) std::cout << "Info " << value << " " << this << std::endl;
if (debugging) std::cout << "Info " << value << " " << this << std::endl;
}
int value;
static const bool debug = false;
static const bool debugging = false;
static int count;
};
int XXX::count = 0;

View file

@ -1,4 +1,4 @@
/*
/*
This testcase tests that nested structs/unions work. Named structs/unions declared within
a struct produced redefinition errors in SWIG 1.3.6 as reported by SF bug #447488.
Also tests reported error when a #define placed in a deeply embedded struct/union.
@ -6,6 +6,13 @@ Also tests reported error when a #define placed in a deeply embedded struct/unio
%module nested
#if defined(SWIGSCILAB)
%rename(OutStNamed) OuterStructNamed;
%rename(InStNamed) OuterStructNamed::InnerStructNamed;
%rename(InUnNamed) OuterStructNamed::Inner_union_named;
#endif
%inline %{
struct TestStruct {
@ -22,6 +29,13 @@ struct OuterStructNamed {
} inner_union_named;
};
%}
#if !defined(SWIGSCILAB)
%inline %{
struct OuterStructUnnamed {
struct {
double xx;
@ -32,7 +46,6 @@ struct OuterStructUnnamed {
} inner_union_unnamed;
};
typedef struct OuterStruct {
union {
@ -52,3 +65,41 @@ typedef struct OuterStruct {
} OuterStruct;
%}
#else
%inline %{
struct OutStUnnamed {
struct {
double xx;
} inSt;
union {
double yy;
int zz;
} inUn;
};
typedef struct OutSt {
union {
struct nst_st {
union in_un {
#define BAD_STYLE 1
int red;
struct TestStruct green;
} InUn;
struct in_st {
int blue;
} InSt;
} NstdSt;
} EmbedUn;
} OutSt;
%}
#endif

View file

@ -1,5 +1,33 @@
%module nested_class
#if defined(SWIGSCILAB)
%rename(Out) Outer;
%rename(InSt1) InnerStruct1;
%rename(InCls1) InnerClass1;
%rename(InCls2) InnerClass2;
%rename(InClas3Inst) InnerClass3Instance;
%rename(InSt3Inst) InnerStruct3Instance;
%rename(InCls4Type) InnerClass4Typedef;
%rename(InSt4Type) InnerStruct4Typedef;
%rename(InCls5Type) InnerClass5Typedef;
%rename(InSt5Type) InnerStruct5Typedef;
%rename(InMul) InnerMultiple;
%rename(InMulDrv) InnerMultipleDerived;
%rename(MulInst1) MultipleInstance1;
%rename(MulInst2) MultipleInstance2;
%rename(MulInst3) MultipleInstance3;
%rename(MulInst4) MultipleInstance4;
%rename(MulDrvInst1) MultipleDerivedInstance1;
%rename(MulDrvInst2) MultipleDerivedInstance2;
%rename(MulDrvInst3) MultipleDerivedInstance3;
%rename(MulDrvInst4) MultipleDerivedInstance4;
%rename(MulInstAnnDrv1) MultipleInstanceAnonDerived1;
%rename(MulInstAnnDrv2) MultipleInstanceAnonDerived2;
%rename(MulInstAnnDrv3) MultipleInstanceAnonDerived3;
%rename(MulInstAnnDrv4) MultipleInstanceAnonDerived4;
#endif
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass1;
@ -21,6 +49,12 @@
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer2::IgnoreMe;
%inline %{
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
/* ISO C++ prohibits anonymous structs [-Werror=pedantic] */
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
struct Outer {
typedef int Integer;
///////////////////////////////////////////
@ -49,6 +83,9 @@ struct Outer {
struct {
Integer b;
};
#else
Integer a;
Integer b;
#endif
union {
@ -164,6 +201,9 @@ struct Outer {
public:
Integer yy;
};
#else
Integer xx;
Integer yy;
#endif
///////////////////////////////////////////

View file

@ -95,7 +95,7 @@ typedef struct {
} bar;
} FOO;
struct {
static struct {
int i;
} THING;
%}

View file

@ -26,39 +26,42 @@ namespace ns {
#endif
};
}
#ifndef __clang__
class Outer1 {
struct Nested1;
public:
struct Nested2;
template <class T> class Abstract;
#ifdef __clang__
struct Nested2 {
int data;
};
#endif
template <class T> class AbstractClass;
class Real;
};
#ifndef __clang__
struct Outer1::Nested2 {
int data;
};
#endif
class Class {
class Klass {
public:
template <class T> class Abstract;
template <class T> class AbstractClass;
class Real;
};
template <class T> class Class::Abstract {
template <class T> class Klass::AbstractClass {
public:
virtual void Method() = 0;
virtual ~AbstractClass() {}
};
#endif
%}
#ifndef __clang__
%template(abstract_int) Class::Abstract <int>;
#endif
%template(abstract_int) Klass::AbstractClass <int>;
%inline %{
#ifndef __clang__
class Class::Real : public Abstract <int> {
class Klass::Real : public AbstractClass <int> {
public:
virtual void Method() {}
};
#endif
%}

View file

@ -0,0 +1,38 @@
%module nested_template_base
%inline %{
template <class T> class OuterT {
public:
T outer(T t) { return t; }
};
%}
// The %template goes after OuterT and before OuterC as OuterC::InnerC's base is handled inside OuterC
%template(OuterTInnerS) OuterT<OuterC::InnerS>;
#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
%feature("flatnested") OuterC::InnerS;
%feature("flatnested") OuterC::InnerC;
#endif
%inline %{
class OuterC {
public:
struct InnerS;
class InnerC;
};
struct OuterC::InnerS {
int val;
InnerS(int val = 0) : val(val) {}
};
class OuterC::InnerC : public OuterT<InnerS> {
public:
OuterT<InnerS>& innerc() {
return *this;
}
};
%}

View file

@ -0,0 +1,566 @@
1;
li_boost_shared_ptr;
function verifyValue(expected, got)
if (expected ~= got)
error("verify value failed.");% Expected: ", expected, " Got: ", got)
end
endfunction
function verifyCount(expected, k)
got = use_count(k);
if (expected ~= got)
error("verify use_count failed. Expected: %d Got: %d ", expected, got);
end
endfunction
function runtest()
li_boost_shared_ptr; # KTTODO this needs to be here at present. Global module failure?
# simple shared_ptr usage - created in C++
k = Klass("me oh my");
val = k.getValue();
verifyValue("me oh my", val)
verifyCount(1, k)
# simple shared_ptr usage - not created in C++
k = factorycreate();
val = k.getValue();
verifyValue("factorycreate", val)
verifyCount(1, k)
# pass by shared_ptr
k = Klass("me oh my");
kret = smartpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointertest", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer
k = Klass("me oh my");
kret = smartpointerpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointertest", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr reference
k = Klass("me oh my");
kret = smartpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerreftest", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer reference
k = Klass("me oh my");
kret = smartpointerpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest", val)
verifyCount(2, k)
verifyCount(2, kret)
# const pass by shared_ptr
k = Klass("me oh my");
kret = constsmartpointertest(k);
val = kret.getValue();
verifyValue("me oh my", val)
verifyCount(2, k)
verifyCount(2, kret)
# const pass by shared_ptr pointer
k = Klass("me oh my");
kret = constsmartpointerpointertest(k);
val = kret.getValue();
verifyValue("me oh my", val)
verifyCount(2, k)
verifyCount(2, kret)
# const pass by shared_ptr reference
k = Klass("me oh my");
kret = constsmartpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by value
k = Klass("me oh my");
kret = valuetest(k);
val = kret.getValue();
verifyValue("me oh my valuetest", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by pointer
k = Klass("me oh my");
kret = pointertest(k);
val = kret.getValue();
verifyValue("me oh my pointertest", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by reference
k = Klass("me oh my");
kret = reftest(k);
val = kret.getValue();
verifyValue("me oh my reftest", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by pointer reference
k = Klass("me oh my");
kret = pointerreftest(k);
val = kret.getValue();
verifyValue("me oh my pointerreftest", val)
verifyCount(1, k)
verifyCount(1, kret)
# null tests
#KTODO None not defined
# k = None;
# if (smartpointertest(k) ~= None)
# error("return was not null")
# end
# if (smartpointerpointertest(k) ~= None)
# error("return was not null")
# end
# if (smartpointerreftest(k) ~= None)
# error("return was not null")
# end
# if (smartpointerpointerreftest(k) ~= None)
# error("return was not null")
# end
# if (nullsmartpointerpointertest(None) ~= "null pointer")
# error("not null smartpointer pointer")
# end
# # try:
# # valuetest(k)
# # error("Failed to catch null pointer")
# # except ValueError:
# # pass
# if (pointertest(k) ~= None)
# error("return was not null")
# end
# # try:
# # reftest(k)
# # error("Failed to catch null pointer")
# # except ValueError:
# # pass
# $owner
k = pointerownertest();
val = k.getValue();
verifyValue("pointerownertest", val)
verifyCount(1, k)
k = smartpointerpointerownertest();
val = k.getValue();
verifyValue("smartpointerpointerownertest", val)
verifyCount(1, k)
# //////////////////////////////// Derived class ////////////////////////////////////////
# derived pass by shared_ptr
k = KlassDerived("me oh my");
kret = derivedsmartptrtest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrtest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by shared_ptr pointer
k = KlassDerived("me oh my");
kret = derivedsmartptrpointertest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointertest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by shared_ptr ref
k = KlassDerived("me oh my");
kret = derivedsmartptrreftest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by shared_ptr pointer ref
k = KlassDerived("me oh my");
kret = derivedsmartptrpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by pointer
k = KlassDerived("me oh my");
kret = derivedpointertest(k);
val = kret.getValue();
verifyValue("me oh my derivedpointertest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# derived pass by ref
k = KlassDerived("me oh my");
kret = derivedreftest(k);
val = kret.getValue();
verifyValue("me oh my derivedreftest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# //////////////////////////////// Derived and base class mixed ////////////////////////////////////////
# pass by shared_ptr (mixed)
k = KlassDerived("me oh my");
kret = smartpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointertest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer (mixed)
k = KlassDerived("me oh my");
kret = smartpointerpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointertest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr reference (mixed)
k = KlassDerived("me oh my");
kret = smartpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer reference (mixed)
k = KlassDerived("me oh my");
kret = smartpointerpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by value (mixed)
k = KlassDerived("me oh my");
kret = valuetest(k);
val = kret.getValue();
verifyValue("me oh my valuetest", val) # note slicing
verifyCount(1, k)
verifyCount(1, kret)
# pass by pointer (mixed)
k = KlassDerived("me oh my");
kret = pointertest(k);
val = kret.getValue();
verifyValue("me oh my pointertest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by ref (mixed)
k = KlassDerived("me oh my");
kret = reftest(k);
val = kret.getValue();
verifyValue("me oh my reftest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# //////////////////////////////// Overloading tests ////////////////////////////////////////
# Base class
k = Klass("me oh my");
verifyValue(overload_rawbyval(k), "rawbyval")
verifyValue(overload_rawbyref(k), "rawbyref")
verifyValue(overload_rawbyptr(k), "rawbyptr")
verifyValue(overload_rawbyptrref(k), "rawbyptrref")
verifyValue(overload_smartbyval(k), "smartbyval")
verifyValue(overload_smartbyref(k), "smartbyref")
verifyValue(overload_smartbyptr(k), "smartbyptr")
verifyValue(overload_smartbyptrref(k), "smartbyptrref")
# Derived class
k = KlassDerived("me oh my");
verifyValue(overload_rawbyval(k), "rawbyval")
verifyValue(overload_rawbyref(k), "rawbyref")
verifyValue(overload_rawbyptr(k), "rawbyptr")
verifyValue(overload_rawbyptrref(k), "rawbyptrref")
verifyValue(overload_smartbyval(k), "smartbyval")
verifyValue(overload_smartbyref(k), "smartbyref")
verifyValue(overload_smartbyptr(k), "smartbyptr")
verifyValue(overload_smartbyptrref(k), "smartbyptrref")
# 3rd derived class
k = Klass3rdDerived("me oh my");
val = k.getValue();
verifyValue("me oh my-3rdDerived", val)
verifyCount(1, k)
val = test3rdupcast(k);
verifyValue("me oh my-3rdDerived", val)
verifyCount(1, k)
# //////////////////////////////// Member variables ////////////////////////////////////////
# smart pointer by value
m = MemberVariables();
k = Klass("smart member value");
m.SmartMemberValue = k;
val = k.getValue();
verifyValue("smart member value", val)
verifyCount(2, k)
kmember = m.SmartMemberValue;
val = kmember.getValue();
verifyValue("smart member value", val)
verifyCount(3, kmember)
verifyCount(3, k)
clear m
verifyCount(2, kmember)
verifyCount(2, k)
# smart pointer by pointer
m = MemberVariables();
k = Klass("smart member pointer");
m.SmartMemberPointer = k;
val = k.getValue();
verifyValue("smart member pointer", val)
verifyCount(1, k)
kmember = m.SmartMemberPointer;
val = kmember.getValue();
verifyValue("smart member pointer", val)
verifyCount(2, kmember)
verifyCount(2, k)
clear m
verifyCount(2, kmember)
verifyCount(2, k)
# smart pointer by reference
m = MemberVariables();
k = Klass("smart member reference");
m.SmartMemberReference = k;
val = k.getValue();
verifyValue("smart member reference", val)
verifyCount(2, k)
kmember = m.SmartMemberReference;
val = kmember.getValue();
verifyValue("smart member reference", val)
verifyCount(3, kmember)
verifyCount(3, k)
# The C++ reference refers to SmartMemberValue...
kmemberVal = m.SmartMemberValue;
val = kmember.getValue();
verifyValue("smart member reference", val)
verifyCount(4, kmemberVal)
verifyCount(4, kmember)
verifyCount(4, k)
clear m
verifyCount(3, kmemberVal)
verifyCount(3, kmember)
verifyCount(3, k)
# plain by value
m = MemberVariables();
k = Klass("plain member value");
m.MemberValue = k;
val = k.getValue();
verifyValue("plain member value", val)
verifyCount(1, k)
kmember = m.MemberValue;
val = kmember.getValue();
verifyValue("plain member value", val)
verifyCount(1, kmember)
verifyCount(1, k)
clear m
verifyCount(1, kmember)
verifyCount(1, k)
# plain by pointer
m = MemberVariables();
k = Klass("plain member pointer");
m.MemberPointer = k;
val = k.getValue();
verifyValue("plain member pointer", val)
verifyCount(1, k)
kmember = m.MemberPointer;
val = kmember.getValue();
verifyValue("plain member pointer", val)
verifyCount(1, kmember)
verifyCount(1, k)
clear m
verifyCount(1, kmember)
verifyCount(1, k)
# plain by reference
m = MemberVariables();
k = Klass("plain member reference");
m.MemberReference = k;
val = k.getValue();
verifyValue("plain member reference", val)
verifyCount(1, k)
kmember = m.MemberReference;
val = kmember.getValue();
verifyValue("plain member reference", val)
verifyCount(1, kmember)
verifyCount(1, k)
clear m
verifyCount(1, kmember)
verifyCount(1, k)
# null member variables
m = MemberVariables();
# shared_ptr by value
k = m.SmartMemberValue;
#KTODO None not defined
# if (k ~= None)
# error("expected null")
# end
# m.SmartMemberValue = None
# k = m.SmartMemberValue
# if (k ~= None)
# error("expected null")
# end
# verifyCount(0, k)
# # plain by value
# # try:
# # m.MemberValue = None
# # error("Failed to catch null pointer")
# # except ValueError:
# # pass
# # ////////////////////////////////// Global variables ////////////////////////////////////////
# # smart pointer
# kglobal = cvar.GlobalSmartValue
# if (kglobal ~= None)
# error("expected null")
# end
k = Klass("smart global value");
cvar.GlobalSmartValue = k;
verifyCount(2, k)
kglobal = cvar.GlobalSmartValue;
val = kglobal.getValue();
verifyValue("smart global value", val)
verifyCount(3, kglobal)
verifyCount(3, k)
verifyValue("smart global value", cvar.GlobalSmartValue.getValue())
#KTTODO cvar.GlobalSmartValue = None
# plain value
k = Klass("global value");
cvar.GlobalValue = k;
verifyCount(1, k)
kglobal = cvar.GlobalValue;
val = kglobal.getValue();
verifyValue("global value", val)
verifyCount(1, kglobal)
verifyCount(1, k)
verifyValue("global value", cvar.GlobalValue.getValue())
# try:
# cvar.GlobalValue = None
# error("Failed to catch null pointer")
# except ValueError:
# pass
# plain pointer
kglobal = cvar.GlobalPointer;
#KTODO if (kglobal ~= None)
#KTODO error("expected null")
#KTODO end
k = Klass("global pointer");
cvar.GlobalPointer = k;
verifyCount(1, k)
kglobal = cvar.GlobalPointer;
val = kglobal.getValue();
verifyValue("global pointer", val)
verifyCount(1, kglobal)
verifyCount(1, k)
#KTODO cvar.GlobalPointer = None
# plain reference
kglobal;
k = Klass("global reference");
cvar.GlobalReference = k;
verifyCount(1, k)
kglobal = cvar.GlobalReference;
val = kglobal.getValue();
verifyValue("global reference", val)
verifyCount(1, kglobal)
verifyCount(1, k)
# try:
# cvar.GlobalReference = None
# error("Failed to catch null pointer")
# except ValueError:
# pass
# ////////////////////////////////// Templates ////////////////////////////////////////
pid = PairIntDouble(10, 20.2);
if (pid.baseVal1 ~= 20 || pid.baseVal2 ~= 40.4)
error("Base values wrong")
end
if (pid.val1 ~= 10 || pid.val2 ~= 20.2)
error("Derived Values wrong")
end
endfunction
debug = false;%true;
if (debug)
fprintf( "Started\n" )
end
cvar.debug_shared = debug;
# Change loop count to run for a long time to monitor memory
loopCount = 1; #5000
for i=0:loopCount
runtest()
end
# Expect 1 instance - the one global variable (GlobalValue)
#KTTODO next fails, possibly because we commented GlobalSmartValue=None
#if (Klass.getTotal_count() ~= 1)
# error("Klass.total_count=%d", Klass.getTotal_count())
#end
wrapper_count = shared_ptr_wrapper_count() ;
#KTTODO next fails as NOT_COUNTING not in octave name space, so we hard-wire it here
#if (wrapper_count ~= NOT_COUNTING)
if (wrapper_count ~= -123456)
# Expect 1 instance - the one global variable (GlobalSmartValue)
if (wrapper_count ~= 1)
error("shared_ptr wrapper count=%s", wrapper_count)
end
end
if (debug)
fprintf( "Finished\n" )
end

View file

@ -73,12 +73,6 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
#ifdef SWIG_ALLEGRO_CL
%{
#include <stdio.h>
%}
#endif
#ifdef SWIGD
// Due to the way operator overloading is implemented in D1 and D2, the prefix
// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
@ -89,6 +83,7 @@ see bottom for a set of possible tests
%rename(DoubleCast) operator double();
%inline %{
#include <stdio.h>
#if defined(_MSC_VER)
#include <iso646.h> /* for named logical operator, eg 'operator or' */

View file

@ -0,0 +1,148 @@
// Tests of overloaded functions of arrays
// Based on overload_simple testcase
%module overload_arrays
#ifdef SWIGCHICKEN
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fbool;
#endif
#ifdef SWIGLUA
// lua only has one numeric type, so most of the overloads shadow each other creating warnings
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) bar;
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Spam;
#endif
#ifdef SWIGGO
%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
%rename(Foos) Foo;
#endif
#ifndef SWIG_NO_OVERLOAD
%immutable Spam::type;
%inline %{
#define SIZE 3
struct Foo {
};
class Bar {
public:
Bar(int i = 0) { num = i; }
static int foo(int a=0, int b=0) {return 0;}
int num;
};
char *foo() {
return (char *) "foo:";
}
char *foo(int[SIZE]) {
return (char*) "foo:int[SIZE]";
}
char *foo(double[SIZE]) {
return (char*) "foo:double[SIZE]";
}
char *foo(char *[SIZE]) {
return (char*) "foo:char *[SIZE]";
}
char *foo(Foo *[SIZE]) {
return (char*) "foo:Foo *[SIZE]";
}
char *foo(Bar *[SIZE]) {
return (char *) "foo:Bar *[SIZE]";
}
char *foo(void *[SIZE]) {
return (char *) "foo:void *[SIZE]";
}
char *foo(Foo *[SIZE], int[SIZE]) {
return (char *) "foo:Foo *[SIZE],int[SIZE]";
}
char *foo(double[SIZE], Bar *[SIZE]) {
return (char *) "foo:double[SIZE],Bar *[SIZE]";
}
char *blah(double[SIZE]) {
return (char *) "blah:double[SIZE]";
}
char *blah(char *[SIZE]) {
return (char *) "blah:char *[SIZE]";
}
class Spam {
public:
Spam() { type = "none"; }
Spam(int[SIZE]) { type = "int[SIZE]"; }
Spam(double[SIZE]) { type = "double[SIZE]"; }
Spam(char *[SIZE]) { type = "char *[SIZE]"; }
Spam(Foo *[SIZE]) { type = "Foo *[SIZE]"; }
Spam(Bar *[SIZE]) { type = "Bar *[SIZE]"; }
Spam(void *[SIZE]) { type = "void *[SIZE]"; }
const char *type;
char *foo(int[SIZE]) {
return (char*) "foo:int[SIZE]";
}
char *foo(double[SIZE]) {
return (char*) "foo:double[SIZE]";
}
char *foo(char *[SIZE]) {
return (char*) "foo:char *[SIZE]";
}
char *foo(Foo *[SIZE]) {
return (char*) "foo:Foo *[SIZE]";
}
char *foo(Bar *[SIZE]) {
return (char *) "foo:Bar *[SIZE]";
}
char *foo(void *[SIZE]) {
return (char *) "foo:void *[SIZE]";
}
static char *bar(int[SIZE]) {
return (char*) "bar:int[SIZE]";
}
static char *bar(double[SIZE]) {
return (char*) "bar:double[SIZE]";
}
static char *bar(char *[SIZE]) {
return (char*) "bar:char *[SIZE]";
}
static char *bar(Foo *[SIZE]) {
return (char*) "bar:Foo *[SIZE]";
}
static char *bar(Bar *[SIZE]) {
return (char *) "bar:Bar *[SIZE]";
}
static char *bar(void *[SIZE]) {
return (char *) "bar:void *[SIZE]";
}
};
%}
#endif
%inline {
class ClassA
{
public:
ClassA() {}
int method1( ) {return 0;}
int method1( int arg1[SIZE] ) {return arg1[0];}
protected:
int method1( int arg1[SIZE], int arg2[SIZE] ) {return arg1[0] + arg2[0];}
};
}

View file

@ -4,7 +4,7 @@ require "tests.php";
require "director_exception.php";
// No new functions
check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar));
check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
// No new classes
check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
// now new vars

View file

@ -3,6 +3,9 @@
require "tests.php";
require "director_thread.php";
# Fails in a ZTS-build of PHP - see: https://github.com/swig/swig/pull/155
exit(0);
// No new functions
check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
// No new classes

View file

@ -2,7 +2,7 @@
require "tests.php";
require "exception_order.php";
check::functions(array(a_foo,a_bar,a_foobar,a_barfoo));
check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));

View file

@ -3,7 +3,7 @@ require "tests.php";
require "import_nomodule.php";
// No new functions
check::functions(array(create_foo,delete_foo,test1));
check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
// No new classes
check::classes(array(import_nomodule,Bar));
// now new vars

View file

@ -4,9 +4,9 @@ require "tests.php";
require "threads_exception.php";
// Check functions
check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi));
check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
// Check classes.
check::classes(array(Exc,Test));
check::classes(array(Exc,Test,threads_exception));
// Chek globals.
check::globals(array(exc_code,exc_msg));

View file

@ -11,6 +11,13 @@
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
#pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */
%{
#if defined(__clang__)
//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
#pragma clang diagnostic ignored "-Wconstant-logical-operand"
#endif
%}
/* check __cplusplus case */
%header
%{
@ -225,8 +232,8 @@ This testcase tests operators for defines
#define A7 13 & 14
#define A8 15 | 16
#define A9 17 ^ 18
#define A10 19 && 20
#define A11 21 || 21
#define A10 1 && 0
#define A11 1 || 0
#define A12 ~22
#define A13 !23
@ -346,3 +353,20 @@ int method(struct TypeNameTraits tnt) {
return tnt.val;
}
%}
/* Null directive */
# /* comment 1 */
# // comment 2
# /** comment 3 */
# /* comment 4 */ /*comment 5*/
# /** comment 6
#
# more comment 6 */
#
#
#
int methodX(int x);
%{
int methodX(int x) { return x+100; }
%}

View file

@ -1,5 +1,12 @@
%module preproc_constants
%{
#if defined(__clang__)
//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
#pragma clang diagnostic ignored "-Wconstant-logical-operand"
#endif
%}
// Note: C types are slightly different to C++ types as (a && b) is int in C and bool in C++
// Simple constants
@ -102,3 +109,4 @@ enum MyEnum {
enum MyEnum {
kValue = BIT(2)
};

View file

@ -2,7 +2,7 @@
// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying)
#define MYLINE __LINE__
#define MYLINE_ADJUSTED __LINE__ + 100
#define MYLINE_ADJUSTED __LINE__ + 100
#define MYFILE __FILE__
#define MYFILE_ADJUSTED __FILE__ ".bak"
@ -78,7 +78,7 @@ struct NAME { \
int num; \
};
#endif
KLASS(SillyMultipleMacroStruct)
KLASS(SillyMulMacroStruc)
%}
%inline %{

View file

@ -1,6 +1,11 @@
// Massive primitive datatype test.
%module(directors="1") primitive_types
#if defined(SWIGSCILAB)
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) ovr_val;
%rename(TestDir) TestDirector;
#endif
%{
#if defined(_MSC_VER)
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
@ -322,10 +327,19 @@ macro(size_t, pfx, sizet)
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
// return 0;
}
}
%enddef
/* check variables (arrays can't be compared so compare as strings) */
%define var_array_check(type, pfx, name)
std::ostringstream a; std::ostringstream b;
a << pfx##_##name;
b << def_##name;
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
}
%enddef
/* check a function call */
%define call_check(type, pfx, name)
@ -337,7 +351,6 @@ macro(size_t, pfx, sizet)
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
// return 0;
}
}
%enddef
@ -456,7 +469,7 @@ macro(size_t, pfx, sizet)
{
%test_prim_types_stc(var_check, stc)
%test_prim_types(var_check, var)
var_check(namet, var, namet);
var_array_check(namet, var, namet);
return 1;
}
@ -540,7 +553,7 @@ macro(size_t, pfx, sizet)
{
%test_prim_types(var_check, cct)
%test_prim_types(var_check, var)
var_check(namet, var, namet);
var_array_check(namet, var, namet);
return 1;
}

View file

@ -11,6 +11,7 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
PEP8 = @PEP8@
PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
@ -126,13 +127,13 @@ py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
check_pep8 = \
if [ -n "$(PEP8)" ]; then \
$(PEP8) --ignore=E501,E30,W291,W391 $(SCRIPTPREFIX)$*.py;\
$(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py;\
fi
check_pep8_multi_cpp = \
if [ -n "$(PEP8)" ]; then \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(PEP8) --ignore=E501,E30,W291,W391 $$f.py; \
$(PEP8) $(PEP8_FLAGS) $$f.py; \
done \
fi

View file

@ -2,6 +2,13 @@ from autodoc import *
from commentVerifier import check
import sys
def is_new_style_class(cls):
return hasattr(cls, "__class__")
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is used!
sys.exit(0)
check(A.__doc__, "Proxy of C++ A class")
check(A.funk.__doc__, "just a string")
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")

View file

@ -0,0 +1,15 @@
import constant_directive
if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1):
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1)))
if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1):
raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance())))
if constant_directive.TYPE1_CONSTANT1.val != 1:
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val)
if constant_directive.TYPE1_CONSTANT2.val != 2:
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val)
if constant_directive.TYPE1_CONSTANT3.val != 3:
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val)

View file

@ -1,7 +1,16 @@
#!/usr/bin/evn python
from cpp_static import *
StaticFunctionTest.static_func()
StaticFunctionTest.static_func_2(1)
StaticFunctionTest.static_func_3(1,2)
def is_new_style_class(cls):
return hasattr(cls, "__class__")
if is_new_style_class(StaticFunctionTest):
StaticFunctionTest.static_func()
StaticFunctionTest.static_func_2(1)
StaticFunctionTest.static_func_3(1,2)
else:
StaticFunctionTest().static_func()
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1,2)
StaticMemberTest.static_int = 10
assert StaticMemberTest.static_int == 10

View file

@ -1,67 +1,98 @@
import default_args
# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
ec = default_args.EnumClass()
if not ec.blah():
raise RuntimeError,"EnumClass::blah() default arguments don't work"
def is_new_style_class(cls):
return hasattr(cls, "__class__")
if default_args.Statics_staticMethod() != 60:
raise RuntimeError
if default_args.cfunc1(1) != 2:
raise RuntimeError
def run(module_name):
default_args = __import__(module_name)
ec = default_args.EnumClass()
if not ec.blah():
raise RuntimeError("EnumClass::blah() default arguments don't work")
if default_args.cfunc2(1) != 3:
raise RuntimeError
de = default_args.DerivedEnumClass()
de.accelerate()
de.accelerate(default_args.EnumClass.SLOW)
if default_args.cfunc3(1) != 4:
raise RuntimeError
if default_args.Statics_staticMethod() != 60:
raise RuntimeError
if default_args.cfunc1(1) != 2:
raise RuntimeError
if default_args.cfunc2(1) != 3:
raise RuntimeError
if default_args.cfunc3(1) != 4:
raise RuntimeError
f = default_args.Foo()
f = default_args.Foo()
f.newname()
f.newname(1)
f.newname()
f.newname(1)
try:
f = default_args.Foo(1)
error = 1
except:
error = 0
if error: raise RuntimeError,"Foo::Foo ignore is not working"
try:
f = default_args.Foo(1)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::Foo ignore is not working")
try:
f = default_args.Foo(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError,"Foo::Foo ignore is not working"
try:
f = default_args.Foo(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::Foo ignore is not working")
try:
f = default_args.Foo(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError,"Foo::Foo ignore is not working"
try:
f = default_args.Foo(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::Foo ignore is not working")
try:
m = f.meth(1)
error = 1
except:
error = 0
if error: raise RuntimeError,"Foo::meth ignore is not working"
try:
m = f.meth(1)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::meth ignore is not working")
try:
m = f.meth(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError,"Foo::meth ignore is not working"
try:
m = f.meth(1,2)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::meth ignore is not working")
try:
m = f.meth(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError,"Foo::meth ignore is not working"
try:
m = f.meth(1,2,3)
error = 1
except:
error = 0
if error: raise RuntimeError("Foo::meth ignore is not working")
if is_new_style_class(default_args.Klass):
Klass_inc = default_args.Klass.inc
else:
Klass_inc = default_args.Klass_inc
if Klass_inc(100, default_args.Klass(22)).val != 122:
raise RuntimeError("Klass::inc failed")
if Klass_inc(100).val != 99:
raise RuntimeError("Klass::inc failed")
if Klass_inc().val != 0:
raise RuntimeError("Klass::inc failed")
default_args.trickyvalue1(10); default_args.trickyvalue1(10, 10)
default_args.trickyvalue2(10); default_args.trickyvalue2(10, 10)
default_args.trickyvalue3(10); default_args.trickyvalue3(10, 10)
default_args.seek(); default_args.seek(10)
if __name__=="__main__":
run('default_args')

View file

@ -1,5 +1,8 @@
import director_abstract
def is_new_style_class(cls):
return hasattr(cls, "__class__")
class MyFoo(director_abstract.Foo):
def __init__(self):
director_abstract.Foo.__init__(self)
@ -32,12 +35,20 @@ me1 = MyExample1()
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
raise RuntimeError
if is_new_style_class(MyExample2):
MyExample2_static = MyExample2
else:
MyExample2_static = MyExample2(0, 0)
me2 = MyExample2(1,2)
if MyExample2.get_color(me2, 1,2,3) != 2:
if MyExample2_static.get_color(me2, 1,2,3) != 2:
raise RuntimeError
if is_new_style_class(MyExample3):
MyExample3_static = MyExample3
else:
MyExample3_static = MyExample3()
me3 = MyExample3()
if MyExample3.get_color(me3, 1,2,3) != 3:
if MyExample3_static.get_color(me3, 1,2,3) != 3:
raise RuntimeError
error = 1

View file

@ -1,5 +1,8 @@
from global_namespace import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
k1 = Klass1()
k2 = Klass2()
k3 = Klass3()
@ -8,8 +11,12 @@ k5 = Klass5()
k6 = Klass6()
k7 = Klass7()
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
if is_new_style_class(KlassMethods):
KlassMethods_static = KlassMethods
else:
KlassMethods_static = KlassMethods()
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1A()
k2 = getKlass2A()
@ -19,8 +26,8 @@ k5 = getKlass5A()
k6 = getKlass6A()
k7 = getKlass7A()
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1B()
k2 = getKlass2B()
@ -30,11 +37,19 @@ k5 = getKlass5B()
k6 = getKlass6B()
k7 = getKlass7B()
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
if is_new_style_class(XYZMethods):
XYZMethods_static = XYZMethods
else:
XYZMethods_static = XYZMethods()
XYZMethods_static.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
XYZMethods_static.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
TheEnumMethods.methodA(theenum1, theenum2, theenum3)
TheEnumMethods.methodA(theenum1, theenum2, theenum3)
if is_new_style_class(TheEnumMethods):
TheEnumMethods_static = TheEnumMethods
else:
TheEnumMethods_static = TheEnumMethods()
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)

View file

@ -4,6 +4,9 @@ def check(a, b):
if a != b:
raise RuntimeError(str(a) + " does not equal " + str(b))
def is_new_style_class(cls):
return hasattr(cls, "__class__")
#### Class ####
# No implicit conversion
@ -39,13 +42,17 @@ check(2, A_int(1.0).get())
check(3, A_int(B()).get())
check(4, A_int("hello").get())
check(1, A_int.sget(1))
check(2, A_int.sget(1.0))
check(3, A_int.sget(B()))
if is_new_style_class(A_int):
A_int_static = A_int
else:
A_int_static = A_int(0)
check(1, A_int_static.sget(1))
check(2, A_int_static.sget(1.0))
check(3, A_int_static.sget(B()))
# explicit constructor:
try:
check(4, A_int.sget("hello"))
check(4, A_int_static.sget("hello"))
raise RuntimeError
except TypeError:
pass

View file

@ -51,7 +51,7 @@ if foo_fn(b=2) != 3:
raise RuntimeError
#Funtions with keywords
#Functions with keywords
if foo_kw(_from=2) != 4:
raise RuntimeError
@ -65,3 +65,17 @@ if foo_mm(min=2) != 4:
if foo_mm(max=3) != 4:
raise RuntimeError
#Default args with references
if rfoo(n=123) != 120:
raise RuntimeError
if rfoo(x=10) != -10:
raise RuntimeError
if rfoo(n=11, x=22) != -11:
raise RuntimeError
if rfoo(x=11, n=22) != 11:
raise RuntimeError

View file

@ -1,5 +1,8 @@
from li_boost_shared_ptr_bits import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
def check(nd):
nd.i = 200
i = nd.i
@ -30,5 +33,8 @@ if sum != 66:
raise "sum is wrong"
################################
p = HiddenDestructor.create()
if is_new_style_class(HiddenDestructor):
p = HiddenDestructor.create()
else:
p = HiddenDestructor_create()

View file

@ -17,7 +17,7 @@ class li_boost_shared_ptr_runme:
self.runtest()
# Expect 1 instance - the one global variable (GlobalValue)
if (li_boost_shared_ptr.Klass.getTotal_count() != 1):
if (li_boost_shared_ptr.Klass_getTotal_count() != 1):
raise RuntimeError("Klass.total_count=%s" % li_boost_shared_ptr.Klass.getTotal_count())
wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count()

View file

@ -2,16 +2,16 @@ from li_std_auto_ptr import *
k1 = makeKlassAutoPtr("first")
k2 = makeKlassAutoPtr("second")
if Klass.getTotal_count() != 2:
if Klass_getTotal_count() != 2:
raise "number of objects should be 2"
del k1
if Klass.getTotal_count() != 1:
if Klass_getTotal_count() != 1:
raise "number of objects should be 1"
if k2.getLabel() != "second":
raise "wrong object label"
del k2
if Klass.getTotal_count() != 0:
if Klass_getTotal_count() != 0:
raise "no objects should be left"

View file

@ -1,5 +1,8 @@
from namespace_class import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
try:
p = Private1()
error = 1
@ -18,7 +21,10 @@ except:
if (error):
raise RuntimeError, "Private2 is private"
EulerT3D.toFrame(1,1,1)
if is_new_style_class(EulerT3D):
EulerT3D.toFrame(1,1,1)
else:
EulerT3D().toFrame(1,1,1)
b = BooT_i()
b = BooT_H()
@ -33,6 +39,7 @@ f.moo(1)
f = FooT_H()
f.foo(Hi)
f_type = str(type(f))
if f_type.find("'namespace_class.FooT_H'") == -1:
raise RuntimeError("Incorrect type: " + f_type)
if is_new_style_class(FooT_H):
f_type = str(type(f))
if f_type.find("'namespace_class.FooT_H'") == -1:
raise RuntimeError("Incorrect type: " + f_type)

View file

@ -0,0 +1,13 @@
from nested_template_base import *
ois = InnerS(123);
oic = InnerC();
# Check base method is available
if (oic.outer(ois).val != 123):
raise RuntimeError("Wrong value calling outer");
# Check non-derived class using base class
if (oic.innerc().outer(ois).val != 123):
raise RuntimeError("Wrong value calling innerc");

View file

@ -1,4 +1,8 @@
from overload_template_fast import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
f = foo()
a = maximum(3,4)
@ -140,6 +144,9 @@ if (nsoverload() != 1050):
raise RuntimeError, ("nsoverload(const char *)")
A.foo(1)
if is_new_style_class(A):
A.foo(1)
else:
A_foo(1)
b = B()
b.foo(1)

View file

@ -12,3 +12,5 @@ if preproc.defined != 1:
if 2*preproc.one != preproc.two:
raise RuntimeError
if preproc.methodX(99) != 199:
raise RuntimeError

View file

@ -1,12 +1,18 @@
from python_append import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
# test not relevant for -builtin
if is_python_builtin():
exit(0)
t=Test()
t.func()
t.static_func()
if is_new_style_class(Test):
t.static_func()
else:
Test_static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError("grabpath failed")

View file

@ -5,7 +5,7 @@ from refcount import *
a = A3()
b1 = B(a)
b2 = B.create(a)
b2 = B_create(a)
@ -14,7 +14,7 @@ if a.ref_count() != 3:
rca = b2.get_rca()
b3 = B.create(rca)
b3 = B_create(rca)
if a.ref_count() != 5:
raise RuntimeError("Count = %d" % a.ref_count())
@ -39,7 +39,7 @@ b5 = global_create(a)
if b5.ref_count() != 1:
raise RuntimeError
b6 = Factory.create(a)
b6 = Factory_create(a)
if b6.ref_count() != 1:
raise RuntimeError

View file

@ -1,12 +1,12 @@
import return_const_value
import sys
p = return_const_value.Foo_ptr.getPtr()
p = return_const_value.Foo_ptr_getPtr()
if (p.getVal() != 17):
print "Runtime test1 faild. p.getVal()=", p.getVal()
sys.exit(1)
p = return_const_value.Foo_ptr.getConstPtr()
p = return_const_value.Foo_ptr_getConstPtr()
if (p.getVal() != 17):
print "Runtime test2 faild. p.getVal()=", p.getVal()
sys.exit(1)

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