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:
William S Fulton 2019-01-31 07:21:50 +00:00
commit 526b2cf0ae
5 changed files with 79 additions and 9 deletions

View file

@ -21,20 +21,13 @@ cpp_enum \
default_constructor \
director_binary_string \
director_enum \
director_exception \
director_exception_nothrow \
director_ignore \
director_nested \
director_pass_by_value \
director_primitives \
director_protected \
director_redefined \
director_string \
director_using \
enum_thorough \
li_windows \
member_pointer_const \
nested_directors \
preproc_constants \
smart_pointer_inherit \
typedef_mptr \

View file

@ -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().")

View file

@ -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()")

View 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)