[pygccxml-commit] SF.net SVN: pygccxml:[1761] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2009-10-01 22:57:09
|
Revision: 1761
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1761&view=rev
Author: roman_yakovenko
Date: 2009-10-01 22:56:50 +0000 (Thu, 01 Oct 2009)
Log Message:
-----------
Adding "explicit" attribute to constructor_t class
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/calldef.py
pygccxml_dev/pygccxml/declarations/decl_printer.py
pygccxml_dev/pygccxml/parser/scanner.py
pygccxml_dev/unittests/data/declarations_calldef.hpp
pygccxml_dev/unittests/declarations_tester.py
pygccxml_dev/unittests/filters_tester.py
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2009-09-22 18:41:38 UTC (rev 1760)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2009-10-01 22:56:50 UTC (rev 1761)
@@ -532,7 +532,19 @@
"""describes constructor declaration"""
def __init__( self, *args, **keywords ):
member_calldef_t.__init__( self, *args, **keywords )
+ self._explicit = True
+ def _get_explicit(self):
+ return self._explicit
+ def _set_explicit(self, explicit):
+ if explicit in [True, '1']:
+ self._explicit = True
+ else:
+ self._explicit = False
+ explicit = property( _get_explicit, _set_explicit
+ , doc="""True, if constructor has "explicit" keyword, False otherwise
+ @type: bool""" )
+
def __str__(self):
# Get the full name of the calldef...
name = algorithm.full_name(self)
@@ -568,7 +580,6 @@
def is_trivial_constructor(self):
return not bool( self.arguments )
-
class destructor_t( member_calldef_t ):
"""describes deconstructor declaration"""
def __init__( self, *args, **keywords ):
Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-09-22 18:41:38 UTC (rev 1760)
+++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-10-01 22:56:50 UTC (rev 1761)
@@ -146,8 +146,11 @@
self.print_decl_header()
self.print_calldef_info()
+ indent = ' ' * (self.level+1) * self.INDENT_SIZE
+ self.writer( indent + "explicit: " + str(self.__inst.explicit) + os.linesep)
+
if self.__print_details:
- self.writer( ' ' * ( self.level + 1 ) * self.INDENT_SIZE
+ self.writer( indent
+ 'copy constructor: ' + str(self.__inst.is_copy_constructor) + os.linesep)
def visit_destructor( self ):
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2009-09-22 18:41:38 UTC (rev 1760)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2009-10-01 22:56:50 UTC (rev 1761)
@@ -29,6 +29,7 @@
XML_AN_CVS_REVISION = "cvs_revision"
XML_AN_DEFAULT = "default"
XML_AN_DEMANGLED = "demangled"
+XML_AN_EXPLICIT = "explicit"
XML_AN_EXTERN = "extern"
XML_AN_FILE = "file"
XML_AN_ID = "id"
@@ -494,6 +495,7 @@
def __read_constructor( self, attrs ):
constructor = self.__decl_factory.create_constructor()
self.__read_member_function( constructor, attrs, True )
+ constructor.explicit = attrs.get( XML_AN_EXPLICIT, False )
return constructor
def __read_function(self, attrs):
Modified: pygccxml_dev/unittests/data/declarations_calldef.hpp
===================================================================
--- pygccxml_dev/unittests/data/declarations_calldef.hpp 2009-09-22 18:41:38 UTC (rev 1760)
+++ pygccxml_dev/unittests/data/declarations_calldef.hpp 2009-10-01 22:56:50 UTC (rev 1761)
@@ -27,8 +27,10 @@
struct calldefs_t{
calldefs_t();
- calldefs_t(char);
+ explicit calldefs_t(char);
+ calldefs_t(some_exception_t);
+
calldefs_t(int,double);
calldefs_t(const calldefs_t&);
Modified: pygccxml_dev/unittests/declarations_tester.py
===================================================================
--- pygccxml_dev/unittests/declarations_tester.py 2009-09-22 18:41:38 UTC (rev 1760)
+++ pygccxml_dev/unittests/declarations_tester.py 2009-10-01 22:56:50 UTC (rev 1761)
@@ -123,7 +123,7 @@
destructor = struct_calldefs.calldef( '~calldefs_t' )
self._test_calldef_args( destructor, [] )
- self._test_calldef_return_type( destructor, None.__class__)
+ self._test_calldef_return_type( destructor, None.__class__)
#well, now we have a few functions ( constructors ) with the same name, there is no easy way
#to find the desired one. Well in my case I have only 4 constructors
@@ -132,14 +132,23 @@
#3. default
#4. copy constructor
constructor_found = struct_calldefs.constructors( 'calldefs_t' )
- self.failUnless( len( constructor_found ) == 4
- , "struct 'calldefs_t' has 4 constructors, pygccxml parser reports only about %d." \
+ self.failUnless( len( constructor_found ) == 5
+ , "struct 'calldefs_t' has 5 constructors, pygccxml parser reports only about %d." \
% len( constructor_found ) )
self.failUnless( 1 == len( filter( lambda constructor: constructor.is_copy_constructor, constructor_found ) )
, "copy constructor has not been found" )
#there is nothing to check about constructors - I know the implementation of parser
#In this case it doesn't different from any other function
+ c = struct_calldefs.constructor( 'calldefs_t', arg_types=['char'] )
+ self.failUnless( c.explicit == True
+ , "calldef_t constructor defined with 'explicit' keyword, for some reason the value is False ")
+
+ arg_type = declarated_t( self.global_ns.class_('some_exception_t') )
+ c = struct_calldefs.constructor( 'calldefs_t', arg_types=[arg_type] )
+ self.failUnless( c.explicit == False
+ , "calldef_t constructor defined without 'explicit' keyword, for some reason the value is True ")
+
def test_operator_symbol(self):
calldefs_operators = ['=', '==' ]
calldefs_cast_operators = ['char *', 'double']
Modified: pygccxml_dev/unittests/filters_tester.py
===================================================================
--- pygccxml_dev/unittests/filters_tester.py 2009-09-22 18:41:38 UTC (rev 1760)
+++ pygccxml_dev/unittests/filters_tester.py 2009-10-01 22:56:50 UTC (rev 1761)
@@ -40,9 +40,9 @@
public_members = declarations.matcher.find( criteria, self.global_ns )
if '0.9' in public_members[0].compiler:
public_members = filter( lambda d: not d.is_artificial, public_members )
- self.failUnless( 16 == len( public_members ) )
+ self.failUnless( 17 == len( public_members ) )
else:
- self.failUnless( 20 == len( public_members ) )
+ self.failUnless( 21 == len( public_members ) )
def test_or_matcher( self ):
criteria1 = declarations.regex_matcher_t( 'oper.*'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|