Merge branch 'master' into gsoc2017-php7-classes-via-c-api

This commit is contained in:
Olly Betts 2021-04-13 15:15:09 +12:00
commit 37f575b7b4
6 changed files with 21 additions and 11 deletions

View file

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress) Version 4.1.0 (in progress)
=========================== ===========================
2021-04-12: olly
#1777 [Python] Specifying -py3 now generates a check for Python
version >= 3.0.
2021-03-26: olly 2021-03-26: olly
[PHP] Add PHP keywords 'fn' (added in 7.4) and 'match' (added in [PHP] Add PHP keywords 'fn' (added in 7.4) and 'match' (added in
8.0) to the list SWIG knows to automatically rename. 8.0) to the list SWIG knows to automatically rename.

View file

@ -453,7 +453,7 @@ public:
Printv(df->def, "static Scheme_Object *\n", dname, "(int argc, Scheme_Object **argv) {", NIL); Printv(df->def, "static Scheme_Object *\n", dname, "(int argc, Scheme_Object **argv) {", NIL);
Printv(df->code, dispatch, "\n", NIL); Printv(df->code, dispatch, "\n", NIL);
Printf(df->code, "scheme_signal_error(\"No matching function for overloaded '%s'\");\n", iname); Printf(df->code, "scheme_signal_error(\"No matching function for overloaded '%s'\");\n", iname);
Printf(df->code, "return NULL;\n", iname); Printf(df->code, "return NULL;\n");
Printv(df->code, "}\n", NIL); Printv(df->code, "}\n", NIL);
Wrapper_print(df, f_wrappers); Wrapper_print(df, f_wrappers);
Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, dname, proc_name, 0, maxargs); Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, dname, proc_name, 0, maxargs);

View file

@ -815,7 +815,7 @@ public:
Printf(tmp, "}"); Printf(tmp, "}");
Wrapper_add_local(f, "argv", tmp); Wrapper_add_local(f, "argv", tmp);
Printv(f->code, dispatch, "\n", NIL); Printv(f->code, dispatch, "\n", NIL);
Printf(f->code, "error(\"No matching function for overload\");\n", iname); Printf(f->code, "error(\"No matching function for overload\");\n");
Printf(f->code, "return octave_value_list();\n"); Printf(f->code, "return octave_value_list();\n");
Printv(f->code, "}\n", NIL); Printv(f->code, "}\n", NIL);

View file

@ -2341,7 +2341,7 @@ public:
Replaceall(tm, "$error", "ERRSV"); Replaceall(tm, "$error", "ERRSV");
Printv(w->code, Str(tm), "\n", NIL); Printv(w->code, Str(tm), "\n", NIL);
} else { } else {
Printf(w->code, " Swig::DirectorMethodException::raise(ERRSV);\n", classname, pyname); Printf(w->code, " Swig::DirectorMethodException::raise(ERRSV);\n");
} }
Append(w->code, "}\n"); Append(w->code, "}\n");
Delete(tm); Delete(tm);

View file

@ -1892,7 +1892,6 @@ public:
virtual int constructorHandler(Node *n) { virtual int constructorHandler(Node *n) {
if (Swig_directorclass(n)) { if (Swig_directorclass(n)) {
String *name = GetChar(Swig_methodclass(n), "name");
String *ctype = GetChar(Swig_methodclass(n), "classtype"); String *ctype = GetChar(Swig_methodclass(n), "classtype");
String *sname = GetChar(Swig_methodclass(n), "sym:name"); String *sname = GetChar(Swig_methodclass(n), "sym:name");
String *args = NewStringEmpty(); String *args = NewStringEmpty();
@ -1920,7 +1919,7 @@ public:
Printf(director_ctor_code, "if (Swig::Director::swig_is_overridden_method(\"%s\", arg0)) { /* not subclassed */\n", class_name); Printf(director_ctor_code, "if (Swig::Director::swig_is_overridden_method(\"%s\", arg0)) { /* not subclassed */\n", class_name);
Printf(director_prot_ctor_code, "if (Swig::Director::swig_is_overridden_method(\"%s\", arg0)) { /* not subclassed */\n", class_name); Printf(director_prot_ctor_code, "if (Swig::Director::swig_is_overridden_method(\"%s\", arg0)) { /* not subclassed */\n", class_name);
Printf(director_ctor_code, " %s = new %s(%s);\n", Swig_cresult_name(), ctype, args); Printf(director_ctor_code, " %s = new %s(%s);\n", Swig_cresult_name(), ctype, args);
Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args); Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n");
if (i) { if (i) {
Insert(args, 0, ", "); Insert(args, 0, ", ");
} }
@ -2225,7 +2224,7 @@ public:
// typemap_directorout testcase requires that 0 can be assigned to the // typemap_directorout testcase requires that 0 can be assigned to the
// variable named after the result of Swig_cresult_name(), so that can't // variable named after the result of Swig_cresult_name(), so that can't
// be a zval - make it a pointer to one instead. // be a zval - make it a pointer to one instead.
Printf(w->code, "zval swig_zval_result, swig_funcname;\n", Swig_cresult_name()); Printf(w->code, "zval swig_zval_result, swig_funcname;\n");
Printf(w->code, "zval * SWIGUNUSED %s = &swig_zval_result;\n", Swig_cresult_name()); Printf(w->code, "zval * SWIGUNUSED %s = &swig_zval_result;\n", Swig_cresult_name());
const char * funcname = GetChar(n, "sym:name"); const char * funcname = GetChar(n, "sym:name");
Printf(w->code, "ZVAL_STRINGL(&swig_funcname, \"%s\", %d);\n", funcname, strlen(funcname)); Printf(w->code, "ZVAL_STRINGL(&swig_funcname, \"%s\", %d);\n", funcname, strlen(funcname));

View file

@ -846,8 +846,13 @@ public:
Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL);
Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL); Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL);
if (py3) {
Printv(f_shadow_py, "if _swig_python_version_info < (3, 0):\n", NULL);
Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 3.x or later required\")\n\n", NULL);
} else {
Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL); Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL);
Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 2.7 or later required\")\n\n", NULL); Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 2.7 or later required\")\n\n", NULL);
}
if (Len(f_shadow_after_begin) > 0) if (Len(f_shadow_after_begin) > 0)
Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL); Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL);
@ -3608,7 +3613,7 @@ public:
// class type (the SWIG_init() is called before shadow classes are // class type (the SWIG_init() is called before shadow classes are
// defined and registered). // defined and registered).
Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname); Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname);
Printf(f_wrappers, tab2 "PyObject *module;\n", tm); Printf(f_wrappers, tab2 "PyObject *module;\n");
Printf(f_wrappers, tab2 "PyObject *d;\n"); Printf(f_wrappers, tab2 "PyObject *d;\n");
Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n"); Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n");
Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n"); Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n");
@ -4018,7 +4023,7 @@ public:
if (GetFlag(mgetset, "static")) { if (GetFlag(mgetset, "static")) {
Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry); Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry);
Printf(f_init, "static_getset = SwigPyStaticVar_new_getset(metatype, &%s_def);\n", gspair); Printf(f_init, "static_getset = SwigPyStaticVar_new_getset(metatype, &%s_def);\n", gspair);
Printf(f_init, "PyDict_SetItemString(d, static_getset->d_getset->name, (PyObject *) static_getset);\n", memname); Printf(f_init, "PyDict_SetItemString(d, static_getset->d_getset->name, (PyObject *) static_getset);\n");
Printf(f_init, "Py_DECREF(static_getset);\n"); Printf(f_init, "Py_DECREF(static_getset);\n");
} else { } else {
Printf(getset_def, " %s,\n", entry); Printf(getset_def, " %s,\n", entry);
@ -4467,7 +4472,9 @@ public:
Printf(f_shadow, "(Exception)"); Printf(f_shadow, "(Exception)");
} else { } else {
Printf(f_shadow, "(object"); Printf(f_shadow, "(object");
Printf(f_shadow, py3 && GetFlag(n, "feature:python:nondynamic") ? ", metaclass=_SwigNonDynamicMeta" : "", ")"); if (py3 && GetFlag(n, "feature:python:nondynamic")) {
Printf(f_shadow, ", metaclass=_SwigNonDynamicMeta");
}
Printf(f_shadow, ")"); Printf(f_shadow, ")");
} }
} }