From 4d6578deea16774a3cb9c4c1e531df072d9aa50a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 May 2004 15:03:46 +0000 Subject: [PATCH] Fix for exception specifications that are references. Also improves the generated exception declarations in the catch handler for pointers - a pointer is used instead of a reference to a pointer. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5940 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/emit.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SWIG/Source/Modules/emit.cxx b/SWIG/Source/Modules/emit.cxx index 0d86a4547..79ad45474 100644 --- a/SWIG/Source/Modules/emit.cxx +++ b/SWIG/Source/Modules/emit.cxx @@ -405,7 +405,7 @@ void emit_action(Node *n, Wrapper *f) { /* saves action -> eaction for postcatching exception */ String *eaction = NewString(""); - /* If we are in C++ mode and there is a throw specifier. We're going to + /* If we are in C++ mode and there is an exception specification. We're going to enclose the block in a try block */ if (throws) { Printf(eaction,"try {\n"); @@ -419,7 +419,13 @@ void emit_action(Node *n, Wrapper *f) { for (Parm *ep = throws; ep; ep = nextSibling(ep)) { String *em = Swig_typemap_lookup_new("throws",ep,"_e",0); if (em) { - Printf(eaction,"catch(%s) {\n", SwigType_str(Getattr(ep,"type"),"&_e")); + SwigType *et = Getattr(ep,"type"); + SwigType *etr = SwigType_typedef_resolve_all(et); + if (SwigType_isreference(etr) || SwigType_ispointer(etr)) { + Printf(eaction,"catch(%s) {\n", SwigType_str(et, "_e")); + } else { + Printf(eaction,"catch(%s) {\n", SwigType_str(et, "&_e")); + } Printv(eaction,em,"\n",NIL); Printf(eaction,"}\n"); } else {