Merge branch 'ZackerySpytz-OCaml-director-classes-throw'
* ZackerySpytz-OCaml-director-classes-throw: [OCaml] Fix handling of exception specifications for director classes
This commit is contained in:
commit
526b2cf0ae
5 changed files with 79 additions and 9 deletions
|
|
@ -21,20 +21,13 @@ cpp_enum \
|
||||||
default_constructor \
|
default_constructor \
|
||||||
director_binary_string \
|
director_binary_string \
|
||||||
director_enum \
|
director_enum \
|
||||||
director_exception \
|
|
||||||
director_exception_nothrow \
|
|
||||||
director_ignore \
|
|
||||||
director_nested \
|
|
||||||
director_pass_by_value \
|
director_pass_by_value \
|
||||||
director_primitives \
|
director_primitives \
|
||||||
director_protected \
|
|
||||||
director_redefined \
|
director_redefined \
|
||||||
director_string \
|
director_string \
|
||||||
director_using \
|
|
||||||
enum_thorough \
|
enum_thorough \
|
||||||
li_windows \
|
li_windows \
|
||||||
member_pointer_const \
|
member_pointer_const \
|
||||||
nested_directors \
|
|
||||||
preproc_constants \
|
preproc_constants \
|
||||||
smart_pointer_inherit \
|
smart_pointer_inherit \
|
||||||
typedef_mptr \
|
typedef_mptr \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
open Swig
|
||||||
|
open Director_exception_catches
|
||||||
|
|
||||||
|
exception CustomException of string
|
||||||
|
|
||||||
|
let new_MyClass ob meth args =
|
||||||
|
match meth with
|
||||||
|
| "description" -> raise (CustomException "CustomException thrown in description().")
|
||||||
|
| _ -> (invoke ob) meth args
|
||||||
|
|
||||||
|
let b = new_derived_object new_BaseClass (new_MyClass) '()
|
||||||
|
try
|
||||||
|
ignore (_BaseClass_call_description (b)); assert false
|
||||||
|
with CustomException s ->
|
||||||
|
assert (s = "CustomException thrown in description().")
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
open Swig
|
||||||
|
open Director_exception_nothrow
|
||||||
|
|
||||||
|
let _MyBar ob meth args =
|
||||||
|
match meth with
|
||||||
|
| "pang" -> C_string "_MyBar::pang()"
|
||||||
|
| _ -> (invoke ob) meth args
|
||||||
|
|
||||||
|
let a = new_derived_object new_Bar (_MyBar) '()
|
||||||
|
let _ = assert (_MyBar a "pang" '() as string = "_MyBar::pang()")
|
||||||
|
let b = new_Bar '()
|
||||||
|
let _ = assert (b -> pang () as string = "Bar::pang()")
|
||||||
18
Examples/test-suite/ocaml/director_ignore_runme.ml
Normal file
18
Examples/test-suite/ocaml/director_ignore_runme.ml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
open Swig
|
||||||
|
open Director_ignore
|
||||||
|
|
||||||
|
let _DIgnoresDerived ob meth args =
|
||||||
|
match meth with
|
||||||
|
| "OverloadedMethod" -> C_int 0
|
||||||
|
| _ -> (invoke ob) meth args
|
||||||
|
|
||||||
|
let a =new_derived_object new_DIgnores (_DIgnoresDerived) '()
|
||||||
|
let _ = assert (a -> Triple (5) as int = 15)
|
||||||
|
|
||||||
|
let _DAbstractIgnoresDerived ob meth args =
|
||||||
|
match meth with
|
||||||
|
| "OverloadedMethod" -> C_int 0
|
||||||
|
| _ -> (invoke ob) meth args
|
||||||
|
|
||||||
|
let a = new_derived_object new_DAbstractIgnores (_DAbstractIgnoresDerived) '()
|
||||||
|
let _ = assert (a -> Quadruple (5) as int = 20)
|
||||||
|
|
@ -1407,14 +1407,46 @@ public:
|
||||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0);
|
target = Swig_method_decl(rtype, decl, qualified_name, l, 0);
|
||||||
Printf(w->def, "%s {", target);
|
Printf(w->def, "%s", target);
|
||||||
Delete(qualified_name);
|
Delete(qualified_name);
|
||||||
Delete(target);
|
Delete(target);
|
||||||
/* header declaration */
|
/* header declaration */
|
||||||
target = Swig_method_decl(rtype, decl, name, l, 1);
|
target = Swig_method_decl(rtype, decl, name, l, 1);
|
||||||
Printf(declaration, " virtual %s;", target);
|
Printf(declaration, " virtual %s", target);
|
||||||
Delete(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
|
/* declare method return value
|
||||||
* if the return value is a reference or const reference, a specialized typemap must
|
* if the return value is a reference or const reference, a specialized typemap must
|
||||||
* handle it, including declaration of c_result ($result).
|
* handle it, including declaration of c_result ($result).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue