[pygccxml-commit] SF.net SVN: pygccxml: [853] pyplusplus_dev/unittests/data
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2007-01-07 05:40:51
|
Revision: 853
http://svn.sourceforge.net/pygccxml/?rev=853&view=rev
Author: roman_yakovenko
Date: 2007-01-06 21:40:51 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
adding "no-throw" specifier to generated virtual functions
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/calldef.py
pygccxml_dev/pygccxml/parser/scanner.py
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/unittests/data/throw_to_be_exported.hpp
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2007-01-06 21:55:12 UTC (rev 852)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2007-01-07 05:40:51 UTC (rev 853)
@@ -105,13 +105,14 @@
class calldef_t( declaration.declaration_t ):
"""base class for all "callable" declarations"""
- def __init__( self, name='', arguments=None, exceptions=None, return_type=None, has_extern=False ):
+ def __init__( self, name='', arguments=None, exceptions=None, return_type=None, has_extern=False, does_throw=True ):
declaration.declaration_t.__init__( self, name )
if not arguments:
arguments = []
self._arguments = arguments
if not exceptions:
exceptions = []
+ self._does_throw = does_throw
self._exceptions = exceptions
self._return_type = return_type
self._has_extern = has_extern
@@ -126,6 +127,7 @@
items = [ self.arguments
, self.return_type
, self.has_extern
+ , self.does_throw
, self._sorted_list( self.exceptions ) ]
items.extend( self._get__cmp__call_items() )
return items
@@ -136,6 +138,7 @@
return self.return_type == other.return_type \
and self.arguments == other.arguments \
and self.has_extern == other.has_extern \
+ and self.does_throw == other.does_throw \
and self._sorted_list( self.exceptions ) \
== other._sorted_list( other.exceptions )
@@ -168,6 +171,16 @@
"""list of all optional arguments, the arguments that have default value"""
return self.arguments[ len( self.required_args ) : ]
+ def _get_does_throw(self):
+ return self._does_throw
+ def _set_does_throw(self, does_throw):
+ self._does_throw = does_throw
+ does_throw = property( _get_does_throw, _set_does_throw,
+ doc="""If False, than function does not throw any exception.
+ In this case, function was declared with empty throw
+ statement.
+ """)
+
def _get_exceptions(self):
return self._exceptions
def _set_exceptions(self, exceptions):
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2007-01-06 21:55:12 UTC (rev 852)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2007-01-07 05:40:51 UTC (rev 853)
@@ -322,7 +322,16 @@
if isinstance( calldef, declaration_t ):
calldef.name = attrs.get(XML_AN_NAME, '')
calldef.has_extern = attrs.get( XML_AN_EXTERN, False )
- calldef.exceptions = attrs.get( XML_AN_THROW, "" ).split()
+ throw_stmt = attrs.get( XML_AN_THROW, "" )
+ if None is throw_stmt:
+ calldef.does_throw = True
+ calldef.exceptions = []
+ elif "" == throw_stmt:
+ calldef.does_throw = False
+ calldef.exceptions = []
+ else:
+ calldef.does_throw = True
+ calldef.exceptions = throw_stmt.split()
def __read_member_function( self, calldef, attrs ):
self.__read_calldef( calldef, attrs )
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-01-06 21:55:12 UTC (rev 852)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-01-07 05:40:51 UTC (rev 853)
@@ -158,12 +158,16 @@
return 'throw std::logic_error("%s");' % msg
def throw_specifier_code( self ):
- if not self.declaration.exceptions:
- return ''
- exceptions = map( lambda exception:
- algorithm.create_identifier( self, declarations.full_name( exception ) )
- , self.declaration.exceptions )
- return ' throw( ' + self.PARAM_SEPARATOR.join( exceptions ) + ' )'
+ if self.declaration.does_throw:
+ if not self.declaration.exceptions:
+ return ''
+ else:
+ exceptions = map( lambda exception:
+ algorithm.create_identifier( self, declarations.full_name( exception ) )
+ , self.declaration.exceptions )
+ return ' throw( ' + self.PARAM_SEPARATOR.join( exceptions ) + ' )'
+ else:
+ return ' throw()'
class free_function_t( calldef_t ):
def __init__( self, function ):
Modified: pyplusplus_dev/unittests/data/throw_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/throw_to_be_exported.hpp 2007-01-06 21:55:12 UTC (rev 852)
+++ pyplusplus_dev/unittests/data/throw_to_be_exported.hpp 2007-01-07 05:40:51 UTC (rev 853)
@@ -18,7 +18,7 @@
struct mem_fun_throw_exception_t{
void raise_nothing() throw() {};
- void raise_nothing(int) throw() {};
+ virtual void raise_nothing(int) throw() {};
virtual void raise_always() throw( my_exception ){};
virtual void raise_always(int) throw( my_exception ){};
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|