[pygccxml-commit] SF.net SVN: pygccxml:[1451] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-11-23 20:53:25
|
Revision: 1451
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1451&view=rev
Author: roman_yakovenko
Date: 2008-11-23 20:53:20 +0000 (Sun, 23 Nov 2008)
Log Message:
-----------
fix for few bugs related to free operators
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/module_creator/creator.py
pyplusplus_dev/unittests/data/operators_to_be_exported.hpp
pyplusplus_dev/unittests/operators_tester.py
pyplusplus_dev/unittests/test_all.py
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2008-11-22 21:36:02 UTC (rev 1450)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2008-11-23 20:53:20 UTC (rev 1451)
@@ -101,6 +101,7 @@
self.curr_decl = None
self.__array_1_registered = set() #(type.decl_string,size)
self.__free_operators = []
+ self.__std_containers_free_operators = {}
self.__exposed_free_fun_overloads = set()
self.__fc_manager = fake_constructors_manager.manager_t( global_ns )
@@ -174,30 +175,13 @@
pass
else:
assert not "Found %d class code creators" % len(creator)
-
+
find = code_creators.creator_finder.find_by_declaration
if operator.target_class and operator.target_class.ignore == False:
found = find( lambda decl: operator.target_class is decl
, self.__extmodule.body.creators )
adopt_operator_impl( operator, found )
- """
- find = code_creators.creator_finder.find_by_declaration
- if isinstance( operator.parent, declarations.class_t ):
- found = find( lambda decl: operator.parent is decl
- , self.__extmodule.body.creators )
- adopt_operator_impl( operator, found )
- else:
- #select all to be exposed declarations
- included = filter( lambda decl: decl.ignore == False, operator.class_types )
- if not included:
- msg = 'Py++ bug found!' \
- ' For some reason Py++ decided to expose free operator "%s", when all class types related to the operator definition are excluded.' \
- ' Please report this bug. Thanks! '
- raise RuntimeError( msg % str( operator ) )
- found = find( lambda decl: included[0] is decl, self.__extmodule.body.creators )
- adopt_operator_impl( operator, found )
- """
def _is_registered_smart_pointer_creator( self, creator, db ):
for registered in db:
if not isinstance( creator, registered.__class__ ):
@@ -292,7 +276,6 @@
creators = []
created_value_traits = set()
-
for cls in self.__get_exposed_containers():
self.__print_readme( cls )
@@ -322,6 +305,12 @@
self.__extmodule.adopt_declaration_creator( element_type_cc )
cls_creator.adopt_creator( code_creators.indexing_suite2_t(cls) )
+ scfo = self.__std_containers_free_operators
+ if cls in scfo:
+ for operator in scfo[cls]:
+ self.__dependencies_manager.add_exported( operator )
+ cls_creator.adopt_creator( code_creators.operator_t( operator=operator ) )
+
creators.reverse()
self.__module_body.adopt_creators( creators, 0 )
@@ -535,8 +524,18 @@
def visit_free_operator( self ):
self.__types_db.update( self.curr_decl )
- self.__free_operators.append( self.curr_decl )
+ operator = self.curr_decl
+ target_class = operator.target_class
+ scfo = self.__std_containers_free_operators
+ if target_class and target_class.indexing_suite:
+ if target_class not in scfo:
+ scfo[ target_class ] = [ operator ]
+ else:
+ scfo[ target_class ].append( operator )
+ else:
+ self.__free_operators.append( self.curr_decl )
+
def visit_class_declaration(self ):
pass
Modified: pyplusplus_dev/unittests/data/operators_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/operators_to_be_exported.hpp 2008-11-22 21:36:02 UTC (rev 1450)
+++ pyplusplus_dev/unittests/data/operators_to_be_exported.hpp 2008-11-23 20:53:20 UTC (rev 1451)
@@ -65,18 +65,33 @@
namespace PointsUtils{
struct VecOfInts{};
- //typedef std::vector<int> VecOfInts;
}
- class Class2 {
+ class Class {
int i;
};
+ //this one should not be generated
extern PointsUtils::VecOfInts&
- operator += ( PointsUtils::VecOfInts &vec, const Class2&){
+ operator += ( PointsUtils::VecOfInts &vec, const Class&){
return vec;
}
}
+namespace Geometry2{
+ namespace PointsUtils2{
+ typedef std::vector<int> VecOfInts2;
+ }
+
+ class Class2 {
+ int i;
+ };
+
+ extern PointsUtils2::VecOfInts2&
+ operator += ( PointsUtils2::VecOfInts2 &vec, const Class2&){
+ return vec;
+ }
+}
+
#endif//__operators_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/operators_tester.py
===================================================================
--- pyplusplus_dev/unittests/operators_tester.py 2008-11-22 21:36:02 UTC (rev 1450)
+++ pyplusplus_dev/unittests/operators_tester.py 2008-11-23 20:53:20 UTC (rev 1451)
@@ -66,6 +66,8 @@
mb.namespace( 'Geometry' ).include()
mb.namespace( 'Geometry' ).class_( 'VecOfInts' ).exclude()
+ mb.namespace( 'Geometry2' ).include()
+
def run_tests(self, module):
pyrational = module.pyrational
self.failUnless( pyrational( 28, 7) == 4 )
@@ -100,6 +102,15 @@
y = module.YYY()
print str( y )
+ vec = module.vector_less__int__greater_()
+ ins_cls_2 = module.Class2()
+ vec += ins_cls_2
+
+ ins_cls_1 = module.Class()
+ def tmp():
+ vec += ins_cls_1
+ self.failIfNotRaisesAny( tmp )
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2008-11-22 21:36:02 UTC (rev 1450)
+++ pyplusplus_dev/unittests/test_all.py 2008-11-23 20:53:20 UTC (rev 1451)
@@ -312,6 +312,7 @@
if __name__ == "__main__":
+ os.nice( 20 )
runner = process_tester_runner_t( testers )
runner()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|