test-suite fixes for compilers that don't support vararg macros
Split TESTCASE_THROW into multiple macros taking different number of arguments. Fixes Visual Studio compiler errors.
This commit is contained in:
parent
1c46662c39
commit
196a965067
19 changed files with 127 additions and 117 deletions
|
|
@ -3,9 +3,11 @@
|
|||
%module python_builtin
|
||||
|
||||
// throw is invalid in C++17 and later, only SWIG to use it
|
||||
#define TESTCASE_THROW(TYPES...) throw(TYPES)
|
||||
#define TESTCASE_THROW1(T1) throw(T1)
|
||||
#define TESTCASE_THROW2(T1, T2) throw(T1, T2)
|
||||
%{
|
||||
#define TESTCASE_THROW(TYPES...)
|
||||
#define TESTCASE_THROW1(T1)
|
||||
#define TESTCASE_THROW2(T1, T2)
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
|
@ -192,13 +194,13 @@ void Dealloc2Destroyer(PyObject *v) {
|
|||
return size;
|
||||
}
|
||||
|
||||
int __getitem__(Py_ssize_t n) TESTCASE_THROW(std::out_of_range) {
|
||||
int __getitem__(Py_ssize_t n) TESTCASE_THROW1(std::out_of_range) {
|
||||
if (n >= (int)size)
|
||||
throw std::out_of_range("Index too large");
|
||||
return numbers[n];
|
||||
}
|
||||
|
||||
SimpleArray __getitem__(PySliceObject *slice) TESTCASE_THROW(std::out_of_range, std::invalid_argument) {
|
||||
SimpleArray __getitem__(PySliceObject *slice) TESTCASE_THROW2(std::out_of_range, std::invalid_argument) {
|
||||
if (!PySlice_Check(slice))
|
||||
throw std::invalid_argument("Slice object expected");
|
||||
Py_ssize_t i, j, step;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue