From: William F. <wsf...@us...> - 2005-07-27 20:09:52
|
Update of /cvsroot/swig/SWIG/Lib/tcl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25880/tcl Modified Files: std_common.i std_map.i std_vector.i Log Message: use exception specification instead of %exception to handle STL error checking Index: std_vector.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/tcl/std_vector.i,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** std_vector.i 13 Jun 2005 16:43:34 -0000 1.11 --- std_vector.i 27 Jul 2005 20:09:42 -0000 1.12 *************** *** 6,39 **** // Tcl implementation ! ! %include exception.i ! ! // containers ! ! // methods which can raise are caused to throw an IndexError ! %exception std::vector::get { ! try { ! $action ! } catch (std::out_of_range& e) { ! SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what())); ! } ! } ! ! %exception std::vector::set { ! try { ! $action ! } catch (std::out_of_range& e) { ! SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what())); ! } ! } ! ! %exception std::vector::pop { ! try { ! $action ! } catch (std::out_of_range& e) { ! SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what())); ! } ! } ! // ------------------------------------------------------------------------ --- 6,10 ---- // Tcl implementation ! %include <std_common.i> // ------------------------------------------------------------------------ *************** *** 242,246 **** void push_back(const T& x); %extend { ! T pop() { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); --- 213,217 ---- void push_back(const T& x); %extend { ! T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); *************** *** 249,253 **** return x; } ! T& get(int i) { int size = int(self->size()); if (i<0) i += size; --- 220,224 ---- return x; } ! T& get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; *************** *** 257,261 **** throw std::out_of_range("vector index out of range"); } ! void set(int i, const T& x) { int size = int(self->size()); if (i<0) i+= size; --- 228,232 ---- throw std::out_of_range("vector index out of range"); } ! void set(int i, const T& x) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i+= size; *************** *** 393,397 **** void push_back(T x); %extend { ! T pop() { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); --- 364,368 ---- void push_back(T x); %extend { ! T pop() throw (std::out_of_range) { if (self->size() == 0) throw std::out_of_range("pop from empty vector"); *************** *** 400,404 **** return x; } ! T get(int i) { int size = int(self->size()); if (i<0) i += size; --- 371,375 ---- return x; } ! T get(int i) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i += size; *************** *** 408,412 **** throw std::out_of_range("vector index out of range"); } ! void set(int i, T x) { int size = int(self->size()); if (i<0) i+= size; --- 379,383 ---- throw std::out_of_range("vector index out of range"); } ! void set(int i, T x) throw (std::out_of_range) { int size = int(self->size()); if (i<0) i+= size; Index: std_common.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/tcl/std_common.i,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** std_common.i 15 Nov 2004 20:56:36 -0000 1.4 --- std_common.i 27 Jul 2005 20:09:41 -0000 1.5 *************** *** 6,9 **** --- 6,11 ---- // Tcl implementation + %include <std/std_except.i> + %types(std::size_t); %apply size_t { std::size_t }; Index: std_map.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/tcl/std_map.i,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** std_map.i 27 Feb 2003 10:05:55 -0000 1.1 --- std_map.i 27 Jul 2005 20:09:42 -0000 1.2 *************** *** 6,27 **** // Common implementation ! %include std_common.i ! %include exception.i ! ! %exception std::map::get { ! try { ! $action ! } catch (std::out_of_range& e) { ! SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what())); ! } ! } ! ! %exception std::map::del { ! try { ! $action ! } catch (std::out_of_range& e) { ! SWIG_exception(SWIG_IndexError,const_cast<char*>(e.what())); ! } ! } // ------------------------------------------------------------------------ --- 6,10 ---- // Common implementation ! %include <std_common.i> // ------------------------------------------------------------------------ *************** *** 49,53 **** void clear(); %extend { ! T& get(const K& key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 32,36 ---- void clear(); %extend { ! T& get(const K& key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 59,63 **** (*self)[key] = x; } ! void del(const K& key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 42,46 ---- (*self)[key] = x; } ! void del(const K& key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 88,92 **** void clear(); %extend { ! T& get(K key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 71,75 ---- void clear(); %extend { ! T& get(K key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 98,102 **** (*self)[key] = x; } ! void del(K key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 81,85 ---- (*self)[key] = x; } ! void del(K key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 124,128 **** void clear(); %extend { ! T get(const K& key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 107,111 ---- void clear(); %extend { ! T get(const K& key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 134,138 **** (*self)[key] = x; } ! void del(const K& key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 117,121 ---- (*self)[key] = x; } ! void del(const K& key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 161,165 **** void clear(); %extend { ! T get(K key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 144,148 ---- void clear(); %extend { ! T get(K key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) *************** *** 171,175 **** (*self)[key] = x; } ! void del(K key) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) --- 154,158 ---- (*self)[key] = x; } ! void del(K key) throw (std::out_of_range) { std::map<K,T >::iterator i = self->find(key); if (i != self->end()) |