Drop support for Python classic classes
There were only needed to support Python < 2.2, and we now require at least Python 2.6. Conflicts: .travis.yml Examples/test-suite/python/autodoc_runme.py Source/Modules/python.cxx This is a cherry-pick and merge from patch in #1261
This commit is contained in:
parent
dcbccc6f6f
commit
728b8955bd
20 changed files with 96 additions and 241 deletions
|
|
@ -65,7 +65,6 @@ static String *methods;
|
|||
static String *class_name;
|
||||
static String *shadow_indent = 0;
|
||||
static int in_class = 0;
|
||||
static int classic = 0;
|
||||
static int modern = 0;
|
||||
static int new_repr = 1;
|
||||
static int no_header_file = 0;
|
||||
|
|
@ -123,7 +122,6 @@ Python Options (available with -python)\n\
|
|||
-buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\
|
||||
-builtin - Create new python built-in types, rather than proxy classes, for better performance\n\
|
||||
-castmode - Enable the casting mode, which allows implicit cast between types in python\n\
|
||||
-classic - Use classic classes only\n\
|
||||
-classptr - Generate shadow 'ClassPtr' as in older swig versions\n\
|
||||
-cppcast - Enable C++ casting operators (default) \n\
|
||||
-dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\
|
||||
|
|
@ -393,10 +391,8 @@ public:
|
|||
SWIG_cparse_set_compact_default_args(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-classic") == 0) {
|
||||
classic = 1;
|
||||
modernargs = 0;
|
||||
modern = 0;
|
||||
Swig_mark_arg(i);
|
||||
Printf(stderr, "*** %s is no longer supported.\n", argv[i]);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else if (strcmp(argv[i], "-cppcast") == 0) {
|
||||
cppcast = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -510,7 +506,6 @@ public:
|
|||
proxydel = 0;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-modern") == 0) {
|
||||
classic = 0;
|
||||
modern = 1;
|
||||
modernargs = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -527,7 +522,6 @@ public:
|
|||
no_header_file = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-O") == 0) {
|
||||
classic = 0;
|
||||
modern = 1;
|
||||
safecstrings = 0;
|
||||
buildnone = 0;
|
||||
|
|
@ -562,11 +556,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (py3) {
|
||||
/* force disable features that not compatible with Python 3.x */
|
||||
classic = 0;
|
||||
}
|
||||
|
||||
if (cppcast) {
|
||||
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
|
||||
}
|
||||
|
|
@ -745,10 +734,6 @@ public:
|
|||
Printf(f_runtime, "#define SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS\n");
|
||||
}
|
||||
|
||||
if (classic) {
|
||||
Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n");
|
||||
}
|
||||
|
||||
if (builtin) {
|
||||
Printf(f_runtime, "#define SWIGPYTHON_BUILTIN\n");
|
||||
}
|
||||
|
|
@ -911,14 +896,12 @@ public:
|
|||
tab4, "if not static:\n",
|
||||
#endif
|
||||
NIL);
|
||||
if (!classic) {
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL);
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL);
|
||||
}
|
||||
if (classic || !modern)
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL);
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL);
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, tab4, "self.__dict__[name] = value\n", NIL);
|
||||
Printv(f_shadow,
|
||||
tab4, "else:\n",
|
||||
|
|
@ -937,7 +920,7 @@ public:
|
|||
tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n",
|
||||
tab4, "except __builtin__.Exception:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
|
||||
|
||||
if (!classic && !modern) {
|
||||
if (!modern) {
|
||||
Printv(f_shadow,
|
||||
"try:\n",
|
||||
tab4, "_object = object\n", tab4, "_newclass = 1\n",
|
||||
|
|
@ -1057,7 +1040,7 @@ public:
|
|||
|
||||
if (shadow) {
|
||||
Swig_banner_target_lang(f_shadow_py, "#");
|
||||
if (!modern && !classic) {
|
||||
if (!modern) {
|
||||
Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL);
|
||||
}
|
||||
if (Len(f_shadow_begin) > 0)
|
||||
|
|
@ -4433,7 +4416,6 @@ public:
|
|||
}
|
||||
|
||||
virtual int classHandler(Node *n) {
|
||||
int oldclassic = classic;
|
||||
int oldmodern = modern;
|
||||
File *f_shadow_file = f_shadow;
|
||||
Node *base_node = NULL;
|
||||
|
|
@ -4445,15 +4427,12 @@ public:
|
|||
have_repr = 0;
|
||||
|
||||
if (GetFlag(n, "feature:classic")) {
|
||||
classic = 1;
|
||||
modern = 0;
|
||||
}
|
||||
if (GetFlag(n, "feature:modern")) {
|
||||
classic = 0;
|
||||
modern = 1;
|
||||
}
|
||||
if (GetFlag(n, "feature:exceptionclass")) {
|
||||
classic = 1;
|
||||
modern = 0;
|
||||
}
|
||||
|
||||
|
|
@ -4541,14 +4520,13 @@ public:
|
|||
if (Len(base_class)) {
|
||||
Printf(f_shadow, "(%s)", base_class);
|
||||
} else {
|
||||
if (!classic) {
|
||||
if (GetFlag(n, "feature:exceptionclass")) {
|
||||
Printf(f_shadow, "(Exception)");
|
||||
} else {
|
||||
Printf(f_shadow, modern ? "(object" : "(_object");
|
||||
Printf(f_shadow, modern && py3 && GetFlag(n, "feature:python:nondynamic") ? ", metaclass=_SwigNonDynamicMeta" : "", ")");
|
||||
Printf(f_shadow, ")");
|
||||
}
|
||||
if (GetFlag(n, "feature:exceptionclass")) {
|
||||
Printf(f_shadow, "(Exception)");
|
||||
}
|
||||
}
|
||||
|
||||
Printf(f_shadow, ":\n");
|
||||
|
|
@ -4718,7 +4696,6 @@ public:
|
|||
Clear(builtin_methods);
|
||||
}
|
||||
|
||||
classic = oldclassic;
|
||||
modern = oldmodern;
|
||||
|
||||
/* Restore shadow file back to original version */
|
||||
|
|
@ -4913,15 +4890,12 @@ public:
|
|||
}
|
||||
Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL);
|
||||
} else {
|
||||
if (!classic) {
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
|
||||
")\n", NIL);
|
||||
}
|
||||
if (classic || !modern) {
|
||||
if (!classic)
|
||||
Printv(f_shadow, tab4, "else:\n", tab4, NIL);
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
|
||||
")\n", NIL);
|
||||
if (!modern) {
|
||||
Printv(f_shadow, tab4, "else:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL);
|
||||
}
|
||||
}
|
||||
|
|
@ -5153,14 +5127,12 @@ public:
|
|||
}
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
|
||||
}
|
||||
if (!classic) {
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL);
|
||||
if (assignable)
|
||||
Printv(f_shadow, ", ", module, ".", setname, NIL);
|
||||
Printv(f_shadow, ")\n", NIL);
|
||||
}
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL);
|
||||
if (assignable)
|
||||
Printv(f_shadow, ", ", module, ".", setname, NIL);
|
||||
Printv(f_shadow, ")\n", NIL);
|
||||
Delete(mname);
|
||||
Delete(setname);
|
||||
Delete(getname);
|
||||
|
|
@ -5227,7 +5199,7 @@ public:
|
|||
}
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
|
||||
}
|
||||
if (!classic && !builtin) {
|
||||
if (!builtin) {
|
||||
if (!modern)
|
||||
Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
|
||||
Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue