Merge branch 'python-builtin-test-suite'
* python-builtin-test-suite: Add Python -builtin Travis testing Bypass Python exmples not supported by -builtin Remove Python swigrun example Display testname when running the import_packages Python examples Fix Python 3 import_packages/relativeimport2 example clean Fixes when using python -builtin and STL container wrappers. Bypass Python tests not supported by -builtin Bypass Python tests not supported by -builtin Bypass Python tests not supported by -builtin Bypass Python tests not supported by -builtin Bypass Python tests failing with -builtin Bypass Python tests throwing base classes as exceptions for -builtin Add some more Python -builtin tests that don't work Disable test not relevant for Python -builtin Conflicts: CHANGES.current
This commit is contained in:
commit
d10efb658e
45 changed files with 428 additions and 258 deletions
|
|
@ -42,6 +42,10 @@ matrix:
|
||||||
env: SWIGLANG=python PY3=3 VER=3.3
|
env: SWIGLANG=python PY3=3 VER=3.3
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=python PY3=3 VER=3.4
|
env: SWIGLANG=python PY3=3 VER=3.4
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-builtin
|
||||||
|
- compiler: gcc
|
||||||
|
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=1
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: SWIGLANG=ruby
|
env: SWIGLANG=ruby
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.3 (in progress)
|
Version 3.0.3 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2014-10-06: wsfulton
|
||||||
|
[Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
|
||||||
|
of single elements, such as 'del vec[0]'.
|
||||||
|
|
||||||
2014-09-30: oliverb
|
2014-09-30: oliverb
|
||||||
[Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
|
[Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ simple
|
||||||
smartptr
|
smartptr
|
||||||
std_vector
|
std_vector
|
||||||
std_map
|
std_map
|
||||||
swigrun
|
|
||||||
template
|
template
|
||||||
varargs
|
varargs
|
||||||
variables
|
variables
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,12 @@
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,17 @@ try:
|
||||||
except RuntimeError,e:
|
except RuntimeError,e:
|
||||||
print e.args[0]
|
print e.args[0]
|
||||||
|
|
||||||
try:
|
if not example.is_python_builtin():
|
||||||
t.hosed()
|
try:
|
||||||
except example.Exc,e:
|
t.hosed()
|
||||||
print e.code, e.msg
|
except example.Exc,e:
|
||||||
|
print e.code, e.msg
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
t.hosed()
|
||||||
|
except BaseException,e:
|
||||||
|
# Throwing builtin classes as exceptions not supported (-builtin option)
|
||||||
|
print e
|
||||||
|
|
||||||
for i in range(1,4):
|
for i in range(1,4):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,12 @@
|
||||||
%template(doubleQueue) Queue<double>;
|
%template(doubleQueue) Queue<double>;
|
||||||
|
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
# file: runme.py
|
# file: runme.py
|
||||||
import example
|
import example
|
||||||
|
|
||||||
|
if example.is_python_builtin():
|
||||||
|
print "Skipping example: -builtin option does not support %exceptionclass"
|
||||||
|
exit(0)
|
||||||
|
|
||||||
q = example.intQueue(10)
|
q = example.intQueue(10)
|
||||||
|
|
||||||
print "Inserting items into intQueue"
|
print "Inserting items into intQueue"
|
||||||
|
|
||||||
|
print type(example.FullError)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i in range(0,100):
|
for i in range(0,100):
|
||||||
q.enqueue(i)
|
q.enqueue(i)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
# Test import of modules content from within __init__.py
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||||
|
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3,0):
|
||||||
import py2.pkg2
|
import py2.pkg2
|
||||||
print " Finished importing py2.pkg2"
|
print " Finished importing py2.pkg2"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
# Test import of modules content from within __init__.py
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||||
|
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3,0):
|
||||||
import py2.pkg2
|
import py2.pkg2
|
||||||
print " Finished importing py2.pkg2"
|
print " Finished importing py2.pkg2"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
# Test import of modules content from within __init__.py
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||||
|
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3,0):
|
||||||
import py2.pkg2
|
import py2.pkg2
|
||||||
print " Finished importing py2.pkg2"
|
print " Finished importing py2.pkg2"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print "Testing %module(package=...) with -relativeimport"
|
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
# Test import of modules content from within __init__.py
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) with -relativeimport"
|
||||||
|
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3,0):
|
||||||
import py2.pkg2.bar
|
import py2.pkg2.bar
|
||||||
print " Finished importing py2.pkg2.bar"
|
print " Finished importing py2.pkg2.bar"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
# Test import of modules content from within __init__.py
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||||
|
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3,0):
|
||||||
import py2.pkg2.bar
|
import py2.pkg2.bar
|
||||||
print " Finished importing py2.pkg2.bar"
|
print " Finished importing py2.pkg2.bar"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print("Testing %module(package=...) + python 'import' in __init__.py")
|
|
||||||
import sys
|
|
||||||
if sys.version_info < (3, 0):
|
|
||||||
import py2.pkg2.bar
|
|
||||||
print(" Finished importing py2.pkg2.bar")
|
|
||||||
else:
|
|
||||||
import py3.pkg2.bar
|
|
||||||
print(" Finished importing py3.pkg2.bar")
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Test import of modules content from within __init__.py
|
|
||||||
print "Testing %module(package=...) with -relativeimport"
|
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
# Test import of modules content from within __init__.py
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) with -relativeimport"
|
||||||
|
|
||||||
if sys.version_info < (3,0):
|
if sys.version_info < (3,0):
|
||||||
import py2.pkg2.bar
|
import py2.pkg2.bar
|
||||||
print " Finished importing py2.pkg2.bar"
|
print " Finished importing py2.pkg2.bar"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
|
import os.path
|
||||||
|
|
||||||
# Test import of same modules from different packages
|
# Test import of same modules from different packages
|
||||||
print "Testing %module(package=...) + %import + same modules in different packages"
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||||
|
|
||||||
import pkg2.foo
|
import pkg2.foo
|
||||||
print " Finished importing pkg2.foo"
|
print " Finished importing pkg2.foo"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||||
|
|
||||||
import pkg1.pkg2.foo
|
import pkg1.pkg2.foo
|
||||||
print " Finished importing pkg1.pkg2.foo"
|
print " Finished importing pkg1.pkg2.foo"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
TOP = ../..
|
|
||||||
SWIG = $(TOP)/../preinst-swig
|
|
||||||
CXXSRCS = example.cxx
|
|
||||||
TARGET = example
|
|
||||||
INTERFACE = example.i
|
|
||||||
LIBS = -lm
|
|
||||||
SWIGOPT =
|
|
||||||
|
|
||||||
check: build
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
|
|
||||||
|
|
||||||
build:
|
|
||||||
$(SWIG) -python -external-runtime
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
|
|
||||||
|
|
||||||
static:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
|
|
||||||
rm -f swigpyrun.h
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
/* File : example.cxx */
|
|
||||||
|
|
||||||
#include <Python.h>
|
|
||||||
#include "swigpyrun.h"
|
|
||||||
#include "example.h"
|
|
||||||
|
|
||||||
|
|
||||||
Manager* convert_to_Manager(PyObject *py_obj)
|
|
||||||
{
|
|
||||||
Manager* c_ptr;
|
|
||||||
swig_type_info *ty = SWIG_TypeQuery("Manager *");
|
|
||||||
printf("manager ty %p \n", (void *)ty);
|
|
||||||
if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) {
|
|
||||||
c_ptr = 0;
|
|
||||||
} else {
|
|
||||||
Py_XINCREF(py_obj);
|
|
||||||
}
|
|
||||||
return c_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
/* File : example.h */
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
class Employee {
|
|
||||||
private:
|
|
||||||
std::string name;
|
|
||||||
public:
|
|
||||||
Employee(const char* n): name(n) {}
|
|
||||||
virtual std::string getTitle() { return getPosition() + " " + getName(); }
|
|
||||||
virtual std::string getName() { return name; }
|
|
||||||
virtual std::string getPosition() const { return "Employee"; }
|
|
||||||
virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Manager: public Employee {
|
|
||||||
public:
|
|
||||||
Manager(const char* n): Employee(n) {}
|
|
||||||
virtual std::string getPosition() const { return "Manager"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class EmployeeList {
|
|
||||||
std::vector<Employee*> list;
|
|
||||||
public:
|
|
||||||
EmployeeList() {
|
|
||||||
list.push_back(new Employee("Bob"));
|
|
||||||
list.push_back(new Employee("Jane"));
|
|
||||||
list.push_back(new Manager("Ted"));
|
|
||||||
}
|
|
||||||
void addEmployee(Employee *p) {
|
|
||||||
list.push_back(p);
|
|
||||||
std::cout << "New employee added. Current employees are:" << std::endl;
|
|
||||||
std::vector<Employee*>::iterator i;
|
|
||||||
for (i=list.begin(); i!=list.end(); i++) {
|
|
||||||
std::cout << " " << (*i)->getTitle() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const Employee *get_item(int i) {
|
|
||||||
return list[i];
|
|
||||||
}
|
|
||||||
~EmployeeList() {
|
|
||||||
std::vector<Employee*>::iterator i;
|
|
||||||
std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
|
|
||||||
for (i=list.begin(); i!=list.end(); i++) {
|
|
||||||
delete *i;
|
|
||||||
}
|
|
||||||
std::cout << "~EmployeeList empty." << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Manager* convert_to_Manager(PyObject *obj);
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
/* File : example.i */
|
|
||||||
%module(directors="1") example
|
|
||||||
%{
|
|
||||||
#include "example.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include "std_vector.i"
|
|
||||||
%include "std_string.i"
|
|
||||||
|
|
||||||
/* turn on director wrapping for Manager */
|
|
||||||
%feature("director") Employee;
|
|
||||||
%feature("director") Manager;
|
|
||||||
|
|
||||||
%include "example.h"
|
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
# file: runme.py
|
|
||||||
|
|
||||||
# This file illustrates the cross language polymorphism using directors.
|
|
||||||
|
|
||||||
import example
|
|
||||||
|
|
||||||
|
|
||||||
# CEO class, which overrides Employee::getPosition().
|
|
||||||
|
|
||||||
class CEO(example.Manager):
|
|
||||||
def __init__(self, name):
|
|
||||||
example.Manager.__init__(self, name)
|
|
||||||
def getPosition(self):
|
|
||||||
return "CEO"
|
|
||||||
def __del__(self):
|
|
||||||
print "CEO.__del__(),", self.getName()
|
|
||||||
# for proxy class extensions that are not "disowned" and
|
|
||||||
# define a __del__ method, it is very important to call the
|
|
||||||
# base class __del__. otherwise the c++ objects will never
|
|
||||||
# be deleted.
|
|
||||||
example.Manager.__del__(self)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
e = CEO("Alice")
|
|
||||||
m = example.convert_to_Manager(e)
|
|
||||||
print m
|
|
||||||
|
|
@ -133,3 +133,11 @@ typedef int Integer;
|
||||||
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,5 +168,11 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,4 +152,10 @@ Foo *launder(Foo *f) {
|
||||||
virtual Bar return_Bar() { return Bar(); }
|
virtual Bar return_Bar() { return Bar(); }
|
||||||
virtual ~ReturnAllTypes() {}
|
virtual ~ReturnAllTypes() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,13 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int A::sfoovar = 1;
|
int A::sfoovar = 1;
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%template(ET_i) ET<int>;
|
%template(ET_i) ET<int>;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
%import "import_nomodule.h"
|
%import "import_nomodule.h"
|
||||||
|
|
||||||
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD)
|
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGPYTHON_BUILTIN)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The proxy class does not have Bar derived from Foo, yet an instance of Bar
|
* The proxy class does not have Bar derived from Foo, yet an instance of Bar
|
||||||
|
|
@ -40,3 +40,10 @@ class Bar : public Foo { };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,11 @@ void test_domain_error() throw(std::domain_error)
|
||||||
%include <std_except.i>
|
%include <std_except.i>
|
||||||
void test_domain_error() throw(std::domain_error)
|
void test_domain_error() throw(std::domain_error)
|
||||||
{ throw std::domain_error("std::domain_error"); }
|
{ throw std::domain_error("std::domain_error"); }
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "li_std_string.i"
|
%include "li_std_string.i"
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,12 @@ void test_throw() throw(std::wstring){
|
||||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,19 +86,6 @@ C_TEST_CASES += \
|
||||||
|
|
||||||
include $(srcdir)/../common.mk
|
include $(srcdir)/../common.mk
|
||||||
|
|
||||||
BUILTIN_BROKEN = \
|
|
||||||
default_constructor.cpptest \
|
|
||||||
director_exception.cpptest \
|
|
||||||
exception_order.cpptest \
|
|
||||||
li_std_string_extra.cpptest \
|
|
||||||
li_std_wstring.cpptest \
|
|
||||||
python_abstractbase.cpptest \
|
|
||||||
threads_exception.cpptest
|
|
||||||
|
|
||||||
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
|
|
||||||
|
|
||||||
builtin-check : $(BUILTIN_NOT_BROKEN)
|
|
||||||
|
|
||||||
# Overridden variables here
|
# Overridden variables here
|
||||||
SCRIPTDIR = .
|
SCRIPTDIR = .
|
||||||
LIBS = -L.
|
LIBS = -L.
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,24 @@
|
||||||
from autodoc import *
|
from autodoc import *
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def check(got, expected):
|
def check(got, expected, expected_builtin = None, skip = False):
|
||||||
if expected != got:
|
if not skip:
|
||||||
raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]")
|
expect = expected_builtin if is_python_builtin() and expected_builtin != None else expected
|
||||||
|
if expect != got:
|
||||||
|
raise RuntimeError("\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
|
||||||
|
|
||||||
check(A.__doc__, "Proxy of C++ A class")
|
skip = True # skip builtin check - the autodoc is missing, but it probably should not be
|
||||||
|
|
||||||
|
check(A.__doc__, "Proxy of C++ A class", "::A")
|
||||||
check(A.funk.__doc__, "just a string")
|
check(A.funk.__doc__, "just a string")
|
||||||
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
|
check(A.func0.__doc__,
|
||||||
check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
|
"func0(self, arg2, hello) -> int",
|
||||||
check(A.func2.__doc__, "\n"
|
"func0(arg2, hello) -> int")
|
||||||
|
check(A.func1.__doc__,
|
||||||
|
"func1(A self, short arg2, Tuple hello) -> int",
|
||||||
|
"func1(short arg2, Tuple hello) -> int")
|
||||||
|
check(A.func2.__doc__,
|
||||||
|
"\n"
|
||||||
" func2(self, arg2, hello) -> int\n"
|
" func2(self, arg2, hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -17,8 +26,18 @@ check(A.func2.__doc__, "\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func2(arg2, hello) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" arg2: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
"\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func3.__doc__, "\n"
|
check(A.func3.__doc__,
|
||||||
|
"\n"
|
||||||
" func3(A self, short arg2, Tuple hello) -> int\n"
|
" func3(A self, short arg2, Tuple hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -26,19 +45,41 @@ check(A.func3.__doc__, "\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func3(short arg2, Tuple hello) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" arg2: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
"\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
check(A.func0default.__doc__, "\n"
|
check(A.func0default.__doc__,
|
||||||
|
"\n"
|
||||||
" func0default(self, e, arg3, hello, f=2) -> int\n"
|
" func0default(self, e, arg3, hello, f=2) -> int\n"
|
||||||
" func0default(self, e, arg3, hello) -> int\n"
|
" func0default(self, e, arg3, hello) -> int\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func0default(e, arg3, hello, f=2) -> int\n"
|
||||||
|
"func0default(e, arg3, hello) -> int\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func1default.__doc__, "\n"
|
check(A.func1default.__doc__,
|
||||||
|
"\n"
|
||||||
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
|
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
|
"func1default(A e, short arg3, Tuple hello) -> int\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func2default.__doc__, "\n"
|
check(A.func2default.__doc__,
|
||||||
|
"\n"
|
||||||
" func2default(self, e, arg3, hello, f=2) -> int\n"
|
" func2default(self, e, arg3, hello, f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -55,8 +96,27 @@ check(A.func2default.__doc__, "\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func2default(e, arg3, hello, f=2) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg3: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
" f: double\n"
|
||||||
|
"\n"
|
||||||
|
"func2default(e, arg3, hello) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg3: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
"\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func3default.__doc__, "\n"
|
check(A.func3default.__doc__,
|
||||||
|
"\n"
|
||||||
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -73,19 +133,50 @@ check(A.func3default.__doc__, "\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg3: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
" f: double\n"
|
||||||
|
"\n"
|
||||||
|
"func3default(A e, short arg3, Tuple hello) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg3: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
"\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
check(A.func0static.__doc__, "\n"
|
check(A.func0static.__doc__,
|
||||||
|
"\n"
|
||||||
" func0static(e, arg2, hello, f=2) -> int\n"
|
" func0static(e, arg2, hello, f=2) -> int\n"
|
||||||
" func0static(e, arg2, hello) -> int\n"
|
" func0static(e, arg2, hello) -> int\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func0static(e, arg2, hello, f=2) -> int\n"
|
||||||
|
"func0static(e, arg3, hello) -> int\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func1static.__doc__, "\n"
|
check(A.func1static.__doc__,
|
||||||
|
"\n"
|
||||||
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
" func1static(A e, short arg2, Tuple hello) -> int\n"
|
" func1static(A e, short arg2, Tuple hello) -> int\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
|
"func1static(A e, short arg3, Tuple hello) -> int\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func2static.__doc__, "\n"
|
check(A.func2static.__doc__,
|
||||||
|
"\n"
|
||||||
" func2static(e, arg2, hello, f=2) -> int\n"
|
" func2static(e, arg2, hello, f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -102,8 +193,27 @@ check(A.func2static.__doc__, "\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func2static(e, arg2, hello, f=2) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg2: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
" f: double\n"
|
||||||
|
"\n"
|
||||||
|
"func2static(e, arg3, hello) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg3: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
"\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
check(A.func3static.__doc__, "\n"
|
check(A.func3static.__doc__,
|
||||||
|
"\n"
|
||||||
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -120,31 +230,65 @@ check(A.func3static.__doc__, "\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg2: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
" f: double\n"
|
||||||
|
"\n"
|
||||||
|
"func3static(A e, short arg3, Tuple hello) -> int\n"
|
||||||
|
"\n"
|
||||||
|
"Parameters:\n"
|
||||||
|
" e: A *\n"
|
||||||
|
" arg3: short\n"
|
||||||
|
" hello: int tuple[2]\n"
|
||||||
|
"\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
if sys.version_info[0:2] > (2, 4):
|
if sys.version_info[0:2] > (2, 4):
|
||||||
# Python 2.4 does not seem to work
|
# Python 2.4 does not seem to work
|
||||||
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
|
check(A.variable_a.__doc__,
|
||||||
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
|
"A_variable_a_get(self) -> int",
|
||||||
check(A.variable_c.__doc__, "\n"
|
"A.variable_a"
|
||||||
|
)
|
||||||
|
check(A.variable_b.__doc__,
|
||||||
|
"A_variable_b_get(A self) -> int",
|
||||||
|
"A.variable_b"
|
||||||
|
)
|
||||||
|
check(A.variable_c.__doc__,
|
||||||
|
"\n"
|
||||||
"A_variable_c_get(self) -> int\n"
|
"A_variable_c_get(self) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Parameters:\n"
|
"Parameters:\n"
|
||||||
" self: A *\n"
|
" self: A *\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
,
|
||||||
|
"A.variable_c"
|
||||||
)
|
)
|
||||||
check(A.variable_d.__doc__, "\n"
|
check(A.variable_d.__doc__,
|
||||||
|
"\n"
|
||||||
"A_variable_d_get(A self) -> int\n"
|
"A_variable_d_get(A self) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Parameters:\n"
|
"Parameters:\n"
|
||||||
" self: A *\n"
|
" self: A *\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
,
|
||||||
|
"A.variable_d"
|
||||||
)
|
)
|
||||||
|
|
||||||
check(B.__doc__, "Proxy of C++ B class")
|
check(B.__doc__,
|
||||||
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
|
"Proxy of C++ B class",
|
||||||
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
|
"::B"
|
||||||
check(E.__init__.__doc__, "\n"
|
)
|
||||||
|
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
|
||||||
|
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D", None, skip)
|
||||||
|
check(E.__init__.__doc__,
|
||||||
|
"\n"
|
||||||
" __init__(self, a, b, h) -> E\n"
|
" __init__(self, a, b, h) -> E\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -153,8 +297,10 @@ check(E.__init__.__doc__, "\n"
|
||||||
" h: enum Hola\n"
|
" h: enum Hola\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
, None, skip
|
||||||
)
|
)
|
||||||
check(F.__init__.__doc__, "\n"
|
check(F.__init__.__doc__,
|
||||||
|
"\n"
|
||||||
" __init__(F self, int a, int b, Hola h) -> F\n"
|
" __init__(F self, int a, int b, Hola h) -> F\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
|
|
@ -163,14 +309,23 @@ check(F.__init__.__doc__, "\n"
|
||||||
" h: enum Hola\n"
|
" h: enum Hola\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" "
|
||||||
|
, None, skip
|
||||||
)
|
)
|
||||||
|
|
||||||
check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
|
check(B.funk.__doc__,
|
||||||
|
"funk(B self, int c, int d) -> int",
|
||||||
|
"funk(int c, int d) -> int")
|
||||||
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
|
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
|
||||||
check(funkdefaults.__doc__, "\n"
|
check(funkdefaults.__doc__,
|
||||||
|
"\n"
|
||||||
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
||||||
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
||||||
" "
|
" "
|
||||||
|
,
|
||||||
|
"\n"
|
||||||
|
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
||||||
|
"funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
||||||
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
check(func_input.__doc__, "func_input(int * INPUT) -> int")
|
check(func_input.__doc__, "func_input(int * INPUT) -> int")
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
|
import _default_constructor
|
||||||
|
|
||||||
# This test is expected to fail with -builtin option.
|
# This test is expected to fail with -builtin option.
|
||||||
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
|
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
|
||||||
# which is not provided with the -builtin option.
|
# which is not provided with the -builtin option.
|
||||||
|
if _default_constructor.is_python_builtin():
|
||||||
import _default_constructor
|
exit(0)
|
||||||
|
|
||||||
dc = _default_constructor
|
dc = _default_constructor
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,14 +68,13 @@ if not ok:
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
# This is expected to fail with -builtin option
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
try:
|
if not is_python_builtin():
|
||||||
raise Exception2()
|
try:
|
||||||
except Exception2:
|
raise Exception2()
|
||||||
pass
|
except Exception2:
|
||||||
|
pass
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
try:
|
||||||
# Throwing builtin classes as exceptions not supported
|
raise Exception1()
|
||||||
try:
|
except Exception1:
|
||||||
raise Exception1()
|
pass
|
||||||
except Exception1:
|
|
||||||
pass
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ from exception_order import *
|
||||||
|
|
||||||
# This test is expected to fail with -builtin option.
|
# This test is expected to fail with -builtin option.
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
|
if is_python_builtin():
|
||||||
|
exit(0)
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
from import_nomodule import *
|
from import_nomodule import *
|
||||||
|
|
||||||
|
# This test is expected to fail with -builtin option.
|
||||||
|
# The base class is needed for the builtin class hierarchy
|
||||||
|
if is_python_builtin():
|
||||||
|
exit(0)
|
||||||
|
|
||||||
f = create_Foo()
|
f = create_Foo()
|
||||||
test1(f,42)
|
test1(f,42)
|
||||||
delete_Foo(f)
|
delete_Foo(f)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
||||||
from li_std_except_as_class import *
|
from li_std_except_as_class import *
|
||||||
|
|
||||||
# std::domain_error hierarchy
|
# This test is expected to fail with -builtin option.
|
||||||
try: test_domain_error()
|
# Throwing builtin classes as exceptions not supported
|
||||||
except domain_error: pass
|
if is_python_builtin():
|
||||||
try: test_domain_error()
|
try: test_domain_error()
|
||||||
except logic_error: pass
|
except RuntimeError: pass
|
||||||
try: test_domain_error()
|
try: test_domain_error()
|
||||||
except exception: pass
|
except RuntimeError: pass
|
||||||
|
try: test_domain_error()
|
||||||
|
except RuntimeError: pass
|
||||||
|
else:
|
||||||
|
# std::domain_error hierarchy
|
||||||
|
try: test_domain_error()
|
||||||
|
except domain_error: pass
|
||||||
|
try: test_domain_error()
|
||||||
|
except logic_error: pass
|
||||||
|
try: test_domain_error()
|
||||||
|
except exception: pass
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,13 @@ if a + " world" != "hello world":
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
# This is expected to fail with -builtin option
|
||||||
# Reverse operators not supported in builtin types
|
# Reverse operators not supported in builtin types
|
||||||
if "hello" + b != "hello world":
|
if not li_std_string_extra.is_python_builtin():
|
||||||
raise RuntimeError, "bad string mapping"
|
if "hello" + b != "hello world":
|
||||||
|
raise RuntimeError, "bad string mapping"
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
c = "hello" + b
|
||||||
# Reverse operators not supported in builtin types
|
if c.find_last_of("l") != 9:
|
||||||
c = "hello" + b
|
raise RuntimeError, "bad string mapping"
|
||||||
if c.find_last_of("l") != 9:
|
|
||||||
raise RuntimeError, "bad string mapping"
|
|
||||||
|
|
||||||
s = "hello world"
|
s = "hello world"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,14 @@ if a + " world" != "hello world":
|
||||||
raise RuntimeError("bad string mapping")
|
raise RuntimeError("bad string mapping")
|
||||||
|
|
||||||
# This is expected to fail if -builtin is used
|
# This is expected to fail if -builtin is used
|
||||||
if "hello" + b != "hello world":
|
# Reverse operators not supported in builtin types
|
||||||
raise RuntimeError("bad string mapping")
|
if not li_std_wstring.is_python_builtin():
|
||||||
|
if "hello" + b != "hello world":
|
||||||
|
raise RuntimeError("bad string mapping")
|
||||||
|
|
||||||
# This is expected to fail if -builtin is used
|
c = "hello" + b
|
||||||
c = "hello" + b
|
if c.find_last_of("l") != 9:
|
||||||
if c.find_last_of("l") != 9:
|
raise RuntimeError("bad string mapping")
|
||||||
raise RuntimeError("bad string mapping")
|
|
||||||
|
|
||||||
s = "hello world"
|
s = "hello world"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ from collections import *
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
# This is expected to fail with -builtin option
|
||||||
# Builtin types can't inherit from pure-python abstract bases
|
# Builtin types can't inherit from pure-python abstract bases
|
||||||
|
if is_python_builtin():
|
||||||
|
exit(0)
|
||||||
|
|
||||||
assert issubclass(Mapii, MutableMapping)
|
assert issubclass(Mapii, MutableMapping)
|
||||||
assert issubclass(Multimapii, MutableMapping)
|
assert issubclass(Multimapii, MutableMapping)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
from python_append import *
|
from python_append import *
|
||||||
|
|
||||||
|
# test not relevant for -builtin
|
||||||
|
if is_python_builtin():
|
||||||
|
exit(0)
|
||||||
|
|
||||||
t=Test()
|
t=Test()
|
||||||
t.func()
|
t.func()
|
||||||
t.static_func()
|
t.static_func()
|
||||||
|
|
||||||
if grabpath() != os.path.dirname(mypath):
|
if grabpath() != os.path.dirname(mypath):
|
||||||
raise RuntimeError
|
raise RuntimeError("grabpath failed")
|
||||||
|
|
||||||
if grabstaticpath() != os.path.basename(mypath):
|
if grabstaticpath() != os.path.basename(mypath):
|
||||||
raise RuntimeError
|
raise RuntimeError("grabstaticpath failed")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,16 @@ except RuntimeError,e:
|
||||||
|
|
||||||
# This is expected fail with -builtin option
|
# This is expected fail with -builtin option
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
try:
|
if not threads_exception.is_python_builtin():
|
||||||
t.hosed()
|
try:
|
||||||
except threads_exception.Exc,e:
|
t.hosed()
|
||||||
code = e.code
|
except threads_exception.Exc,e:
|
||||||
if code != 42:
|
code = e.code
|
||||||
raise RuntimeError, "bad... code: %d" % code
|
if code != 42:
|
||||||
msg = e.msg
|
raise RuntimeError, "bad... code: %d" % code
|
||||||
if msg != "Hosed":
|
msg = e.msg
|
||||||
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
|
if msg != "Hosed":
|
||||||
|
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
|
||||||
|
|
||||||
for i in range(1,4):
|
for i in range(1,4):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,11 @@ namespace std
|
||||||
%template(IntVector) vector<int>;
|
%template(IntVector) vector<int>;
|
||||||
%template(IntList) list<int>;
|
%template(IntList) list<int>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -46,5 +46,10 @@ public:
|
||||||
void func() {};
|
void func() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,10 @@ public:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
|
bool is_python_builtin() { return true; }
|
||||||
|
#else
|
||||||
|
bool is_python_builtin() { return false; }
|
||||||
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -874,6 +874,13 @@ namespace swig
|
||||||
*(swig::getpos(self,i)) = x;
|
*(swig::getpos(self,i)) = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON_BUILTIN)
|
||||||
|
// This will be called through the mp_ass_subscript slot to delete an entry.
|
||||||
|
void __setitem__(difference_type i) throw (std::out_of_range) {
|
||||||
|
self->erase(swig::getpos(self,i));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void append(const value_type& x) {
|
void append(const value_type& x) {
|
||||||
self->push_back(x);
|
self->push_back(x);
|
||||||
}
|
}
|
||||||
|
|
@ -892,6 +899,13 @@ namespace swig
|
||||||
*(swig::getpos(self,i)) = x;
|
*(swig::getpos(self,i)) = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(SWIGPYTHON_BUILTIN)
|
||||||
|
// This will be called through the mp_ass_subscript slot to delete an entry.
|
||||||
|
void __setitem__(difference_type i) throw (std::out_of_range) {
|
||||||
|
self->erase(swig::getpos(self,i));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void append(value_type x) {
|
void append(value_type x) {
|
||||||
self->push_back(x);
|
self->push_back(x);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue