pygccxml-commit Mailing List for C++ Python language bindings (Page 32)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(190) |
Apr
(166) |
May
(170) |
Jun
(75) |
Jul
(105) |
Aug
(131) |
Sep
(99) |
Oct
(84) |
Nov
(67) |
Dec
(54) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(66) |
Feb
(49) |
Mar
(25) |
Apr
(62) |
May
(21) |
Jun
(34) |
Jul
(9) |
Aug
(21) |
Sep
(5) |
Oct
|
Nov
(63) |
Dec
(34) |
| 2008 |
Jan
(10) |
Feb
(42) |
Mar
(26) |
Apr
(25) |
May
(6) |
Jun
(40) |
Jul
(18) |
Aug
(29) |
Sep
(6) |
Oct
(32) |
Nov
(14) |
Dec
(56) |
| 2009 |
Jan
(127) |
Feb
(52) |
Mar
(2) |
Apr
(10) |
May
(29) |
Jun
(3) |
Jul
|
Aug
(16) |
Sep
(4) |
Oct
(11) |
Nov
(8) |
Dec
(14) |
| 2010 |
Jan
(31) |
Feb
(1) |
Mar
(7) |
Apr
(9) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
(8) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <rom...@us...> - 2007-07-03 20:46:50
|
Revision: 1083
http://svn.sourceforge.net/pygccxml/?rev=1083&view=rev
Author: roman_yakovenko
Date: 2007-07-03 13:46:49 -0700 (Tue, 03 Jul 2007)
Log Message:
-----------
adding support for double type
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/array_1.py
pyplusplus_dev/unittests/data/global_variables_to_be_exported.cpp
pyplusplus_dev/unittests/data/global_variables_to_be_exported.hpp
Modified: pyplusplus_dev/pyplusplus/code_repository/array_1.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/array_1.py 2007-06-26 05:31:20 UTC (rev 1082)
+++ pyplusplus_dev/pyplusplus/code_repository/array_1.py 2007-07-03 20:46:49 UTC (rev 1083)
@@ -22,6 +22,9 @@
#define __array_1_pyplusplus_hpp__
#include "boost/python.hpp"
+#include "boost/mpl/if.hpp"
+#include "boost/type_traits/is_same.hpp"
+#include "boost/type_traits/is_fundamental.hpp"
//1 - dimension
namespace pyplusplus{ namespace containers{ namespace static_sized{
@@ -33,11 +36,33 @@
}
}
+namespace details{
+
+template<class T>
+struct is_immutable{
+ BOOST_STATIC_CONSTANT(
+ bool
+ , value = ( boost::is_same< T, std::string >::value )
+ || ( boost::is_same< T, std::wstring >::value )
+ || ( boost::is_fundamental< T >::value )
+ || ( boost::is_enum< T >::value )
+ );
+
+};
+
+}//details
+
template< class TItemType, long unsigned int size >
struct const_array_1_t{
+
+ typedef BOOST_DEDUCED_TYPENAME boost::call_traits<const TItemType>::param_type param_type;
+
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
+ details::is_immutable<TItemType>::value
+ , TItemType
+ , param_type
+ >::type reference_type;
- typedef BOOST_DEDUCED_TYPENAME boost::call_traits<const TItemType>::param_type reference_type;
-
const_array_1_t( TItemType const * const data )
: m_data( data ){
if( !data ){
@@ -63,7 +88,13 @@
template< class TItemType, long unsigned int size >
struct array_1_t{
- typedef BOOST_DEDUCED_TYPENAME boost::call_traits<const TItemType>::param_type reference_type;
+ typedef BOOST_DEDUCED_TYPENAME boost::call_traits<const TItemType>::param_type param_type;
+
+ typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
+ details::is_immutable<TItemType>::value
+ , TItemType
+ , param_type
+ >::type reference_type;
array_1_t( TItemType * data )
: m_data( data ){
Modified: pyplusplus_dev/unittests/data/global_variables_to_be_exported.cpp
===================================================================
--- pyplusplus_dev/unittests/data/global_variables_to_be_exported.cpp 2007-06-26 05:31:20 UTC (rev 1082)
+++ pyplusplus_dev/unittests/data/global_variables_to_be_exported.cpp 2007-07-03 20:46:49 UTC (rev 1083)
@@ -1,21 +1,22 @@
-// Copyright 2004 Roman Yakovenko.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include "global_variables_to_be_exported.hpp"
-
-namespace global_variables{
-
-const color const_var = red;
-color non_const_var = blue;
-
-data garray[10];
-
-void init_garray(){
- for( int i =0; i < 10; ++i ){
- garray[i].value = -i;
- }
-}
-
-}
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include "global_variables_to_be_exported.hpp"
+
+namespace global_variables{
+
+const color const_var = red;
+color non_const_var = blue;
+
+data garray[10];
+double arr_of_doubles[100];
+
+void init_garray(){
+ for( int i =0; i < 10; ++i ){
+ garray[i].value = -i;
+ }
+}
+
+}
Modified: pyplusplus_dev/unittests/data/global_variables_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/global_variables_to_be_exported.hpp 2007-06-26 05:31:20 UTC (rev 1082)
+++ pyplusplus_dev/unittests/data/global_variables_to_be_exported.hpp 2007-07-03 20:46:49 UTC (rev 1083)
@@ -1,23 +1,24 @@
-// Copyright 2004 Roman Yakovenko.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef __global_variables_to_be_exported_hpp__
-#define __global_variables_to_be_exported_hpp__
-
-namespace global_variables{
-
-enum color{ red, green, blue };
-
-extern const color const_var;
-extern color non_const_var;
-
-struct data{ int value; };
-extern data garray[10];
-
-void init_garray();
-
-}
-
-#endif//__global_variables_to_be_exported_hpp__
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __global_variables_to_be_exported_hpp__
+#define __global_variables_to_be_exported_hpp__
+
+namespace global_variables{
+
+enum color{ red, green, blue };
+
+extern const color const_var;
+extern color non_const_var;
+
+struct data{ int value; };
+extern data garray[10];
+
+extern double arr_of_doubles[100];
+void init_garray();
+
+}
+
+#endif//__global_variables_to_be_exported_hpp__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-26 05:35:54
|
Revision: 1082
http://svn.sourceforge.net/pygccxml/?rev=1082&view=rev
Author: roman_yakovenko
Date: 2007-06-25 22:31:20 -0700 (Mon, 25 Jun 2007)
Log Message:
-----------
small temporal patch to fix non-generated value traits header file
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
Modified: pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2007-06-24 05:55:32 UTC (rev 1081)
+++ pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2007-06-26 05:31:20 UTC (rev 1082)
@@ -46,7 +46,10 @@
self.__predefined_include_creators \
= filter( lambda creator: isinstance( creator, code_creators.include_t )
, self.extmodule.creators )
+ self.__value_traits = filter( lambda x: isinstance(x, code_creators.value_traits_t)
+ , self.extmodule.creators )
+
def write_file( self, fpath, content ):
self.written_files.append( fpath )
writer.writer_t.write_file( fpath, content, self.files_sum_repository, self.encoding )
@@ -130,6 +133,16 @@
return None
if not isinstance( code_creator.declaration.indexing_suite, decl_wrappers.indexing_suite2_t ):
return None
+
+ #sometimes, for some reason I expose containers as regular classes ( hash_map )
+ #and in this case I do generate include to
+ classes = ( code_creators.indexing_suite1_t, code_creators.indexing_suite2_t )
+ for cont_code_creator in code_creator.creators:
+ if isinstance( cont_code_creator, classes ):
+ break
+ else:
+ return None
+
try:
element_type = code_creator.declaration.indexing_suite.element_type
class_traits = declarations.class_traits
@@ -365,9 +378,7 @@
self.extmodule.do_include_dirs_optimization()
- value_traits_classes = filter( lambda x: isinstance(x, code_creators.value_traits_t )
- , self.extmodule.creators )
- map( self.split_value_traits, value_traits_classes )
+ map( self.split_value_traits, self.__value_traits )
# Obtain a list of all class creators...
class_creators = filter( lambda x: isinstance(x, ( code_creators.class_t, code_creators.class_declaration_t ) )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-24 05:55:30
|
Revision: 1081
http://svn.sourceforge.net/pygccxml/?rev=1081&view=rev
Author: roman_yakovenko
Date: 2007-06-23 22:55:32 -0700 (Sat, 23 Jun 2007)
Log Message:
-----------
bug fix: any type could also be used as exception modifier in throw statement, in function definition
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/__init__.py
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py
pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py
pyplusplus_dev/unittests/indexing_suites2_tester.py
Modified: pyplusplus_dev/pyplusplus/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/__init__.py 2007-06-24 05:16:11 UTC (rev 1080)
+++ pyplusplus_dev/pyplusplus/__init__.py 2007-06-24 05:55:32 UTC (rev 1081)
@@ -37,7 +37,7 @@
__version__ = '0.9.0'
import pygccxml
-if not hasattr( pygccxml, '__revision__' ) or pygccxml.__revision__ < 1053:
+if not hasattr( pygccxml, '__revision__' ) or pygccxml.__revision__ < 1080:
msg = 'This revision of Py++ requieres pygccxml revision to be ' \
'greater or equal to %d. ' \
'Please install right pygccxml version.'
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-06-24 05:16:11 UTC (rev 1080)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-06-24 05:55:32 UTC (rev 1081)
@@ -168,8 +168,7 @@
if not self.declaration.exceptions:
return ''
else:
- exceptions = map( lambda exception:
- algorithm.create_identifier( self, declarations.full_name( exception ) )
+ exceptions = map( lambda exception: algorithm.create_identifier( self, exception.decl_string )
, self.declaration.exceptions )
return ' throw( ' + self.PARAM_SEPARATOR.join( exceptions ) + ' )'
else:
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2007-06-24 05:16:11 UTC (rev 1080)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2007-06-24 05:55:32 UTC (rev 1081)
@@ -74,19 +74,19 @@
indexing_suite_version = property( _get_indexing_suite_version, _set_indexing_suite_version
, doc="indexing suite version")
- def _get_indexing_suite( self ):
+ @property
+ def indexing_suite( self ):
+ """reference to indexing suite configuration class.
+
+ If the class is not STD container, this property will contain None"
+ """
if self._indexing_suite is None:
- for container_traits in declarations.all_container_traits:
- if container_traits.is_my_case( self ):
- if self._isuite_version == 1:
- self._indexing_suite = isuite1.indexing_suite1_t( self, container_traits )
- else:
- self._indexing_suite = isuite2.indexing_suite2_t( self, container_traits )
- break
+ if self.container_traits:
+ if self._isuite_version == 1:
+ self._indexing_suite = isuite1.indexing_suite1_t( self )
+ else:
+ self._indexing_suite = isuite2.indexing_suite2_t( self )
return self._indexing_suite
- indexing_suite = property( _get_indexing_suite
- , doc="reference to indexing suite configuration class. " \
- +"If the class is not STD container, returns None")
def guess_always_expose_using_scope_value( self ):
if isinstance( self.indexing_suite, isuite2.indexing_suite2_t ) \
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2007-06-24 05:16:11 UTC (rev 1080)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2007-06-24 05:55:32 UTC (rev 1081)
@@ -24,12 +24,11 @@
indexing suite.
"""
- def __init__( self, container_class, container_traits, no_proxy=None, derived_policies=None ):
+ def __init__( self, container_class, no_proxy=None, derived_policies=None ):
object.__init__( self )
self.__no_proxy = no_proxy
self.__derived_policies = derived_policies
self.__container_class = container_class
- self.__container_traits = container_traits
self.__include_files = None
@property
@@ -40,12 +39,12 @@
@property
def element_type(self):
"""reference to container value_type( mapped_type ) type"""
- return self.__container_traits.element_type( self.container_class )
+ return self.container_class.container_traits.element_type( self.container_class )
@property
def container_traits( self ):
"reference to container traits. See pygccxml documentation for more information."
- return self.__container_traits
+ return self.container_class.container_traits
def _get_no_proxy( self ):
if self.__no_proxy is None:
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2007-06-24 05:16:11 UTC (rev 1080)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2007-06-24 05:55:32 UTC (rev 1081)
@@ -66,11 +66,10 @@
, 'insert' : ( 'method_append', 'method_insert', 'method_extend' )
}
- def __init__( self, container_class, container_traits ):
+ def __init__( self, container_class ):
object.__init__( self )
self.__call_policies = None
self.__container_class = container_class
- self.__container_traits = container_traits
self._disabled_methods = set()
self._disabled_groups = set()
self._default_applied = False
@@ -83,22 +82,21 @@
self._use_container_suite = value
use_container_suite = property( get_use_container_suite, set_use_container_suite )
- def _get_container_class( self ):
+ @property
+ def container_class( self ):
+ """reference to the parent( STD container ) class"""
return self.__container_class
- container_class = property( _get_container_class
- , doc="Reference to STD container class" )
- def _get_container_traits( self ):
- return self.__container_traits
- container_traits = property( _get_container_traits
- , doc="Reference to container traits. See "
- "pygccxml documentation for STD container traits.")
+ @property
+ def element_type(self):
+ """reference to container value_type( mapped_type ) type"""
+ return self.container_traits.element_type( self.container_class )
+
+ @property
+ def container_traits( self ):
+ "reference to container traits. See pygccxml documentation for more information."
+ return self.container_class.container_traits
- def _get_element_type(self):
- return self.__container_traits.element_type( self.container_class )
- element_type = property( _get_element_type
- , doc="Reference to container value_type( mapped_type ) type" )
-
def _get_call_policies( self ):
if self.__call_policies:
return self.__call_policies
Modified: pyplusplus_dev/unittests/indexing_suites2_tester.py
===================================================================
--- pyplusplus_dev/unittests/indexing_suites2_tester.py 2007-06-24 05:16:11 UTC (rev 1080)
+++ pyplusplus_dev/unittests/indexing_suites2_tester.py 2007-06-24 05:55:32 UTC (rev 1081)
@@ -54,8 +54,8 @@
self.failUnless( kv.key == "x" and kv.value == "y" )
for k, v in name2value:
self.failUnless( k == "x" and v == "y" )
- for k, v in name2value.iteritems():
- self.failUnless( k == "x" and v == "y" )
+ #~ for k, v in name2value.iteritems():
+ #~ self.failUnless( k == "x" and v == "y" )
items_ptr = module.items_ptr_t()
items_ptr.append( item )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-24 05:16:09
|
Revision: 1080
http://svn.sourceforge.net/pygccxml/?rev=1080&view=rev
Author: roman_yakovenko
Date: 2007-06-23 22:16:11 -0700 (Sat, 23 Jun 2007)
Log Message:
-----------
updating dependency version
Modified Paths:
--------------
pygccxml_dev/pygccxml/__init__.py
Modified: pygccxml_dev/pygccxml/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/__init__.py 2007-06-24 05:15:13 UTC (rev 1079)
+++ pygccxml_dev/pygccxml/__init__.py 2007-06-24 05:16:11 UTC (rev 1080)
@@ -39,4 +39,4 @@
__version__ = '0.9.0'
-__revision__ = 1054
+__revision__ = 1080
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-24 05:15:12
|
Revision: 1079
http://svn.sourceforge.net/pygccxml/?rev=1079&view=rev
Author: roman_yakovenko
Date: 2007-06-23 22:15:13 -0700 (Sat, 23 Jun 2007)
Log Message:
-----------
updating history
Modified Paths:
--------------
pygccxml_dev/docs/history/history.rest
Modified: pygccxml_dev/docs/history/history.rest
===================================================================
--- pygccxml_dev/docs/history/history.rest 2007-06-24 05:03:05 UTC (rev 1078)
+++ pygccxml_dev/docs/history/history.rest 2007-06-24 05:15:13 UTC (rev 1079)
@@ -20,6 +20,7 @@
* Gaetan Lehmann
* Martin Preisler
* Miguel Lobo
+* Jeremy Sanders
-----------
SVN Version
@@ -33,6 +34,9 @@
.. _`GCC-XML attributes`: http://www.gccxml.org/HTML/Running.html
+3. A bug in parsing a function exception specification was fixed. Many thanks to
+ Jeremy Sanders.
+
-------------
Version 0.9.0
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-24 05:03:05
|
Revision: 1078
http://svn.sourceforge.net/pygccxml/?rev=1078&view=rev
Author: roman_yakovenko
Date: 2007-06-23 22:03:05 -0700 (Sat, 23 Jun 2007)
Log Message:
-----------
bug fix: any type could also be used as exception modifier in throw statement, in function definition
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/linker.py
pygccxml_dev/unittests/test_all.py
Added Paths:
-----------
pygccxml_dev/unittests/data/type_as_exception_bug.h
pygccxml_dev/unittests/type_as_exception_bug_tester.py
Modified: pygccxml_dev/pygccxml/parser/linker.py
===================================================================
--- pygccxml_dev/pygccxml/parser/linker.py 2007-06-24 04:28:27 UTC (rev 1077)
+++ pygccxml_dev/pygccxml/parser/linker.py 2007-06-24 05:03:05 UTC (rev 1078)
@@ -67,7 +67,10 @@
for arg in self.__inst.arguments:
arg.type = self.__link_type(arg.type)
for index in range( len( self.__inst.exceptions ) ):
- self.__inst.exceptions[index] = self.__decls[ self.__inst.exceptions[index] ]
+ try:
+ self.__inst.exceptions[index] = self.__decls[ self.__inst.exceptions[index] ]
+ except KeyError:
+ self.__inst.exceptions[index] = self.__link_type( self.__inst.exceptions[index] )
def visit_member_function( self ):
self.__link_calldef()
Added: pygccxml_dev/unittests/data/type_as_exception_bug.h
===================================================================
--- pygccxml_dev/unittests/data/type_as_exception_bug.h (rev 0)
+++ pygccxml_dev/unittests/data/type_as_exception_bug.h 2007-06-24 05:03:05 UTC (rev 1078)
@@ -0,0 +1,10 @@
+#ifndef __key_error_bug_h__
+#define __key_error_bug_h__
+
+struct ExpressionError{};
+
+struct xxx{
+ virtual void buggy() throw( ExpressionError& );
+};
+
+#endif//__key_error_bug_h__
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2007-06-24 04:28:27 UTC (rev 1077)
+++ pygccxml_dev/unittests/test_all.py 2007-06-24 05:03:05 UTC (rev 1078)
@@ -44,6 +44,7 @@
import remove_template_defaults_tester
import find_container_traits_tester
import attributes_tester
+import type_as_exception_bug_tester
def create_suite():
testers = [
@@ -87,6 +88,7 @@
, remove_template_defaults_tester
, find_container_traits_tester
, attributes_tester
+ , type_as_exception_bug_tester
]
main_suite = unittest.TestSuite()
Added: pygccxml_dev/unittests/type_as_exception_bug_tester.py
===================================================================
--- pygccxml_dev/unittests/type_as_exception_bug_tester.py (rev 0)
+++ pygccxml_dev/unittests/type_as_exception_bug_tester.py 2007-06-24 05:03:05 UTC (rev 1078)
@@ -0,0 +1,46 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import unittest
+import autoconfig
+import parser_test_case
+
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
+
+class tester_t( parser_test_case.parser_test_case_t ):
+ global_ns = None
+ def __init__(self, *args ):
+ parser_test_case.parser_test_case_t.__init__( self, *args )
+ self.header = 'type_as_exception_bug.h'
+
+ def setUp(self):
+ if not tester_t.global_ns:
+ decls = parser.parse( [self.header], self.config )
+ tester_t.global_ns = declarations.get_global_namespace( decls )
+ tester_t.global_ns.init_optimizer()
+
+ def test( self ):
+ pass
+ #~ buggy = self.global_ns.mem_fun( 'buggy' )
+ #~ ExpressionError = self.global_ns.class_( 'ExpressionError' )
+ #~ self.failUnless( len( buggy.exceptions ) == 1 )
+ #~ err = buggy.exceptions[0]
+ #~ self.failUnless( declarations.is_reference( err ) )
+ #~ err = declarations.remove_declarated( declarations.remove_reference( err ) )
+ #~ self.failUnless( err is ExpressionError )
+
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-24 04:28:31
|
Revision: 1077
http://svn.sourceforge.net/pygccxml/?rev=1077&view=rev
Author: roman_yakovenko
Date: 2007-06-23 21:28:27 -0700 (Sat, 23 Jun 2007)
Log Message:
-----------
committing attributes_tester.py
Added Paths:
-----------
pygccxml_dev/unittests/attributes_tester.py
pygccxml_dev/unittests/data/attributes.hpp
Added: pygccxml_dev/unittests/attributes_tester.py
===================================================================
--- pygccxml_dev/unittests/attributes_tester.py (rev 0)
+++ pygccxml_dev/unittests/attributes_tester.py 2007-06-24 04:28:27 UTC (rev 1077)
@@ -0,0 +1,43 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import unittest
+import autoconfig
+import parser_test_case
+
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
+
+class tester_t( parser_test_case.parser_test_case_t ):
+ global_ns = None
+ def __init__(self, *args ):
+ parser_test_case.parser_test_case_t.__init__( self, *args )
+ self.header = 'attributes.hpp'
+
+ def setUp(self):
+ if not tester_t.global_ns:
+ decls = parser.parse( [self.header], self.config )
+ tester_t.global_ns = declarations.get_global_namespace( decls )
+ tester_t.global_ns.init_optimizer()
+
+ def test( self ):
+ numeric = self.global_ns.class_( 'numeric_t' )
+ self.failUnless( None is numeric.attributes )
+ do_nothing = numeric.mem_fun( 'do_nothing' )
+ self.failUnless( "gccxml(no throw)" == do_nothing.attributes )
+ arg = do_nothing.arguments[0]
+ self.failUnless( "gccxml(out)" == arg.attributes )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Added: pygccxml_dev/unittests/data/attributes.hpp
===================================================================
--- pygccxml_dev/unittests/data/attributes.hpp (rev 0)
+++ pygccxml_dev/unittests/data/attributes.hpp 2007-06-24 04:28:27 UTC (rev 1077)
@@ -0,0 +1,24 @@
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __atributes_hpp__
+#define __atributes_hpp__
+
+#define _out_ __attribute( (gccxml( "out" ) ) )
+#define _sealed_ __attribute( (gccxml( "sealed" ) ) )
+#define _no_throw_ __attribute( (gccxml( "no throw" ) ) )
+
+namespace attributes{
+
+_sealed_ struct numeric_t{
+
+ _no_throw_ void do_nothing( _out_ int& x ){}
+
+};
+
+}
+
+#endif//__atributes_hpp__
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-22 16:22:18
|
Revision: 1076
http://svn.sourceforge.net/pygccxml/?rev=1076&view=rev
Author: roman_yakovenko
Date: 2007-06-22 09:22:18 -0700 (Fri, 22 Jun 2007)
Log Message:
-----------
adding support for "remove_defaults" for gcc
Modified Paths:
--------------
pygccxml_dev/unittests/remove_template_defaults_tester.py
Modified: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-22 16:21:57 UTC (rev 1075)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-22 16:22:18 UTC (rev 1076)
@@ -107,7 +107,8 @@
def test_hash_set( self ):
hs_v_int = self.global_ns.typedef( 'hs_v_int' )
self.failUnless( 'hash_set< std::vector< int > >'
- == declarations.hash_set_traits.remove_defaults( hs_v_int ) )
+ == declarations.hash_set_traits.remove_defaults( hs_v_int )
+ , declarations.hash_set_traits.remove_defaults( hs_v_int ) )
hs_string = self.global_ns.typedef( 'hs_string' )
self.failUnless( 'hash_set< std::string >'
== declarations.hash_set_traits.remove_defaults( hs_string ) )
@@ -136,8 +137,13 @@
self.failUnless( 'hash_multimap< const std::wstring, double >'
== declarations.hash_multimap_traits.remove_defaults( hmm_wstr2d ) )
hmm_v_i2mm_wstr2d = self.global_ns.typedef( 'hmm_v_i2mm_wstr2d' )
- self.failUnless( 'hash_multimap< const std::vector< int >, const std::hash_multimap< const std::wstring, double > >'
- == declarations.hash_multimap_traits.remove_defaults( hmm_v_i2mm_wstr2d ) )
+
+ possible_values = (
+ 'hash_multimap< const std::vector< int >, const __gnu_cxx::hash_multimap< const std::wstring, double > >'
+ , 'hash_multimap< const std::vector< int >, const std::hash_multimap< const std::wstring, double > >' )
+
+ self.failUnless( declarations.hash_multimap_traits.remove_defaults( hmm_v_i2mm_wstr2d )
+ in possible_values )
def create_suite():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-22 16:21:56
|
Revision: 1075
http://svn.sourceforge.net/pygccxml/?rev=1075&view=rev
Author: roman_yakovenko
Date: 2007-06-22 09:21:57 -0700 (Fri, 22 Jun 2007)
Log Message:
-----------
adding support for "remove_defaults" for gcc
Modified Paths:
--------------
pygccxml_dev/unittests/find_container_traits_tester.py
Modified: pygccxml_dev/unittests/find_container_traits_tester.py
===================================================================
--- pygccxml_dev/unittests/find_container_traits_tester.py 2007-06-22 16:21:23 UTC (rev 1074)
+++ pygccxml_dev/unittests/find_container_traits_tester.py 2007-06-22 16:21:57 UTC (rev 1075)
@@ -26,7 +26,11 @@
def __cmp_traits( self, typedef, expected ):
if isinstance( typedef, str ):
typedef = self.global_ns.typedef( typedef )
- self.failUnless( declarations.find_container_traits( typedef ) is expected )
+ traits = declarations.find_container_traits( typedef )
+ self.failUnless( traits, 'container traits for "%s" not found' % str( typedef ) )
+ self.failUnless( traits is expected
+ , 'container "%s", expected %s, got %s'
+ % ( str(typedef), expected.__name__, traits.__name__ ) )
cls = declarations.remove_declarated( typedef )
self.failUnless( cls.container_traits is expected )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-22 16:21:21
|
Revision: 1074
http://svn.sourceforge.net/pygccxml/?rev=1074&view=rev
Author: roman_yakovenko
Date: 2007-06-22 09:21:23 -0700 (Fri, 22 Jun 2007)
Log Message:
-----------
adding support for "remove_defaults" for gcc
Modified Paths:
--------------
pygccxml_dev/unittests/data/remove_template_defaults.hpp
Modified: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-22 16:17:05 UTC (rev 1073)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-22 16:21:23 UTC (rev 1074)
@@ -6,8 +6,15 @@
#ifndef __remove_template_defaults_hpp__
#define __remove_template_defaults_hpp__
-#include <hash_set>
-#include <hash_map>
+#if defined( __GNUC__ )
+ #include <ext/hash_set>
+ #include <ext/hash_map>
+ #define HASH_XXX_NS __gnu_cxx
+#else
+ #include <hash_set>
+ #include <hash_map>
+ #define HASH_XXX_NS std
+#endif
#include <string>
#include <vector>
#include <deque>
@@ -71,25 +78,25 @@
}
namespace hash_sets{
- typedef std::hash_set< std::vector< int > > hs_v_int;
- typedef std::hash_set< std::string > hs_string;
+ typedef HASH_XXX_NS::hash_set< std::vector< int > > hs_v_int;
+ typedef HASH_XXX_NS::hash_set< std::string > hs_string;
}
namespace hash_multisets{
- typedef std::hash_multiset< std::vector< int > > mhs_v_int;
- typedef std::hash_multiset< std::string > mhs_string;
+ typedef HASH_XXX_NS::hash_multiset< std::vector< int > > mhs_v_int;
+ typedef HASH_XXX_NS::hash_multiset< std::string > mhs_string;
}
namespace hash_maps{
- typedef std::hash_map< int, double > hm_i2d;
- typedef std::hash_map< std::wstring, double > hm_wstr2d;
+ typedef HASH_XXX_NS::hash_map< int, double > hm_i2d;
+ typedef HASH_XXX_NS::hash_map< std::wstring, double > hm_wstr2d;
}
namespace hash_multimaps{
- typedef std::hash_multimap< int, double > hmm_i2d;
- typedef std::hash_multimap< std::wstring const, double > hmm_wstr2d;
- typedef std::hash_multimap< std::vector< int > const, hmm_wstr2d const > hmm_v_i2mm_wstr2d;
+ typedef HASH_XXX_NS::hash_multimap< int, double > hmm_i2d;
+ typedef HASH_XXX_NS::hash_multimap< std::wstring const, double > hmm_wstr2d;
+ typedef HASH_XXX_NS::hash_multimap< std::vector< int > const, hmm_wstr2d const > hmm_v_i2mm_wstr2d;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-22 16:17:06
|
Revision: 1073
http://svn.sourceforge.net/pygccxml/?rev=1073&view=rev
Author: roman_yakovenko
Date: 2007-06-22 09:17:05 -0700 (Fri, 22 Jun 2007)
Log Message:
-----------
adding support for "remove_defaults" for gcc
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/container_traits.py
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-21 20:05:56 UTC (rev 1072)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-22 16:17:05 UTC (rev 1073)
@@ -16,6 +16,8 @@
import type_traits
import class_declaration
+std_namespaces = ( 'std', 'stdext', '__gnu_cxx' )
+
class defaults_eraser:
@staticmethod
def normalize( type_str ):
@@ -69,7 +71,8 @@
ri = defaults_eraser.recursive_impl
no_std = lambda cls_name: ri.decorated_call_prefix( cls_name, 'std::', ri.erase_call )
no_stdext = lambda cls_name: ri.decorated_call_prefix( cls_name, 'stdext::', no_std )
- no_const = lambda cls_name: ri.decorated_call_prefix( cls_name, 'const ', no_stdext )
+ no_gnustd = lambda cls_name: ri.decorated_call_prefix( cls_name, '__gnu_cxx::', no_stdext )
+ no_const = lambda cls_name: ri.decorated_call_prefix( cls_name, 'const ', no_gnustd )
no_end_const = lambda cls_name: ri.decorated_call_suffix( cls_name, ' const', no_const )
return no_end_const( cls_name )
@@ -150,8 +153,6 @@
, mapped_type=mapped_type
, compare=default_compare
, allocator=default_allocator )
- #~ print '\noriginal: ', defaults_eraser.normalize(cls_name)
- #~ print '\ntmpl : ', defaults_eraser.normalize(tmpl)
if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
return templates.join( c_name
, [ defaults_eraser.erase_recursive( key_type )
@@ -159,51 +160,86 @@
@staticmethod
- def erase_hash_allocator( cls_name
- , default_hash='stdext::hash_compare'
- , default_compare='std::less'
- , default_allocator='std::allocator' ):
+ def erase_hash_allocator( cls_name ):
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
- if 3 != len( c_args ):
- return
+ if len( c_args ) < 3:
+ return
+
+ default_hash=None
+ default_less='std::less'
+ default_equal_to='std::equal_to'
+ default_allocator='std::allocator'
+
+ tmpl = None
+ if 3 == len( c_args ):
+ default_hash='hash_compare'
+ tmpl = "$container< $value_type, $hash<$value_type, $less<$value_type> >, $allocator<$value_type> >"
+ elif 4 == len( c_args ):
+ default_hash='hash'
+ tmpl = "$container< $value_type, $hash<$value_type >, $equal_to<$value_type >, $allocator<$value_type> >"
+ else:
+ return
+
value_type = c_args[0]
- tmpl = string.Template( "$container< $value_type, $hash<$value_type, $less<$value_type> >, $allocator<$value_type> >" )
- tmpl = tmpl.substitute( container=c_name
- , value_type=value_type
- , hash=default_hash
- , less=default_compare
- , allocator=default_allocator )
- if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
- return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
+ tmpl = string.Template( tmpl )
+ for ns in std_namespaces:
+ inst = tmpl.substitute( container=c_name
+ , value_type=value_type
+ , hash= ns + '::' + default_hash
+ , less=default_less
+ , equal_to=default_equal_to
+ , allocator=default_allocator )
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( inst ):
+ return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
@staticmethod
- def erase_hashmap_compare_allocator( cls_name
- , default_hash='stdext::hash_compare'
- , default_compare='std::less'
- , default_allocator='std::allocator' ):
+ def erase_hashmap_compare_allocator( cls_name ):
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
- if 4 != len( c_args ):
- return
- key_type = c_args[0]
- mapped_type = c_args[1]
- tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< const $key_type, $mapped_type> > >" )
- if key_type.startswith( 'const ' ) or key_type.endswith( ' const' ):
- tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< $key_type, $mapped_type> > >" )
- tmpl = tmpl.substitute( container=c_name
- , key_type=key_type
- , mapped_type=mapped_type
- , hash=default_hash
- , less=default_compare
- , allocator=default_allocator )
- if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
- return templates.join( c_name
- , [ defaults_eraser.erase_recursive( key_type )
- , defaults_eraser.erase_recursive( mapped_type )] )
+ default_hash=None
+ default_less='std::less'
+ default_allocator='std::allocator'
+ default_equal_to = 'std::equal_to'
+
+ tmpl = None
+ key_type = None
+ mapped_type = None
+ if 2 < len( c_args ):
+ key_type = c_args[0]
+ mapped_type = c_args[1]
+ else:
+ return
+
+ if 4 == len( c_args ):
+ default_hash = 'hash_compare'
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< const $key_type, $mapped_type> > >" )
+ if key_type.startswith( 'const ' ) or key_type.endswith( ' const' ):
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< $key_type, $mapped_type> > >" )
+ elif 5 == len( c_args ):
+ default_hash = 'hash'
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type >, $equal_to<$key_type>, $allocator< $mapped_type> >" )
+ if key_type.startswith( 'const ' ) or key_type.endswith( ' const' ):
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type >, $equal_to<$key_type>, $allocator< $mapped_type > >" )
+ else:
+ return
+ for ns in std_namespaces:
+ inst = tmpl.substitute( container=c_name
+ , key_type=key_type
+ , mapped_type=mapped_type
+ , hash=ns + '::' + default_hash
+ , less=default_less
+ , equal_to = default_equal_to
+ , allocator=default_allocator )
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( inst ):
+ return templates.join( c_name
+ , [ defaults_eraser.erase_recursive( key_type )
+ , defaults_eraser.erase_recursive( mapped_type )] )
+
+
class container_traits_impl_t:
"""this class implements the functionality needed for convinient work with
STD container classes.
@@ -245,9 +281,9 @@
if not cls.name.startswith( self.name + '<' ):
return
- if not type_traits.impl_details.is_defined_in_xxx( 'std', cls ):
- return
- return cls
+ for ns in std_namespaces:
+ if type_traits.impl_details.is_defined_in_xxx( ns, cls ):
+ return cls
def is_my_case( self, type ):
"""checks, whether type is STD container or not"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-21 20:06:03
|
Revision: 1072
http://svn.sourceforge.net/pygccxml/?rev=1072&view=rev
Author: roman_yakovenko
Date: 2007-06-21 13:05:56 -0700 (Thu, 21 Jun 2007)
Log Message:
-----------
adding support for member variable pointers
Modified Paths:
--------------
pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp
Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2007-06-21 20:05:23 UTC (rev 1071)
+++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2007-06-21 20:05:56 UTC (rev 1072)
@@ -7,6 +7,7 @@
#define __member_variables_to_be_exported_hpp__
#include <memory>
#include <string>
+#include <iostream>
namespace member_variables{
@@ -76,7 +77,8 @@
static char* reserved;
};
-struct tree_node_t{
+struct tree_node_t{
+
data_t *data;
tree_node_t *left;
tree_node_t *right;
@@ -90,15 +92,7 @@
{}
~tree_node_t(){
- if( left ){
- delete left;
- }
- if( right ){
- delete right;
- }
- if( data ){
- delete data;
- }
+ std::cout << "\n~tree_node_t";
}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-21 20:05:24
|
Revision: 1071
http://svn.sourceforge.net/pygccxml/?rev=1071&view=rev
Author: roman_yakovenko
Date: 2007-06-21 13:05:23 -0700 (Thu, 21 Jun 2007)
Log Message:
-----------
adding support for member variable pointers
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/member_variable.py
Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2007-06-21 20:04:05 UTC (rev 1070)
+++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2007-06-21 20:05:23 UTC (rev 1071)
@@ -61,7 +61,9 @@
answer.append('"%s"' % self.alias)
answer.append( self.PARAM_SEPARATOR )
- call_pol = call_policies.return_value_policy( call_policies.reference_existing_object ).create( self )
+ #according to David Abrahams:
+ #http://mail.python.org/pipermail/c++-sig/2003-January/003276.html
+ call_pol = call_policies.return_internal_reference().create( self )
make_function = algorithm.create_identifier( self, '::boost::python::make_function' )
answer.append( '%(mk_func)s( (%(getter_type)s)(&%(wfname)s), %(call_pol)s )'
@@ -71,11 +73,11 @@
, 'call_pol' : call_pol } )
#don't generate setter method, right now I don't know how to do it.
- if False and self.wrapper.has_setter:
+ if self.wrapper.has_setter:
answer.append( self.PARAM_SEPARATOR )
call_pol = ''
if not self.declaration.type_qualifiers.has_static:
- call_pol = ", " + call_policies.with_custodian_and_ward_postcall( 0, 1 ).crate(self)
+ call_pol = ", " + call_policies.with_custodian_and_ward_postcall( 1, 2 ).create(self)
answer.append( '%(mk_func)s( (%(setter_type)s)(&%(wfname)s)%(call_pol)s )'
% { 'mk_func' : make_function
, 'setter_type' : self.wrapper.setter_type
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-21 20:04:08
|
Revision: 1070
http://svn.sourceforge.net/pygccxml/?rev=1070&view=rev
Author: roman_yakovenko
Date: 2007-06-21 13:04:05 -0700 (Thu, 21 Jun 2007)
Log Message:
-----------
don't generate template default argument
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2007-06-21 19:06:55 UTC (rev 1069)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2007-06-21 20:04:05 UTC (rev 1070)
@@ -160,7 +160,10 @@
return '::boost::python::return_internal_reference'
def _get_args(self, function_creator):
- return [ str( self.position ) ]
+ if self.position == 1:
+ return [] #don't generate default template arguments
+ else:
+ return [ str( self.position ) ]
def return_internal_reference( arg_pos=1, base=None):
"""create boost::python::return_internal_reference call policies code generator"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-21 19:06:54
|
Revision: 1069
http://svn.sourceforge.net/pygccxml/?rev=1069&view=rev
Author: roman_yakovenko
Date: 2007-06-21 12:06:55 -0700 (Thu, 21 Jun 2007)
Log Message:
-----------
adding initial support to unicode
Added Paths:
-----------
pyplusplus_dev/unittests/unicode_bug.py
Added: pyplusplus_dev/unittests/unicode_bug.py
===================================================================
--- pyplusplus_dev/unittests/unicode_bug.py (rev 0)
+++ pyplusplus_dev/unittests/unicode_bug.py 2007-06-21 19:06:55 UTC (rev 1069)
@@ -0,0 +1,22 @@
+# -*- coding: UTF-8 -*-
+
+import os
+import unittest
+import autoconfig
+from pygccxml import parser
+from pygccxml import declarations
+from pyplusplus import code_creators
+from pyplusplus import module_creator
+from pyplusplus import module_builder
+from pyplusplus import utils as pypp_utils
+from pyplusplus import function_transformers as ft
+
+
+mb = module_builder.module_builder_t(
+ [ module_builder.create_text_fc( 'struct x{};' ) ]
+ , gccxml_path=autoconfig.gccxml.executable
+ , encoding='UTF-8')
+
+mb.build_code_creator( module_name='unicode_bug' )
+mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
+mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-21 19:06:08
|
Revision: 1068
http://svn.sourceforge.net/pygccxml/?rev=1068&view=rev
Author: roman_yakovenko
Date: 2007-06-21 12:06:10 -0700 (Thu, 21 Jun 2007)
Log Message:
-----------
adding initial support to unicode
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/module_builder/builder.py
Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/builder.py 2007-06-21 19:05:25 UTC (rev 1067)
+++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2007-06-21 19:06:10 UTC (rev 1068)
@@ -38,7 +38,8 @@
, optimize_queries=True
, ignore_gccxml_output=False
, indexing_suite_version=1
- , cflags=""):
+ , cflags=""
+ , encoding='ascii'):
"""
@param files: list of files, declarations from them you want to export
@type files: list of strings or L{file_configuration_t} instances
@@ -61,6 +62,7 @@
"""
object.__init__( self )
self.logger = _logging_.loggers.module_builder
+ self.__encoding = encoding
gccxml_config = parser.config_t(
gccxml_path=gccxml_path
, working_directory=working_directory
@@ -95,10 +97,15 @@
self.__registrations_code_head = []
self.__registrations_code_tail = []
- def _get_global_ns( self ):
+ @property
+ def global_ns( self ):
+ """reference to global namespace"""
return self.__global_ns
- global_ns = property( _get_global_ns, doc="reference to global namespace" )
+ @property
+ def encoding( self ):
+ return self.__encoding
+
def run_query_optimizer(self):
"""
It is possible to optimze time that takes to execute queries. In most cases
@@ -301,7 +308,7 @@
@type file_name: string
"""
self.__merge_user_code()
- file_writers.write_file( self.code_creator, file_name )
+ file_writers.write_file( self.code_creator, file_name, encoding=self.encoding )
def split_module( self
, dir_name
@@ -335,13 +342,15 @@
written_files = file_writers.write_multiple_files(
self.code_creator
, dir_name
- , files_sum_repository=files_sum_repository )
+ , files_sum_repository=files_sum_repository
+ , encoding=self.encoding)
else:
written_files = file_writers.write_class_multiple_files(
self.code_creator
, dir_name
, huge_classes
- , files_sum_repository=files_sum_repository )
+ , files_sum_repository=files_sum_repository
+ , encoding=self.encoding)
all_files = os.listdir( dir_name )
all_files = map( lambda fname: os.path.join( dir_name, fname ), all_files )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-21 19:05:23
|
Revision: 1067
http://svn.sourceforge.net/pygccxml/?rev=1067&view=rev
Author: roman_yakovenko
Date: 2007-06-21 12:05:25 -0700 (Thu, 21 Jun 2007)
Log Message:
-----------
adding initial support to unicode
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/file_writers/__init__.py
pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py
pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
pyplusplus_dev/pyplusplus/file_writers/single_file.py
pyplusplus_dev/pyplusplus/file_writers/writer.py
Modified: pyplusplus_dev/pyplusplus/file_writers/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/__init__.py 2007-06-20 05:23:38 UTC (rev 1066)
+++ pyplusplus_dev/pyplusplus/file_writers/__init__.py 2007-06-21 19:05:25 UTC (rev 1067)
@@ -31,22 +31,22 @@
return True
return False
-def write_file( data, file_path ):
+def write_file( data, file_path, encoding='ascii' ):
"""writes data to file"""
if isinstance( data, types.StringTypes ):
- writer_t.write_file( data, file_path )
+ writer_t.write_file( data, file_path, encoding=encoding )
else:
- sf = single_file_t( data, file_path )
+ sf = single_file_t( data, file_path, encoding=encoding )
sf.write()
-def write_multiple_files( extmodule, dir_path, files_sum_repository=None ):
+def write_multiple_files( extmodule, dir_path, files_sum_repository=None, encoding='ascii' ):
"""writes extmodule to multiple files"""
- mfs = multiple_files_t( extmodule, dir_path, files_sum_repository=files_sum_repository )
+ mfs = multiple_files_t( extmodule, dir_path, files_sum_repository=files_sum_repository, encoding=encoding )
mfs.write()
return mfs.written_files
-def write_class_multiple_files( extmodule, dir_path, huge_classes, files_sum_repository ):
+def write_class_multiple_files( extmodule, dir_path, huge_classes, files_sum_repository, encoding='ascii' ):
"""writes extmodule to multiple files and splits huge classes to few source files"""
- mfs = class_multiple_files_t( extmodule, dir_path, huge_classes, files_sum_repository=files_sum_repository )
+ mfs = class_multiple_files_t( extmodule, dir_path, huge_classes, files_sum_repository=files_sum_repository, encoding=encoding )
mfs.write()
return mfs.written_files
Modified: pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py 2007-06-20 05:23:38 UTC (rev 1066)
+++ pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py 2007-06-21 19:05:25 UTC (rev 1067)
@@ -34,11 +34,13 @@
, directory_path
, huge_classes
, num_of_functions_per_file=20
- , files_sum_repository=None ):
+ , files_sum_repository=None
+ , encoding='ascii'):
multiple_files.multiple_files_t.__init__(self
, extmodule
, directory_path
- , files_sum_repository=files_sum_repository)
+ , files_sum_repository=files_sum_repository
+ , encoding=encoding)
self.huge_classes = huge_classes
self.num_of_functions_per_file = num_of_functions_per_file
self.internal_splitters = [
Modified: pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2007-06-20 05:23:38 UTC (rev 1066)
+++ pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2007-06-21 19:05:25 UTC (rev 1067)
@@ -22,7 +22,7 @@
HEADER_EXT = '.pypp.hpp'
SOURCE_EXT = '.pypp.cpp'
- def __init__(self, extmodule, directory_path, write_main=True, files_sum_repository=None):
+ def __init__(self, extmodule, directory_path, write_main=True, files_sum_repository=None, encoding='ascii'):
"""Constructor.
@param extmodule: The root of a code creator tree
@@ -34,7 +34,7 @@
that calls all the registration methods.
@type write_main: boolean
"""
- writer.writer_t.__init__( self, extmodule, files_sum_repository )
+ writer.writer_t.__init__( self, extmodule, files_sum_repository, encoding=encoding )
self.__directory_path = directory_path
self.create_dir( directory_path )
self.include_creators = [] # List of include_t creators that contain the generated headers
@@ -49,7 +49,7 @@
def write_file( self, fpath, content ):
self.written_files.append( fpath )
- writer.writer_t.write_file( fpath, content, self.files_sum_repository )
+ writer.writer_t.write_file( fpath, content, self.files_sum_repository, self.encoding )
def create_dir( self, directory_path ):
"""Create the output directory if it doesn't already exist.
Modified: pyplusplus_dev/pyplusplus/file_writers/single_file.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/single_file.py 2007-06-20 05:23:38 UTC (rev 1066)
+++ pyplusplus_dev/pyplusplus/file_writers/single_file.py 2007-06-21 19:05:25 UTC (rev 1067)
@@ -11,18 +11,18 @@
class single_file_t(writer.writer_t):
"""generates all code into single cpp file"""
- def __init__(self, extmodule, file_name):
- writer.writer_t.__init__(self, extmodule)
+ def __init__(self, extmodule, file_name, encoding='ascii'):
+ writer.writer_t.__init__(self, extmodule, encoding=encoding)
self.__fname = file_name
- def _get_file_name(self):
+ @property
+ def file_name(self):
return self.__fname
- file_name = property( _get_file_name )
def write(self):
headers = self.get_user_headers( [self.extmodule] )
map( lambda header: self.extmodule.add_include( header )
, headers )
self.write_code_repository( os.path.split( self.file_name )[0] )
- self.write_file( self.file_name, self.extmodule.create() )
+ self.write_file( self.file_name, self.extmodule.create(), encoding=self.encoding )
Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/writer.py 2007-06-20 05:23:38 UTC (rev 1066)
+++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2007-06-21 19:05:25 UTC (rev 1067)
@@ -7,6 +7,7 @@
import os
import time
+import codecs
from pyplusplus import _logging_
from pyplusplus import code_creators
from pyplusplus import code_repository
@@ -22,14 +23,20 @@
"""
logger = _logging_.loggers.file_writer
- def __init__(self, extmodule, files_sum_repository=None):
+ def __init__(self, extmodule, files_sum_repository=None, encoding='ascii'):
object.__init__(self)
self.__extmodule = extmodule
self.__files_sum_repository = files_sum_repository
+ self.__encoding=encoding
if None is files_sum_repository:
self.__files_sum_repository = md5sum_repository.dummy_repository_t()
-
+
@property
+ def encoding( self ):
+ """encoding name used to write generated code to files"""
+ return self.__encoding
+
+ @property
def extmodule(self):
"""The root of the code creator tree ( code_creators.module_t )"""
return self.__extmodule
@@ -63,7 +70,7 @@
self.write_file( os.path.join( dir, code_repository.named_tuple.file_name )
, code_repository.named_tuple.code )
@staticmethod
- def write_file( fpath, content, files_sum_repository=None ):
+ def write_file( fpath, content, files_sum_repository=None, encoding='ascii' ):
"""Write a source file.
This method writes the string content into the specified file.
@@ -102,7 +109,7 @@
#It could be a first time the user uses files_sum_repository, don't force him
#to recompile the code
#small optimization to cut down compilation time
- f = file( fpath, 'rb' )
+ f = codecs.open( fpath, 'rb', encoding )
fcontent = f.read()
f.close()
if fcontent == fcontent_new:
@@ -113,8 +120,8 @@
writer_t.logger.debug( 'file changed or it does not exist' )
writer_t.create_backup( fpath )
- f = file( fpath, 'w+b' )
- f.write( fcontent_new )
+ f = codecs.open( fpath, 'w+b', encoding )
+ f.write( unicode( fcontent_new, encoding ) )
f.close()
if new_hash_value:
files_sum_repository.update_value( fname, new_hash_value )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-20 05:23:38
|
Revision: 1066
http://svn.sourceforge.net/pygccxml/?rev=1066&view=rev
Author: roman_yakovenko
Date: 2007-06-19 22:23:38 -0700 (Tue, 19 Jun 2007)
Log Message:
-----------
adding support to GCC-XML attributes
Modified Paths:
--------------
pygccxml_dev/docs/history/history.rest
pygccxml_dev/pygccxml/declarations/calldef.py
pygccxml_dev/pygccxml/declarations/declaration.py
pygccxml_dev/pygccxml/parser/scanner.py
pygccxml_dev/unittests/test_all.py
Modified: pygccxml_dev/docs/history/history.rest
===================================================================
--- pygccxml_dev/docs/history/history.rest 2007-06-19 09:51:56 UTC (rev 1065)
+++ pygccxml_dev/docs/history/history.rest 2007-06-20 05:23:38 UTC (rev 1066)
@@ -19,6 +19,7 @@
* Gottfried Ganssauge
* Gaetan Lehmann
* Martin Preisler
+* Miguel Lobo
-----------
SVN Version
@@ -27,6 +28,11 @@
1. Class ``free_operator_t`` is now able to provide references to the class declarations
instances it works on.
+2. Support for `GCC-XML attributes`_ was added. Many thanks to Miguel Lobo for
+ the implementation.
+
+.. _`GCC-XML attributes`: http://www.gccxml.org/HTML/Running.html
+
-------------
Version 0.9.0
-------------
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2007-06-19 09:51:56 UTC (rev 1065)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2007-06-20 05:23:38 UTC (rev 1066)
@@ -39,11 +39,12 @@
class, that describes argument of "callable" declaration
"""
- def __init__( self, name='', type=None, default_value=None ):
+ def __init__( self, name='', type=None, default_value=None, attributes=None ):
object.__init__(self)
self._name = name
self._default_value = default_value
self._type = type
+ self._attributes = attributes
def clone( self, **keywd ):
"""constructs new argument_t instance
@@ -54,7 +55,8 @@
"""
return argument_t( name=keywd.get( 'name', self.name )
, type=keywd.get( 'type', self.type )
- , default_value=keywd.get( 'default_value', self.default_value ) )
+ , default_value=keywd.get( 'default_value', self.default_value )
+ , attributes=keywd.get( 'attributes', self.attributes ) )
def __str__(self):
if self.default_value==None:
@@ -102,7 +104,17 @@
type = property( _get_type, _set_type
, doc="""The type of the argument.
@type: L{type_t}""")
+
+ def _get_attributes( self ):
+ return self._attributes
+ def _set_attributes( self, attributes ):
+ self._attributes = attributes
+ attributes = property( _get_attributes, _set_attributes
+ , doc="""GCCXML attributes, set using __attribute__((gccxml("...")))
+ @type: str
+ """ )
+
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, does_throw=True ):
Modified: pygccxml_dev/pygccxml/declarations/declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/declaration.py 2007-06-19 09:51:56 UTC (rev 1065)
+++ pygccxml_dev/pygccxml/declarations/declaration.py 2007-06-20 05:23:38 UTC (rev 1066)
@@ -57,12 +57,13 @@
class declaration_t( object ):
"""base class for all classes that represent a C++ declaration"""
- def __init__( self, name='', location=None, is_artificial=False, mangled=None, demangled=None ):
+ def __init__( self, name='', location=None, is_artificial=False, mangled=None, demangled=None, attributes=None ):
self._name = name
self._location = location
self._is_artificial = is_artificial
self._mangled = mangled
self._demangled = demangled
+ self._attributes = attributes
self._parent = None
self._cache = algorithms_cache.declaration_algs_cache_t()
@@ -218,6 +219,17 @@
@type: str
""" )
+ def _get_attributes( self ):
+ return self._attributes
+ def _set_attributes( self, attributes ):
+ self._attributes = attributes
+ attributes = property( _get_attributes, _set_attributes
+ , doc="""GCCXML attributes, set using __attribute__((gccxml("...")))
+ @type: str
+ """ )
+
+
+
def _create_decl_string(self):
return algorithm.full_name( self )
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2007-06-19 09:51:56 UTC (rev 1065)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2007-06-20 05:23:38 UTC (rev 1066)
@@ -19,6 +19,7 @@
XML_AN_ABSTRACT = "abstract"
XML_AN_ACCESS = "access"
XML_AN_ARTIFICIAL = "artificial"
+XML_AN_ATTRIBUTES = "attributes"
XML_AN_BASE_TYPE = "basetype"
XML_AN_BASES = "bases"
XML_AN_BITS = "bits"
@@ -203,6 +204,7 @@
self.__read_artificial(obj, attrs)
self.__read_mangled( obj, attrs)
self.__read_demangled( obj, attrs)
+ self.__read_attributes(obj, attrs)
elif isinstance( obj, type_t ):
self.__types[ element_id ] = obj
elif isinstance( obj, types.StringTypes ):
@@ -246,6 +248,9 @@
def __read_demangled( self, decl, attrs ):
decl.demangled = attrs.get( XML_AN_DEMANGLED, None )
+ def __read_attributes( self, decl, attrs ):
+ decl.attributes = attrs.get( XML_AN_ATTRIBUTES, None )
+
def __read_access( self, attrs ):
self.__access[ attrs[XML_AN_ID] ] = attrs.get( XML_AN_ACCESS, ACCESS_TYPES.PUBLIC )
@@ -330,6 +335,7 @@
argument.name = attrs.get( XML_AN_NAME, 'arg%d' % len(self.__inst.arguments) )
argument.type = attrs[XML_AN_TYPE]
argument.default_value = attrs.get( XML_AN_DEFAULT, None )
+ self.__read_attributes( argument, attrs )
if argument.default_value == '<gccxml-cast-expr>':
argument.default_value = None
self.__inst.arguments.append( argument )
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2007-06-19 09:51:56 UTC (rev 1065)
+++ pygccxml_dev/unittests/test_all.py 2007-06-20 05:23:38 UTC (rev 1066)
@@ -43,6 +43,7 @@
import free_operators_tester
import remove_template_defaults_tester
import find_container_traits_tester
+import attributes_tester
def create_suite():
testers = [
@@ -85,6 +86,7 @@
, free_operators_tester
, remove_template_defaults_tester
, find_container_traits_tester
+ , attributes_tester
]
main_suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-19 09:51:54
|
Revision: 1065
http://svn.sourceforge.net/pygccxml/?rev=1065&view=rev
Author: roman_yakovenko
Date: 2007-06-19 02:51:56 -0700 (Tue, 19 Jun 2007)
Log Message:
-----------
adding new test case for "create_with_signature"
Modified Paths:
--------------
pyplusplus_dev/unittests/algorithms_tester.py
Modified: pyplusplus_dev/unittests/algorithms_tester.py
===================================================================
--- pyplusplus_dev/unittests/algorithms_tester.py 2007-06-19 09:35:45 UTC (rev 1064)
+++ pyplusplus_dev/unittests/algorithms_tester.py 2007-06-19 09:51:56 UTC (rev 1065)
@@ -122,6 +122,27 @@
minus_minus = xxx.operator( symbol='--' )
self.failUnless( 1 == len( minus_minus.readme() ), os.linesep.join( minus_minus.readme() ) )
+
+class use_function_signature_bug_tester_t( unittest.TestCase ):
+ CODE = \
+ """
+ struct base{
+ void f();
+ };
+
+ struct derived : public base {
+ void f(int i);
+ using base::f;
+ };
+ """
+ def test(self):
+ mb = module_builder.module_builder_t(
+ [ module_builder.create_text_fc( self.CODE )]
+ , gccxml_path=autoconfig.gccxml.executable )
+ d = mb.class_( 'derived' )
+ f = d.mem_fun( 'f' )
+ self.failUnless( f.create_with_signature == True )
+
class class_multiple_files_tester_t(unittest.TestCase):
CLASS_DEF = \
"""
@@ -242,6 +263,8 @@
suite.addTest( unittest.makeSuite(readme_tester_t))
suite.addTest( unittest.makeSuite(split_sequence_tester_t))
suite.addTest( unittest.makeSuite(exclude_erronious_tester_t))
+ suite.addTest( unittest.makeSuite(use_function_signature_bug_tester_t))
+
return suite
def run_suite():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-19 09:35:52
|
Revision: 1064
http://svn.sourceforge.net/pygccxml/?rev=1064&view=rev
Author: roman_yakovenko
Date: 2007-06-19 02:35:45 -0700 (Tue, 19 Jun 2007)
Log Message:
-----------
moving functionality "container_traits" from Py++ to pygccxml
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/class_declaration.py
pygccxml_dev/pygccxml/declarations/container_traits.py
pygccxml_dev/unittests/remove_template_defaults_tester.py
pygccxml_dev/unittests/test_all.py
Added Paths:
-----------
pygccxml_dev/unittests/find_container_traits_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2007-06-18 14:27:30 UTC (rev 1063)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2007-06-19 09:35:45 UTC (rev 1064)
@@ -181,6 +181,7 @@
from container_traits import hash_set_traits
from container_traits import multiset_traits
from container_traits import hash_multiset_traits
+from container_traits import find_container_traits
from function_traits import is_same_function
Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/class_declaration.py 2007-06-18 14:27:30 UTC (rev 1063)
+++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2007-06-19 09:35:45 UTC (rev 1064)
@@ -81,6 +81,8 @@
"""creates class that describes C++ class declaration( and not definition )"""
declaration.declaration_t.__init__( self, name )
self._aliases = []
+ self._container_traits = None
+ self._container_traits_set = False
def _get__cmp__items(self):
"""implementation details"""
@@ -96,6 +98,15 @@
aliases = property( _get_aliases, _set_aliases
, doc="List of L{aliases<typedef_t>} to this instance")
+ @property
+ def container_traits( self ):
+ """reference to L{container traits<container_traits.py>} or None"""
+ if self._container_traits_set == False:
+ import container_traits #prevent cyclic dependencies
+ self._container_traits_set = True
+ self._container_traits = container_traits.find_container_traits( self )
+ return self._container_traits
+
class class_t( scopedef.scopedef_t ):
"""describes class definition"""
@@ -113,6 +124,8 @@
self._private_members = []
self._protected_members = []
self._aliases = []
+ self._container_traits = None
+ self._container_traits_set = False
def _get_name_impl( self ):
if not self._name: #class with empty name
@@ -365,4 +378,13 @@
return answer
+ @property
+ def container_traits( self ):
+ """reference to L{container traits<container_traits.py>} or None"""
+ if self._container_traits_set == False:
+ import container_traits #prevent cyclic dependencies
+ self._container_traits_set = True
+ self._container_traits = container_traits.find_container_traits( self )
+ return self._container_traits
+
class_types = ( class_t, class_declaration_t )
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-18 14:27:30 UTC (rev 1063)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-19 09:35:45 UTC (rev 1064)
@@ -373,7 +373,7 @@
return cls_traits
else:
for cls_traits in container_traits:
- if cls_traits.is_my_case( cls ):
+ if cls_traits.is_my_case( cls_or_string ):
return cls_traits
Added: pygccxml_dev/unittests/find_container_traits_tester.py
===================================================================
--- pygccxml_dev/unittests/find_container_traits_tester.py (rev 0)
+++ pygccxml_dev/unittests/find_container_traits_tester.py 2007-06-19 09:35:45 UTC (rev 1064)
@@ -0,0 +1,57 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import unittest
+import autoconfig
+import parser_test_case
+
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
+
+class tester_t( parser_test_case.parser_test_case_t ):
+ global_ns = None
+ def __init__(self, *args ):
+ parser_test_case.parser_test_case_t.__init__( self, *args )
+ self.header = 'remove_template_defaults.hpp'
+
+ def setUp(self):
+ if not tester_t.global_ns:
+ decls = parser.parse( [self.header], self.config )
+ tester_t.global_ns = declarations.get_global_namespace( decls )
+ tester_t.global_ns.init_optimizer()
+
+ def __cmp_traits( self, typedef, expected ):
+ if isinstance( typedef, str ):
+ typedef = self.global_ns.typedef( typedef )
+ self.failUnless( declarations.find_container_traits( typedef ) is expected )
+ cls = declarations.remove_declarated( typedef )
+ self.failUnless( cls.container_traits is expected )
+
+ def test_find_traits( self ):
+ self.__cmp_traits( 'v_int', declarations.vector_traits )
+ self.__cmp_traits( 'l_int', declarations.list_traits )
+ self.__cmp_traits( 'd_v_int', declarations.deque_traits )
+ self.__cmp_traits( 'q_int', declarations.queue_traits )
+ self.__cmp_traits( 'pq_int', declarations.priority_queue_traits)
+ self.__cmp_traits( 's_v_int', declarations.set_traits)
+ self.__cmp_traits( 'ms_v_int', declarations.multiset_traits)
+ self.__cmp_traits( 'm_i2d', declarations.map_traits )
+ self.__cmp_traits( 'mm_i2d', declarations.multimap_traits )
+ self.__cmp_traits( 'hs_v_int', declarations.hash_set_traits )
+ self.__cmp_traits( 'mhs_v_int', declarations.hash_multiset_traits )
+ self.__cmp_traits( 'hm_i2d', declarations.hash_map_traits )
+ self.__cmp_traits( 'hmm_i2d', declarations.hash_multimap_traits )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-18 14:27:30 UTC (rev 1063)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-19 09:35:45 UTC (rev 1064)
@@ -22,7 +22,7 @@
decls = parser.parse( [self.header], self.config )
tester_t.global_ns = declarations.get_global_namespace( decls )
tester_t.global_ns.init_optimizer()
-
+
def test_vector( self ):
v_int = self.global_ns.typedef( 'v_int' )
self.failUnless( 'vector< int >'
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2007-06-18 14:27:30 UTC (rev 1063)
+++ pygccxml_dev/unittests/test_all.py 2007-06-19 09:35:45 UTC (rev 1064)
@@ -42,6 +42,7 @@
import dependencies_tester
import free_operators_tester
import remove_template_defaults_tester
+import find_container_traits_tester
def create_suite():
testers = [
@@ -83,6 +84,7 @@
, dependencies_tester
, free_operators_tester
, remove_template_defaults_tester
+ , find_container_traits_tester
]
main_suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-18 14:27:28
|
Revision: 1063
http://svn.sourceforge.net/pygccxml/?rev=1063&view=rev
Author: roman_yakovenko
Date: 2007-06-18 07:27:30 -0700 (Mon, 18 Jun 2007)
Log Message:
-----------
adding another set of containers to remove_defaults functionality
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/container_traits.py
pygccxml_dev/unittests/data/remove_template_defaults.hpp
pygccxml_dev/unittests/remove_template_defaults_tester.py
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-18 07:17:19 UTC (rev 1062)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-18 14:27:30 UTC (rev 1063)
@@ -37,7 +37,7 @@
class recursive_impl:
@staticmethod
- def decorated_call( cls_name, text, doit ):
+ def decorated_call_prefix( cls_name, text, doit ):
has_text = cls_name.startswith( text )
if has_text:
cls_name = cls_name[ len( text ): ]
@@ -47,6 +47,16 @@
return answer
@staticmethod
+ def decorated_call_suffix( cls_name, text, doit ):
+ has_text = cls_name.endswith( text )
+ if has_text:
+ cls_name = cls_name[: len( text )]
+ answer = doit( cls_name )
+ if has_text:
+ answer = answer + text
+ return answer
+
+ @staticmethod
def erase_call( cls_name ):
global find_container_traits
c_traits = find_container_traits( cls_name )
@@ -57,9 +67,11 @@
@staticmethod
def erase_recursive( cls_name ):
ri = defaults_eraser.recursive_impl
- no_std = lambda cls_name: ri.decorated_call( cls_name, 'std::', ri.erase_call )
- no_const = lambda cls_name: ri.decorated_call( cls_name, 'const ', no_std )
- return no_const( cls_name )
+ no_std = lambda cls_name: ri.decorated_call_prefix( cls_name, 'std::', ri.erase_call )
+ no_stdext = lambda cls_name: ri.decorated_call_prefix( cls_name, 'stdext::', no_std )
+ no_const = lambda cls_name: ri.decorated_call_prefix( cls_name, 'const ', no_stdext )
+ no_end_const = lambda cls_name: ri.decorated_call_suffix( cls_name, ' const', no_const )
+ return no_end_const( cls_name )
@staticmethod
def erase_recursive( cls_name ):
@@ -145,6 +157,53 @@
, [ defaults_eraser.erase_recursive( key_type )
, defaults_eraser.erase_recursive( mapped_type )] )
+
+ @staticmethod
+ def erase_hash_allocator( cls_name
+ , default_hash='stdext::hash_compare'
+ , default_compare='std::less'
+ , default_allocator='std::allocator' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 3 != len( c_args ):
+ return
+ value_type = c_args[0]
+ tmpl = string.Template( "$container< $value_type, $hash<$value_type, $less<$value_type> >, $allocator<$value_type> >" )
+ tmpl = tmpl.substitute( container=c_name
+ , value_type=value_type
+ , hash=default_hash
+ , less=default_compare
+ , allocator=default_allocator )
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
+ return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
+
+
+ @staticmethod
+ def erase_hashmap_compare_allocator( cls_name
+ , default_hash='stdext::hash_compare'
+ , default_compare='std::less'
+ , default_allocator='std::allocator' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 4 != len( c_args ):
+ return
+ key_type = c_args[0]
+ mapped_type = c_args[1]
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< const $key_type, $mapped_type> > >" )
+ if key_type.startswith( 'const ' ) or key_type.endswith( ' const' ):
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< $key_type, $mapped_type> > >" )
+ tmpl = tmpl.substitute( container=c_name
+ , key_type=key_type
+ , mapped_type=mapped_type
+ , hash=default_hash
+ , less=default_compare
+ , allocator=default_allocator )
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
+ return templates.join( c_name
+ , [ defaults_eraser.erase_recursive( key_type )
+ , defaults_eraser.erase_recursive( mapped_type )] )
+
+
class container_traits_impl_t:
"""this class implements the functionality needed for convinient work with
STD container classes.
@@ -278,14 +337,14 @@
map_traits = create_traits_class( 'map', 1, 'mapped_type', defaults_eraser.erase_map_compare_allocator )
multimap_traits = create_traits_class( 'multimap', 1, 'mapped_type', defaults_eraser.erase_map_compare_allocator )
-hash_map_traits = create_traits_class( 'hash_map', 1, 'mapped_type' )
-hash_multimap_traits = create_traits_class( 'hash_multimap', 1, 'mapped_type' )
+hash_map_traits = create_traits_class( 'hash_map', 1, 'mapped_type', defaults_eraser.erase_hashmap_compare_allocator )
+hash_multimap_traits = create_traits_class( 'hash_multimap', 1, 'mapped_type', defaults_eraser.erase_hashmap_compare_allocator )
set_traits = create_traits_class( 'set', 0, 'value_type', defaults_eraser.erase_compare_allocator)
multiset_traits = create_traits_class( 'multiset', 0, 'value_type', defaults_eraser.erase_compare_allocator )
-hash_set_traits = create_traits_class( 'hash_set', 0, 'value_type' )
-hash_multiset_traits = create_traits_class( 'hash_multiset', 0, 'value_type' )
+hash_set_traits = create_traits_class( 'hash_set', 0, 'value_type', defaults_eraser.erase_hash_allocator )
+hash_multiset_traits = create_traits_class( 'hash_multiset', 0, 'value_type', defaults_eraser.erase_hash_allocator )
container_traits = (
list_traits
Modified: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-18 07:17:19 UTC (rev 1062)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-18 14:27:30 UTC (rev 1063)
@@ -6,6 +6,8 @@
#ifndef __remove_template_defaults_hpp__
#define __remove_template_defaults_hpp__
+#include <hash_set>
+#include <hash_map>
#include <string>
#include <vector>
#include <deque>
@@ -68,7 +70,28 @@
typedef std::multimap< std::vector< int > const, mm_wstr2d const > mm_v_i2mm_wstr2d;
}
+namespace hash_sets{
+ typedef std::hash_set< std::vector< int > > hs_v_int;
+ typedef std::hash_set< std::string > hs_string;
}
+namespace hash_multisets{
+ typedef std::hash_multiset< std::vector< int > > mhs_v_int;
+ typedef std::hash_multiset< std::string > mhs_string;
+}
+
+namespace hash_maps{
+ typedef std::hash_map< int, double > hm_i2d;
+ typedef std::hash_map< std::wstring, double > hm_wstr2d;
+}
+
+namespace hash_multimaps{
+ typedef std::hash_multimap< int, double > hmm_i2d;
+ typedef std::hash_multimap< std::wstring const, double > hmm_wstr2d;
+ typedef std::hash_multimap< std::vector< int > const, hmm_wstr2d const > hmm_v_i2mm_wstr2d;
+}
+
+}
+
#endif//__remove_template_defaults_hpp__
Modified: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-18 07:17:19 UTC (rev 1062)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-18 14:27:30 UTC (rev 1063)
@@ -104,6 +104,42 @@
self.failUnless( 'multimap< const std::vector< int >, const std::multimap< const std::wstring, double > >'
== declarations.multimap_traits.remove_defaults( mm_v_i2mm_wstr2d ) )
+ def test_hash_set( self ):
+ hs_v_int = self.global_ns.typedef( 'hs_v_int' )
+ self.failUnless( 'hash_set< std::vector< int > >'
+ == declarations.hash_set_traits.remove_defaults( hs_v_int ) )
+ hs_string = self.global_ns.typedef( 'hs_string' )
+ self.failUnless( 'hash_set< std::string >'
+ == declarations.hash_set_traits.remove_defaults( hs_string ) )
+
+ def test_hash_multiset( self ):
+ mhs_v_int = self.global_ns.typedef( 'mhs_v_int' )
+ self.failUnless( 'hash_multiset< std::vector< int > >'
+ == declarations.hash_multiset_traits.remove_defaults( mhs_v_int ) )
+ mhs_string = self.global_ns.typedef( 'mhs_string' )
+ self.failUnless( 'hash_multiset< std::string >'
+ == declarations.hash_multiset_traits.remove_defaults( mhs_string ) )
+
+ def test_hash_map( self ):
+ hm_i2d = self.global_ns.typedef( 'hm_i2d' )
+ self.failUnless( 'hash_map< int, double >'
+ == declarations.hash_map_traits.remove_defaults( hm_i2d ) )
+ hm_wstr2d = self.global_ns.typedef( 'hm_wstr2d' )
+ self.failUnless( 'hash_map< std::wstring, double >'
+ == declarations.hash_map_traits.remove_defaults( hm_wstr2d ) )
+
+ def test_hash_multimap( self ):
+ hmm_i2d = self.global_ns.typedef( 'hmm_i2d' )
+ self.failUnless( 'hash_multimap< int, double >'
+ == declarations.hash_multimap_traits.remove_defaults( hmm_i2d ) )
+ hmm_wstr2d = self.global_ns.typedef( 'hmm_wstr2d' )
+ self.failUnless( 'hash_multimap< const std::wstring, double >'
+ == declarations.hash_multimap_traits.remove_defaults( hmm_wstr2d ) )
+ hmm_v_i2mm_wstr2d = self.global_ns.typedef( 'hmm_v_i2mm_wstr2d' )
+ self.failUnless( 'hash_multimap< const std::vector< int >, const std::hash_multimap< const std::wstring, double > >'
+ == declarations.hash_multimap_traits.remove_defaults( hmm_v_i2mm_wstr2d ) )
+
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-18 07:17:18
|
Revision: 1062
http://svn.sourceforge.net/pygccxml/?rev=1062&view=rev
Author: roman_yakovenko
Date: 2007-06-18 00:17:19 -0700 (Mon, 18 Jun 2007)
Log Message:
-----------
adding another set of containers to remove_defaults functionality
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/algorithm.py
pygccxml_dev/pygccxml/declarations/container_traits.py
pygccxml_dev/unittests/data/remove_template_defaults.hpp
pygccxml_dev/unittests/remove_template_defaults_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2007-06-18 06:59:29 UTC (rev 1061)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2007-06-18 07:17:19 UTC (rev 1062)
@@ -72,6 +72,7 @@
from variable import variable_t
from algorithm import full_name
+from algorithm import full_name_from_declaration_path
from algorithm import make_flatten
from algorithm import apply_visitor
from algorithm import declaration_path
Modified: pygccxml_dev/pygccxml/declarations/algorithm.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/algorithm.py 2007-06-18 06:59:29 UTC (rev 1061)
+++ pygccxml_dev/pygccxml/declarations/algorithm.py 2007-06-18 07:17:19 UTC (rev 1062)
@@ -34,6 +34,13 @@
else:
return decl.cache.declaration_path
+def full_name_from_declaration_path( dpath ):
+ ##Here I have lack of knowledge:
+ ##TODO: "What is the full name of declaration declared in unnamed namespace?"
+ result = filter( None, dpath )
+ result = result[0] + '::'.join( result[1:] )
+ return result
+
def full_name( decl ):
"""
returns full name of the declaration
@@ -47,17 +54,9 @@
if None is decl:
raise RuntimeError( "Unable to generate full name for None object!" )
if not decl.cache.full_name:
- decl_path = declaration_path( decl )
- ##Here I have lack of knowledge:
- ##TODO: "What is the full name of declaration declared in unnamed namespace?"
- result = filter( None, decl_path )
- result = result[0] + '::'.join( result[1:] )
- decl.cache.full_name = result
- return result
- else:
- return decl.cache.full_name
+ decl.cache.full_name = full_name_from_declaration_path( declaration_path( decl ) )
+ return decl.cache.full_name
-
def make_flatten( decl_or_decls ):
"""
converts tree representation of declarations to flatten one.
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-18 06:59:29 UTC (rev 1061)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-18 07:17:19 UTC (rev 1062)
@@ -8,6 +8,7 @@
"""
import types
+import string
import calldef
import cpptypes
import namespace
@@ -15,95 +16,135 @@
import type_traits
import class_declaration
-def __normalize_type( type_str ):
- return type_str.replace( ' ', '' )
+class defaults_eraser:
+ @staticmethod
+ def normalize( type_str ):
+ return type_str.replace( ' ', '' )
-def __remove_basic_string( cls_name ):
- strings = {
- 'std::string' : ( 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
- , 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' )
- , 'std::wstring' : ( 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >'
- , 'std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' ) }
-
- new_name = cls_name
- for short_name, long_names in strings.iteritems():
- for lname in long_names:
- new_name = new_name.replace( lname, short_name )
- return new_name
+ @staticmethod
+ def replace_basic_string( cls_name ):
+ strings = {
+ 'std::string' : ( 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
+ , 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' )
+ , 'std::wstring' : ( 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >'
+ , 'std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' ) }
+
+ new_name = cls_name
+ for short_name, long_names in strings.iteritems():
+ for lname in long_names:
+ new_name = new_name.replace( lname, short_name )
+ return new_name
-def __remove_defaults_recursive( cls_name ):
- global find_container_traits
- if not cls_name.startswith( 'std::' ):
- return cls_name
- no_std_cls_name = cls_name[5:]
- c_traits = find_container_traits( no_std_cls_name )
- if not c_traits:
- return cls_name
- return 'std::' + c_traits.remove_defaults( no_std_cls_name )
+ class recursive_impl:
+ @staticmethod
+ def decorated_call( cls_name, text, doit ):
+ has_text = cls_name.startswith( text )
+ if has_text:
+ cls_name = cls_name[ len( text ): ]
+ answer = doit( cls_name )
+ if has_text:
+ answer = text + answer
+ return answer
-def __remove_allocator( cls_name, default_allocator='std::allocator' ):
- cls_name = __remove_basic_string( cls_name )
- # "vector<int,std::allocator<int> >"
- c_name, c_args = templates.split( cls_name )
- #"vector", [ "int", "std::allocator<int>" ]
- if 2 != len( c_args ):
- return
- a_name, a_args = templates.split( c_args[1] )
- if __normalize_type(default_allocator) != __normalize_type( a_name ):
- return
- if 1 != len( a_args ):
- return
- if __normalize_type( c_args[0] ) != __normalize_type( a_args[0] ):
- return
- value_type = __remove_defaults_recursive( c_args[0] )
- return templates.join( c_name, [value_type] )
+ @staticmethod
+ def erase_call( cls_name ):
+ global find_container_traits
+ c_traits = find_container_traits( cls_name )
+ if not c_traits:
+ return cls_name
+ return c_traits.remove_defaults( cls_name )
+
+ @staticmethod
+ def erase_recursive( cls_name ):
+ ri = defaults_eraser.recursive_impl
+ no_std = lambda cls_name: ri.decorated_call( cls_name, 'std::', ri.erase_call )
+ no_const = lambda cls_name: ri.decorated_call( cls_name, 'const ', no_std )
+ return no_const( cls_name )
-def __remove_container( cls_name, default_container_name='std::deque' ):
- cls_name = __remove_basic_string( cls_name )
- c_name, c_args = templates.split( cls_name )
- if 2 != len( c_args ):
- return
- dc_no_defaults = __remove_defaults_recursive( c_args[1] )
- if __normalize_type( dc_no_defaults ) \
- != __normalize_type( templates.join( default_container_name, [c_args[0]] ) ):
- return
- value_type = __remove_defaults_recursive( c_args[0] )
- return templates.join( c_name, [value_type] )
+ @staticmethod
+ def erase_recursive( cls_name ):
+ return defaults_eraser.recursive_impl.erase_recursive( cls_name )
+ @staticmethod
+ def erase_allocator( cls_name, default_allocator='std::allocator' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 2 != len( c_args ):
+ return
+ value_type = c_args[0]
+ tmpl = string.Template( "$container< $value_type, $allocator<$value_type> >" )
+ tmpl = tmpl.substitute( container=c_name, value_type=value_type, allocator=default_allocator )
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
+ return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
-def __remove_container_compare( cls_name, default_container_name='std::vector', default_compare='std::less' ):
- cls_name = __remove_basic_string( cls_name )
- c_name, c_args = templates.split( cls_name )
- if 3 != len( c_args ):
- return
- dc_no_defaults = __remove_defaults_recursive( c_args[1] )
- if __normalize_type( dc_no_defaults ) \
- != __normalize_type( templates.join( default_container_name, [c_args[0]] ) ):
- return
- dcomp_no_defaults = __remove_defaults_recursive( c_args[2] )
- if __normalize_type( dcomp_no_defaults ) \
- != __normalize_type( templates.join( default_compare, [c_args[0]] ) ):
- return
- value_type = __remove_defaults_recursive( c_args[0] )
- return templates.join( c_name, [value_type] )
+ @staticmethod
+ def erase_container( cls_name, default_container_name='std::deque' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 2 != len( c_args ):
+ return
+ value_type = c_args[0]
+ dc_no_defaults = defaults_eraser.erase_recursive( c_args[1] )
+ if defaults_eraser.normalize( dc_no_defaults ) \
+ != defaults_eraser.normalize( templates.join( default_container_name, [value_type] ) ):
+ return
+ return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
-def __remove_compare_allocator( cls_name, default_compare='std::less', default_allocator='std::allocator' ):
- cls_name = __remove_basic_string( cls_name )
- c_name, c_args = templates.split( cls_name )
- if 3 != len( c_args ):
- return
- dc_no_defaults = __remove_defaults_recursive( c_args[1] )
- if __normalize_type( dc_no_defaults ) \
- != __normalize_type( templates.join( default_compare, [c_args[0]] ) ):
- return
- da_no_defaults = __remove_defaults_recursive( c_args[2] )
- if __normalize_type( da_no_defaults ) \
- != __normalize_type( templates.join( default_allocator, [c_args[0]] ) ):
- return
- value_type = __remove_defaults_recursive( c_args[0] )
- return templates.join( c_name, [value_type] )
+ @staticmethod
+ def erase_container_compare( cls_name, default_container_name='std::vector', default_compare='std::less' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 3 != len( c_args ):
+ return
+ dc_no_defaults = defaults_eraser.erase_recursive( c_args[1] )
+ if defaults_eraser.normalize( dc_no_defaults ) \
+ != defaults_eraser.normalize( templates.join( default_container_name, [c_args[0]] ) ):
+ return
+ dcomp_no_defaults = defaults_eraser.erase_recursive( c_args[2] )
+ if defaults_eraser.normalize( dcomp_no_defaults ) \
+ != defaults_eraser.normalize( templates.join( default_compare, [c_args[0]] ) ):
+ return
+ value_type = defaults_eraser.erase_recursive( c_args[0] )
+ return templates.join( c_name, [value_type] )
+ @staticmethod
+ def erase_compare_allocator( cls_name, default_compare='std::less', default_allocator='std::allocator' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 3 != len( c_args ):
+ return
+ value_type = c_args[0]
+ tmpl = string.Template( "$container< $value_type, $compare<$value_type>, $allocator<$value_type> >" )
+ tmpl = tmpl.substitute( container=c_name
+ , value_type=value_type
+ , compare=default_compare
+ , allocator=default_allocator )
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
+ return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
+ @staticmethod
+ def erase_map_compare_allocator( cls_name, default_compare='std::less', default_allocator='std::allocator' ):
+ cls_name = defaults_eraser.replace_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 4 != len( c_args ):
+ return
+ key_type = c_args[0]
+ mapped_type = c_args[1]
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $compare<$key_type>, $allocator< std::pair< const $key_type, $mapped_type> > >" )
+ if key_type.startswith( 'const ' ) or key_type.endswith( ' const' ):
+ tmpl = string.Template( "$container< $key_type, $mapped_type, $compare<$key_type>, $allocator< std::pair< $key_type, $mapped_type> > >" )
+ tmpl = tmpl.substitute( container=c_name
+ , key_type=key_type
+ , mapped_type=mapped_type
+ , compare=default_compare
+ , allocator=default_allocator )
+ #~ print '\noriginal: ', defaults_eraser.normalize(cls_name)
+ #~ print '\ntmpl : ', defaults_eraser.normalize(tmpl)
+ if defaults_eraser.normalize( cls_name ) == defaults_eraser.normalize( tmpl ):
+ return templates.join( c_name
+ , [ defaults_eraser.erase_recursive( key_type )
+ , defaults_eraser.erase_recursive( mapped_type )] )
+
class container_traits_impl_t:
"""this class implements the functionality needed for convinient work with
STD container classes.
@@ -222,28 +263,28 @@
return no_defaults
return xxx_traits
-list_traits = create_traits_class( 'list', 0, 'value_type', __remove_allocator )
+list_traits = create_traits_class( 'list', 0, 'value_type', defaults_eraser.erase_allocator )
-deque_traits = create_traits_class( 'deque', 0, 'value_type', __remove_allocator )
+deque_traits = create_traits_class( 'deque', 0, 'value_type', defaults_eraser.erase_allocator )
-queue_traits = create_traits_class( 'queue', 0, 'value_type', __remove_container )
+queue_traits = create_traits_class( 'queue', 0, 'value_type', defaults_eraser.erase_container )
-priority_queue_traits = create_traits_class( 'priority_queue', 0, 'value_type', __remove_container_compare )
+priority_queue_traits = create_traits_class( 'priority_queue', 0, 'value_type', defaults_eraser.erase_container_compare )
-vector_traits = create_traits_class( 'vector', 0, 'value_type', __remove_allocator )
+vector_traits = create_traits_class( 'vector', 0, 'value_type', defaults_eraser.erase_allocator )
-stack_traits = create_traits_class( 'stack', 0, 'value_type', __remove_container )
+stack_traits = create_traits_class( 'stack', 0, 'value_type', defaults_eraser.erase_container )
-map_traits = create_traits_class( 'map', 1, 'mapped_type' )
-multimap_traits = create_traits_class( 'multimap', 1, 'mapped_type' )
+map_traits = create_traits_class( 'map', 1, 'mapped_type', defaults_eraser.erase_map_compare_allocator )
+multimap_traits = create_traits_class( 'multimap', 1, 'mapped_type', defaults_eraser.erase_map_compare_allocator )
hash_map_traits = create_traits_class( 'hash_map', 1, 'mapped_type' )
hash_multimap_traits = create_traits_class( 'hash_multimap', 1, 'mapped_type' )
-set_traits = create_traits_class( 'set', 0, 'value_type', __remove_compare_allocator )
+set_traits = create_traits_class( 'set', 0, 'value_type', defaults_eraser.erase_compare_allocator)
+multiset_traits = create_traits_class( 'multiset', 0, 'value_type', defaults_eraser.erase_compare_allocator )
+
hash_set_traits = create_traits_class( 'hash_set', 0, 'value_type' )
-
-multiset_traits = create_traits_class( 'multiset', 0, 'value_type', __remove_compare_allocator )
hash_multiset_traits = create_traits_class( 'hash_multiset', 0, 'value_type' )
container_traits = (
Modified: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-18 06:59:29 UTC (rev 1061)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-18 07:17:19 UTC (rev 1062)
@@ -12,6 +12,7 @@
#include <queue>
#include <list>
#include <set>
+#include <map>
namespace rtd{
@@ -55,6 +56,19 @@
}
+namespace maps{
+ typedef std::map< int, double > m_i2d;
+ typedef std::map< std::wstring, double > m_wstr2d;
+ typedef std::map< const std::vector< int >, m_wstr2d > m_v_i2m_wstr2d;
}
+namespace multimaps{
+ typedef std::multimap< int, double > mm_i2d;
+ typedef std::multimap< std::wstring const, double > mm_wstr2d;
+ typedef std::multimap< std::vector< int > const, mm_wstr2d const > mm_v_i2mm_wstr2d;
+}
+
+
+}
+
#endif//__remove_template_defaults_hpp__
Modified: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-18 06:59:29 UTC (rev 1061)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-18 07:17:19 UTC (rev 1062)
@@ -30,7 +30,7 @@
v_string = self.global_ns.typedef( 'v_string' )
self.failUnless( 'vector< std::string >'
== declarations.vector_traits.remove_defaults( v_string ) )
- v_v_int = self.global_ns.typedef( 'v_v_int' )
+ v_v_int = self.global_ns.typedef( 'v_v_int' )
self.failUnless( 'vector< std::vector< int > >'
== declarations.vector_traits.remove_defaults( v_v_int ) )
@@ -82,6 +82,28 @@
self.failUnless( 'multiset< std::string >'
== declarations.multiset_traits.remove_defaults( ms_string ) )
+ def test_map( self ):
+ m_i2d = self.global_ns.typedef( 'm_i2d' )
+ self.failUnless( 'map< int, double >'
+ == declarations.map_traits.remove_defaults( m_i2d ) )
+ m_wstr2d = self.global_ns.typedef( 'm_wstr2d' )
+ self.failUnless( 'map< std::wstring, double >'
+ == declarations.map_traits.remove_defaults( m_wstr2d ) )
+ m_v_i2m_wstr2d = self.global_ns.typedef( 'm_v_i2m_wstr2d' )
+ self.failUnless( 'map< const std::vector< int >, std::map< std::wstring, double > >'
+ == declarations.map_traits.remove_defaults( m_v_i2m_wstr2d ) )
+
+ def test_multimap( self ):
+ mm_i2d = self.global_ns.typedef( 'mm_i2d' )
+ self.failUnless( 'multimap< int, double >'
+ == declarations.multimap_traits.remove_defaults( mm_i2d ) )
+ mm_wstr2d = self.global_ns.typedef( 'mm_wstr2d' )
+ self.failUnless( 'multimap< const std::wstring, double >'
+ == declarations.multimap_traits.remove_defaults( mm_wstr2d ) )
+ mm_v_i2mm_wstr2d = self.global_ns.typedef( 'mm_v_i2mm_wstr2d' )
+ self.failUnless( 'multimap< const std::vector< int >, const std::multimap< const std::wstring, double > >'
+ == declarations.multimap_traits.remove_defaults( mm_v_i2mm_wstr2d ) )
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-18 06:59:27
|
Revision: 1061
http://svn.sourceforge.net/pygccxml/?rev=1061&view=rev
Author: roman_yakovenko
Date: 2007-06-17 23:59:29 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
adding container_traits property
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2007-06-17 10:42:04 UTC (rev 1060)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2007-06-18 06:59:29 UTC (rev 1061)
@@ -32,16 +32,21 @@
self.__container_traits = container_traits
self.__include_files = None
- def _get_container_class( self ):
+ @property
+ def container_class( self ):
+ """reference to the parent( STD container ) class"""
return self.__container_class
- container_class = property( _get_container_class
- , doc="Reference to STD container class" )
- def _get_element_type(self):
+ @property
+ def element_type(self):
+ """reference to container value_type( mapped_type ) type"""
return self.__container_traits.element_type( self.container_class )
- element_type = property( _get_element_type
- , doc="Reference to container value_type( mapped_type ) type" )
-
+
+ @property
+ def container_traits( self ):
+ "reference to container traits. See pygccxml documentation for more information."
+ return self.__container_traits
+
def _get_no_proxy( self ):
if self.__no_proxy is None:
self.__no_proxy = python_traits.is_immutable( self.element_type )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-17 10:42:05
|
Revision: 1060
http://svn.sourceforge.net/pygccxml/?rev=1060&view=rev
Author: roman_yakovenko
Date: 2007-06-17 03:42:04 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
adding another set of containers to remove_defaults functionality
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/container_traits.py
pygccxml_dev/unittests/data/remove_template_defaults.hpp
pygccxml_dev/unittests/remove_template_defaults_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2007-06-17 08:27:49 UTC (rev 1059)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2007-06-17 10:42:04 UTC (rev 1060)
@@ -169,7 +169,7 @@
from container_traits import list_traits
from container_traits import deque_traits
from container_traits import queue_traits
-from container_traits import priority_queue
+from container_traits import priority_queue_traits
from container_traits import vector_traits
from container_traits import stack_traits
from container_traits import map_traits
@@ -183,31 +183,15 @@
from function_traits import is_same_function
-all_container_traits = \
-[
- list_traits
- , deque_traits
- , queue_traits
- , priority_queue
- , vector_traits
- , stack_traits
- , map_traits
- , multimap_traits
- , hash_map_traits
- , hash_multimap_traits
- , set_traits
- , hash_set_traits
- , multiset_traits
- , hash_multiset_traits
-]
-"""list, that contains all STD container traits classes"""
+all_container_traits = container_traits.container_traits
+"""tuple of all STD container traits classes"""
sequential_container_traits = \
[
list_traits
, deque_traits
, queue_traits
- , priority_queue
+ , priority_queue_traits
, vector_traits
, stack_traits
, set_traits
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-17 08:27:49 UTC (rev 1059)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-17 10:42:04 UTC (rev 1060)
@@ -15,6 +15,9 @@
import type_traits
import class_declaration
+def __normalize_type( type_str ):
+ return type_str.replace( ' ', '' )
+
def __remove_basic_string( cls_name ):
strings = {
'std::string' : ( 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
@@ -38,7 +41,7 @@
return cls_name
return 'std::' + c_traits.remove_defaults( no_std_cls_name )
-def __remove_allocator( cls_name ):
+def __remove_allocator( cls_name, default_allocator='std::allocator' ):
cls_name = __remove_basic_string( cls_name )
# "vector<int,std::allocator<int> >"
c_name, c_args = templates.split( cls_name )
@@ -46,28 +49,61 @@
if 2 != len( c_args ):
return
a_name, a_args = templates.split( c_args[1] )
- if 'allocator' not in a_name:
+ if __normalize_type(default_allocator) != __normalize_type( a_name ):
return
if 1 != len( a_args ):
return
- if c_args[0].strip() != a_args[0]:
+ if __normalize_type( c_args[0] ) != __normalize_type( a_args[0] ):
return
value_type = __remove_defaults_recursive( c_args[0] )
return templates.join( c_name, [value_type] )
-def __remove_container( cls_name, default_container_name='deque' ):
+def __remove_container( cls_name, default_container_name='std::deque' ):
cls_name = __remove_basic_string( cls_name )
- # "vector<int,std::allocator<int> >"
c_name, c_args = templates.split( cls_name )
- #"vector", [ "int", "std::allocator<int>" ]
if 2 != len( c_args ):
return
dc_no_defaults = __remove_defaults_recursive( c_args[1] )
- if dc_no_defaults != templates.join( 'std::' + default_container_name, [c_args[0]] ):
+ if __normalize_type( dc_no_defaults ) \
+ != __normalize_type( templates.join( default_container_name, [c_args[0]] ) ):
return
value_type = __remove_defaults_recursive( c_args[0] )
return templates.join( c_name, [value_type] )
+
+def __remove_container_compare( cls_name, default_container_name='std::vector', default_compare='std::less' ):
+ cls_name = __remove_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 3 != len( c_args ):
+ return
+ dc_no_defaults = __remove_defaults_recursive( c_args[1] )
+ if __normalize_type( dc_no_defaults ) \
+ != __normalize_type( templates.join( default_container_name, [c_args[0]] ) ):
+ return
+ dcomp_no_defaults = __remove_defaults_recursive( c_args[2] )
+ if __normalize_type( dcomp_no_defaults ) \
+ != __normalize_type( templates.join( default_compare, [c_args[0]] ) ):
+ return
+ value_type = __remove_defaults_recursive( c_args[0] )
+ return templates.join( c_name, [value_type] )
+
+def __remove_compare_allocator( cls_name, default_compare='std::less', default_allocator='std::allocator' ):
+ cls_name = __remove_basic_string( cls_name )
+ c_name, c_args = templates.split( cls_name )
+ if 3 != len( c_args ):
+ return
+ dc_no_defaults = __remove_defaults_recursive( c_args[1] )
+ if __normalize_type( dc_no_defaults ) \
+ != __normalize_type( templates.join( default_compare, [c_args[0]] ) ):
+ return
+ da_no_defaults = __remove_defaults_recursive( c_args[2] )
+ if __normalize_type( da_no_defaults ) \
+ != __normalize_type( templates.join( default_allocator, [c_args[0]] ) ):
+ return
+ value_type = __remove_defaults_recursive( c_args[0] )
+ return templates.join( c_name, [value_type] )
+
+
class container_traits_impl_t:
"""this class implements the functionality needed for convinient work with
STD container classes.
@@ -192,7 +228,7 @@
queue_traits = create_traits_class( 'queue', 0, 'value_type', __remove_container )
-priority_queue = create_traits_class( 'priority_queue', 0, 'value_type' )
+priority_queue_traits = create_traits_class( 'priority_queue', 0, 'value_type', __remove_container_compare )
vector_traits = create_traits_class( 'vector', 0, 'value_type', __remove_allocator )
@@ -204,17 +240,17 @@
hash_map_traits = create_traits_class( 'hash_map', 1, 'mapped_type' )
hash_multimap_traits = create_traits_class( 'hash_multimap', 1, 'mapped_type' )
-set_traits = create_traits_class( 'set', 0, 'value_type' )
+set_traits = create_traits_class( 'set', 0, 'value_type', __remove_compare_allocator )
hash_set_traits = create_traits_class( 'hash_set', 0, 'value_type' )
-multiset_traits = create_traits_class( 'multiset', 0, 'value_type' )
+multiset_traits = create_traits_class( 'multiset', 0, 'value_type', __remove_compare_allocator )
hash_multiset_traits = create_traits_class( 'hash_multiset', 0, 'value_type' )
container_traits = (
list_traits
, deque_traits
, queue_traits
- , priority_queue
+ , priority_queue_traits
, vector_traits
, stack_traits
, map_traits
@@ -225,6 +261,7 @@
, hash_set_traits
, multiset_traits
, hash_multiset_traits )
+"""tuple of all STD container traits classes"""
def find_container_traits( cls_or_string ):
if isinstance( cls_or_string, types.StringTypes ):
Modified: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-17 08:27:49 UTC (rev 1059)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-17 10:42:04 UTC (rev 1060)
@@ -11,6 +11,7 @@
#include <deque>
#include <queue>
#include <list>
+#include <set>
namespace rtd{
@@ -36,6 +37,24 @@
}
+namespace priority_queues{
+ typedef std::priority_queue< int > pq_int;
+ typedef std::priority_queue< std::string > pq_string;
+
}
+namespace sets{
+ typedef std::set< std::vector< int > > s_v_int;
+ typedef std::set< std::string > s_string;
+
+}
+
+namespace multiset_sets{
+ typedef std::multiset< std::vector< int > > ms_v_int;
+ typedef std::multiset< std::string > ms_string;
+
+}
+
+}
+
#endif//__remove_template_defaults_hpp__
Modified: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-17 08:27:49 UTC (rev 1059)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-17 10:42:04 UTC (rev 1060)
@@ -58,7 +58,30 @@
self.failUnless( 'queue< std::string >'
== declarations.queue_traits.remove_defaults( q_string ) )
+ def test_priority_queue( self ):
+ pq_int = self.global_ns.typedef( 'pq_int' )
+ self.failUnless( 'priority_queue< int >'
+ == declarations.priority_queue_traits.remove_defaults( pq_int ) )
+ pq_string = self.global_ns.typedef( 'pq_string' )
+ self.failUnless( 'priority_queue< std::string >'
+ == declarations.priority_queue_traits.remove_defaults( pq_string ) )
+ def test_set( self ):
+ s_v_int = self.global_ns.typedef( 's_v_int' )
+ self.failUnless( 'set< std::vector< int > >'
+ == declarations.set_traits.remove_defaults( s_v_int ) )
+ s_string = self.global_ns.typedef( 's_string' )
+ self.failUnless( 'set< std::string >'
+ == declarations.set_traits.remove_defaults( s_string ) )
+
+ def test_multiset( self ):
+ ms_v_int = self.global_ns.typedef( 'ms_v_int' )
+ self.failUnless( 'multiset< std::vector< int > >'
+ == declarations.multiset_traits.remove_defaults( ms_v_int ) )
+ ms_string = self.global_ns.typedef( 'ms_string' )
+ self.failUnless( 'multiset< std::string >'
+ == declarations.multiset_traits.remove_defaults( ms_string ) )
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-06-17 08:27:52
|
Revision: 1059
http://svn.sourceforge.net/pygccxml/?rev=1059&view=rev
Author: roman_yakovenko
Date: 2007-06-17 01:27:49 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
adding initial ability to create std container names without default values
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/container_traits.py
pygccxml_dev/unittests/test_all.py
Added Paths:
-----------
pygccxml_dev/unittests/data/remove_template_defaults.hpp
pygccxml_dev/unittests/remove_template_defaults_tester.py
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-13 08:25:38 UTC (rev 1058)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2007-06-17 08:27:49 UTC (rev 1059)
@@ -7,13 +7,67 @@
defines few algorithms, that deals with different properties of std containers
"""
+import types
import calldef
import cpptypes
import namespace
import templates
+import type_traits
import class_declaration
-import type_traits
+def __remove_basic_string( cls_name ):
+ strings = {
+ 'std::string' : ( 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
+ , 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' )
+ , 'std::wstring' : ( 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >'
+ , 'std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' ) }
+
+ new_name = cls_name
+ for short_name, long_names in strings.iteritems():
+ for lname in long_names:
+ new_name = new_name.replace( lname, short_name )
+ return new_name
+
+def __remove_defaults_recursive( cls_name ):
+ global find_container_traits
+ if not cls_name.startswith( 'std::' ):
+ return cls_name
+ no_std_cls_name = cls_name[5:]
+ c_traits = find_container_traits( no_std_cls_name )
+ if not c_traits:
+ return cls_name
+ return 'std::' + c_traits.remove_defaults( no_std_cls_name )
+
+def __remove_allocator( cls_name ):
+ cls_name = __remove_basic_string( cls_name )
+ # "vector<int,std::allocator<int> >"
+ c_name, c_args = templates.split( cls_name )
+ #"vector", [ "int", "std::allocator<int>" ]
+ if 2 != len( c_args ):
+ return
+ a_name, a_args = templates.split( c_args[1] )
+ if 'allocator' not in a_name:
+ return
+ if 1 != len( a_args ):
+ return
+ if c_args[0].strip() != a_args[0]:
+ return
+ value_type = __remove_defaults_recursive( c_args[0] )
+ return templates.join( c_name, [value_type] )
+
+def __remove_container( cls_name, default_container_name='deque' ):
+ cls_name = __remove_basic_string( cls_name )
+ # "vector<int,std::allocator<int> >"
+ c_name, c_args = templates.split( cls_name )
+ #"vector", [ "int", "std::allocator<int>" ]
+ if 2 != len( c_args ):
+ return
+ dc_no_defaults = __remove_defaults_recursive( c_args[1] )
+ if dc_no_defaults != templates.join( 'std::' + default_container_name, [c_args[0]] ):
+ return
+ value_type = __remove_defaults_recursive( c_args[0] )
+ return templates.join( c_name, [value_type] )
+
class container_traits_impl_t:
"""this class implements the functionality needed for convinient work with
STD container classes.
@@ -84,16 +138,24 @@
% ( self.name, cls.decl_string ) )
return ref
+
-def create_traits_class( container_name, element_type_index, element_type_typedef ):
+def create_traits_class( container_name
+ , element_type_index
+ , element_type_typedef
+ , remove_defaults_=None ):
""" creates concrete container traits class """
class xxx_traits:
"""extract information from the container"""
impl = container_traits_impl_t( container_name, element_type_index, element_type_typedef )
-
+
@staticmethod
+ def name():
+ return xxx_traits.impl.name
+
+ @staticmethod
def is_my_case( type ):
"""returns True if type is the container class, otherwise False"""
return xxx_traits.impl.is_my_case( type )
@@ -108,19 +170,33 @@
"""returns reference to container name value\\mapped type class"""
return xxx_traits.impl.element_type( type )
+ @staticmethod
+ def remove_defaults( type_or_string ):
+ name = None
+ if not isinstance( type_or_string, types.StringTypes ):
+ name = xxx_traits.class_declaration( type_or_string ).name
+ else:
+ name = type_or_string
+ if not remove_defaults_:
+ return name
+ no_defaults = remove_defaults_( name )
+ if not no_defaults:
+ return name
+ else:
+ return no_defaults
return xxx_traits
-list_traits = create_traits_class( 'list', 0, 'value_type' )
+list_traits = create_traits_class( 'list', 0, 'value_type', __remove_allocator )
-deque_traits = create_traits_class( 'deque', 0, 'value_type' )
+deque_traits = create_traits_class( 'deque', 0, 'value_type', __remove_allocator )
-queue_traits = create_traits_class( 'queue', 0, 'value_type' )
+queue_traits = create_traits_class( 'queue', 0, 'value_type', __remove_container )
priority_queue = create_traits_class( 'priority_queue', 0, 'value_type' )
-vector_traits = create_traits_class( 'vector', 0, 'value_type' )
+vector_traits = create_traits_class( 'vector', 0, 'value_type', __remove_allocator )
-stack_traits = create_traits_class( 'stack', 0, 'value_type' )
+stack_traits = create_traits_class( 'stack', 0, 'value_type', __remove_container )
map_traits = create_traits_class( 'map', 1, 'mapped_type' )
multimap_traits = create_traits_class( 'multimap', 1, 'mapped_type' )
@@ -134,6 +210,33 @@
multiset_traits = create_traits_class( 'multiset', 0, 'value_type' )
hash_multiset_traits = create_traits_class( 'hash_multiset', 0, 'value_type' )
+container_traits = (
+ list_traits
+ , deque_traits
+ , queue_traits
+ , priority_queue
+ , vector_traits
+ , stack_traits
+ , map_traits
+ , multimap_traits
+ , hash_map_traits
+ , hash_multimap_traits
+ , set_traits
+ , hash_set_traits
+ , multiset_traits
+ , hash_multiset_traits )
+
+def find_container_traits( cls_or_string ):
+ if isinstance( cls_or_string, types.StringTypes ):
+ if not templates.is_instantiation( cls_or_string ):
+ return None
+ name = templates.name( cls_or_string )
+ for cls_traits in container_traits:
+ if cls_traits.name() == name:
+ return cls_traits
+ else:
+ for cls_traits in container_traits:
+ if cls_traits.is_my_case( cls ):
+ return cls_traits
-
Added: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp (rev 0)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2007-06-17 08:27:49 UTC (rev 1059)
@@ -0,0 +1,41 @@
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __remove_template_defaults_hpp__
+#define __remove_template_defaults_hpp__
+
+#include <string>
+#include <vector>
+#include <deque>
+#include <queue>
+#include <list>
+
+namespace rtd{
+
+namespace vectors{
+ typedef std::vector< int > v_int;
+ typedef std::vector< std::string > v_string;
+ typedef std::vector< v_int > v_v_int;
+}
+
+namespace lists{
+ typedef std::list< int > l_int;
+ typedef std::list< std::wstring > l_wstring;
+}
+
+namespace deques{
+ typedef std::deque< std::vector< int > > d_v_int;
+ typedef std::deque< std::list< std::string > > d_l_string;
+}
+
+namespace queues{
+ typedef std::queue< int > q_int;
+ typedef std::queue< std::string > q_string;
+
+}
+
+}
+
+#endif//__remove_template_defaults_hpp__
Added: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py (rev 0)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2007-06-17 08:27:49 UTC (rev 1059)
@@ -0,0 +1,71 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import unittest
+import autoconfig
+import parser_test_case
+
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
+
+class tester_t( parser_test_case.parser_test_case_t ):
+ global_ns = None
+ def __init__(self, *args ):
+ parser_test_case.parser_test_case_t.__init__( self, *args )
+ self.header = 'remove_template_defaults.hpp'
+
+ def setUp(self):
+ if not tester_t.global_ns:
+ decls = parser.parse( [self.header], self.config )
+ tester_t.global_ns = declarations.get_global_namespace( decls )
+ tester_t.global_ns.init_optimizer()
+
+ def test_vector( self ):
+ v_int = self.global_ns.typedef( 'v_int' )
+ self.failUnless( 'vector< int >'
+ == declarations.vector_traits.remove_defaults( v_int ) )
+ v_string = self.global_ns.typedef( 'v_string' )
+ self.failUnless( 'vector< std::string >'
+ == declarations.vector_traits.remove_defaults( v_string ) )
+ v_v_int = self.global_ns.typedef( 'v_v_int' )
+ self.failUnless( 'vector< std::vector< int > >'
+ == declarations.vector_traits.remove_defaults( v_v_int ) )
+
+ def test_list( self ):
+ l_int = self.global_ns.typedef( 'l_int' )
+ self.failUnless( 'list< int >'
+ == declarations.list_traits.remove_defaults( l_int ) )
+ l_wstring = self.global_ns.typedef( 'l_wstring' )
+ self.failUnless( 'list< std::wstring >'
+ == declarations.list_traits.remove_defaults( l_wstring ) )
+
+ def test_deque( self ):
+ d_v_int = self.global_ns.typedef( 'd_v_int' )
+ self.failUnless( 'deque< std::vector< int > >'
+ == declarations.deque_traits.remove_defaults( d_v_int ) )
+ d_l_string = self.global_ns.typedef( 'd_l_string' )
+ self.failUnless( 'deque< std::list< std::string > >'
+ == declarations.deque_traits.remove_defaults( d_l_string ) )
+
+ def test_queue( self ):
+ q_int = self.global_ns.typedef( 'q_int' )
+ self.failUnless( 'queue< int >'
+ == declarations.queue_traits.remove_defaults( q_int ) )
+ q_string = self.global_ns.typedef( 'q_string' )
+ self.failUnless( 'queue< std::string >'
+ == declarations.queue_traits.remove_defaults( q_string ) )
+
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2007-06-13 08:25:38 UTC (rev 1058)
+++ pygccxml_dev/unittests/test_all.py 2007-06-17 08:27:49 UTC (rev 1059)
@@ -41,6 +41,7 @@
import algorithms_cache_tester
import dependencies_tester
import free_operators_tester
+import remove_template_defaults_tester
def create_suite():
testers = [
@@ -81,6 +82,7 @@
, algorithms_cache_tester
, dependencies_tester
, free_operators_tester
+ , remove_template_defaults_tester
]
main_suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|