[OCaml] Fix handling of exception specifications for director classes
The OCaml module was generating invalid code for director classes which contain methods with exception specifications. The fix is based on some of the code in python.cxx's classDirectorMethod(). This commit fixes compilation failures for a number of director unit tests. Add director_exception_catches_runme.ml, director_exception_nothrow_runme.ml, and director_ignore_runme.ml.
This commit is contained in:
parent
7118e4ef1e
commit
35663b1622
5 changed files with 79 additions and 9 deletions
|
|
@ -1400,14 +1400,46 @@ public:
|
|||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0);
|
||||
Printf(w->def, "%s {", target);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
Delete(target);
|
||||
/* header declaration */
|
||||
target = Swig_method_decl(rtype, decl, name, l, 1);
|
||||
Printf(declaration, " virtual %s;", target);
|
||||
Printf(declaration, " virtual %s", target);
|
||||
Delete(target);
|
||||
|
||||
// Get any exception classes in the throws typemap
|
||||
if (Getattr(n, "noexcept")) {
|
||||
Append(w->def, " noexcept");
|
||||
Append(declaration, " noexcept");
|
||||
}
|
||||
ParmList *throw_parm_list = 0;
|
||||
if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
|
||||
Parm *p;
|
||||
int gencomma = 0;
|
||||
|
||||
Append(w->def, " throw(");
|
||||
Append(declaration, " throw(");
|
||||
|
||||
if (throw_parm_list)
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
}
|
||||
String *str = SwigType_str(Getattr(p, "type"), 0);
|
||||
Append(w->def, str);
|
||||
Append(declaration, str);
|
||||
Delete(str);
|
||||
}
|
||||
}
|
||||
Append(w->def, ")");
|
||||
Append(declaration, ")");
|
||||
}
|
||||
Append(w->def, " {");
|
||||
Append(declaration, ";\n");
|
||||
/* declare method return value
|
||||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue