From a925249e0b5703bbcd05e51b40dc2e9559cc5bb7 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 10 Jan 2006 23:17:15 +0000 Subject: [PATCH] change the %catchs name to %catches git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8357 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 24 ++++++++++++++++++------ Examples/ruby/exception_class/example.i | 15 ++++++++------- Examples/test-suite/exception_order.i | 2 +- Lib/swig.swg | 6 +++--- Source/Modules/allocate.cxx | 2 +- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index cd069a0ec..44643fb8c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,17 @@ Version 1.3.28 (unreleased). =========================== +01/10/2006: mmatus + - Ass the 'utitle' encoder, as an example of how to add + your own encoder. I added the encoder method in misc.c + but you can add another one, the same way, inside any + target language. + + Well, 'utitle' is the reverse of 'ctitle', ie: + + %rename("%(ctitle)s") camel_case; -> CamelCase; + %rename("%(utitle)s") CamelCase; -> camel_case; + + 01/10/2006: cfisavage Updated Ruby Exception handling. Classes that are specified in throws clauses, or are marked as %exceptionclass, are now inherited from rb_eRuntimeError. @@ -10,7 +22,7 @@ Version 1.3.28 (unreleased). 01/10/2006: mmatus - - Add the %catchs directive, which complements the %exception + - Add the %catches directive, which complements the %exception directive in a more automatic way. For example, if you have int foo() throw(E1); @@ -39,7 +51,7 @@ Version 1.3.28 (unreleased). } catch(E2) { ... } } - which is very tedious. Well, the %catchs directive defines + which is very tedious. Well, the %catches directive defines the list of exception to catch, and from swig: %catch(E1,E2) barfoo(int i); @@ -49,7 +61,7 @@ Version 1.3.28 (unreleased). int barfoo(int i) throw(E1,E2); - Note, however, that the %catchs list doesn't have to + Note, however, that the %catches list doesn't have to correspond to the C++ 'throw' list. For example, if you have: @@ -61,7 +73,7 @@ Version 1.3.28 (unreleased). you can define - %catchs(E) barfoo(int i); + %catches(E) barfoo(int i); and swig will generate an action code equivalent to @@ -78,9 +90,9 @@ Version 1.3.28 (unreleased). Also, you can now specify that you want to catch the unknown exception '...', for example: - %catchs(E1,E2,...) barfoo(int); + %catches(E1,E2,...) barfoo(int); - In any case, the %catchs directive will emit the + In any case, the %catches directive will emit the 'rethrowing' code using the 'throw' typemap. For the same, for the '...' case to work, you need to diff --git a/Examples/ruby/exception_class/example.i b/Examples/ruby/exception_class/example.i index 593cc0649..5094b7a60 100644 --- a/Examples/ruby/exception_class/example.i +++ b/Examples/ruby/exception_class/example.i @@ -17,10 +17,10 @@ /* The EmpytError doesn't appear in a throw declaration, and hence we need to tell SWIG that the dequeue method throws it. This can now be done via the %catchs feature. */ -%catchs(EmptyError) *::dequeue(); +%catches(EmptyError) *::dequeue(); -/* What the catchs clause is doing under the covers is this: +/* What the catches clause is doing under the covers is this: %exceptionclass EmptyError; @@ -28,11 +28,12 @@ try { $action } catch(EmptyError& e) { - // Create a new instance of the EmptyError, wrap it as a Ruby object that Ruby owns, - // and return it as the exception. For this to work EmtpyError must inherit from - // a standard Ruby exception class such as rb_eRuntimeError. SWIG automatically does - // this when the class is marked as %exceptionclass or is a throws specification. - %raise(SWIG_NewPointerObj(new EmptyError(e), SWIGTYPE_p_EmptyError, SWIG_POINTER_OWN), "EmptyError", SWIGTYPE_p_EmptyError); + // Create a new instance of the EmptyError, wrap it as a Ruby object that Ruby owns, + // and return it as the exception. For this to work EmtpyError must inherit from + // a standard Ruby exception class such as rb_eRuntimeError. SWIG automatically does + // this when the class is marked as %exceptionclass or is a throws specification. + %raise(SWIG_NewPointerObj(new EmptyError(e),SWIGTYPE_p_EmptyError, SWIG_POINTER_OWN), + "EmptyError", SWIGTYPE_p_EmptyError); } } */ diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i index 3c376b6e8..4de5e0365 100644 --- a/Examples/test-suite/exception_order.i +++ b/Examples/test-suite/exception_order.i @@ -15,7 +15,7 @@ } } -%catchs(E1,E2*,ET,ET,...) A::barfoo(int i); +%catches(E1,E2*,ET,ET,...) A::barfoo(int i); %inline %{ diff --git a/Lib/swig.swg b/Lib/swig.swg index 23e0d8edc..a34bf7ac2 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -88,10 +88,10 @@ #define %clearexception %feature("except","") -/* the %catchs directive */ +/* the %catches directive */ -#define %catchs(tlist...) %feature("catchs","("`tlist`")") -#define %clearcatchs %feature("catchs","") +#define %catches(tlist...) %feature("catches","("`tlist`")") +#define %clearcatches %feature("catches","") /* the %exceptionclass directive */ diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index af7edaf5c..71afc0287 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -467,7 +467,7 @@ class Allocate : public Dispatcher { void mark_exception_classes(Node *n) { ParmList *throws = 0; /* the "catchs" feature take precedence over the original throw list */ - String *sthrows = Getattr(n,"feature:catchs"); + String *sthrows = Getattr(n,"feature:catches"); if (sthrows) { throws = Swig_cparse_parms(sthrows); if (throws) {