Revert introduction of python:defaultargs feature

See issue #294
This commit is contained in:
William S Fulton 2015-01-12 21:35:47 +00:00
commit 9d87b9f099
7 changed files with 29 additions and 55 deletions

View file

@ -9,18 +9,13 @@ Version 3.0.4 (in progress)
[PHP] Fix segfault in director upcall check when using PHP built with
ZTS enabled. Fixes #155, reported by Pierre Labastie.
2015-01-08: wsfulton
2015-01-12: vadz
[Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when
wrapping functions with default arguments. Now any method with default
arguments obtains the default arguments from C++ instead of generating
Python code with the default arguments.
The "python:defaultargs" feature has been introduced for users to
optionally generate Python methods with the default arguments instead
the default *args.
wrapping functions with default arguments. Invalid or missing default
arguments were sometimes being generated into the python layer.
2015-01-08: olly
Allow C++11 "explicit constexpr". Fixes github issue#284 reported
Allow C++11 "explicit constexpr". Fixes github issue #284 reported
by Paweł Tomulik. Also handle "constexpr explicit" and "constexpr
static".

View file

@ -13,7 +13,7 @@
%inline %{
#include <string>
// All kinds of numbers: hex, octal (which pose special problems to Python (using %pythondefaultargs), negative...
// 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) {}
@ -23,6 +23,10 @@
// 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) {}
// Anonymous arguments
int anonymous(int = 7771);

View file

@ -58,7 +58,6 @@ CPP_TEST_CASES += \
primitive_types \
python_abstractbase \
python_append \
python_default_args \
python_director \
python_nondynamic \
python_overload_simple_cast \

View file

@ -1,3 +0,0 @@
# Test %feature("python:defaultargs") using the test code in default_args_runme.py (which does not use the feature)
import default_args_runme
default_args_runme.run('python_default_args')

View file

@ -1,6 +0,0 @@
%module python_default_args
// Testing use of %pythondefaultargs
%pythondefaultargs;
%include "default_args.i"

View file

@ -185,17 +185,6 @@ These methods "may be called" if needed.
#define %clearpythonappend %feature("pythonappend","")
/* ------------------------------------------------------------------------- */
/*
Python default argument handling (for non-builtin)
*/
#define %pythondefaultargs %feature("python:defaultargs")
#define %nopythondefaultargs %feature("python:defaultargs", "0")
#define %clearpythondefaultargs %feature("python:defaultargs", "")
/* ------------------------------------------------------------------------- */
/*
%extend_smart_pointer extend the smart pointer support.

View file

@ -1975,33 +1975,29 @@ public:
bool is_representable = true;
if (Getattr(n, "sym:overloaded")) {
if (GetFlag(n, "feature:python:defaultargs")) {
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p;
Parm *pnext;
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p;
Parm *pnext;
for (p = plist; p; p = pnext) {
pnext = NIL;
String *tm = Getattr(p, "tmap:in");
if (tm) {
pnext = Getattr(p, "tmap:in:next");
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
}
if (!pnext) {
pnext = nextSibling(p);
}
if (String *value = Getattr(p, "value")) {
String *type = Getattr(p, "type");
if (!convertValue(value, type)) {
is_representable = false;
break;
}
for (p = plist; p; p = pnext) {
pnext = NIL;
String *tm = Getattr(p, "tmap:in");
if (tm) {
pnext = Getattr(p, "tmap:in:next");
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
}
if (!pnext) {
pnext = nextSibling(p);
}
if (String *value = Getattr(p, "value")) {
String *type = Getattr(p, "type");
if (!convertValue(value, type)) {
is_representable = false;
break;
}
}
} else {
is_representable = false;
}
}
return is_representable;