[pygccxml-commit] SF.net SVN: pygccxml:[1618] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-01-26 10:40:19
|
Revision: 1618 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1618&view=rev Author: roman_yakovenko Date: 2009-01-26 10:40:12 +0000 (Mon, 26 Jan 2009) Log Message: ----------- removing deprecated functionality Modified Paths: -------------- pygccxml_dev/pygccxml/__init__.py pygccxml_dev/pygccxml/binary_parsers/undname.py pygccxml_dev/pygccxml/declarations/__init__.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/utils/__init__.py pygccxml_dev/unittests/test_all.py pyplusplus_dev/pyplusplus/messages/__init__.py pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py pyplusplus_dev/unittests/fundamental_tester_base.py Removed Paths: ------------- pygccxml_dev/pygccxml/declarations/filtering.py pygccxml_dev/unittests/filtering_tester.py Modified: pygccxml_dev/pygccxml/__init__.py =================================================================== --- pygccxml_dev/pygccxml/__init__.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/pygccxml/__init__.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -34,8 +34,7 @@ import pygccxml.utils as utils #TODO: -# 1. Write documentation for filtering functionality. -# 2. Add "explicit" property for constructors +# 1. Add "explicit" property for constructors __version__ = '1.0.0' Modified: pygccxml_dev/pygccxml/binary_parsers/undname.py =================================================================== --- pygccxml_dev/pygccxml/binary_parsers/undname.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/pygccxml/binary_parsers/undname.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -4,7 +4,14 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -provides functionality needed to undecorate\demangle compiler generated unique names +provides low-level functionality, needed to undecorate\demangle compiler generated +unique names and map them to the declarations + +On Windows: + ctypes package is used to call UnDecorateSymbolName function from dbghelp.dll + +On Linux: + "nm" utility is used. """ import os @@ -14,6 +21,8 @@ from pygccxml import declarations class UNDECORATE_NAME_OPTIONS: + """defines few constants for UnDecorateSymbolName function""" + UNDNAME_COMPLETE = 0x0000 #Enables full undecoration. UNDNAME_NO_LEADING_UNDERSCORES = 0x0001 #Removes leading underscores from Microsoft extended keywords. UNDNAME_NO_MS_KEYWORDS = 0x0002 #Disables expansion of Microsoft extended keywords. @@ -48,39 +57,19 @@ SHORT_UNIQUE_NAME = UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU -#~ The following code doesn't work - access violation +class undname_creator_t: + """formats declarations string representation and exported symbols, so they + could be matched later. -#~__unDName definition was taken from: -#~http://www.tech-archive.net/Archive/VC/microsoft.public.vc.language/2006-02/msg00754.html + The class formats variables, free and member functions, symbols exported from + .dll, .map and .so files. -#~ msvcrxx = ctypes.windll.msvcr90 -#~ free_type = ctypes.CFUNCTYPE( None, ctypes.c_void_p ) #free type -#~ malloc_type = ctypes.CFUNCTYPE( ctypes.c_void_p, ctypes.c_uint ) #malloc type -#~ __unDName = msvcrxx.__unDName -#~ __unDName.argtypes = [ ctypes.c_char_p #undecorated name - #~ , ctypes.c_char_p #decorated name - #~ , ctypes.c_int #sizeof undecorated name - #~ , malloc_type - #~ , free_type - #~ , ctypes.c_ushort #flags - #~ ] -#~ __unDName.restype = ctypes.c_char_p -#~ def undecorate_name( name, options=None ): - #~ if not name: - #~ return '' - #~ if options is None: - #~ options = UNDECORATE_NAME_OPTIONS.SHORT_UNIQUE_NAME - #~ buffer_size = 1024 * 32 - #~ undecorated_name = ctypes.create_string_buffer('\0' * buffer_size) #should be enouph for any symbol - #~ __unDName( undecorated_name - #~ , str(name) - #~ , buffer_size - #~ , malloc_type( msvcrxx.malloc ) - #~ , free_type( msvcrxx.free ) - #~ , options ) - #~ return undecorated_name.value + On Windows, the class works with unique name produced by MSVC compiler and + with undecorated names produced by dbghelp.dll -class undname_creator_t: + On Linux, the class works with mangled names produced by GCC-XML ( GCC 4.2 ) + compiler and demangled name produced by "nm" utility. + """ def __init__( self ): if 'win32' in sys.platform: import ctypes.wintypes @@ -147,7 +136,6 @@ result = result.replace( ' ' + x, x ) return result - def __normalize( self, name ): for what, with_ in self.__fundamental_types: name = name.replace( what, with_ ) Modified: pygccxml_dev/pygccxml/declarations/__init__.py =================================================================== --- pygccxml_dev/pygccxml/declarations/__init__.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/pygccxml/declarations/__init__.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -217,8 +217,6 @@ import templates import call_invocation -from filtering import filtering - from decl_factory import decl_factory_t from matchers import matcher_base_t Deleted: pygccxml_dev/pygccxml/declarations/filtering.py =================================================================== --- pygccxml_dev/pygccxml/declarations/filtering.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/pygccxml/declarations/filtering.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -1,79 +0,0 @@ -# Copyright 2004-2008 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) - -""" -deprecated! - -This module defines few algorithms for filtering declarations. -""" - -import os -import algorithm - -class filtering: - """deprecated! - - defines few algorithms for filtering declarations - """ - - @staticmethod - def normalize_path( some_path ): - """return os.path.normcase( os.path.normpath( some_path ) )""" - return os.path.normcase( os.path.normpath( some_path ) ) - - @staticmethod - def contains_parent_dir( fpath, dirs ): - #precondition: dirs and fpath should be normalize_path'ed before calling this function - return bool( filter( lambda dir: fpath.startswith( dir ), dirs ) ) - - @staticmethod - def by_location( decls, locations ): - """ - returns list of declarations that belongs to specified locations. - - This function works recursively. Pay attention: if you remove namespace, - then you remove all declarations defined within the namespace. - - @param decls: declaration or list of declarations - @type decls: L{declaration<declaration_t>} or list of L{declarations<declaration_t>} - - @param locations: list of directories and/or files names - @type locations: list of strings - - @return: list of L{declarations<declaration_t>} - """ - #precondition: decls is a list of op level namespaces - #locations is list of directories and\or files - temp_decls = algorithm.make_flatten( decls ) - locations = map( filtering.normalize_path, locations ) - dirs = filter( lambda location: os.path.isdir( location ), locations ) - files = filter( lambda location: os.path.isfile( location ), locations ) - result = [] - for decl in temp_decls: - if not decl.location: - result.append( decl ) - continue - fpath = filtering.normalize_path( decl.location.file_name ) - if filtering.contains_parent_dir( fpath, dirs ) or fpath in files: - result.append( decl ) - return result - - @staticmethod - def user_defined( decls, matcher ): - """ - returns list of declarations that match user specified criteria. - - This function works recursively. - - @param decls: declaration or list of declarations - @type decls: L{declaration<declaration_t>} or list of L{declarations<declaration_t>} - - @param matcher: callable object, that takes 1 argument - declaration - and returns True if object should stay, and false otherwise - - @return: list of L{declarations<declaration_t>} - """ - #precondition: decls is a list of op level namespaces - return filter( matcher, algorithm.make_flatten( decls ) ) Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -9,7 +9,6 @@ import time import algorithm -import filtering import templates import declaration import mdecl_wrapper Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/pygccxml/utils/__init__.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -89,6 +89,13 @@ """return os.path.normpath( os.path.normcase( some_path ) )""" return os.path.normpath( os.path.normcase( some_path ) ) +def contains_parent_dir( fpath, dirs ): + """returns bool( filter( lambda dir: fpath.startswith( dir ), dirs ) ) + precondition: dirs and fpath should be normalize_path'ed before calling this function + """ + return bool( filter( lambda dir: fpath.startswith( dir ), dirs ) ) + + def get_architecture(): """returns computer architecture: 32 or 64. Deleted: pygccxml_dev/unittests/filtering_tester.py =================================================================== --- pygccxml_dev/unittests/filtering_tester.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/unittests/filtering_tester.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -1,46 +0,0 @@ -# Copyright 2004-2008 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 os -import unittest -import autoconfig -import parser_test_case - -from pygccxml import parser -from pygccxml import declarations - -class tester_t( parser_test_case.parser_test_case_t ): - def __init__(self, *args): - parser_test_case.parser_test_case_t.__init__(self, *args) - self.__fname = 'declarations_for_filtering.hpp' - self.__fpath = declarations.filtering.normalize_path( - os.path.join( autoconfig.data_directory, self.__fname ) ) - - def test_by_location(self): - reader = parser.source_reader_t( self.config ) - decls = reader.read_file( self.__fname ) - decls_count = len( declarations.make_flatten( decls ) ) - filtered = declarations.filtering.by_location( decls, [autoconfig.data_directory] ) - flatten_filtered = declarations.make_flatten( filtered ) - self.failUnless( len( flatten_filtered ) != decls_count ) - for decl in flatten_filtered: - if decl.location: - self.failUnless( declarations.filtering.normalize_path( decl.location.file_name ) - , self.__fpath ) - self.failUnless( declarations.find_declaration( filtered - , name='color' - , type=declarations.enumeration_t - , recursive=False) ) - -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() \ No newline at end of file Modified: pygccxml_dev/unittests/test_all.py =================================================================== --- pygccxml_dev/unittests/test_all.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pygccxml_dev/unittests/test_all.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -19,7 +19,6 @@ import type_traits_tester import core_tester import xmlfile_reader_tester -import filtering_tester import text_reader_tester import hierarchy_traveling import patcher_tester @@ -70,7 +69,6 @@ , type_traits_tester , core_tester , xmlfile_reader_tester - , filtering_tester , text_reader_tester , hierarchy_traveling , patcher_tester Modified: pyplusplus_dev/pyplusplus/messages/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/messages/__init__.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pyplusplus_dev/pyplusplus/messages/__init__.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -8,16 +8,6 @@ """ from warnings_ import * -#implementation using regular expression is deprecated, I will leave it here for -#some time to be sure that the new one does not cause any problems. -#import re -#__RE_GET_WARNING_ID = re.compile( r'warning\s(?P<id>W(\d){4})' ) -#match_obj = __RE_GET_WARNING_ID.search(msg) -# if not match_obj: -# return None -# else: -# return match_obj.group( 'id' ) - def find_out_message_id( msg ): return msg.identifier Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -11,6 +11,7 @@ import module_builder from pygccxml import parser +from pygccxml import utils as pygccxml_utils from pygccxml import declarations as decls_package from pyplusplus import utils @@ -76,7 +77,7 @@ , compiler=compiler) #may be in future I will add those directories to user_defined_directories to self.__code_creator. - self.__parsed_files = map( decls_package.filtering.normalize_path + self.__parsed_files = map( pygccxml_utils.normalize_path , parser.project_reader_t.get_os_file_names( files ) ) tmp = map( lambda file_: os.path.split( file_ )[0], self.__parsed_files ) self.__parsed_dirs = filter( None, tmp ) @@ -151,8 +152,8 @@ for decl in flatten_decls: if not decl.location: continue - fpath = decls_package.filtering.normalize_path( decl.location.file_name ) - if decls_package.filtering.contains_parent_dir( fpath, self.__parsed_dirs ): + fpath = pygccxml_utils.normalize_path( decl.location.file_name ) + if pygccxml_utils.contains_parent_dir( fpath, self.__parsed_dirs ): continue if fpath in self.__parsed_files: continue @@ -203,7 +204,6 @@ def build_code_creator( self , module_name , boost_python_ns_name='bp' - , create_casting_constructor=True , call_policies_resolver_=None , types_db=None , target_configuration=None @@ -226,16 +226,7 @@ and returns documentation string @type doc_extractor: callable or None """ - if not create_casting_constructor: - msg = os.linesep.join([ - "create_casting_constructor argument is deprecated." - , "If want to disable boost::python::implicitly_convertible code generation, consider to use allow_implicit_conversion constructor property" - , ">>> mb = module_builder_t(...)" - , ">>> mb.constructors().allow_implicit_conversion = False"]) - warnings.warn(msg, DeprecationWarning, stacklevel=2) - self.global_ns.constructors(allow_empty=True).allow_implicit_conversion = False - creator = creators_factory.bpcreator_t( self.global_ns , module_name , boost_python_ns_name Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2009-01-26 09:11:26 UTC (rev 1617) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2009-01-26 10:40:12 UTC (rev 1618) @@ -102,7 +102,7 @@ , include_paths=[autoconfig.boost.include] , undefine_symbols=['__MINGW32__'] , indexing_suite_version=self.__indexing_suite_version - , compiler=pygccxml.utils.native_compiler.get_gccxml_compiler()) + , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler) for decl in mb.decls(): decl.documentation = '"documentation"' self.customize( mb ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |