[pygccxml-commit] SF.net SVN: pygccxml:[1399] pyplusplus_dev/unittests/data
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2008-08-20 11:32:40
|
Revision: 1399 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1399&view=rev Author: roman_yakovenko Date: 2008-08-20 11:32:49 +0000 (Wed, 20 Aug 2008) Log Message: ----------- improve dependencies_manager.py class algorithm Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/dependencies.py pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py pyplusplus_dev/unittests/data/mem_fun_with_exception_to_be_exported.hpp Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2008-08-20 06:20:45 UTC (rev 1398) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2008-08-20 11:32:49 UTC (rev 1399) @@ -310,13 +310,13 @@ , doc="returns function demangled name. It can help you to deal with function template instantiations") def i_depend_on_them( self, recursive=True ): - report_dependency = lambda x: dependencies.dependency_info_t( self, x ) + report_dependency = lambda *args, **keywd: dependencies.dependency_info_t( self, *args, **keywd ) answer = [] + if self.return_type: + answer.append( report_dependency( self.return_type, hint="return type" ) ) map( lambda arg: answer.append( report_dependency( arg.type ) ) , self.arguments ) - if self.return_type: - answer.append( report_dependency( self.return_type ) ) - map( lambda exception: answer.append( report_dependency( exception ) ) + map( lambda exception: answer.append( report_dependency( exception, hint="exception" ) ) , self.exceptions ) return answer Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-08-20 06:20:45 UTC (rev 1398) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-08-20 11:32:49 UTC (rev 1399) @@ -457,9 +457,10 @@ def i_depend_on_them( self, recursive=True ): report_dependency = lambda *args: dependencies.dependency_info_t( self, *args ) + answer = [] - map( lambda base: answer.append( report_dependency( base.related_class, base.access_type ) ) + map( lambda base: answer.append( report_dependency( base.related_class, base.access_type, "base class" ) ) , self.bases ) if recursive: Modified: pygccxml_dev/pygccxml/declarations/dependencies.py =================================================================== --- pygccxml_dev/pygccxml/declarations/dependencies.py 2008-08-20 06:20:45 UTC (rev 1398) +++ pygccxml_dev/pygccxml/declarations/dependencies.py 2008-08-20 11:32:49 UTC (rev 1399) @@ -10,7 +10,7 @@ import cpptypes class dependency_info_t( object ): - def __init__( self, declaration, depend_on_it, access_type=None ): + def __init__( self, declaration, depend_on_it, access_type=None, hint=None ): object.__init__( self ) #prevent recursive import import class_declaration @@ -18,6 +18,7 @@ self._declaration = declaration self._depend_on_it = depend_on_it self._access_type = access_type + self._hint = hint @property def declaration( self ): @@ -39,6 +40,12 @@ return 'declaration "%s" depends( %s ) on "%s" ' \ % ( self.declaration, self.access_type, self.depend_on_it ) + @property + def hint(self): + """the declaration, that report dependency can put some additional inforamtion + about dependency. It can be used later""" + return self._hint + def find_out_depend_on_declaration( self ): """if declaration depends on other declaration and not on some type this function will return reference to it. Otherwise None will be returned Modified: pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2008-08-20 06:20:45 UTC (rev 1398) +++ pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2008-08-20 11:32:49 UTC (rev 1399) @@ -76,12 +76,14 @@ if decl.already_exposed: return [] dependencies = decl.i_depend_on_them(recursive=False) + if isinstance( decl, declarations.class_t ): dependencies = filter( lambda d: d.access_type != declarations.ACCESS_TYPES.PRIVATE - , dependencies ) + , dependencies ) + return dependencies - def __has_unexposed_dependency( self, exported_ids, depend_on_decl ): + def __has_unexposed_dependency( self, exported_ids, depend_on_decl, dependency ): sptr_traits = declarations.smart_pointer_traits if None is depend_on_decl: @@ -93,7 +95,7 @@ if sptr_traits.is_smart_pointer( depend_on_decl ): try: value_type = sptr_traits.value_type( depend_on_decl ) - return self.__has_unexposed_dependency( exported_ids, value_type ) + return self.__has_unexposed_dependency( exported_ids, value_type, dependency ) except RuntimeError: pass @@ -103,9 +105,23 @@ if isinstance( depend_on_decl, declarations.class_types ): if depend_on_decl.opaque: return + if dependency.hint == "base class": + return #base class for some class don't have to be exported if isinstance( depend_on_decl, declarations.variable_t ): if not decl.expose_value: return + + if isinstance( dependency.decl, declarations.variable_t ): + #the only dependency of the variable is its type + if not dependency.decl.expose_value: + return + + if dependency.hint == "return type": + #in this case we don't check, the return type but the function + if isinstance( dependency.decl, declarations.calldef_t ): + if dependency.decl.return_type and dependency.decl.call_policies \ + and decl_wrappers.is_return_opaque_pointer_policy( dependency.decl.call_policies ): + return return id( depend_on_decl ) not in exported_ids @@ -115,7 +131,7 @@ for decl in self.__exported_decls: for dependency in self.__build_dependencies( decl ): depend_on_decl = dependency.find_out_depend_on_declaration() - if self.__has_unexposed_dependency( exported_ids, depend_on_decl ): + if self.__has_unexposed_dependency( exported_ids, depend_on_decl, dependency ): if messages.filter_disabled_msgs([messages.W1040], depend_on_decl.disabled_messages ): #need to report dependency errors used_not_exported.append(dependency) Modified: pyplusplus_dev/unittests/data/mem_fun_with_exception_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/mem_fun_with_exception_to_be_exported.hpp 2008-08-20 06:20:45 UTC (rev 1398) +++ pyplusplus_dev/unittests/data/mem_fun_with_exception_to_be_exported.hpp 2008-08-20 11:32:49 UTC (rev 1399) @@ -1,23 +1,23 @@ -// 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 __mem_fun_with_exception_to_be_exported_hpp__ -#define __mem_fun_with_exception_to_be_exported_hpp__ - -#include <exception> - -namespace mem_fun_with_exception{ +// 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 __mem_fun_with_exception_to_be_exported_hpp__ +#define __mem_fun_with_exception_to_be_exported_hpp__ + +#include <stdexcept> + +namespace mem_fun_with_exception{ + struct data_t{ public: - virtual void do_nothing() throw( std::exception ) + virtual void do_nothing() throw( std::exception ) {} }; - -} - + +} + #endif//__mem_fun_with_exception_to_be_exported_hpp__ - - + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |