pygccxml-commit Mailing List for C++ Python language bindings (Page 15)
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...> - 2008-12-27 10:57:42
|
Revision: 1507
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1507&view=rev
Author: roman_yakovenko
Date: 2008-12-27 10:57:29 +0000 (Sat, 27 Dec 2008)
Log Message:
-----------
first code creators classes for ctypes
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/class_declaration.py
pygccxml_dev/unittests/data/core_cache.hpp
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
pyplusplus_dev/pyplusplus/code_creators/declaration_based.py
pyplusplus_dev/pyplusplus/code_repository/__init__.py
pyplusplus_dev/pyplusplus/cpptypes/tester.py
pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
pyplusplus_dev/pyplusplus/file_writers/writer.py
pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
pyplusplus_dev/unittests/ctypes_pof_tester.py
pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp
pyplusplus_dev/unittests/data/ctypes_pof/mydll.h
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_creators/class_introduction.py
pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py
pyplusplus_dev/pyplusplus/code_creators/fields_definition.py
pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py
pyplusplus_dev/pyplusplus/code_creators/methods_definition.py
pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py
pyplusplus_dev/pyplusplus/code_repository/ctypes_cpp_utils.py
Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -457,7 +457,7 @@
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, "base class" ) )
@@ -500,8 +500,8 @@
return 'wstring'
else:
return get_partial_name( self.name )
-
- def find_noncopyable_vars( self ):
+
+ def find_noncopyable_vars( self ):
"""returns list of all noncopyable variables"""
import type_traits as tt#prevent cyclic dependencies
logger = utils.loggers.cxx_parser
@@ -524,9 +524,17 @@
cls = tt.class_traits.get_declaration( type_ )
if tt.is_noncopyable( cls ):
logger.debug( "__contains_noncopyable_mem_var - %s - TRUE - containes member variable - class that is not copyable" % self.decl_string )
- noncopyable_vars.append( mvar )
+ noncopyable_vars.append( mvar )
logger.debug( "__contains_noncopyable_mem_var - %s - false - doesn't contains noncopyable members" % self.decl_string )
return noncopyable_vars
+ @property
+ def has_vtable( self ):
+ """True, if class has virtual table, False otherwise"""
+ import calldef
+ return bool( self.calldefs( lambda f: isinstance( f, calldef.member_function_t ) \
+ and f.virtuality != calldef.VIRTUALITY_TYPES.NOT_VIRTUAL
+ , recursive=False
+ , allow_empty=True ) )
class_types = ( class_t, class_declaration_t )
Modified: pygccxml_dev/unittests/data/core_cache.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_cache.hpp 2008-12-26 23:56:12 UTC (rev 1506)
+++ pygccxml_dev/unittests/data/core_cache.hpp 2008-12-27 10:57:29 UTC (rev 1507)
@@ -22,4 +22,4 @@
#endif//__core_cache_hpp__
-//touch//touch
\ No newline at end of file
+//touch//touch//touch
\ No newline at end of file
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -146,4 +146,10 @@
from import_ import import_t
from library_reference import library_reference_t
from name_mappings import name_mappings_t
-
+from namespace_as_pyclass import namespace_as_pyclass_t
+from class_introduction import class_introduction_t
+from mem_fun_introduction import mem_fun_introduction_t
+from mem_fun_introduction import vmem_fun_introduction_t
+from fields_definition import fields_definition_t
+from embedded_code_repository import embedded_code_repository_t
+from methods_definition import methods_definition_t
Added: pyplusplus_dev/pyplusplus/code_creators/class_introduction.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/class_introduction.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/class_introduction.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,33 @@
+# 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 compound
+import declaration_based
+from pygccxml import declarations
+
+class class_introduction_t(compound.compound_t, declaration_based.declaration_based_t):
+ def __init__( self, class_ ):
+ compound.compound_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, class_ )
+
+ def _create_impl(self):
+ result = []
+ result.append( "class %s(ctypes.Structure):" % self.alias )
+ result.append( self.indent( '"""class %s"""' % self.decl_identifier ) )
+ result.append( self.indent( '#_fields_ = [] <-- class member variables definition list' ) )
+ result.append( self.indent( '#_methods_ = {} <-- class non-virtual member functions definition list' ) )
+ if self.creators:
+ result.append( self.indent( '' ) )
+ result.append( compound.compound_t.create_internal_code( self.creators ) )
+
+ if isinstance( self.declaration.parent, declarations.namespace_t ) \
+ and self.declaration.parent is not self.declaration.top_parent: #not a global namespace
+ result.append( '%(ns_full_name)s = %(name)s'
+ % dict( ns_full_name=self.complete_py_name, name=self.alias ))
+ return os.linesep.join( result )
+
+ def _get_system_headers_impl( self ):
+ return []
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -166,7 +166,7 @@
, os.linesep )
@staticmethod
- def is_comment( line ):
+ def is_comment( line, language='C++' ):
"""
function that returns true if content of the line is comment, otherwise
false.
@@ -174,10 +174,19 @@
@param line: C++ source code
@type line: str
@rtype: bool
+
+ @param language: the programming language, the line was written in. Possible values: C++, Python
+ @type line: str
"""
assert isinstance( line, types.StringTypes )
l = line.lstrip()
- return l.startswith( '//' ) or l.startswith( '/*' )
+ if language == 'C++':
+ return l.startswith( '//' ) or l.startswith( '/*' )
+ elif language == 'Python':
+ return l.startswith( '#' )
+ else:
+ raise RuntimeError( "Language %s is not supported. The possible values are: Python, C++"
+ % language )
@staticmethod
def iif( condition, true_, false_ ):
Modified: pyplusplus_dev/pyplusplus/code_creators/declaration_based.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -5,6 +5,7 @@
import algorithm
import code_creator
+from pygccxml import utils
class declaration_based_t:
"""Code creator that is based on a declaration.
@@ -18,12 +19,12 @@
@type parent: code_creator_t
"""
self._decl = declaration
-
+
def _generate_valid_name(self, name=None):
if name == None:
name = self.declaration.name
return algorithm.create_valid_name( name )
-
+
@property
def declaration(self):
"""The declaration this code creator is based on.
@@ -33,23 +34,39 @@
def _get_alias_impl( self ):
return self.declaration.alias
-
- def _get_alias(self):
- return self._get_alias_impl()
+
+ def _get_alias(self):
+ return self._get_alias_impl()
def _set_alias(self, alias):
self.declaration.alias = alias
alias = property( _get_alias, _set_alias )
-
+
+ @utils.cached
+ def undecorated_decl_name( self ):
+ from pygccxml import msvc #prevent import on Linux
+ return msvc.undecorate_decl( self.declaration )
+
+ @utils.cached
+ def complete_py_name( self ):
+ aliases = []
+ current = self.declaration
+ while current:
+ aliases.append( current.alias )
+ current = current.parent
+ del aliases[-1] # :: from the global namespace
+ aliases.reverse()
+ return '.'.join( aliases )
+
@property
def decl_identifier( self ):
return algorithm.create_identifier( self, self.declaration.partial_decl_string )
-
+
@property
def documentation( self ):
if None is self.declaration.documentation:
return ''
return self.declaration.documentation
-
+
def get_user_headers( self, recursive=False, unique=False ):
"""return list of user header files to be included from the generated file"""
return self.declaration.include_files
Added: pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,18 @@
+# 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 code_creator
+
+class embedded_code_repository_t(code_creator.code_creator_t):
+ """Creates Python import directive"""
+ def __init__( self, code_repository_module ):
+ code_creator.code_creator_t.__init__(self)
+ self.__code = code_repository_module.code
+
+ def _create_impl(self):
+ return self.__code
+
+ def _get_system_headers_impl( self ):
+ return []
Added: pyplusplus_dev/pyplusplus/code_creators/fields_definition.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/fields_definition.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/fields_definition.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,31 @@
+# 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 code_creator
+import declaration_based
+from pygccxml import declarations
+
+class fields_definition_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
+ def __init__( self, class_ ):
+ code_creator.code_creator_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, class_ )
+
+ def _create_impl(self):
+ result = []
+ result.append( '%(complete_py_name)s._fields_ = [ #class member variables definition list'
+ % dict( complete_py_name=self.complete_py_name ) )
+ if self.declaration.has_vtable:
+ result.append( self.indent( '("_vtable_", ctypes.POINTER(ctypes.c_void_p)),' ) )
+ result.append( self.indent( "#TODO: don't hide public member variables" ) )
+ result.append( self.indent( "#TODO: how _fields_ should be defined in a class hierarchy" ) )
+ result.append( self.indent( "#TODO: fix 64bit issue with calculating vtable pointer size" ) )
+ result.append( self.indent( '("__hidden__", ctypes.c_char * %d),'
+ % ( self.declaration.byte_size - 4*int(self.declaration.has_vtable) ) ) )
+ result.append( ']' )
+ return os.linesep.join( result )
+
+ def _get_system_headers_impl( self ):
+ return []
Added: pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,41 @@
+# 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 code_creator
+import declaration_based
+from pygccxml import declarations
+
+class mem_fun_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
+ def __init__( self, mem_fun ):
+ code_creator.code_creator_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, mem_fun )
+
+ def _create_impl(self):
+ tmpl = ['def %(alias)s( self, *args ):']
+ tmpl.append( self.indent('"""%(name)s"""') )
+ tmpl.append( self.indent("return self._methods_['%(alias)s']( ctypes.byref( self ), *args )") )
+ return os.linesep.join( tmpl ) \
+ % dict( alias=self.declaration.alias, name=self.undecorated_decl_name )
+
+ def _get_system_headers_impl( self ):
+ return []
+
+class vmem_fun_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
+ def __init__( self, mem_fun ):
+ code_creator.code_creator_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, mem_fun )
+
+ def _create_impl(self):
+ tmpl = ['def %(alias)s( self, *args ):']
+ tmpl.append( self.indent('"""%(name)s"""') )
+ tmpl.append( self.indent("return self._vtable_['%(ordinal)d'].%(alias)s( ctypes.byref( self ), *args )") )
+ return os.linesep.join( tmpl ) \
+ % dict( alias=self.declaration.alias
+ , name=self.undecorated_decl_name
+ , ordinal=0)
+
+ def _get_system_headers_impl( self ):
+ return []
Added: pyplusplus_dev/pyplusplus/code_creators/methods_definition.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/methods_definition.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/methods_definition.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,40 @@
+# 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 compound
+import declaration_based
+from pygccxml import declarations
+
+class methods_definition_t(compound.compound_t, declaration_based.declaration_based_t):
+ def __init__( self, class_ ):
+ compound.compound_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, class_ )
+
+ @property
+ def mem_fun_factory_var_name(self):
+ return "mfcreator"
+
+ def _create_impl(self):
+ result = []
+ scope = declarations.algorithm.declaration_path( self.declaration )
+ del scope[0] #del :: from the global namespace
+
+
+ result.append( '%(mem_fun_factory_var_name)s = mem_fun_factory( %(library_var_name)s, %(complete_py_name)s, "%(class_name)s", "%(ns)s" )'
+ % dict( mem_fun_factory_var_name=self.mem_fun_factory_var_name
+ , library_var_name=self.top_parent.library_var_name
+ , complete_py_name=self.complete_py_name
+ , class_name=self.declaration.name
+ , ns='::'.join(scope) ) )
+ result.append( '%(complete_py_name)s._methods_ = { #class non-virtual member functions definition list'
+ % dict( complete_py_name=self.complete_py_name ) )
+ result.append( compound.compound_t.create_internal_code( self.creators ) )
+ result.append( '}' )
+ result.append( 'del %s' % self.mem_fun_factory_var_name )
+ return os.linesep.join( result )
+
+ def _get_system_headers_impl( self ):
+ return []
Added: pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,25 @@
+# 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 compound
+import declaration_based
+
+class namespace_as_pyclass_t(compound.compound_t, declaration_based.declaration_based_t):
+ def __init__( self, ns ):
+ compound.compound_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, ns )
+
+ def _create_impl(self):
+ result = []
+ result.append( "class %s:" % self.alias )
+ result.append( self.indent( '"""namespace %s"""' % self.decl_identifier ) )
+ if self.creators:
+ result.append( self.indent( "" ) )
+ result.append( compound.compound_t.create_internal_code( self.creators ) )
+ return os.linesep.join( result )
+
+ def _get_system_headers_impl( self ):
+ return []
Modified: pyplusplus_dev/pyplusplus/code_repository/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/__init__.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/code_repository/__init__.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -19,6 +19,7 @@
import convenience
import return_range
import call_policies
+import ctypes_cpp_utils
import ctypes_integration
all = [ array_1
@@ -27,6 +28,7 @@
, call_policies
, named_tuple
, return_range
+ , ctypes_cpp_utils
, ctypes_integration ]
headers = map( lambda f: f.file_name, all )
Added: pyplusplus_dev/pyplusplus/code_repository/ctypes_cpp_utils.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/ctypes_cpp_utils.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/ctypes_cpp_utils.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -0,0 +1,92 @@
+# 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)
+
+file_name = "ctypes_cpp_utils.py"
+
+license = \
+"""# 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)
+"""
+
+
+code = \
+"""
+# what is the best way to treat overloaded constructors
+class mem_fun_callable( object ):
+ def __init__(self, dll, name, restype=None, argtypes=None ):
+ self.name = name
+ self.func = getattr( dll, dll.undecorated_names[name] )
+ self.func.restype = restype
+ self.func.argtypes = argtypes
+
+ def __call__(self, *args, **keywd ):
+ return self.func( *args, **keywd )
+
+class mem_fun_factory( object ):
+ def __init__( self, dll, wrapper, class_name, namespace='' ):
+ self.dll = dll
+ self.namespace = namespace
+ self.class_name = class_name
+ self.this_type = ctypes.POINTER( wrapper )
+
+ def __call__( self, name, **keywd ):
+ if 'argtypes' not in keywd:
+ keywd['argtypes'] = [ self.this_type ]
+ else:
+ keywd['argtypes'].insert( 0, self.this_type )
+ return mem_fun_callable( self.dll, name, **keywd )
+
+ def __get_ns_name(self):
+ if self.namespace:
+ return self.namespace + '::'
+ else:
+ return ''
+
+ def default_constructor( self ):
+ return self( '%(ns)s%(class_name)s::%(class_name)s(void)'
+ % dict( ns=self.__get_ns_name()
+ , class_name=self.class_name ) )
+
+ def constructor( self, argtypes_str, **keywd ):
+ return self( '%(ns)s%(class_name)s::%(class_name)s(%(args)s)'
+ % dict( ns=self.__get_ns_name()
+ , class_name=self.class_name
+ , args=argtypes_str )
+ , **keywd )
+
+ def copy_constructor( self ):
+ return self( '%(ns)s%(class_name)s::%(class_name)s(%(class_name)s const &)'
+ % dict( ns=self.__get_ns_name()
+ , class_name=self.class_name )
+ , argtypes=[self.this_type] )
+
+ def destructor( self ):
+ return self( '%(ns)s%(class_name)s::~%(class_name)s(void)'
+ % dict( ns=self.__get_ns_name()
+ , class_name=self.class_name ) )
+
+ def operator_assign( self ):
+ return self( '%(ns)s%(class_name)s & %(class_name)s::operator=(%(class_name)s const &)'
+ % dict( ns=self.__get_ns_name()
+ , class_name=self.class_name )
+ , restype=self.this_type
+ , argtypes=[self.this_type] )
+
+ def method( self, name, restype_str=None, argtypes_str=None, **keywd ):
+ if None is restype_str:
+ restype_str = 'void'
+ if None is argtypes_str:
+ argtypes_str = 'void'
+
+ return self( '%(return_)s %(ns)s%(class_name)s::%(method_name)s(%(args)s)'
+ % dict( return_=restype_str
+ , ns=self.__get_ns_name()
+ , class_name=self.class_name
+ , method_name=name
+ , args=argtypes_str )
+ , **keywd )
+"""
Modified: pyplusplus_dev/pyplusplus/cpptypes/tester.py
===================================================================
--- pyplusplus_dev/pyplusplus/cpptypes/tester.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/cpptypes/tester.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -10,13 +10,13 @@
# GCCXML reports mangled and demangled names of the function, but it is not a cross platform( compile ) solution.
# It looks like I will have to cause mspdb package to work ( from where ctypes loads dlls? ctypes.windll.msvcr90 ???
-mydll.name_mapping = name_mapping.data
+mydll.undecorated_names = name_mapping.data
# what is the best way to treat overloaded constructors
-class public( object ):
+class mem_fun_callable( object ):
def __init__(self, dll, name, restype=None, argtypes=None ):
self.name = name
- self.func = getattr( dll, dll.name_mapping[name] )
+ self.func = getattr( dll, dll.undecorated_names[name] )
self.func.restype = restype
self.func.argtypes = argtypes
@@ -35,7 +35,7 @@
keywd['argtypes'] = [ self.this_type ]
else:
keywd['argtypes'].insert( 0, self.this_type )
- return public( self.dll, name, **keywd )
+ return mem_fun_callable( self.dll, name, **keywd )
def __get_ns_name(self):
if self.namespace:
Modified: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -3,7 +3,7 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-
+import sort_algorithms
import dependencies_manager
from pygccxml import declarations
from pyplusplus import decl_wrappers
@@ -24,16 +24,18 @@
self.logger = _logging_.loggers.module_builder
self.decl_logger = _logging_.loggers.declarations
+ self.global_ns = global_ns
+
self.__library_path = library_path
self.__exported_symbols = exported_symbols
-
- self.__extmodule = code_creators.ctypes_module_t( global_ns )
+ self.module = code_creators.ctypes_module_t( global_ns )
self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)
#~ prepared_decls = self.__prepare_decls( global_ns, doc_extractor )
#~ self.__decls = sort_algorithms.sort( prepared_decls )
self.curr_decl = global_ns
- self.curr_code_creator = self.__extmodule
+ self.curr_code_creator = self.module
+ self.__class2introduction = {}
def __print_readme( self, decl ):
readme = decl.readme()
@@ -48,6 +50,12 @@
for msg in readme:
self.decl_logger.warn( "%s;%s" % ( decl, msg ) )
+ def __should_generate_code( self, decl ):
+ if decl.ignore or decl.already_exposed:
+ return False
+ return True
+
+
#~ def __prepare_decls( self, global_ns, doc_extractor ):
#~ to_be_exposed = []
#~ for decl in declarations.make_flatten( global_ns ):
@@ -74,7 +82,28 @@
#~ return to_be_exposed
+ def __contains_exported( self, decl ):
+ return bool( decl.decls( self.__should_generate_code, recursive=True, allow_empty=True ) )
+ # - implement better 0(n) algorithm
+ def __add_class_introductions( self, cc, class_ ):
+ ci_creator = code_creators.class_introduction_t( class_ )
+ self.__class2introduction[ class_ ] = ci_creator
+ cc.adopt_creator( ci_creator )
+ classes = class_.classes( recursive=False, allow_empty=True)
+ classes = sort_algorithms.sort_classes( classes )
+ for internal_class in classes:
+ if self.__contains_exported( internal_class ):
+ self.__add_class_introductions( ci_creator, internal_class )
+
+ # - implement better 0(n) algorithm
+ def __add_namespaces( self, cc, ns ):
+ ns_creator = code_creators.namespace_as_pyclass_t( ns )
+ cc.adopt_creator( ns_creator )
+ for internal_ns in ns.namespaces( recursive=False, allow_empty=True):
+ if self.__contains_exported( ns ):
+ self.__add_namespaces( ns_creator, internal_ns )
+
def create(self ):
"""Create and return the module for the extension.
@@ -82,20 +111,43 @@
@rtype: L{module_t<code_creators.module_t>}
"""
# Invoke the appropriate visit_*() method on all decls
- self.__extmodule.adopt_creator( code_creators.import_t( 'ctypes' ) )
- self.__extmodule.adopt_creator( code_creators.separator_t() )
- self.__extmodule.adopt_creator( code_creators.library_reference_t( self.__library_path ) )
- self.__extmodule.adopt_creator( code_creators.name_mappings_t( self.__exported_symbols ) )
- self.__extmodule.adopt_creator( code_creators.separator_t() )
+ ccc = self.curr_code_creator
+ ccc.adopt_creator( code_creators.import_t( 'ctypes' ) )
+ ccc.adopt_creator( code_creators.separator_t() )
+ ccc.adopt_creator( code_creators.library_reference_t( self.__library_path ) )
+ ccc.adopt_creator( code_creators.name_mappings_t( self.__exported_symbols ) )
+ ccc.adopt_creator( code_creators.separator_t() )
+ #adding namespaces
+ for ns in self.global_ns.namespaces( recursive=False, allow_empty=True):
+ if self.__contains_exported( ns ):
+ self.__add_namespaces( ccc, ns )
+ #adding class introductions
+ f = lambda cls: self.__should_generate_code( cls ) \
+ and isinstance( cls.parent, declarations.namespace_t )
+ ns_classes = self.global_ns.classes( f, recursive=True, allow_empty=True)
+ ns_classes = sort_algorithms.sort_classes( ns_classes )
+ for class_ in ns_classes:
+ if self.__contains_exported( ns ):
+ self.__add_class_introductions( ccc, class_ )
+ ccc.adopt_creator( code_creators.embedded_code_repository_t( code_repository.ctypes_cpp_utils ) )
+
declarations.apply_visitor( self, self.curr_decl )
self.__dependencies_manager.inform_user()
- return self.__extmodule
+ return self.module
def visit_member_function( self ):
self.__dependencies_manager.add_exported( self.curr_decl )
+ cls_intro_cc = self.__class2introduction[ self.curr_decl.parent ]
+ cls_intro_cc.adopt_creator( code_creators.mem_fun_introduction_t( self.curr_decl ) )
+ #~ if self.curr_decl.virtuality == VIRTUALITY_TYPES.NOT_VIRTUAL:
+ #~ cls_intro_cc.adopt_creator( code_creators.mem_fun_introduction_t( self.curr_decl ) )
+ #~ elif self.curr_decl.virtuality == VIRTUALITY_TYPES.VIRTUAL:
+ #~ cls_intro_cc.adopt_creator( code_creators.vmem_fun_introduction_t( self.curr_decl ) )
+ #~ else:
+ #~ pass
def visit_constructor( self ):
self.__dependencies_manager.add_exported( self.curr_decl )
@@ -118,17 +170,33 @@
def visit_class_declaration(self ):
self.__dependencies_manager.add_exported( self.curr_decl )
- def visit_class(self ):
+ def visit_class(self):
self.__dependencies_manager.add_exported( self.curr_decl )
+ #fields definition should be recursive using the visitor
+ self.curr_code_creator.adopt_creator( code_creators.fields_definition_t( self.curr_decl ) )
+ self.curr_code_creator.adopt_creator( code_creators.methods_definition_t( self.curr_decl ) )
+ class_ = self.curr_decl
+ for decl in self.curr_decl.decls( recursive=False, allow_empty=True ):
+ if self.__should_generate_code( decl ):
+ self.curr_decl = decl
+ declarations.apply_visitor( self, decl )
+ self.curr_decl = class_
def visit_enumeration(self):
self.__dependencies_manager.add_exported( self.curr_decl )
- def visit_namespace(self):
- self.__dependencies_manager.add_exported( self.curr_decl )
-
def visit_typedef(self):
self.__dependencies_manager.add_exported( self.curr_decl )
def visit_variable(self):
self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_namespace(self ):
+ ns = self.curr_decl
+ for decl in self.curr_decl.decls( recursive=False, allow_empty=True ):
+ if isinstance( decl, declarations.namespace_t) or self.__should_generate_code( decl ):
+ self.curr_decl = decl
+ declarations.apply_visitor( self, decl )
+ self.curr_decl = ns
+
+
Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/writer.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -16,14 +16,14 @@
class writer_t(object):
"""Base class for all module/code writers.
-
+
All writers should have similar usage::
-
+
w = writer_class(module, file, ...)
w.write()
"""
logger = _logging_.loggers.file_writer
-
+
def __init__(self, extmodule, files_sum_repository=None, encoding='ascii'):
object.__init__(self)
self.__extmodule = extmodule
@@ -32,14 +32,15 @@
if None is files_sum_repository:
self.__files_sum_repository = md5sum_repository.dummy_repository_t()
self.__exposed_decls_db = utils.exposed_decls_db_t()
- self.__exposed_decls_db.register_decls( extmodule.global_ns
- , extmodule.specially_exposed_decls )
+ if isinstance( self.__extmodule, code_creators.bpmodule_t ):
+ self.__exposed_decls_db.register_decls( extmodule.global_ns
+ , extmodule.specially_exposed_decls )
@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 )"""
@@ -52,17 +53,17 @@
def write(self):
""" Main write method. Should be overridden by derived classes. """
raise NotImplementedError()
-
+
@staticmethod
def create_backup(fpath):
"""creates backup of the file, by renaming it to C{fpath + ~}"""
if not os.path.exists( fpath ):
- return
+ return
backup_fpath = fpath + '~'
if os.path.exists( backup_fpath ):
os.remove( backup_fpath )
os.rename( fpath, backup_fpath )
-
+
def write_code_repository(self, dir):
"""creates files defined in L{code_repository} package"""
system_headers = self.extmodule.get_system_headers( recursive=True )
@@ -72,7 +73,7 @@
self.write_file( os.path.join( dir, cr.file_name ), cr.code )
#named_tuple.py is a special case :-(
self.write_file( os.path.join( dir, code_repository.named_tuple.file_name )
- , code_repository.named_tuple.code )
+ , code_repository.named_tuple.code )
@staticmethod
def write_file( fpath, content, files_sum_repository=None, encoding='ascii' ):
"""Write a source file.
@@ -99,8 +100,8 @@
fcontent_new.append( os.linesep ) #keep gcc happy
fcontent_new = ''.join( fcontent_new )
if not isinstance( fcontent_new, unicode ):
- fcontent_new = unicode( fcontent_new, encoding )
-
+ fcontent_new = unicode( fcontent_new, encoding )
+
new_hash_value = None
curr_hash_value = None
if files_sum_repository:
@@ -122,9 +123,9 @@
writer_t.logger.debug( 'file was not changed( content ) - done( %f seconds )'
% ( time.clock() - start_time ) )
return
-
+
writer_t.logger.debug( 'file changed or it does not exist' )
-
+
writer_t.create_backup( fpath )
f = codecs.open( fpath, 'w+b', encoding )
f.write( fcontent_new )
@@ -132,7 +133,7 @@
if new_hash_value:
files_sum_repository.update_value( fname, new_hash_value )
writer_t.logger.info( 'file "%s" - updated( %f seconds )' % ( fname, time.clock() - start_time ) )
-
+
def get_user_headers( self, creators ):
headers = []
creators = filter( lambda creator: isinstance( creator, code_creators.declaration_based_t )
@@ -143,5 +144,5 @@
def save_exposed_decls_db( self, file_path ):
self.__exposed_decls_db.save( file_path )
-
-
+
+
Modified: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -84,12 +84,12 @@
is_exported = lambda d: msvc.undecorate_decl( d ) in undecorated
included_decls = set()
- included_decls.update( self.global_ns.calldefs( is_exported, allow_empty=True ) )
- included_decls.update( self.global_ns.variables( is_exported, allow_empty=True ) )
+ included_decls.update( self.global_ns.calldefs( is_exported, allow_empty=True, recursive=True ) )
+ included_decls.update( self.global_ns.variables( is_exported, allow_empty=True, recursive=True ) )
for d in included_decls:
d.include()
- if isinstance( d, decls_package.class_t ):
+ if isinstance( d.parent, decls_package.class_t ):
d.parent.include()
def build_code_creator( self, library_path, doc_extractor=None ):
@@ -120,7 +120,6 @@
@param file_name: file name
@type file_name: string
"""
- self.__merge_user_code()
file_writers.write_file( self.code_creator, file_name, encoding=self.encoding )
Modified: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2008-12-27 10:57:29 UTC (rev 1507)
@@ -16,12 +16,18 @@
self.project_dir = os.path.join( autoconfig.data_directory, 'ctypes_pof' )
self.header = os.path.join( self.project_dir, 'mydll.h' )
self.symbols_file = os.path.join( self.project_dir, 'release', 'mydll.dll' )
+ self.module_name = 'ctypes_pof'
def test(self):
mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
+ #~ mb.global_ns.include()
mb.build_code_creator( self.symbols_file )
- print mb.code_creator.create()
+ mb.write_module( os.path.join( autoconfig.build_directory, self.module_name + '.py' ) )
+ #mb.code_creator.create()
+ sys.path.append( autoconfig.build_directory )
+ import ctypes_pof
+
def create_suite():
suite = unittest.TestSuite()
if 'win' in sys.platform:
Modified: pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp 2008-12-27 10:57:29 UTC (rev 1507)
@@ -2,6 +2,8 @@
#include "windows.h"
#include <iostream>
+namespace pof{
+
number_t::number_t()
: m_value(0)
{
@@ -38,6 +40,10 @@
return std::auto_ptr<number_t>( new number_t( *this ) );
}
+}
+
+using namespace pof;
+
void do_smth( number_aptr_t& ){
}
Modified: pyplusplus_dev/unittests/data/ctypes_pof/mydll.h
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.h 2008-12-26 23:56:12 UTC (rev 1506)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.h 2008-12-27 10:57:29 UTC (rev 1507)
@@ -2,12 +2,14 @@
#include <memory>
+namespace pof{
+
class __declspec(dllexport) number_t{
public:
number_t();
explicit number_t(int value);
virtual ~number_t();
- void print_it() const;
+ virtual void print_it() const;
int get_value() const;
int get_value(){ return m_value; }
void set_value(int x);
@@ -18,8 +20,9 @@
int m_value;
};
-template class __declspec(dllexport) std::auto_ptr< number_t >;
+}
+template class __declspec(dllexport) std::auto_ptr< pof::number_t >;
-typedef std::auto_ptr< number_t > number_aptr_t;
+typedef std::auto_ptr< pof::number_t > number_aptr_t;
-void __declspec(dllexport) do_smth( number_aptr_t& );
\ No newline at end of file
+void __declspec(dllexport) do_smth( number_aptr_t& );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-26 23:56:14
|
Revision: 1506
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1506&view=rev
Author: roman_yakovenko
Date: 2008-12-26 23:56:12 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
porting to linux
Modified Paths:
--------------
pyplusplus_dev/unittests/autoconfig.py
Modified: pyplusplus_dev/unittests/autoconfig.py
===================================================================
--- pyplusplus_dev/unittests/autoconfig.py 2008-12-26 23:28:13 UTC (rev 1505)
+++ pyplusplus_dev/unittests/autoconfig.py 2008-12-26 23:56:12 UTC (rev 1506)
@@ -49,12 +49,15 @@
@staticmethod
def create_sconstruct():
+ msvc_compiler = ''
+ if 'linux' not in sys.platform:
+ msvc_compiler = str( pygccxml.utils.native_compiler.get_version()[1] )
code = [
"import sys"
, "env = Environment()"
, "if 'linux' not in sys.platform:"
- , " env['MSVS'] = {'VERSION': '%s'}" % str( pygccxml.utils.native_compiler.get_version()[1] )
- , " env['MSVS_VERSION'] = '%s'" % str( pygccxml.utils.native_compiler.get_version()[1] )
+ , " env['MSVS'] = {'VERSION': '%s'}" % msvc_compiler
+ , " env['MSVS_VERSION'] = '%s'" % msvc_compiler
, " Tool('msvc')(env)"
, "t = env.SharedLibrary( target=r'%(target)s'"
, " , source=[ %(sources)s ]"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-26 23:28:16
|
Revision: 1505
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1505&view=rev
Author: roman_yakovenko
Date: 2008-12-26 23:28:13 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
porting to linux
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/common_utils.py
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-26 09:43:47 UTC (rev 1504)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-26 23:28:13 UTC (rev 1505)
@@ -5,8 +5,8 @@
import os
import re
+import sys
import ctypes
-import ctypes.wintypes
from .. import declarations
class UNDECORATE_NAME_OPTIONS:
@@ -77,15 +77,17 @@
#~ return undecorated_name.value
class undname_creator:
- __undname = ctypes.windll.dbghelp.UnDecorateSymbolName
- __undname.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint]
- __clean_ecsu = re.compile( r'(?:(^|\W))(?:(class|enum|struct|union))' )
- __fundamental_types = (
- ( 'short unsigned int', 'unsigned short')
- , ( 'short int', 'short' )
- , ( 'long int', 'long' )
- , ( 'long unsigned int', 'unsigned long' )
- )
+ def __init__( self ):
+ import ctypes.wintypes
+ self.__undname = ctypes.windll.dbghelp.UnDecorateSymbolName
+ self.__undname.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint]
+ self.__clean_ecsu = re.compile( r'(?:(^|\W))(?:(class|enum|struct|union))' )
+ self.__fundamental_types = (
+ ( 'short unsigned int', 'unsigned short')
+ , ( 'short int', 'short' )
+ , ( 'long int', 'long' )
+ , ( 'long unsigned int', 'unsigned long' )
+ )
def undecorate_blob( self, name, options=None ):
if options is None:
@@ -182,10 +184,15 @@
raise NotImplementedError()
return self.__normalize( name )
+if 'win' in sys.platform:
+ undecorate_blob = undname_creator().undecorate_blob
+ undecorate_decl = undname_creator().undecorated_decl
+else:
+ def undecorate_blob( x ):
+ raise NotImplementedError()
+ def undecorate_decl( x ):
+ raise NotImplementedError()
-undecorate_blob = undname_creator().undecorate_blob
-undecorate_decl = undname_creator().undecorated_decl
-
import exceptions
class LicenseWarning( exceptions.UserWarning ):
def __init__( self, *args, **keywd ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-26 09:43:51
|
Revision: 1504
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1504&view=rev
Author: roman_yakovenko
Date: 2008-12-26 09:43:47 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
first code creators classes for ctypes
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/bpmodule.py
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
pyplusplus_dev/pyplusplus/code_creators/compound.py
pyplusplus_dev/pyplusplus/code_creators/import_.py
pyplusplus_dev/pyplusplus/code_creators/library_reference.py
pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
pyplusplus_dev/pyplusplus/creators_factory/__init__.py
pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
pyplusplus_dev/unittests/ctypes_pof_tester.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py
pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
Property Changed:
----------------
pyplusplus_dev/pyplusplus/cpptypes/mydll/
pyplusplus_dev/pyplusplus/cpptypes/mydll/release/
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -15,6 +15,7 @@
"""
from code_creator import code_creator_t
+from code_creator import separator_t
from compound import compound_t
from algorithm import (make_flatten, make_flatten_list, make_flatten_generator)
@@ -141,6 +142,8 @@
from ctypes_integration_creators import expose_sizeof_t
#pure ctypes
+from ctypes_module import ctypes_module_t
from import_ import import_t
from library_reference import library_reference_t
-from name_mappings import name_mapping_t
+from name_mappings import name_mappings_t
+
Modified: pyplusplus_dev/pyplusplus/code_creators/bpmodule.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/bpmodule.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/bpmodule.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -126,15 +126,17 @@
def _create_impl(self):
self.do_include_dirs_optimization()
index = 0
- includes = []
+ code = []
for index in range( len( self.creators ) ):
if not isinstance( self.creators[index], include.include_t ):
break
else:
- includes.append( self.creators[index].create() )
- code = compound.compound_t.create_internal_code( self.creators[index:] )
- code = self.unindent(code)
- return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep
+ code.append( self.creators[index].create() )
+ if code:
+ code.append( 2* os.linesep )
+ code.append( self.create_internal_code( self.creators[index:], indent_code=False ))
+ code.append( os.linesep )
+ return os.linesep.join( code )
def add_include( self, header, user_defined=True, system=False ):
creator = include.include_t( header=header, user_defined=user_defined, system=system )
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -63,7 +63,12 @@
@type: L{target_configuration_t}
""")
- def _get_top_parent(self):
+ @property
+ def top_parent(self):
+ """top_parent - reference to top parent code creator
+
+ @type: L{code_creator_t}
+ """
parent = self.parent
me = self
while True:
@@ -72,11 +77,6 @@
else:
me = parent
parent = me.parent
- """top_parent - reference to top parent code creator"""
- top_parent = property( _get_top_parent,
- doc="""Root of the code creator tree.
- @type: L{code_creator_t}
- """)
def _create_impl(self):
"""
@@ -185,3 +185,16 @@
return true_
else:
return false_
+
+
+class separator_t(code_creator_t):
+ """Creates Python import directive"""
+ def __init__( self, num=1):
+ code_creator_t.__init__(self)
+ self.__code = os.linesep * num
+
+ def _create_impl(self):
+ return self.__code
+
+ def _get_system_headers_impl( self ):
+ return []
Modified: pyplusplus_dev/pyplusplus/code_creators/compound.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/compound.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/compound.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -13,11 +13,11 @@
@param parent: Parent code creator.
@type parent: L{code_creator_t}
"""
- code_creator.code_creator_t.__init__( self )
+ code_creator.code_creator_t.__init__( self )
self._creators = []
-
+
def _get_creators(self):
- return self._creators
+ return self._creators
creators = property(_get_creators,
doc="""A list of children nodes.
@type: list of L{code_creator_t}""")
@@ -58,10 +58,10 @@
@type creator: L{code_creator_t}
"""
creator.parent = None
- del self._creators[ self._creators.index( creator ) ]
+ del self._creators[ self._creators.index( creator ) ]
@staticmethod
- def create_internal_code( creators ):
+ def create_internal_code( creators, indent_code=True ):
"""Concatenate the code from a list of code creators.
@param creators: A list with code creators
@@ -70,20 +70,20 @@
"""
internals = map( lambda expr: expr.create(), creators )
internals = filter(None, internals )
- internals = map( lambda code: code_creator.code_creator_t.indent( code )
- , internals )
+ if indent_code:
+ internals = map( lambda code: code_creator.code_creator_t.indent( code )
+ , internals )
for index in range( len( internals ) - 1):
internals[index] = internals[index] + os.linesep
return os.linesep.join( internals )
-
+
def get_system_headers( self, recursive=False, unique=False ):
files = [ "boost/python.hpp" ]
files.extend( self._get_system_headers_impl() )
if recursive:
- for creator in self._creators:
+ for creator in self._creators:
files.extend( creator.get_system_headers(recursive, unique=False) )
files = filter( None, files )
if unique:
files = self.unique_headers( files )
return files
-
\ No newline at end of file
Added: pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -0,0 +1,31 @@
+# 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 module
+import import_
+import library_reference
+from pygccxml import utils
+
+class ctypes_module_t(module.module_t):
+ """This class represents the source code for the entire extension module.
+
+ The root of the code creator tree is always a module_t object.
+ """
+ def __init__(self, global_ns):
+ """Constructor.
+ """
+ module.module_t.__init__(self, global_ns)
+
+ def _create_impl(self):
+ return self.create_internal_code( self.creators, indent_code=False )
+
+ @utils.cached
+ def library_var_name(self):
+ for creator in self.creators:
+ if isinstance( creator, library_reference.library_reference_t ):
+ return creator.library_var_name
+ else:
+ raise RuntimeError( "Internal Error: library_reference_t creator was not created" )
Modified: pyplusplus_dev/pyplusplus/code_creators/import_.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/import_.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/import_.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -14,7 +14,7 @@
self._module_name = module_name
def _create_impl(self):
- return 'import %(module)s' % dict( module=self.module_name )
+ return 'import %(module)s' % dict( module=self._module_name )
def _get_system_headers_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/library_reference.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/library_reference.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/library_reference.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -3,25 +3,36 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
+import os
import code_creator
+from pyplusplus import decl_wrappers
-
class library_reference_t(code_creator.code_creator_t):
"""Creates reference to a library"""
- def __init__( self, library_var_name, library_path, is_cpp_library ):
+ def __init__( self, library_path, library_var_name=None, is_cpp_library=True ):
code_creator.code_creator_t.__init__(self)
self._library_path = library_path
self._is_cpp_library = is_cpp_library
- self._library_var_name = library_var_name
+ self._library_var_name = self.__create_library_var_name( library_path, library_var_name )
+ @property
+ def library_var_name(self):
+ return self._library_var_name
+
+ def __create_library_var_name( self, library_path, library_var_name ):
+ if library_var_name:
+ return library_var_name
+ else:
+ basename = os.path.splitext( os.path.basename( library_path ) )[0]
+ return decl_wrappers.algorithm.create_valid_name( basename )
+
def _create_impl(self):
return '%(var)s = ctypes.%(loader)s( r"%(path)s" )' \
- % dict( var=self._library_var_name
+ % dict( var=self.library_var_name
, loader=self.iif( self._is_cpp_library, 'CPPDLL', 'CDLL' )
, path=self._library_path )
-
def _get_system_headers_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -7,14 +7,13 @@
import code_creator
-class name_mapping_t(code_creator.code_creator_t):
+class name_mappings_t(code_creator.code_creator_t):
"""creates dictionery { [un]decorated name : [un]decorated name }"""
def __init__( self, exported_symbols ):
code_creator.code_creator_t.__init__(self)
self._exported_symbols = exported_symbols
-
def _create_impl(self):
tmpl = '"%s" : "%s", '
items_decorated = []
@@ -24,7 +23,8 @@
items_undecorated.append( tmpl % ( undecorated, blob ) )
result = []
- result.append('%s.undecorated_names = {#mapping between decorated and undecorated names' % self._dictionary_var_name )
+ result.append( '%s.undecorated_names = {#mapping between decorated and undecorated names'
+ % self.top_parent.library_var_name )
for s in items_undecorated:
result.append( self.indent( s ) )
for s in items_decorated:
@@ -32,7 +32,6 @@
result.append( '}' )
return os.linesep.join( result )
-
def _get_system_headers_impl( self ):
return []
Property changes on: pyplusplus_dev/pyplusplus/cpptypes/mydll
___________________________________________________________________
Added: svn:ignore
+ Debug
*.ncb
*.suo
*.user
Property changes on: pyplusplus_dev/pyplusplus/cpptypes/mydll/release
___________________________________________________________________
Added: svn:ignore
+ *.htm
Modified: pyplusplus_dev/pyplusplus/creators_factory/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/__init__.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/creators_factory/__init__.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -4,6 +4,7 @@
# http://www.boost.org/LICENSE_1_0.txt)
from bpcreator import bpcreator_t
+from ctypes_creator import ctypes_creator_t
from sort_algorithms import sort_classes as findout_desired_order
from call_policies_resolver import built_in_resolver_t
Added: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py (rev 0)
+++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -0,0 +1,134 @@
+# 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 dependencies_manager
+from pygccxml import declarations
+from pyplusplus import decl_wrappers
+from pyplusplus import code_creators
+from pyplusplus import code_repository
+from pyplusplus import _logging_
+
+ACCESS_TYPES = declarations.ACCESS_TYPES
+VIRTUALITY_TYPES = declarations.VIRTUALITY_TYPES
+
+class ctypes_creator_t( declarations.decl_visitor_t ):
+ def __init__( self
+ , global_ns
+ , library_path
+ , exported_symbols
+ , doc_extractor=None ):
+ declarations.decl_visitor_t.__init__(self)
+ self.logger = _logging_.loggers.module_builder
+ self.decl_logger = _logging_.loggers.declarations
+
+ self.__library_path = library_path
+ self.__exported_symbols = exported_symbols
+
+ self.__extmodule = code_creators.ctypes_module_t( global_ns )
+ self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)
+
+ #~ prepared_decls = self.__prepare_decls( global_ns, doc_extractor )
+ #~ self.__decls = sort_algorithms.sort( prepared_decls )
+ self.curr_decl = global_ns
+ self.curr_code_creator = self.__extmodule
+
+ def __print_readme( self, decl ):
+ readme = decl.readme()
+ if not readme:
+ return
+
+ if not decl.exportable:
+ reason = readme[0]
+ readme = readme[1:]
+ self.decl_logger.warn( "%s;%s" % ( decl, reason ) )
+
+ for msg in readme:
+ self.decl_logger.warn( "%s;%s" % ( decl, msg ) )
+
+ #~ def __prepare_decls( self, global_ns, doc_extractor ):
+ #~ to_be_exposed = []
+ #~ for decl in declarations.make_flatten( global_ns ):
+ #~ if decl.ignore:
+ #~ continue
+
+ #~ if not decl.exportable:
+ #~ #leave only decls that user wants to export and that could be exported
+ #~ self.__print_readme( decl )
+ #~ continue
+
+ #~ if decl.already_exposed:
+ #~ #check wether this is already exposed in other module
+ #~ continue
+
+ #~ if isinstance( decl.parent, declarations.namespace_t ):
+ #~ #leave only declarations defined under namespace, but remove namespaces
+ #~ to_be_exposed.append( decl )
+
+ #~ if doc_extractor:
+ #~ decl.documentation = doc_extractor( decl )
+
+ #~ self.__print_readme( decl )
+
+ #~ return to_be_exposed
+
+
+ def create(self ):
+ """Create and return the module for the extension.
+
+ @returns: Returns the root of the code creators tree
+ @rtype: L{module_t<code_creators.module_t>}
+ """
+ # Invoke the appropriate visit_*() method on all decls
+ self.__extmodule.adopt_creator( code_creators.import_t( 'ctypes' ) )
+ self.__extmodule.adopt_creator( code_creators.separator_t() )
+ self.__extmodule.adopt_creator( code_creators.library_reference_t( self.__library_path ) )
+ self.__extmodule.adopt_creator( code_creators.name_mappings_t( self.__exported_symbols ) )
+ self.__extmodule.adopt_creator( code_creators.separator_t() )
+
+ declarations.apply_visitor( self, self.curr_decl )
+
+ self.__dependencies_manager.inform_user()
+
+ return self.__extmodule
+
+ def visit_member_function( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_constructor( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_destructor( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_member_operator( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_casting_operator( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_free_function( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_free_operator( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_class_declaration(self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_class(self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_enumeration(self):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_namespace(self):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_typedef(self):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_variable(self):
+ self.__dependencies_manager.add_exported( self.curr_decl )
Modified: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -92,18 +92,13 @@
if isinstance( d, decls_package.class_t ):
d.parent.include()
- def build_code_creator( self ):
- pass
- #~ creator = creators_factory.creator_t( self.global_ns
- #~ , module_name
- #~ , boost_python_ns_name
- #~ , call_policies_resolver_
- #~ , types_db
- #~ , target_configuration
- #~ , enable_indexing_suite
- #~ , doc_extractor)
- #~ self.__code_creator = creator.create()
- #~ return self.__code_creator
+ def build_code_creator( self, library_path, doc_extractor=None ):
+ creator = creators_factory.ctypes_creator_t( self.global_ns
+ , library_path
+ , self.__blob2undecorated
+ , doc_extractor)
+ self.__code_creator = creator.create()
+ return self.__code_creator
@property
def code_creator( self ):
Modified: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py 2008-12-26 08:09:28 UTC (rev 1503)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2008-12-26 09:43:47 UTC (rev 1504)
@@ -19,6 +19,8 @@
def test(self):
mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
+ mb.build_code_creator( self.symbols_file )
+ print mb.code_creator.create()
def create_suite():
suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-26 08:09:31
|
Revision: 1503
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1503&view=rev
Author: roman_yakovenko
Date: 2008-12-26 08:09:28 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
small refactoring before introducing ctypes code generator
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_creators/module.py
Added: pyplusplus_dev/pyplusplus/code_creators/module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/module.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/module.py 2008-12-26 08:09:28 UTC (rev 1503)
@@ -0,0 +1,45 @@
+# 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 license
+import include
+import compound
+
+class module_t(compound.compound_t):
+ """This class represents the source code for the entire extension module.
+
+ The root of the code creator tree is always a module_t object.
+ """
+ def __init__(self, global_ns):
+ """Constructor.
+ """
+ compound.compound_t.__init__(self)
+ self.__global_ns = global_ns
+
+ @property
+ def global_ns(self):
+ "reference to global_ns ( namespace_t ) declaration"
+ return self.__global_ns
+
+ def _get_license( self ):
+ if isinstance( self.creators[0], license.license_t ):
+ return self.creators[0]
+ return None
+
+ def _set_license( self, license_text ):
+ if not isinstance( license_text, license.license_t ):
+ license_inst = license.license_t( license_text )
+ if isinstance( self.creators[0], license.license_t ):
+ self.remove_creator( self.creators[0] )
+ self.adopt_creator( license_inst, 0 )
+ license = property( _get_license, _set_license,
+ doc="""License text.
+
+ The license text will always be the first children node.
+ @type: str or L{license_t}""")
+
+ def _get_system_headers_impl( self ):
+ return []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-26 08:05:30
|
Revision: 1502
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1502&view=rev
Author: roman_yakovenko
Date: 2008-12-26 08:05:27 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/creators_factory/__init__.py
pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py
Removed Paths:
-------------
pyplusplus_dev/pyplusplus/creators_factory/creator.py
Modified: pyplusplus_dev/pyplusplus/creators_factory/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/__init__.py 2008-12-26 07:58:38 UTC (rev 1501)
+++ pyplusplus_dev/pyplusplus/creators_factory/__init__.py 2008-12-26 08:05:27 UTC (rev 1502)
@@ -3,10 +3,10 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-from creator import creator_t
+from bpcreator import bpcreator_t
from sort_algorithms import sort_classes as findout_desired_order
from call_policies_resolver import built_in_resolver_t
def create( decls, module_name ):
- maker = creator_t(decls, module_name)
+ maker = bpcreator_t(decls, module_name)
return maker.create()
Copied: pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py (from rev 1500, pyplusplus_dev/pyplusplus/creators_factory/creator.py)
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py (rev 0)
+++ pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2008-12-26 08:05:27 UTC (rev 1502)
@@ -0,0 +1,745 @@
+# 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 types_database
+import creators_wizard
+import sort_algorithms
+import dependencies_manager
+import opaque_types_manager
+import call_policies_resolver
+import fake_constructors_manager
+
+from pygccxml import declarations
+from pyplusplus import decl_wrappers
+from pyplusplus import code_creators
+from pyplusplus import code_repository
+from pyplusplus import _logging_
+
+ACCESS_TYPES = declarations.ACCESS_TYPES
+VIRTUALITY_TYPES = declarations.VIRTUALITY_TYPES
+
+class bpcreator_t( declarations.decl_visitor_t ):
+ """Creating code creators.
+
+ This class takes a set of declarations as input and creates a code
+ creator tree that contains the Boost.Python C++ source code for the
+ final extension module. Each node in the code creators tree represents
+ a block of text (C++ source code).
+
+ Usage of this class: Create an instance and pass all relevant input
+ data to the constructor. Then call L{create()} to obtain the code
+ creator tree whose root node is a L{module_t<code_creators.module_t>}
+ object representing the source code for the entire extension module.
+ """
+
+ def __init__( self
+ , decls
+ , module_name
+ , boost_python_ns_name='bp'
+ , call_policies_resolver_=None
+ , types_db=None
+ , target_configuration=None
+ , enable_indexing_suite=True
+ , doc_extractor=None ):
+ """Constructor.
+
+ @param decls: Declarations that should be exposed in the final module.
+ @param module_name: The name of the final module.
+ @param boost_python_ns_name: The alias for the boost::python namespace.
+ @param call_policies_resolver_: Callable that takes one declaration (calldef_t) as input and returns a call policy object which should be used for this declaration.
+ @param types_db: ...todo...
+ @param target_configuration: A target configuration object can be used to customize the generated source code to a particular compiler or a particular version of Boost.Python.
+ @param doc_extractor: callable, that takes as argument declaration reference and returns documentation string
+ @param already_exposed_dbs: list of files/directories other modules, this module depends on, generated their code too
+ @type decls: list of declaration_t
+ @type module_name: str
+ @type boost_python_ns_name: str
+ @type call_policies_resolver_: callable
+ @type types_db: L{types_database_t<types_database.types_database_t>}
+ @type target_configuration: L{target_configuration_t<code_creators.target_configuration_t>}
+ @type doc_extractor: callable
+ @type already_exposed_dbs: list of strings
+ """
+ declarations.decl_visitor_t.__init__(self)
+ self.logger = _logging_.loggers.module_builder
+ self.decl_logger = _logging_.loggers.declarations
+
+ self.__enable_indexing_suite = enable_indexing_suite
+ self.__target_configuration = target_configuration
+ if not self.__target_configuration:
+ self.__target_configuration = code_creators.target_configuration_t()
+
+ self.__call_policies_resolver = call_policies_resolver_
+ if not self.__call_policies_resolver:
+ self.__call_policies_resolver \
+ = call_policies_resolver.built_in_resolver_t(self.__target_configuration)
+
+ self.__types_db = types_db
+ if not self.__types_db:
+ self.__types_db = types_database.types_database_t()
+
+ global_ns = declarations.get_global_namespace(decls)
+ self.__extmodule = code_creators.bpmodule_t( global_ns )
+ if boost_python_ns_name:
+ bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
+ , full_namespace_name='::boost::python' )
+ self.__extmodule.adopt_creator( bp_ns_alias )
+
+ self.__module_body = code_creators.module_body_t( name=module_name )
+
+ self.__extmodule.adopt_creator( self.__module_body )
+
+ self.__opaque_types_manager = opaque_types_manager.manager_t( self.__extmodule )
+ self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)
+
+ prepared_decls = self._prepare_decls( decls, doc_extractor )
+ self.__decls = sort_algorithms.sort( prepared_decls )
+
+ self.curr_code_creator = self.__module_body
+ 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 )
+
+ def __print_readme( self, decl ):
+ readme = decl.readme()
+ if not readme:
+ return
+
+ if not decl.exportable:
+ reason = readme[0]
+ readme = readme[1:]
+ self.decl_logger.warn( "%s;%s" % ( decl, reason ) )
+
+ for msg in readme:
+ self.decl_logger.warn( "%s;%s" % ( decl, msg ) )
+
+ def _prepare_decls( self, decls, doc_extractor ):
+ to_be_exposed = []
+ for decl in declarations.make_flatten( decls ):
+ if decl.ignore:
+ continue
+
+ if isinstance( decl, declarations.namespace_t ):
+ continue
+
+ if not decl.exportable:
+ #leave only decls that user wants to export and that could be exported
+ self.__print_readme( decl )
+ continue
+
+ if decl.already_exposed:
+ #check wether this is already exposed in other module
+ continue
+
+ if isinstance( decl.parent, declarations.namespace_t ):
+ #leave only declarations defined under namespace, but remove namespaces
+ to_be_exposed.append( decl )
+
+ #Right now this functionality introduce a bug: declarations that should
+ #not be exported for some reason are not marked as such. I will need to
+ #find out.
+ #if isinstance( decl, declarations.calldef_t ) and not isinstance( decl, declarations.destructor_t ):
+ #self.__types_db.update( decl )
+ #if None is decl.call_policies:
+ #decl.call_policies = self.__call_policies_resolver( decl )
+
+ #if isinstance( decl, declarations.variable_t ):
+ #self.__types_db.update( decl )
+
+ if doc_extractor:
+ decl.documentation = doc_extractor( decl )
+
+ self.__print_readme( decl )
+
+ return to_be_exposed
+
+ def _adopt_free_operator( self, operator ):
+ def adopt_operator_impl( operator, found_creators ):
+ creator = filter( lambda creator: isinstance( creator, code_creators.class_t )
+ , found_creators )
+ if len(creator) == 1:
+ creator = creator[0]
+ #I think I don't need this condition any more
+ if not find( lambda creator: isinstance( creator, code_creators.declaration_based_t )
+ and operator is creator.declaration
+ , creator.creators ):
+ #expose operator only once
+ self.__dependencies_manager.add_exported( operator )
+ creator.adopt_creator( code_creators.operator_t( operator=operator ) )
+ elif not creator:
+ 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 )
+
+ def _is_registered_smart_pointer_creator( self, creator, db ):
+ for registered in db:
+ if not isinstance( creator, registered.__class__ ):
+ continue
+ elif registered.smart_ptr != creator.smart_ptr:
+ continue
+ elif isinstance( creator, code_creators.smart_pointer_registrator_t ):
+ if creator.declaration is registered.declaration:
+ return True
+ elif isinstance( creator, code_creators.smart_pointers_converter_t ):
+ if ( creator.source is registered.source ) \
+ and ( creator.target is registered.target ):
+ return True
+ else:
+ assert not "unknown instace of registrator: " % str( registered )
+
+ def _treat_smart_pointers( self ):
+ """ Go to all class creators and apply held_type and creator registrators
+ as needed.
+ """
+ find_classes = code_creators.creator_finder.find_by_class_instance
+ class_creators = find_classes( what=code_creators.class_t
+ , where=self.__extmodule.body.creators
+ , recursive=True )
+ registrators_db = []
+ for creator in class_creators:
+ if None is creator.held_type:
+ if not creator.declaration.is_abstract:
+ creator.held_type = self.__types_db.create_holder( creator.declaration )
+ registrators = self.__types_db.create_registrators( creator )
+ for r in registrators:
+ if not self._is_registered_smart_pointer_creator( r, registrators_db ):
+ creator.adopt_creator(r)
+ registrators_db.append(r)
+
+ def _append_user_code( self ):
+ find_classes = code_creators.creator_finder.find_by_class_instance
+ class_creators = find_classes( what=code_creators.class_t
+ , where=self.__extmodule.body.creators
+ , recursive=True )
+
+ ctext_t = code_creators.custom_text_t
+ for cls_creator in class_creators:
+ cls_decl = cls_creator.declaration
+
+ uc_creators_head = map( lambda uc: ctext_t( uc.text, uc.works_on_instance )
+ , cls_decl.registration_code_head )
+ cls_creator.adopt_creators( uc_creators_head, 0 )
+
+ uc_creators_tail = map( lambda uc: ctext_t( uc.text, uc.works_on_instance )
+ , cls_decl.registration_code_tail )
+ cls_creator.adopt_creators( uc_creators_tail )
+
+ uc_creators = map( lambda uc: ctext_t( uc.text ), cls_decl.wrapper_code )
+ if uc_creators:
+ cls_creator.wrapper.adopt_creators( uc_creators )
+
+ uc_creators = map( lambda uc: ctext_t( uc.text ), cls_decl.declaration_code )
+ insert_pos = self.__extmodule.creators.index( self.__module_body )
+ self.__extmodule.adopt_creators( uc_creators, insert_pos )
+ cls_creator.associated_decl_creators.extend( uc_creators )
+
+ def __get_exposed_containers(self):
+ """list of exposed declarations, which were not ``included``, but still
+ were exposed. For example, std containers
+
+ std containers exposed by Py++, even if the user didn't ``include`` them.
+ """
+ cmp_by_name = lambda cls1, cls2: cmp( cls1.decl_string, cls2.decl_string )
+ used_containers = list( self.__types_db.used_containers )
+ used_containers = filter( lambda cls: cls.indexing_suite.include_files
+ , used_containers )
+ used_containers.sort( cmp_by_name )
+ used_containers = filter( lambda cnt: cnt.already_exposed == False
+ , used_containers )
+ return used_containers
+
+ def _treat_indexing_suite( self ):
+ def create_explanation(cls):
+ msg = '//WARNING: the next line of code will not compile, because "%s" does not have operator== !'
+ msg = msg % cls.indexing_suite.element_type.decl_string
+ return code_creators.custom_text_t( msg, False )
+
+ def create_cls_cc( cls ):
+ if isinstance( cls, declarations.class_t ):
+ return code_creators.class_t( class_inst=cls )
+ else:
+ return code_creators.class_declaration_t( class_inst=cls )
+
+ if not self.__types_db.used_containers:
+ return
+
+ creators = []
+ created_value_traits = set()
+ for cls in self.__get_exposed_containers():
+ self.__print_readme( cls )
+
+ cls_creator = create_cls_cc( cls )
+ self.__dependencies_manager.add_exported( cls )
+ creators.append( cls_creator )
+ try:
+ element_type = cls.indexing_suite.element_type
+ except:
+ element_type = None
+
+ if isinstance( cls.indexing_suite, decl_wrappers.indexing_suite1_t ):
+ if not ( None is element_type ) \
+ and declarations.is_class( element_type ) \
+ and not declarations.has_public_equal( element_type ):
+ cls_creator.adopt_creator( create_explanation( cls ) )
+ cls_creator.adopt_creator( code_creators.indexing_suite1_t(cls) )
+ else:
+ class_traits = declarations.class_traits
+ if not ( None is element_type ) and class_traits.is_my_case( element_type ):
+ value_cls = class_traits.get_declaration( element_type )
+ has_prerequisits = value_cls.less_than_comparable \
+ and value_cls.equality_comparable
+ if ( not has_prerequisits ) and ( value_cls not in created_value_traits ):
+ created_value_traits.add( value_cls )
+ element_type_cc = code_creators.value_traits_t( value_cls )
+ 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 )
+
+ def create(self, decl_headers=None):
+ """Create and return the module for the extension.
+
+ @param decl_headers: If None the headers for the wrapped decls are automatically found.
+ But you can pass a list of headers here to override that search.
+ @returns: Returns the root of the code creators tree
+ @rtype: L{module_t<code_creators.module_t>}
+ """
+ # Invoke the appropriate visit_*() method on all decls
+ for decl in self.__decls:
+ self.curr_decl = decl
+ declarations.apply_visitor( self, decl )
+ for operator in self.__free_operators:
+ self._adopt_free_operator( operator )
+ self._treat_smart_pointers()
+ if self.__enable_indexing_suite:
+ self._treat_indexing_suite()
+ for creator in code_creators.make_flatten_generator( self.__extmodule ):
+ creator.target_configuration = self.__target_configuration
+ #last action.
+ self._append_user_code()
+
+ add_include = self.__extmodule.add_include
+ #add system headers
+ system_headers = self.__extmodule.get_system_headers( recursive=True, unique=True )
+ map( lambda header: add_include( header, user_defined=False, system=True )
+ , system_headers )
+ #add user defined header files
+ if decl_headers is None:
+ decl_headers = declarations.declaration_files( self.__decls )
+ map( lambda header: add_include( header, user_defined=False, system=False )
+ , decl_headers )
+
+ self.__dependencies_manager.inform_user()
+
+ return self.__extmodule
+
+ def visit_member_function( self ):
+ self.__types_db.update( self.curr_decl )
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ if self.__fc_manager.is_fake_constructor( self.curr_decl ):
+ return
+
+ fwrapper = None
+ if None is self.curr_decl.call_policies:
+ self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
+
+ maker_cls, fwrapper_cls = creators_wizard.find_out_mem_fun_creator_classes( self.curr_decl )
+
+ maker = None
+ fwrapper = None
+ if fwrapper_cls:
+ fwrapper = fwrapper_cls( function=self.curr_decl )
+ if fwrapper_cls is code_creators.mem_fun_transformed_wrapper_t:
+ if self.curr_code_creator.wrapper:
+ class_wrapper = self.curr_code_creator.wrapper
+ class_wrapper.adopt_creator( fwrapper )
+ else:
+ self.__extmodule.adopt_declaration_creator( fwrapper )
+ self.curr_code_creator.associated_decl_creators.append(fwrapper)
+ else:
+ class_wrapper = self.curr_code_creator.wrapper
+ class_wrapper.adopt_creator( fwrapper )
+
+ if maker_cls:
+ if fwrapper:
+ maker = maker_cls( function=self.curr_decl, wrapper=fwrapper )
+ else:
+ maker = maker_cls( function=self.curr_decl )
+ self.curr_code_creator.adopt_creator( maker )
+ self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
+
+ if self.curr_decl.has_static:
+ #static_method should be created only once.
+ found = filter( lambda creator: isinstance( creator, code_creators.static_method_t )
+ and creator.declaration.name == self.curr_decl.name
+ , self.curr_code_creator.creators )
+ if not found:
+ static_method = code_creators.static_method_t( function=self.curr_decl
+ , function_code_creator=maker )
+ self.curr_code_creator.adopt_creator( static_method )
+
+ def visit_constructor( self ):
+ self.__types_db.update( self.curr_decl )
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ cwrapper = None
+ if self.curr_decl.parent.is_wrapper_needed():
+ class_wrapper = self.curr_code_creator.wrapper
+ cwrapper = code_creators.constructor_wrapper_t( constructor=self.curr_decl )
+ class_wrapper.adopt_creator( cwrapper )
+ #TODO: FT for constructor
+ #~ if self.curr_decl.transformations:
+ #~ cwrapper = code_creators.constructor_transformed_wrapper_t( constructor=self.curr_decl )
+ #~ class_wrapper.adopt_creator( cwrapper )
+ #~ else:
+ #~ if self.curr_decl.transformations:
+ #~ cwrapper = code_creators.constructor_transformed_wrapper_t( constructor=self.curr_decl )
+ #~ class_wrapper.adopt_creator( cwrapper )
+ #~ self.__module_body.adopt_creator( cwrapper )
+ #~ self.curr_code_creator.associated_decl_creators.append( cwrapper )
+ #~ maker = None
+ #~ if self.curr_decl.transformations:
+ #~ maker = code_creators.constructor_transformed_t( constructor=self.curr_decl )
+ #~ else:
+ maker = code_creators.constructor_t( constructor=self.curr_decl, wrapper=cwrapper )
+ if None is self.curr_decl.call_policies:
+ self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
+ self.curr_code_creator.adopt_creator( maker )
+
+ if self.curr_decl.allow_implicit_conversion:
+ maker = code_creators.casting_constructor_t( constructor=self.curr_decl )
+ #casting constructor will be generated in the same file as class
+ self.curr_code_creator.adopt_creator( maker )
+
+
+ def visit_destructor( self ):
+ pass
+
+ def visit_member_operator( self ):
+ if self.curr_decl.symbol in ( '()', '[]', '=' ):
+ self.visit_member_function()
+ else:
+ self.__types_db.update( self.curr_decl )
+ maker = code_creators.operator_t( operator=self.curr_decl )
+ self.curr_code_creator.adopt_creator( maker )
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ def visit_casting_operator( self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+ if None is self.curr_decl.call_policies:
+ self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
+
+ self.__types_db.update( self.curr_decl )
+ if not self.curr_decl.parent.is_abstract and not declarations.is_reference( self.curr_decl.return_type ):
+ maker = code_creators.casting_operator_t( operator=self.curr_decl )
+ self.__module_body.adopt_creator( maker )
+ self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
+
+ #what to do if class is abstract
+ maker = code_creators.casting_member_operator_t( operator=self.curr_decl )
+ self.curr_code_creator.adopt_creator( maker )
+ self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
+
+ def visit_free_function( self ):
+ if self.curr_decl in self.__exposed_free_fun_overloads:
+ return
+
+ if self.__fc_manager.is_fake_constructor( self.curr_decl ):
+ self.__types_db.update( self.curr_decl )
+ self.__dependencies_manager.add_exported( self.curr_decl )
+ return
+
+ elif self.curr_decl.use_overload_macro:
+ parent_decl = self.curr_decl.parent
+ names = set( map( lambda decl: decl.name
+ , parent_decl.free_functions( allow_empty=True, recursive=False ) ) )
+ for name in names:
+ overloads = parent_decl.free_functions( name, allow_empty=True, recursive=False )
+ overloads = filter( lambda decl: decl.ignore == False and decl.use_overload_macro, overloads )
+ if not overloads:
+ continue
+ else:
+ self.__exposed_free_fun_overloads.update( overloads )
+ for f in overloads:
+ self.__types_db.update( f )
+ self.__dependencies_manager.add_exported( f )
+ if None is f.call_policies:
+ f.call_policies = self.__call_policies_resolver( f )
+
+ overloads_cls_creator = code_creators.free_fun_overloads_class_t( overloads )
+ self.__extmodule.adopt_declaration_creator( overloads_cls_creator )
+
+ overloads_reg = code_creators.free_fun_overloads_t( overloads_cls_creator )
+ self.curr_code_creator.adopt_creator( overloads_reg )
+ overloads_reg.associated_decl_creators.append( overloads_cls_creator )
+ self.__opaque_types_manager.register_opaque( overloads_reg, overloads )
+
+ ctext_t = code_creators.custom_text_t
+ for f in overloads:
+ uc_creators = map( lambda uc: ctext_t( uc.text ), f.declaration_code )
+ insert_pos = self.__extmodule.creators.index( self.__module_body )
+ self.__extmodule.adopt_creators( uc_creators, insert_pos )
+ overloads_reg.associated_decl_creators.extend( uc_creators )
+ else:
+ self.__types_db.update( self.curr_decl )
+ self.__dependencies_manager.add_exported( self.curr_decl )
+ if None is self.curr_decl.call_policies:
+ self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
+
+ maker = None
+ if self.curr_decl.transformations:
+ wrapper = code_creators.free_fun_transformed_wrapper_t( self.curr_decl )
+ self.__extmodule.adopt_declaration_creator( wrapper )
+ maker = code_creators.free_fun_transformed_t( self.curr_decl, wrapper )
+ maker.associated_decl_creators.append( wrapper )
+ else:
+ maker = code_creators.free_function_t( function=self.curr_decl )
+ self.curr_code_creator.adopt_creator( maker )
+ self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
+
+ ctext_t = code_creators.custom_text_t
+ uc_creators = map( lambda uc: ctext_t( uc.text ), self.curr_decl.declaration_code )
+ insert_pos = self.__extmodule.creators.index( self.__module_body )
+ self.__extmodule.adopt_creators( uc_creators, insert_pos )
+ maker.associated_decl_creators.extend( uc_creators )
+
+ def visit_free_operator( self ):
+ self.__types_db.update( 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
+
+ def expose_overloaded_mem_fun_using_macro( self, cls, cls_creator ):
+ #returns set of exported member functions
+ exposed = set()
+ names = set( map( lambda decl: decl.name
+ , cls.member_functions( allow_empty=True, recursive=False ) ) )
+ for name in names:
+ overloads = cls.member_functions( name, allow_empty=True, recursive=False )
+ overloads = filter( lambda decl: decl.ignore == False and decl.use_overload_macro
+ , overloads )
+ if not overloads:
+ continue
+ else:
+ exposed.update( overloads )
+
+ for f in overloads:
+ self.__types_db.update( f )
+ self.__dependencies_manager.add_exported( f )
+ if None is f.call_policies:
+ f.call_policies = self.__call_policies_resolver( f )
+
+ overloads_cls_creator = code_creators.mem_fun_overloads_class_t( overloads )
+ self.__extmodule.adopt_declaration_creator( overloads_cls_creator )
+
+ overloads_reg = code_creators.mem_fun_overloads_t( overloads_cls_creator )
+ cls_creator.adopt_creator( overloads_reg )
+ overloads_reg.associated_decl_creators.append( overloads_cls_creator )
+
+ self.__opaque_types_manager.register_opaque( overloads_reg, overloads )
+ return exposed
+
+ def visit_class(self ):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+ cls_decl = self.curr_decl
+ cls_parent_cc = self.curr_code_creator
+ exportable_members = self.curr_decl.get_exportable_members(sort_algorithms.sort)
+
+ wrapper = None
+ cls_cc = None
+ if cls_decl.introduces_new_scope:
+ cls_cc = code_creators.class_t( class_inst=self.curr_decl )
+ else:
+ cls_cc = self.curr_code_creator
+
+ if self.curr_decl.is_wrapper_needed():
+ wrapper = code_creators.class_wrapper_t( declaration=self.curr_decl
+ , class_creator=cls_cc )
+ cls_cc.wrapper = wrapper
+ cls_cc.associated_decl_creators.append( wrapper )
+ #insert wrapper before module body
+ if isinstance( self.curr_decl.parent, declarations.class_t ):
+ #we deal with internal class
+ self.curr_code_creator.wrapper.adopt_creator( wrapper )
+ else:
+ self.__extmodule.adopt_declaration_creator( wrapper )
+
+ #next constructors are not present in code, but compiler generated
+ #Boost.Python requiers them to be declared in the wrapper class
+ noncopyable_vars = self.curr_decl.find_noncopyable_vars()
+
+ copy_constr = self.curr_decl.find_copy_constructor()
+ if not self.curr_decl.noncopyable and copy_constr and copy_constr.is_artificial:
+ cccc = code_creators.copy_constructor_wrapper_t( constructor=copy_constr)
+ wrapper.adopt_creator( cccc )
+
+ trivial_constr = self.curr_decl.find_trivial_constructor()
+ if trivial_constr and trivial_constr.is_artificial and not noncopyable_vars:
+ tcons = code_creators.null_constructor_wrapper_t( constructor=trivial_constr )
+ wrapper.adopt_creator( tcons )
+
+ exposed = self.expose_overloaded_mem_fun_using_macro( cls_decl, cls_cc )
+
+ if cls_decl.introduces_new_scope:
+ cls_parent_cc.adopt_creator( cls_cc )
+ self.curr_code_creator = cls_cc
+
+ if cls_decl.expose_this:
+ cls_cc.adopt_creator( code_creators.expose_this_t( cls_decl ) )
+
+ if cls_decl.expose_sizeof:
+ cls_cc.adopt_creator( code_creators.expose_sizeof_t( cls_decl ) )
+
+ for decl in exportable_members:
+ if decl in exposed:
+ continue
+ self.curr_decl = decl
+ declarations.apply_visitor( self, decl )
+
+ for redefined_func in cls_decl.redefined_funcs():
+ if isinstance( redefined_func, declarations.operator_t ):
+ continue
+ self.curr_decl = redefined_func
+ declarations.apply_visitor( self, redefined_func )
+
+ #all static_methods_t should be moved to the end
+ #better approach is to move them after last def of relevant function
+ static_methods = filter( lambda creator: isinstance( creator, code_creators.static_method_t )
+ , cls_cc.creators )
+ for static_method in static_methods:
+ cls_cc.remove_creator( static_method )
+ cls_cc.adopt_creator( static_method )
+
+ if cls_decl.exception_translation_code:
+ translator = code_creators.exception_translator_t( cls_decl )
+ self.__extmodule.adopt_declaration_creator( translator )
+ cls_cc.associated_decl_creators.append( translator )
+ translator_register \
+ = code_creators.exception_translator_register_t( cls_decl, translator )
+ cls_cc.adopt_creator( translator_register )
+
+ for property_def in cls_decl.properties:
+ cls_cc.adopt_creator( code_creators.property_t(property_def) )
+
+ if wrapper and cls_decl.destructor_code:
+ destructor = code_creators.destructor_wrapper_t( class_=cls_decl )
+ wrapper.adopt_creator( destructor )
+
+ for fc in cls_decl.fake_constructors:
+ if self.__fc_manager.should_generate_code( fc ):
+ self.__dependencies_manager.add_exported( fc )
+ cls_cc.adopt_creator( code_creators.make_constructor_t( fc ) )
+
+ self.curr_decl = cls_decl
+ self.curr_code_creator = cls_parent_cc
+
+
+ def visit_enumeration(self):
+ self.__dependencies_manager.add_exported( self.curr_decl )
+ maker = None
+ if self.curr_decl.name:
+ maker = code_creators.enum_t( enum=self.curr_decl )
+ else:
+ maker = code_creators.unnamed_enum_t( unnamed_enum=self.curr_decl )
+ self.curr_code_creator.adopt_creator( maker )
+
+ def visit_namespace(self):
+ pass
+
+ def visit_typedef(self):
+ pass
+
+ def _register_array_1( self, array_type ):
+ data = ( array_type.decl_string, declarations.array_size( array_type ) )
+ if data in self.__array_1_registered:
+ return False
+ else:
+ self.__array_1_registered.add( data )
+ return True
+
+ def visit_variable(self):
+ self.__types_db.update( self.curr_decl )
+ self.__dependencies_manager.add_exported( self.curr_decl )
+
+ if self.curr_decl.expose_address:
+ creator_type = None
+ if isinstance( self.curr_decl.parent, declarations.namespace_t ):
+ creator_type = code_creators.global_variable_addressof_t
+ else:
+ creator_type = code_creators.member_variable_addressof_t
+ self.curr_code_creator.adopt_creator( creator_type(self.curr_decl) )
+ return
+
+ if not self.curr_decl.expose_value:
+ return
+
+ if declarations.is_array( self.curr_decl.type ):
+ if self._register_array_1( self.curr_decl.type ):
+ array_1_registrator = code_creators.array_1_registrator_t( array_type=self.curr_decl.type )
+ self.curr_code_creator.adopt_creator( array_1_registrator )
+
+ if isinstance( self.curr_decl.parent, declarations.namespace_t ):
+ maker = None
+ wrapper = None
+ if declarations.is_array( self.curr_decl.type ):
+ wrapper = code_creators.array_gv_wrapper_t( variable=self.curr_decl )
+ maker = code_creators.array_gv_t( variable=self.curr_decl, wrapper=wrapper )
+ else:
+ maker = code_creators.global_variable_t( variable=self.curr_decl )
+ if wrapper:
+ self.__extmodule.adopt_declaration_creator( wrapper )
+ else:
+ maker = None
+ wrapper = None
+ if self.curr_decl.bits != None:
+ wrapper = code_creators.bit_field_wrapper_t( variable=self.curr_decl )
+ maker = code_creators.bit_field_t( variable=self.curr_decl, wrapper=wrapper )
+ elif declarations.is_array( self.curr_decl.type ):
+ wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )
+ maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )
+ elif declarations.is_pointer( self.curr_decl.type ):
+ wrapper = code_creators.member_variable_wrapper_t( variable=self.curr_decl )
+ maker = code_creators.member_variable_t( variable=self.curr_decl, wrapper=wrapper )
+ elif declarations.is_reference( self.curr_decl.type ):
+ if None is self.curr_decl.getter_call_policies:
+ self.curr_decl.getter_call_policies = self.__call_policies_resolver( self.curr_decl, 'get' )
+ if None is self.curr_decl.setter_call_policies:
+ self.curr_decl.setter_call_policies = self.__call_policies_resolver( self.curr_decl, 'set' )
+ wrapper = code_creators.mem_var_ref_wrapper_t( variable=self.curr_decl )
+ maker = code_creators.mem_var_ref_t( variable=self.curr_decl, wrapper=wrapper )
+ self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
+ else:
+ maker = code_creators.member_variable_t( variable=self.curr_decl )
+ if wrapper:
+ self.curr_code_creator.wrapper.adopt_creator( wrapper )
+ self.curr_code_creator.adopt_creator( maker )
Deleted: pyplusplus_dev/pyplusplus/creators_factory/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/creator.py 2008-12-26 07:58:38 UTC (rev 1501)
+++ pyplusplus_dev/pyplusplus/creators_factory/creator.py 2008-12-26 08:05:27 UTC (rev 1502)
@@ -1,745 +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 types_database
-import creators_wizard
-import sort_algorithms
-import dependencies_manager
-import opaque_types_manager
-import call_policies_resolver
-import fake_constructors_manager
-
-from pygccxml import declarations
-from pyplusplus import decl_wrappers
-from pyplusplus import code_creators
-from pyplusplus import code_repository
-from pyplusplus import _logging_
-
-ACCESS_TYPES = declarations.ACCESS_TYPES
-VIRTUALITY_TYPES = declarations.VIRTUALITY_TYPES
-
-class creator_t( declarations.decl_visitor_t ):
- """Creating code creators.
-
- This class takes a set of declarations as input and creates a code
- creator tree that contains the Boost.Python C++ source code for the
- final extension module. Each node in the code creators tree represents
- a block of text (C++ source code).
-
- Usage of this class: Create an instance and pass all relevant input
- data to the constructor. Then call L{create()} to obtain the code
- creator tree whose root node is a L{module_t<code_creators.module_t>}
- object representing the source code for the entire extension module.
- """
-
- def __init__( self
- , decls
- , module_name
- , boost_python_ns_name='bp'
- , call_policies_resolver_=None
- , types_db=None
- , target_configuration=None
- , enable_indexing_suite=True
- , doc_extractor=None ):
- """Constructor.
-
- @param decls: Declarations that should be exposed in the final module.
- @param module_name: The name of the final module.
- @param boost_python_ns_name: The alias for the boost::python namespace.
- @param call_policies_resolver_: Callable that takes one declaration (calldef_t) as input and returns a call policy object which should be used for this declaration.
- @param types_db: ...todo...
- @param target_configuration: A target configuration object can be used to customize the generated source code to a particular compiler or a particular version of Boost.Python.
- @param doc_extractor: callable, that takes as argument declaration reference and returns documentation string
- @param already_exposed_dbs: list of files/directories other modules, this module depends on, generated their code too
- @type decls: list of declaration_t
- @type module_name: str
- @type boost_python_ns_name: str
- @type call_policies_resolver_: callable
- @type types_db: L{types_database_t<types_database.types_database_t>}
- @type target_configuration: L{target_configuration_t<code_creators.target_configuration_t>}
- @type doc_extractor: callable
- @type already_exposed_dbs: list of strings
- """
- declarations.decl_visitor_t.__init__(self)
- self.logger = _logging_.loggers.module_builder
- self.decl_logger = _logging_.loggers.declarations
-
- self.__enable_indexing_suite = enable_indexing_suite
- self.__target_configuration = target_configuration
- if not self.__target_configuration:
- self.__target_configuration = code_creators.target_configuration_t()
-
- self.__call_policies_resolver = call_policies_resolver_
- if not self.__call_policies_resolver:
- self.__call_policies_resolver \
- = call_policies_resolver.built_in_resolver_t(self.__target_configuration)
-
- self.__types_db = types_db
- if not self.__types_db:
- self.__types_db = types_database.types_database_t()
-
- global_ns = declarations.get_global_namespace(decls)
- self.__extmodule = code_creators.bpmodule_t( global_ns )
- if boost_python_ns_name:
- bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
- , full_namespace_name='::boost::python' )
- self.__extmodule.adopt_creator( bp_ns_alias )
-
- self.__module_body = code_creators.module_body_t( name=module_name )
-
- self.__extmodule.adopt_creator( self.__module_body )
-
- self.__opaque_types_manager = opaque_types_manager.manager_t( self.__extmodule )
- self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)
-
- prepared_decls = self._prepare_decls( decls, doc_extractor )
- self.__decls = sort_algorithms.sort( prepared_decls )
-
- self.curr_code_creator = self.__module_body
- 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 )
-
- def __print_readme( self, decl ):
- readme = decl.readme()
- if not readme:
- return
-
- if not decl.exportable:
- reason = readme[0]
- readme = readme[1:]
- self.decl_logger.warn( "%s;%s" % ( decl, reason ) )
-
- for msg in readme:
- self.decl_logger.warn( "%s;%s" % ( decl, msg ) )
-
- def _prepare_decls( self, decls, doc_extractor ):
- to_be_exposed = []
- for decl in declarations.make_flatten( decls ):
- if decl.ignore:
- continue
-
- if isinstance( decl, declarations.namespace_t ):
- continue
-
- if not decl.exportable:
- #leave only decls that user wants to export and that could be exported
- self.__print_readme( decl )
- continue
-
- if decl.already_exposed:
- #check wether this is already exposed in other module
- continue
-
- if isinstance( decl.parent, declarations.namespace_t ):
- #leave only declarations defined under namespace, but remove namespaces
- to_be_exposed.append( decl )
-
- #Right now this functionality introduce a bug: declarations that should
- #not be exported for some reason are not marked as such. I will need to
- #find out.
- #if isinstance( decl, declarations.calldef_t ) and not isinstance( decl, declarations.destructor_t ):
- #self.__types_db.update( decl )
- #if None is decl.call_policies:
- #decl.call_policies = self.__call_policies_resolver( decl )
-
- #if isinstance( decl, declarations.variable_t ):
- #self.__types_db.update( decl )
-
- if doc_extractor:
- decl.documentation = doc_extractor( decl )
-
- self.__print_readme( decl )
-
- return to_be_exposed
-
- def _adopt_free_operator( self, operator ):
- def adopt_operator_impl( operator, found_creators ):
- creator = filter( lambda creator: isinstance( creator, code_creators.class_t )
- , found_creators )
- if len(creator) == 1:
- creator = creator[0]
- #I think I don't need this condition any more
- if not find( lambda creator: isinstance( creator, code_creators.declaration_based_t )
- and operator is creator.declaration
- , creator.creators ):
- #expose operator only once
- self.__dependencies_manager.add_exported( operator )
- creator.adopt_creator( code_creators.operator_t( operator=operator ) )
- elif not creator:
- 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 )
-
- def _is_registered_smart_pointer_creator( self, creator, db ):
- for registered in db:
- if not isinstance( creator, registered.__class__ ):
- continue
- elif registered.smart_ptr != creator.smart_ptr:
- continue
- elif isinstance( creator, code_creators.smart_pointer_registrator_t ):
- if creator.declaration is registered.declaration:
- return True
- elif isinstance( creator, code_creators.smart_pointers_converter_t ):
- if ( creator.source is registered.source ) \
- and ( creator.target is registered.target ):
- return True
- else:
- assert not "unknown instace of registrator: " % str( registered )
-
- def _treat_smart_pointers( self ):
- """ Go to all class creators and apply held_type and creator registrators
- as needed.
- """
- find_classes = code_creators.creator_finder.find_by_class_instance
- class_creators = find_classes( what=code_creators.class_t
- , where=self.__extmodule.body.creators
- , recursive=True )
- registrators_db = []
- for creator in class_creators:
- if None is creator.held_type:
- if not creator.declaration.is_abstract:
- creator.held_type = self.__types_db.create_holder( creator.declaration )
- registrators = self.__types_db.create_registrators( creator )
- for r in registrators:
- if not self._is_registered_smart_pointer_creator( r, registrators_db ):
- creator.adopt_creator(r)
- registrators_db.append(r)
-
- def _append_user_code( self ):
- find_classes = code_creators.creator_finder.find_by_class_instance
- class_creators = find_classes( what=code_creators.class_t
- , where=self.__extmodule.body.creators
- , recursive=True )
-
- ctext_t = code_creators.custom_text_t
- for cls_creator in class_creators:
- cls_decl = cls_creator.declaration
-
- uc_creators_head = map( lambda uc: ctext_t( uc.text, uc.works_on_instance )
- , cls_decl.registration_code_head )
- cls_creator.adopt_creators( uc_creators_head, 0 )
-
- uc_creators_tail = map( lambda uc: ctext_t( uc.text, uc.works_on_instance )
- , cls_decl.registration_code_tail )
- cls_creator.adopt_creators( uc_creators_tail )
-
- uc_creators = map( lambda uc: ctext_t( uc.text ), cls_decl.wrapper_code )
- if uc_creators:
- cls_creator.wrapper.adopt_creators( uc_creators )
-
- uc_creators = map( lambda uc: ctext_t( uc.text ), cls_decl.declaration_code )
- insert_pos = self.__extmodule.creators.index( self.__module_body )
- self.__extmodule.adopt_creators( uc_creators, insert_pos )
- cls_creator.associated_decl_creators.extend( uc_creators )
-
- def __get_exposed_containers(self):
- """list of exposed declarations, which were not ``included``, but still
- were exposed. For example, std containers
-
- std containers exposed by Py++, even if the user didn't ``include`` them.
- """
- cmp_by_name = lambda cls1, cls2: cmp( cls1.decl_string, cls2.decl_string )
- used_containers = list( self.__types_db.used_containers )
- used_containers = filter( lambda cls: cls.indexing_suite.include_files
- , used_containers )
- used_containers.sort( cmp_by_name )
- used_containers = filter( lambda cnt: cnt.already_exposed == False
- , used_containers )
- return used_containers
-
- def _treat_indexing_suite( self ):
- def create_explanation(cls):
- msg = '//WARNING: the next line of code will not compile, because "%s" does not have operator== !'
- msg = msg % cls.indexing_suite.element_type.decl_string
- return code_creators.custom_text_t( msg, False )
-
- def create_cls_cc( cls ):
- if isinstance( cls, declarations.class_t ):
- return code_creators.class_t( class_inst=cls )
- else:
- return code_creators.class_declaration_t( class_inst=cls )
-
- if not self.__types_db.used_containers:
- return
-
- creators = []
- created_value_traits = set()
- for cls in self.__get_exposed_containers():
- self.__print_readme( cls )
-
- cls_creator = create_cls_cc( cls )
- self.__dependencies_manager.add_exported( cls )
- creators.append( cls_creator )
- try:
- element_type = cls.indexing_suite.element_type
- except:
- element_type = None
-
- if isinstance( cls.indexing_suite, decl_wrappers.indexing_suite1_t ):
- if not ( None is element_type ) \
- and declarations.is_class( element_type ) \
- and not declarations.has_public_equal( element_type ):
- cls_creator.adopt_creator( create_explanation( cls ) )
- cls_creator.adopt_creator( code_creators.indexing_suite1_t(cls) )
- else:
- class_traits = declarations.class_traits
- if not ( None is element_type ) and class_traits.is_my_case( element_type ):
- value_cls = class_traits.get_declaration( element_type )
- has_prerequisits = value_cls.less_than_comparable \
- and value_cls.equality_comparable
- if ( not has_prerequisits ) and ( value_cls not in created_value_traits ):
- created_value_traits.add( value_cls )
- element_type_cc = code_creators.value_traits_t( value_cls )
- 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 )
-
- def create(self, decl_headers=None):
- """Create and return the module for the extension.
-
- @param decl_headers: If None the headers for the wrapped decls are automatically found.
- But you can pass a list of headers here to override that search.
- @returns: Returns the root of the code creators tree
- @rtype: L{module_t<code_creators.module_t>}
- """
- # Invoke the appropriate visit_*() method on all decls
- for decl in self.__decls:
- self.curr_decl = decl
- declarations.apply_visitor( self, decl )
- for operator in self.__free_operators:
- self._adopt_free_operator( operator )
- self._treat_smart_pointers()
- if self.__enable_indexing_suite:
- self._treat_indexing_suite()
- for creator in code_creators.make_flatten_generator( self.__extmodule ):
- creator.target_configuration = self.__target_configuration
- #last action.
- self._append_user_code()
-
- add_include = self.__extmodule.add_include
- #add system headers
- system_headers = self.__extmodule.get_system_headers( recursive=True, unique=True )
- map( lambda header: add_include( header, user_defined=False, system=True )
- , system_headers )
- #add user defined header files
- if decl_headers is None:
- decl_headers = declarations.declaration_files( self.__decls )
- map( lambda header: add_include( header, user_defined=False, system=False )
- , decl_headers )
-
- self.__dependencies_manager.inform_user()
-
- return self.__extmodule
-
- def visit_member_function( self ):
- self.__types_db.update( self.curr_decl )
- self.__dependencies_manager.add_exported( self.curr_decl )
-
- if self.__fc_manager.is_fake_constructor( self.curr_decl ):
- return
-
- fwrapper = None
- if None is self.curr_decl.call_policies:
- self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
-
- maker_cls, fwrapper_cls = creators_wizard.find_out_mem_fun_creator_classes( self.curr_decl )
-
- maker = None
- fwrapper = None
- if fwrapper_cls:
- fwrapper = fwrapper_cls( function=self.curr_decl )
- if fwrapper_cls is code_creators.mem_fun_transformed_wrapper_t:
- if self.curr_code_creator.wrapper:
- class_wrapper = self.curr_code_creator.wrapper
- class_wrapper.adopt_creator( fwrapper )
- else:
- self.__extmodule.adopt_declaration_creator( fwrapper )
- self.curr_code_creator.associated_decl_creators.append(fwrapper)
- else:
- class_wrapper = self.curr_code_creator.wrapper
- class_wrapper.adopt_creator( fwrapper )
-
- if maker_cls:
- if fwrapper:
- maker = maker_cls( function=self.curr_decl, wrapper=fwrapper )
- else:
- maker = maker_cls( function=self.curr_decl )
- self.curr_code_creator.adopt_creator( maker )
- self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
-
- if self.curr_decl.has_static:
- #static_method should be created only once.
- found = filter( lambda creator: isinstance( creator, code_creators.static_method_t )
- and creator.declaration.name == self.curr_decl.name
- , self.curr_code_creator.creators )
- if not found:
- static_method = code_creators.static_method_t( function=self.curr_decl
- , function_code_creator=maker )
- self.curr_code_creator.adopt_creator( static_method )
-
- def visit_constructor( self ):
- self.__types_db.update( self.curr_decl )
- self.__dependencies_manager.add_exported( self.curr_decl )
-
- cwrapper = None
- if self.curr_decl.parent.is_wrapper_needed():
- class_wrapper = self.curr_code_creator.wrapper
- cwrapper = code_creators.constructor_wrapper_t( constructor=self.curr_decl )
- class_wrapper.adopt_creator( cwrapper )
- #TODO: FT for constructor
- #~ if self.curr_decl.transformations:
- #~ cwrapper = code_creators.constructor_transformed_wrapper_t( constructor=self.curr_decl )
- #~ class_wrapper.adopt_creator( cwrapper )
- #~ else:
- #~ if self.curr_decl.transformations:
- #~ cwrapper = code_creators.constructor_transformed_wrapper_t( constructor=self.curr_decl )
- #~ class_wrapper.adopt_creator( cwrapper )
- #~ self.__module_body.adopt_creator( cwrapper )
- #~ self.curr_code_creator.associated_decl_creators.append( cwrapper )
- #~ maker = None
- #~ if self.curr_decl.transformations:
- #~ maker = code_creators.constructor_transformed_t( constructor=self.curr_decl )
- #~ else:
- maker = code_creators.constructor_t( constructor=self.curr_decl, wrapper=cwrapper )
- if None is self.curr_decl.call_policies:
- self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
- self.curr_code_creator.adopt_creator( maker )
-
- if self.curr_decl.allow_implicit_conversion:
- maker = code_creators.casting_constructor_t( constructor=self.curr_decl )
- #casting constructor will be generated in the same file as class
- self.curr_code_creator.adopt_creator( maker )
-
-
- def visit_destructor( self ):
- pass
-
- def visit_member_operator( self ):
- if self.curr_decl.symbol in ( '()', '[]', '=' ):
- self.visit_member_function()
- else:
- self.__types_db.update( self.curr_decl )
- maker = code_creators.operator_t( operator=self.curr_decl )
- self.curr_code_creator.adopt_creator( maker )
- self.__dependencies_manager.add_exported( self.curr_decl )
-
- def visit_casting_operator( self ):
- self.__dependencies_manager.add_exported( self.curr_decl )
- if None is self.curr_decl.call_policies:
- self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl )
-
- self.__types_db.update( self.curr_decl )
- if not self.curr_decl.parent.is_abstract and not declarations.is_reference( self.curr_decl.return_type ):
- maker = code_creators.casting_operator_t( operator=self.curr_decl )
- self.__module_body.adopt_creator( maker )
- self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
-
- #what to do if class is abstract
- maker = code_creators.casting_member_operator_t( operator=self.curr_decl )
- self.curr_code_creator.adopt_creator( maker )
- self.__opaque_types_manager.register_opaque( maker, self.curr_decl )
-
- def visit_free_function( self ):
- if self.curr_decl in self.__exposed_free_fun_overloads:
- ...
[truncated message content] |
|
From: <rom...@us...> - 2008-12-26 07:58:44
|
Revision: 1501
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1501&view=rev
Author: roman_yakovenko
Date: 2008-12-26 07:58:38 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
small refactoring before introducing ctypes code generator
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_creators/bpmodule.py
Removed Paths:
-------------
pyplusplus_dev/pyplusplus/code_creators/module.py
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-26 07:53:03 UTC (rev 1500)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-26 07:58:38 UTC (rev 1501)
@@ -116,7 +116,7 @@
from license import license_t
-from module import bpmodule_t
+from bpmodule import bpmodule_t
from smart_pointers import held_type_t
from smart_pointers import smart_pointers_converter_t
@@ -143,4 +143,4 @@
#pure ctypes
from import_ import import_t
from library_reference import library_reference_t
-from name_mapping import name_mapping_t
+from name_mappings import name_mapping_t
Copied: pyplusplus_dev/pyplusplus/code_creators/bpmodule.py (from rev 1500, pyplusplus_dev/pyplusplus/code_creators/module.py)
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/bpmodule.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/bpmodule.py 2008-12-26 07:58:38 UTC (rev 1501)
@@ -0,0 +1,173 @@
+# 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 custom
+import module
+import include
+import namespace
+import compound
+import algorithm
+import module_body
+import declaration_based
+import include_directories
+from pygccxml import utils
+
+class bpmodule_t(module.module_t):
+ """This class represents the source code for the entire extension module.
+
+ The root of the code creator tree is always a module_t object.
+ """
+ def __init__(self, global_ns):
+ """Constructor.
+ """
+ module.module_t.__init__(self, global_ns)
+ self.__body = None
+
+ def _get_include_dirs(self):
+ include_dirs = algorithm.creator_finder.find_by_class_instance(
+ what=include_directories.include_directories_t
+ , where=self.creators
+ , recursive=False)
+ if 0 == len( include_dirs ):
+ include_dirs = include_directories.include_directories_t()
+ if self.license:
+ self.adopt_creator( include_dirs, 1 )
+ else:
+ self.adopt_creator( include_dirs, 0 )
+ return include_dirs
+ elif 1 == len( include_dirs ):
+ return include_dirs[0]
+ else:
+ assert not "only single instance of include_directories_t should exist"
+
+ def _get_std_directories(self):
+ include_dirs = self._get_include_dirs()
+ return include_dirs.std
+ std_directories = property( _get_std_directories )
+
+ def _get_user_defined_directories(self):
+ include_dirs = self._get_include_dirs()
+ return include_dirs.user_defined
+ user_defined_directories = property( _get_user_defined_directories )
+
+ @property
+ def body(self):
+ """Return reference to L{module_body_t} code creator"""
+ if None is self.__body:
+ found = algorithm.creator_finder.find_by_class_instance( what=module_body.module_body_t
+ , where=self.creators
+ , recursive=False )
+ if found:
+ self.__body = found[0]
+ return self.__body
+
+ def last_include_index(self):
+ """Return the children index of the last L{include_t} object.
+
+ An exception is raised when there is no include_t object among
+ the children creators.
+
+ @returns: Children index
+ @rtype: int
+ """
+ for i in range( len(self.creators) - 1, -1, -1 ):
+ if isinstance( self.creators[i], include.include_t ):
+ return i
+ else:
+ return 0
+
+ def replace_included_headers( self, headers, leave_system_headers=True ):
+ to_be_removed = []
+ for creator in self.creators:
+ if isinstance( creator, include.include_t ):
+ to_be_removed.append( creator )
+ elif isinstance( creator, module_body.module_body_t ):
+ break
+
+ for creator in to_be_removed:
+ if creator.is_system:
+ if not leave_system_headers:
+ self.remove_creator( creator )
+ elif creator.is_user_defined:
+ pass
+ else:
+ self.remove_creator( creator )
+ map( lambda header: self.adopt_include( include.include_t( header=header ) )
+ , headers )
+
+ def adopt_include(self, include_creator):
+ """Insert an L{include_t} object.
+
+ The include creator is inserted right after the last include file.
+
+ @param include_creator: Include creator object
+ @type include_creator: L{include_t}
+ """
+ lii = self.last_include_index()
+ if lii == 0:
+ if not self.creators:
+ lii = -1
+ elif not isinstance( self.creators[0], include.include_t ):
+ lii = -1
+ else:
+ pass
+ self.adopt_creator( include_creator, lii + 1 )
+
+ def do_include_dirs_optimization(self):
+ include_dirs = self._get_include_dirs()
+ includes = filter( lambda creator: isinstance( creator, include.include_t )
+ , self.creators )
+ for include_creator in includes:
+ include_creator.include_dirs_optimization = include_dirs
+
+ def _create_impl(self):
+ self.do_include_dirs_optimization()
+ index = 0
+ includes = []
+ for index in range( len( self.creators ) ):
+ if not isinstance( self.creators[index], include.include_t ):
+ break
+ else:
+ includes.append( self.creators[index].create() )
+ code = compound.compound_t.create_internal_code( self.creators[index:] )
+ code = self.unindent(code)
+ return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep
+
+ def add_include( self, header, user_defined=True, system=False ):
+ creator = include.include_t( header=header, user_defined=user_defined, system=system )
+ self.adopt_include( creator )
+
+ def add_namespace_usage( self, namespace_name ):
+ self.adopt_creator( namespace.namespace_using_t( namespace_name )
+ , self.last_include_index() + 1 )
+
+ def add_namespace_alias( self, alias, full_namespace_name ):
+ self.adopt_creator( namespace.namespace_alias_t(
+ alias=alias
+ , full_namespace_name=full_namespace_name )
+ , self.last_include_index() + 1 )
+
+ def adopt_declaration_creator( self, creator ):
+ self.adopt_creator( creator, self.creators.index( self.body ) )
+
+ def add_declaration_code( self, code, position ):
+ self.adopt_declaration_creator( custom.custom_text_t( code ) )
+
+ @utils.cached
+ def specially_exposed_decls(self):
+ """list of exposed declarations, which were not ``included``, but still
+ were exposed. For example, std containers.
+ """
+ decls = set()
+ #select all declaration based code creators
+ ccs = filter( lambda cc: isinstance( cc, declaration_based.declaration_based_t )
+ , algorithm.make_flatten_list( self ) )
+ #leave only "ignored"
+ ccs = filter( lambda cc: cc.declaration.ignore == True, ccs )
+
+ decls = map( lambda cc: cc.declaration, ccs )
+
+ return set( decls )
Deleted: pyplusplus_dev/pyplusplus/code_creators/module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/module.py 2008-12-26 07:53:03 UTC (rev 1500)
+++ pyplusplus_dev/pyplusplus/code_creators/module.py 2008-12-26 07:58:38 UTC (rev 1501)
@@ -1,174 +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 custom
-import license
-import include
-import namespace
-import compound
-import algorithm
-import base_module
-import module_body
-import declaration_based
-import include_directories
-from pygccxml import utils
-
-class bpmodule_t(base_module.base_module_t):
- """This class represents the source code for the entire extension module.
-
- The root of the code creator tree is always a module_t object.
- """
- def __init__(self, global_ns):
- """Constructor.
- """
- base_module.base_module_t.__init__(self, global_ns)
- self.__body = None
-
- def _get_include_dirs(self):
- include_dirs = algorithm.creator_finder.find_by_class_instance(
- what=include_directories.include_directories_t
- , where=self.creators
- , recursive=False)
- if 0 == len( include_dirs ):
- include_dirs = include_directories.include_directories_t()
- if self.license:
- self.adopt_creator( include_dirs, 1 )
- else:
- self.adopt_creator( include_dirs, 0 )
- return include_dirs
- elif 1 == len( include_dirs ):
- return include_dirs[0]
- else:
- assert not "only single instance of include_directories_t should exist"
-
- def _get_std_directories(self):
- include_dirs = self._get_include_dirs()
- return include_dirs.std
- std_directories = property( _get_std_directories )
-
- def _get_user_defined_directories(self):
- include_dirs = self._get_include_dirs()
- return include_dirs.user_defined
- user_defined_directories = property( _get_user_defined_directories )
-
- @property
- def body(self):
- """Return reference to L{module_body_t} code creator"""
- if None is self.__body:
- found = algorithm.creator_finder.find_by_class_instance( what=module_body.module_body_t
- , where=self.creators
- , recursive=False )
- if found:
- self.__body = found[0]
- return self.__body
-
- def last_include_index(self):
- """Return the children index of the last L{include_t} object.
-
- An exception is raised when there is no include_t object among
- the children creators.
-
- @returns: Children index
- @rtype: int
- """
- for i in range( len(self.creators) - 1, -1, -1 ):
- if isinstance( self.creators[i], include.include_t ):
- return i
- else:
- return 0
-
- def replace_included_headers( self, headers, leave_system_headers=True ):
- to_be_removed = []
- for creator in self.creators:
- if isinstance( creator, include.include_t ):
- to_be_removed.append( creator )
- elif isinstance( creator, module_body.module_body_t ):
- break
-
- for creator in to_be_removed:
- if creator.is_system:
- if not leave_system_headers:
- self.remove_creator( creator )
- elif creator.is_user_defined:
- pass
- else:
- self.remove_creator( creator )
- map( lambda header: self.adopt_include( include.include_t( header=header ) )
- , headers )
-
- def adopt_include(self, include_creator):
- """Insert an L{include_t} object.
-
- The include creator is inserted right after the last include file.
-
- @param include_creator: Include creator object
- @type include_creator: L{include_t}
- """
- lii = self.last_include_index()
- if lii == 0:
- if not self.creators:
- lii = -1
- elif not isinstance( self.creators[0], include.include_t ):
- lii = -1
- else:
- pass
- self.adopt_creator( include_creator, lii + 1 )
-
- def do_include_dirs_optimization(self):
- include_dirs = self._get_include_dirs()
- includes = filter( lambda creator: isinstance( creator, include.include_t )
- , self.creators )
- for include_creator in includes:
- include_creator.include_dirs_optimization = include_dirs
-
- def _create_impl(self):
- self.do_include_dirs_optimization()
- index = 0
- includes = []
- for index in range( len( self.creators ) ):
- if not isinstance( self.creators[index], include.include_t ):
- break
- else:
- includes.append( self.creators[index].create() )
- code = compound.compound_t.create_internal_code( self.creators[index:] )
- code = self.unindent(code)
- return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep
-
- def add_include( self, header, user_defined=True, system=False ):
- creator = include.include_t( header=header, user_defined=user_defined, system=system )
- self.adopt_include( creator )
-
- def add_namespace_usage( self, namespace_name ):
- self.adopt_creator( namespace.namespace_using_t( namespace_name )
- , self.last_include_index() + 1 )
-
- def add_namespace_alias( self, alias, full_namespace_name ):
- self.adopt_creator( namespace.namespace_alias_t(
- alias=alias
- , full_namespace_name=full_namespace_name )
- , self.last_include_index() + 1 )
-
- def adopt_declaration_creator( self, creator ):
- self.adopt_creator( creator, self.creators.index( self.body ) )
-
- def add_declaration_code( self, code, position ):
- self.adopt_declaration_creator( custom.custom_text_t( code ) )
-
- @utils.cached
- def specially_exposed_decls(self):
- """list of exposed declarations, which were not ``included``, but still
- were exposed. For example, std containers.
- """
- decls = set()
- #select all declaration based code creators
- ccs = filter( lambda cc: isinstance( cc, declaration_based.declaration_based_t )
- , algorithm.make_flatten_list( self ) )
- #leave only "ignored"
- ccs = filter( lambda cc: cc.declaration.ignore == True, ccs )
-
- decls = map( lambda cc: cc.declaration, ccs )
-
- return set( decls )
Modified: pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2008-12-26 07:53:03 UTC (rev 1500)
+++ pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2008-12-26 07:58:38 UTC (rev 1501)
@@ -24,7 +24,7 @@
items_undecorated.append( tmpl % ( undecorated, blob ) )
result = []
- result.append('%s.undecorated_names = {#mapping between decorated and undecorated names' % self._dictionary_var_name ]
+ result.append('%s.undecorated_names = {#mapping between decorated and undecorated names' % self._dictionary_var_name )
for s in items_undecorated:
result.append( self.indent( s ) )
for s in items_decorated:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-26 07:53:06
|
Revision: 1500
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1500&view=rev
Author: roman_yakovenko
Date: 2008-12-26 07:53:03 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
small refactoring before introducing ctypes code generator
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/include.py
pyplusplus_dev/pyplusplus/code_creators/module.py
pyplusplus_dev/pyplusplus/creators_factory/creator.py
pyplusplus_dev/pyplusplus/file_writers/balanced_files.py
pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py
pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -116,7 +116,7 @@
from license import license_t
-from module import module_t
+from module import bpmodule_t
from smart_pointers import held_type_t
from smart_pointers import smart_pointers_converter_t
Modified: pyplusplus_dev/pyplusplus/code_creators/include.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/include.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/code_creators/include.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -13,7 +13,7 @@
def __init__( self, header, user_defined=False, system=False ):
code_creator.code_creator_t.__init__(self)
self._header = include_directories.include_directories_t.normalize( header )
- self._include_dirs_optimization = None #This parameter will be set from module_t.create function
+ self._include_dirs_optimization = None #This parameter will be set from bpmodule_t.create function
self._user_defined = user_defined
self._system = system
self.__created_code = None
Modified: pyplusplus_dev/pyplusplus/code_creators/module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/module.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/code_creators/module.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -7,15 +7,16 @@
import custom
import license
import include
-import namespace
+import namespace
import compound
import algorithm
+import base_module
import module_body
import declaration_based
import include_directories
from pygccxml import utils
-class module_t(compound.compound_t):
+class bpmodule_t(base_module.base_module_t):
"""This class represents the source code for the entire extension module.
The root of the code creator tree is always a module_t object.
@@ -23,20 +24,14 @@
def __init__(self, global_ns):
"""Constructor.
"""
- compound.compound_t.__init__(self)
+ base_module.base_module_t.__init__(self, global_ns)
self.__body = None
- self.__global_ns = global_ns
-
- @property
- def global_ns(self):
- "reference to global_ns ( namespace_t ) declaration"
- return self.__global_ns
-
+
def _get_include_dirs(self):
- include_dirs = algorithm.creator_finder.find_by_class_instance(
+ include_dirs = algorithm.creator_finder.find_by_class_instance(
what=include_directories.include_directories_t
, where=self.creators
- , recursive=False)
+ , recursive=False)
if 0 == len( include_dirs ):
include_dirs = include_directories.include_directories_t()
if self.license:
@@ -46,9 +41,9 @@
return include_dirs
elif 1 == len( include_dirs ):
return include_dirs[0]
- else:
+ else:
assert not "only single instance of include_directories_t should exist"
-
+
def _get_std_directories(self):
include_dirs = self._get_include_dirs()
return include_dirs.std
@@ -59,7 +54,7 @@
return include_dirs.user_defined
user_defined_directories = property( _get_user_defined_directories )
- @property
+ @property
def body(self):
"""Return reference to L{module_body_t} code creator"""
if None is self.__body:
@@ -70,23 +65,6 @@
self.__body = found[0]
return self.__body
- def _get_license( self ):
- if isinstance( self.creators[0], license.license_t ):
- return self.creators[0]
- return None
-
- def _set_license( self, license_text ):
- if not isinstance( license_text, license.license_t ):
- license_inst = license.license_t( license_text )
- if isinstance( self.creators[0], license.license_t ):
- self.remove_creator( self.creators[0] )
- self.adopt_creator( license_inst, 0 )
- license = property( _get_license, _set_license,
- doc="""License text.
-
- The license text will always be the first children node.
- @type: str or L{license_t}""")
-
def last_include_index(self):
"""Return the children index of the last L{include_t} object.
@@ -109,9 +87,9 @@
to_be_removed.append( creator )
elif isinstance( creator, module_body.module_body_t ):
break
-
+
for creator in to_be_removed:
- if creator.is_system:
+ if creator.is_system:
if not leave_system_headers:
self.remove_creator( creator )
elif creator.is_user_defined:
@@ -146,9 +124,6 @@
for include_creator in includes:
include_creator.include_dirs_optimization = include_dirs
- def _get_system_headers_impl( self ):
- return []
-
def _create_impl(self):
self.do_include_dirs_optimization()
index = 0
@@ -159,19 +134,19 @@
else:
includes.append( self.creators[index].create() )
code = compound.compound_t.create_internal_code( self.creators[index:] )
- code = self.unindent(code)
+ code = self.unindent(code)
return os.linesep.join( includes ) + 2 * os.linesep + code + os.linesep
-
+
def add_include( self, header, user_defined=True, system=False ):
creator = include.include_t( header=header, user_defined=user_defined, system=system )
self.adopt_include( creator )
-
+
def add_namespace_usage( self, namespace_name ):
self.adopt_creator( namespace.namespace_using_t( namespace_name )
, self.last_include_index() + 1 )
def add_namespace_alias( self, alias, full_namespace_name ):
- self.adopt_creator( namespace.namespace_alias_t(
+ self.adopt_creator( namespace.namespace_alias_t(
alias=alias
, full_namespace_name=full_namespace_name )
, self.last_include_index() + 1 )
@@ -179,21 +154,21 @@
def adopt_declaration_creator( self, creator ):
self.adopt_creator( creator, self.creators.index( self.body ) )
- def add_declaration_code( self, code, position ):
+ def add_declaration_code( self, code, position ):
self.adopt_declaration_creator( custom.custom_text_t( code ) )
-
- @utils.cached
+
+ @utils.cached
def specially_exposed_decls(self):
- """list of exposed declarations, which were not ``included``, but still
+ """list of exposed declarations, which were not ``included``, but still
were exposed. For example, std containers.
"""
decls = set()
#select all declaration based code creators
ccs = filter( lambda cc: isinstance( cc, declaration_based.declaration_based_t )
, algorithm.make_flatten_list( self ) )
- #leave only "ignored"
+ #leave only "ignored"
ccs = filter( lambda cc: cc.declaration.ignore == True, ccs )
-
+
decls = map( lambda cc: cc.declaration, ccs )
-
+
return set( decls )
Modified: pyplusplus_dev/pyplusplus/creators_factory/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/creator.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/creators_factory/creator.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -81,7 +81,7 @@
self.__types_db = types_database.types_database_t()
global_ns = declarations.get_global_namespace(decls)
- self.__extmodule = code_creators.module_t( global_ns )
+ self.__extmodule = code_creators.bpmodule_t( global_ns )
if boost_python_ns_name:
bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
, full_namespace_name='::boost::python' )
Modified: pyplusplus_dev/pyplusplus/file_writers/balanced_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/balanced_files.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/file_writers/balanced_files.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -3,7 +3,7 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-"""defines a class that writes L{code_creators.module_t} to multiple files"""
+"""defines a class that writes L{code_creators.bpmodule_t} to multiple files"""
import os
import math
@@ -34,7 +34,7 @@
"""Constructor.
@param extmodule: The root of a code creator tree
- @type extmodule: module_t
+ @type extmodule: bpmodule_t
@param directory_path: The output directory where the source files are written
@type directory_path: str
Modified: pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -3,7 +3,7 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-"""defines a class that writes L{code_creators.module_t} to multiple files, the class
+"""defines a class that writes L{code_creators.bpmodule_t} to multiple files, the class
also splits huge C++ classes to few source files
"""
Modified: pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -3,7 +3,7 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-"""defines a class that writes L{code_creators.module_t} to multiple files"""
+"""defines a class that writes L{code_creators.bpmodule_t} to multiple files"""
import os
import writer
@@ -26,7 +26,7 @@
"""Constructor.
@param extmodule: The root of a code creator tree
- @type extmodule: module_t
+ @type extmodule: bpmodule_t
@param directory_path: The output directory where the source files are written
@type directory_path: str
Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -208,7 +208,7 @@
, enable_indexing_suite=True
, doc_extractor=None):
"""
- Creates L{module_t} code creator.
+ Creates L{bpmodule_t} code creator.
@param module_name: module name
@type module_name: string
@@ -248,7 +248,7 @@
@property
def code_creator( self ):
- "reference to L{code_creators.module_t} instance"
+ "reference to L{code_creators.bpmodule_t} instance"
if not self.__code_creator:
raise RuntimeError( "self.module is equal to None. Did you forget to call build_code_creator function?" )
return self.__code_creator
Modified: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-25 11:46:00 UTC (rev 1499)
+++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-26 07:53:03 UTC (rev 1500)
@@ -107,7 +107,7 @@
@property
def code_creator( self ):
- "reference to L{code_creators.module_t} instance"
+ "reference to L{code_creators.ctypes_module_t} instance"
if not self.__code_creator:
raise RuntimeError( "self.module is equal to None. Did you forget to call build_code_creator function?" )
return self.__code_creator
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-25 12:22:03
|
Revision: 1499
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1499&view=rev
Author: roman_yakovenko
Date: 2008-12-25 11:46:00 +0000 (Thu, 25 Dec 2008)
Log Message:
-----------
adding few basic ctypes code creators
Modified Paths:
--------------
pygccxml_dev/unittests/data/core_cache.hpp
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
pyplusplus_dev/pyplusplus/cpptypes/name_mapping.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_creators/import_.py
pyplusplus_dev/pyplusplus/code_creators/library_reference.py
pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
Modified: pygccxml_dev/unittests/data/core_cache.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_cache.hpp 2008-12-24 21:48:48 UTC (rev 1498)
+++ pygccxml_dev/unittests/data/core_cache.hpp 2008-12-25 11:46:00 UTC (rev 1499)
@@ -22,4 +22,4 @@
#endif//__core_cache_hpp__
-//touch
\ No newline at end of file
+//touch//touch
\ No newline at end of file
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-24 21:48:48 UTC (rev 1498)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2008-12-25 11:46:00 UTC (rev 1499)
@@ -139,3 +139,8 @@
from ctypes_integration_creators import expose_this_t
from ctypes_integration_creators import expose_sizeof_t
+
+#pure ctypes
+from import_ import import_t
+from library_reference import library_reference_t
+from name_mapping import name_mapping_t
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2008-12-24 21:48:48 UTC (rev 1498)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2008-12-25 11:46:00 UTC (rev 1499)
@@ -9,8 +9,8 @@
class code_creator_t(object):
"""
code_creator_t is the base class for all code creators.
-
- This class defines the interface that every code creator should implement.
+
+ This class defines the interface that every code creator should implement.
Also it provides few convenience functions.
The purpose of a code creator is the generation of a block of C++
@@ -33,16 +33,16 @@
self._parent = None
self._target_configuration = None
self._works_on_instance = True
-
+
def _get_works_on_instance(self):
return self._works_on_instance
def _set_works_on_instance(self, works_on_instance):
self._works_on_instance = works_on_instance
works_on_instance = property( _get_works_on_instance, _set_works_on_instance )
-
+
def _get_parent( self ):
- return self._parent
+ return self._parent
def _set_parent( self, new_parent ):
if new_parent:
assert isinstance( new_parent, code_creator_t )
@@ -52,7 +52,7 @@
doc="""Parent code creator or None if this is the root node.
@type: L{code_creator_t}
""")
-
+
def _get_target_configuration( self ):
return self._target_configuration
def _set_target_configuration( self, config ):
@@ -62,7 +62,7 @@
doc="""Target configuration.
@type: L{target_configuration_t}
""")
-
+
def _get_top_parent(self):
parent = self.parent
me = self
@@ -80,17 +80,17 @@
def _create_impl(self):
"""
- function that all derived classes should implement. This function
+ function that all derived classes should implement. This function
actually creates code and returns it. Return value of this function is
string.
@rtype: str
"""
raise NotImplementedError()
-
+
def create(self):
"""
- this function should be used in order to get code that should be
+ this function should be used in order to get code that should be
generated.
@returns: Returns a text block of C++ source code.
@@ -109,7 +109,7 @@
used.add( h )
uheaders.append( h )
return uheaders
-
+
def _get_system_headers_impl( self ):
"""Return list of system header files the generated code depends on"""
raise NotImplementedError(self.__class__.__name__)
@@ -132,13 +132,13 @@
"""
assert isinstance( code, types.StringTypes )
return code.strip()
-
+
@staticmethod
def indent( code, size=1 ):
"""
function that implements code indent algorithm.
- @param code: C++ code block.
+ @param code: C++/Python code block.
@type code: str
@param size: The number of indentation levels that the code is shifted
@type size: int
@@ -149,11 +149,11 @@
return code_creator_t.__INDENTATION * size\
+ code.replace( os.linesep
, os.linesep + code_creator_t.__INDENTATION * size )
-
+
@staticmethod
def unindent( code ):
"""
- function that implements code unindent algorithm.
+ function that implements code unindent algorithm.
@param code: C++ code block.
@type code: str
@@ -165,7 +165,7 @@
return code.replace( os.linesep + code_creator_t.__INDENTATION
, os.linesep )
- @staticmethod
+ @staticmethod
def is_comment( line ):
"""
function that returns true if content of the line is comment, otherwise
@@ -178,4 +178,10 @@
assert isinstance( line, types.StringTypes )
l = line.lstrip()
return l.startswith( '//' ) or l.startswith( '/*' )
-
\ No newline at end of file
+
+ @staticmethod
+ def iif( condition, true_, false_ ):
+ if condition:
+ return true_
+ else:
+ return false_
Added: pyplusplus_dev/pyplusplus/code_creators/import_.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/import_.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/import_.py 2008-12-25 11:46:00 UTC (rev 1499)
@@ -0,0 +1,20 @@
+# 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 code_creator
+import include_directories
+
+
+class import_t(code_creator.code_creator_t):
+ """Creates Python import directive"""
+ def __init__( self, module_name ):
+ code_creator.code_creator_t.__init__(self)
+ self._module_name = module_name
+
+ def _create_impl(self):
+ return 'import %(module)s' % dict( module=self.module_name )
+
+ def _get_system_headers_impl( self ):
+ return []
Added: pyplusplus_dev/pyplusplus/code_creators/library_reference.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/library_reference.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/library_reference.py 2008-12-25 11:46:00 UTC (rev 1499)
@@ -0,0 +1,32 @@
+# 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 code_creator
+
+
+class library_reference_t(code_creator.code_creator_t):
+ """Creates reference to a library"""
+
+ def __init__( self, library_var_name, library_path, is_cpp_library ):
+ code_creator.code_creator_t.__init__(self)
+ self._library_path = library_path
+ self._is_cpp_library = is_cpp_library
+ self._library_var_name = library_var_name
+
+ def _create_impl(self):
+ return '%(var)s = ctypes.%(loader)s( r"%(path)s" )' \
+ % dict( var=self._library_var_name
+ , loader=self.iif( self._is_cpp_library, 'CPPDLL', 'CDLL' )
+ , path=self._library_path )
+
+
+ def _get_system_headers_impl( self ):
+ return []
+
+if __name__ == '__main__':
+ lr = library_reference_t( 'library', r'c:\temp\x1.dll', False )
+ print lr.create()
+ lr = library_reference_t( 'library', r'c:\temp\x1.dll', True )
+ print lr.create()
Added: pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/name_mappings.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2008-12-25 11:46:00 UTC (rev 1499)
@@ -0,0 +1,43 @@
+# 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 code_creator
+
+
+class name_mapping_t(code_creator.code_creator_t):
+ """creates dictionery { [un]decorated name : [un]decorated name }"""
+
+ def __init__( self, exported_symbols ):
+ code_creator.code_creator_t.__init__(self)
+ self._exported_symbols = exported_symbols
+
+
+ def _create_impl(self):
+ tmpl = '"%s" : "%s", '
+ items_decorated = []
+ items_undecorated = []
+ for blob, undecorated in self._exported_symbols.iteritems():
+ items_decorated.append( tmpl % ( blob, undecorated ) )
+ items_undecorated.append( tmpl % ( undecorated, blob ) )
+
+ result = []
+ result.append('%s.undecorated_names = {#mapping between decorated and undecorated names' % self._dictionary_var_name ]
+ for s in items_undecorated:
+ result.append( self.indent( s ) )
+ for s in items_decorated:
+ result.append( self.indent( s ) )
+ result.append( '}' )
+ return os.linesep.join( result )
+
+
+ def _get_system_headers_impl( self ):
+ return []
+
+
+if __name__ == '__main__':
+ data = { 'a' : 'AA', 'b' : 'BB' }
+ nm = name_mapping_t( 'name_mapping', data )
+ print nm.create()
Modified: pyplusplus_dev/pyplusplus/cpptypes/name_mapping.py
===================================================================
--- pyplusplus_dev/pyplusplus/cpptypes/name_mapping.py 2008-12-24 21:48:48 UTC (rev 1498)
+++ pyplusplus_dev/pyplusplus/cpptypes/name_mapping.py 2008-12-25 11:46:00 UTC (rev 1499)
@@ -25,8 +25,7 @@
Obviously the result is too big and some additional work should be done.
"""
-data = \
-{u'??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z': u'std::basic_ostream<char,std::char_traits<char> > & std::operator<<<std::char_traits<char> >(std::basic_ostream<char,std::char_traits<char> > &,char const *)',
+data = {u'??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z': u'std::basic_ostream<char,std::char_traits<char> > & std::operator<<<std::char_traits<char> >(std::basic_ostream<char,std::char_traits<char> > &,char const *)',
u'??0?$auto_ptr@Vnumber_t@@@std@@QAE@AAV01@@Z': u'std::auto_ptr<number_t>::auto_ptr<number_t>(std::auto_ptr<number_t> &)',
u'??0?$auto_ptr@Vnumber_t@@@std@@QAE@PAVnumber_t@@@Z': u'std::auto_ptr<number_t>::auto_ptr<number_t>(number_t *)',
u'??0?$auto_ptr@Vnumber_t@@@std@@QAE@U?$auto_ptr_ref@Vnumber_t@@@1@@Z': u'std::auto_ptr<number_t>::auto_ptr<number_t>(std::auto_ptr_ref<number_t>)',
@@ -91,4 +90,9 @@
u'void operator delete[](void *)': u'??_V@YAXPAX@Z',
u"void std::auto_ptr<number_t>::`default constructor closure'(void)": u'??_F?$auto_ptr@Vnumber_t@@@std@@QAEXXZ',
u'void std::auto_ptr<number_t>::reset(number_t *)': u'?reset@?$auto_ptr@Vnumber_t@@@std@@QAEXPAVnumber_t@@@Z',
- u'void terminate(void)': u'?terminate@@YAXXZ'}
+ u'void terminate(void)': u'?terminate@@YAXXZ'
+}
+
+
+ddd
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 22:22:10
|
Revision: 1498
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1498&view=rev
Author: roman_yakovenko
Date: 2008-12-24 21:48:48 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
adding initial test for ctypes builder
Modified Paths:
--------------
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/ctypes_pof_tester.py
pyplusplus_dev/unittests/data/ctypes_pof/
pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp
pyplusplus_dev/unittests/data/ctypes_pof/mydll.h
pyplusplus_dev/unittests/data/ctypes_pof/mydll.vcproj
Added: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py (rev 0)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2008-12-24 21:48:48 UTC (rev 1498)
@@ -0,0 +1,33 @@
+# 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 sys
+import ctypes
+import unittest
+import autoconfig
+from pyplusplus.module_builder import ctypes_module_builder_t
+
+class tester_t(unittest.TestCase):
+ def __init__( self, *args, **keywd ):
+ unittest.TestCase.__init__( self, *args, **keywd )
+ self.project_dir = os.path.join( autoconfig.data_directory, 'ctypes_pof' )
+ self.header = os.path.join( self.project_dir, 'mydll.h' )
+ self.symbols_file = os.path.join( self.project_dir, 'release', 'mydll.dll' )
+
+ def test(self):
+ mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ if 'win' in sys.platform:
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Added: pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp 2008-12-24 21:48:48 UTC (rev 1498)
@@ -0,0 +1,59 @@
+#include "mydll.h"
+#include "windows.h"
+#include <iostream>
+
+number_t::number_t()
+: m_value(0)
+{
+// std::cout << "{C++} number_t( 0 )" << std::endl;
+}
+
+
+number_t::number_t(int value)
+: m_value(value)
+{
+// std::cout << "{C++} number_t( " << value << " )" << std::endl;
+}
+
+number_t::~number_t() {
+// std::cout << "{C++} ~number_t()" << std::endl;
+}
+void number_t::print_it() const {
+ std::cout << "{C++} value: " << m_value << std::endl;
+}
+
+int number_t::get_value() const{
+ return m_value;
+}
+
+void number_t::set_value(int x){
+ m_value = x;
+}
+
+number_t number_t::clone() const{
+ return number_t(*this);
+}
+
+std::auto_ptr<number_t> number_t::clone_ptr() const{
+ return std::auto_ptr<number_t>( new number_t( *this ) );
+}
+
+void do_smth( number_aptr_t& ){
+}
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
Added: pyplusplus_dev/unittests/data/ctypes_pof/mydll.h
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.h (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.h 2008-12-24 21:48:48 UTC (rev 1498)
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <memory>
+
+class __declspec(dllexport) number_t{
+public:
+ number_t();
+ explicit number_t(int value);
+ virtual ~number_t();
+ void print_it() const;
+ int get_value() const;
+ int get_value(){ return m_value; }
+ void set_value(int x);
+
+ number_t clone() const;
+ std::auto_ptr<number_t> clone_ptr() const;
+private:
+ int m_value;
+};
+
+template class __declspec(dllexport) std::auto_ptr< number_t >;
+
+typedef std::auto_ptr< number_t > number_aptr_t;
+
+void __declspec(dllexport) do_smth( number_aptr_t& );
\ No newline at end of file
Added: pyplusplus_dev/unittests/data/ctypes_pof/mydll.vcproj
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.vcproj (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.vcproj 2008-12-24 21:48:48 UTC (rev 1498)
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mydll"
+ ProjectGUID="{E7A34C45-534F-43A6-AF95-3CA2428619E2}"
+ RootNamespace="mydll"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MYDLL_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MYDLL_EXPORTS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapExports="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\mydll.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mydll.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2008-12-24 21:22:12 UTC (rev 1497)
+++ pyplusplus_dev/unittests/test_all.py 2008-12-24 21:48:48 UTC (rev 1498)
@@ -110,6 +110,7 @@
import cp_return_addressof_tester
import make_constructor_tester
import return_auto_ptr_tester
+import ctypes_pof_tester
#import ogre_generate_tester
testers = [
@@ -208,6 +209,7 @@
, make_constructor_tester
, return_auto_ptr_tester
, protected_bug_tester
+ , ctypes_pof_tester
# , ogre_generate_tester too much time
]
@@ -306,7 +308,11 @@
def __call__( self ):
start_time = time.time()
- [ m() for m in self.__m_runners ]
+ for index, tester in enumerate( self.__m_runners ):
+ print '\n\n{[<@>]}running tests complition: %d%%' % int( index * 100.0 // len(self.__m_runners) )
+ print '--------------------------------^^^^^\n\n'
+ ( index, len(self.__m_runners) )
+ tester()
self.__total_time = time.time() - start_time
self.__dump_statistics()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 21:22:15
|
Revision: 1497
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1497&view=rev
Author: roman_yakovenko
Date: 2008-12-24 21:22:12 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
adding new builder
Added Paths:
-----------
pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
Added: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py (rev 0)
+++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2008-12-24 21:22:12 UTC (rev 1497)
@@ -0,0 +1,131 @@
+# 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 sys
+import time
+import types
+import warnings
+import module_builder
+
+from pygccxml import msvc
+from pygccxml import parser
+from pygccxml import declarations as decls_package
+
+from pyplusplus import utils
+from pyplusplus import _logging_
+from pyplusplus import decl_wrappers
+from pyplusplus import file_writers
+from pyplusplus import code_creators
+from pyplusplus import creators_factory
+
+class ctypes_module_builder_t(module_builder.module_builder_t):
+ """
+ This class provides users with simple and intuitive interface to Py++
+ and/or pygccxml functionality. If this is your first attempt to use Py++
+ consider to read tutorials. You can find them on U{web site<http://www.language-binding.net>}.
+ """
+ def __init__( self
+ , files
+ , exported_symbols_file
+ , gccxml_config=None
+ , optimize_queries=True
+ , 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
+
+ @param gccxml_path: path to gccxml binary. If you don't pass this argument,
+ pygccxml parser will try to locate it using you environment PATH variable
+ @type gccxml_path: str
+
+ @param include_paths: additional header files location. You don't have to
+ specify system and standard directories.
+ @type include_paths: list of strings
+
+ @param define_symbols: list of symbols to be defined for preprocessor.
+ @param define_symbols: list of strings
+
+ @param undefine_symbols: list of symbols to be undefined for preprocessor.
+ @param undefine_symbols: list of strings
+
+ @param cflags: Raw string to be added to gccxml command line.
+ """
+ module_builder.module_builder_t.__init__( self, global_ns=None, encoding=encoding )
+
+ self.__blob2undecorated = msvc.exported_symbols.load_from_file( exported_symbols_file )
+ self.global_ns = self.__parse_declarations( files, gccxml_config )
+ self.__include_declarations()
+
+ self.__code_creator = None
+ if optimize_queries:
+ self.run_query_optimizer()
+
+ def __parse_declarations( self, files, gccxml_config, compilation_mode=None, cache=None ):
+ if None is gccxml_config:
+ gccxml_config = parser.config_t()
+ if None is compilation_mode:
+ compilation_mode = parser.COMPILATION_MODE.FILE_BY_FILE
+ start_time = time.clock()
+ self.logger.debug( 'parsing files - started' )
+ reader = parser.project_reader_t( gccxml_config, cache, decl_wrappers.dwfactory_t() )
+ decls = reader.read_files( files, compilation_mode )
+
+ self.logger.debug( 'parsing files - done( %f seconds )' % ( time.clock() - start_time ) )
+
+ return decls_package.matcher.get_single( decls_package.namespace_matcher_t( name='::' )
+ , decls )
+
+ def __include_declarations( self ):
+ self.global_ns.exclude()
+ undecorated = set( self.__blob2undecorated.values() )
+ is_exported = lambda d: msvc.undecorate_decl( d ) in undecorated
+
+ included_decls = set()
+ included_decls.update( self.global_ns.calldefs( is_exported, allow_empty=True ) )
+ included_decls.update( self.global_ns.variables( is_exported, allow_empty=True ) )
+
+ for d in included_decls:
+ d.include()
+ if isinstance( d, decls_package.class_t ):
+ d.parent.include()
+
+ def build_code_creator( self ):
+ pass
+ #~ creator = creators_factory.creator_t( self.global_ns
+ #~ , module_name
+ #~ , boost_python_ns_name
+ #~ , call_policies_resolver_
+ #~ , types_db
+ #~ , target_configuration
+ #~ , enable_indexing_suite
+ #~ , doc_extractor)
+ #~ self.__code_creator = creator.create()
+ #~ return self.__code_creator
+
+ @property
+ def code_creator( self ):
+ "reference to L{code_creators.module_t} instance"
+ if not self.__code_creator:
+ raise RuntimeError( "self.module is equal to None. Did you forget to call build_code_creator function?" )
+ return self.__code_creator
+
+ def has_code_creator( self ):
+ """
+ Function, that will return True if build_code_creator function has been
+ called and False otherwise
+ """
+ return not ( None is self.__code_creator )
+
+ def write_module( self, file_name ):
+ """
+ Writes module to single file
+ @param file_name: file name
+ @type file_name: string
+ """
+ self.__merge_user_code()
+ file_writers.write_file( self.code_creator, file_name, encoding=self.encoding )
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 21:08:39
|
Revision: 1496
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1496&view=rev
Author: roman_yakovenko
Date: 2008-12-24 21:08:35 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
rename module_creator to creators_factory
Modified Paths:
--------------
pyplusplus_dev/docs/documentation/architecture.rest
pyplusplus_dev/docs/documentation/functions/registration_order.rest
pyplusplus_dev/pyplusplus/__init__.py
pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
pyplusplus_dev/setup.py
pyplusplus_dev/unittests/algorithms_tester.py
pyplusplus_dev/unittests/declarations_order_bug_tester.py
pyplusplus_dev/unittests/exposed_decls_db_tester.py
pyplusplus_dev/unittests/finalizables_tester.py
pyplusplus_dev/unittests/module_properties_tester.py
pyplusplus_dev/unittests/ogre_generate_tester.py
pyplusplus_dev/unittests/particle_universe_generate_tester.py
pyplusplus_dev/unittests/unicode_bug.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/creators_factory/
Removed Paths:
-------------
pyplusplus_dev/pyplusplus/module_creator/
Modified: pyplusplus_dev/docs/documentation/architecture.rest
===================================================================
--- pyplusplus_dev/docs/documentation/architecture.rest 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/docs/documentation/architecture.rest 2008-12-24 21:08:35 UTC (rev 1496)
@@ -265,8 +265,8 @@
``Code creators tree`` construction
-----------------------------------
-``pyplusplus.module_creator`` package is responsible for the tree construction.
-``pyplusplus.module_creator.creator_t`` is the main class of the package. It
+``pyplusplus.creators_factory`` package is responsible for the tree construction.
+``pyplusplus.creators_factory.creator_t`` is the main class of the package. It
creates the tree in few steps:
1. It builds set of exposed declarations.
Modified: pyplusplus_dev/docs/documentation/functions/registration_order.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/registration_order.rest 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/docs/documentation/functions/registration_order.rest 2008-12-24 21:08:35 UTC (rev 1496)
@@ -110,7 +110,7 @@
.. code-block:: Python
- from pyplusplus.module_creator import sort_algorithms
+ from pyplusplus.creators_factory import sort_algorithms
sort_algorithms.USE_CALLDEF_ORGANIZER = True
# The functionality is available from version 0.8.3
Modified: pyplusplus_dev/pyplusplus/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/__init__.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/pyplusplus/__init__.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -25,7 +25,7 @@
import code_creators
import file_writers
-import module_creator
+import creators_factory
import code_repository
import utils
import decl_wrappers
Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -18,7 +18,7 @@
from pyplusplus import decl_wrappers
from pyplusplus import file_writers
from pyplusplus import code_creators
-from pyplusplus import module_creator as mcreator_package
+from pyplusplus import creators_factory
class builder_t(module_builder.module_builder_t):
"""
@@ -165,7 +165,7 @@
def __apply_decls_defaults(self, decls):
flatten_decls = decls_package.make_flatten( decls )
self.__filter_by_location( flatten_decls )
- call_policies_resolver = mcreator_package.built_in_resolver_t()
+ call_policies_resolver = creators_factory.built_in_resolver_t()
calldefs = filter( lambda decl: isinstance( decl, decls_package.calldef_t )
, flatten_decls )
map( lambda calldef: calldef.set_call_policies( call_policies_resolver( calldef ) )
@@ -234,7 +234,7 @@
self.global_ns.constructors(allow_empty=True).allow_implicit_conversion = False
- creator = mcreator_package.creator_t( self.global_ns
+ creator = creators_factory.creator_t( self.global_ns
, module_name
, boost_python_ns_name
, call_policies_resolver_
Modified: pyplusplus_dev/setup.py
===================================================================
--- pyplusplus_dev/setup.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/setup.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -100,7 +100,7 @@
packages=[ 'pyplusplus',
'pyplusplus.file_writers',
'pyplusplus.code_creators',
- 'pyplusplus.module_creator',
+ 'pyplusplus.creators_factory',
'pyplusplus.code_repository',
'pyplusplus.decl_wrappers',
'pyplusplus.module_builder',
Modified: pyplusplus_dev/unittests/algorithms_tester.py
===================================================================
--- pyplusplus_dev/unittests/algorithms_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/algorithms_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -11,7 +11,7 @@
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import code_creators
-from pyplusplus import module_creator
+from pyplusplus import creators_factory
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft
@@ -85,7 +85,7 @@
global_ns = parser.parse_string( os.linesep.join( code ), config )
decls = global_ns[0].declarations
- dorder = module_creator.findout_desired_order( decls )
+ dorder = creators_factory.findout_desired_order( decls )
self.failUnless( len( code ) == len( dorder ), 'all classes should stay within the list' )
for i in range( 1, len(dorder) ):
bases = set( self._findout_base_classes( dorder[i] ) )
Modified: pyplusplus_dev/unittests/declarations_order_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/declarations_order_bug_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/declarations_order_bug_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -8,7 +8,7 @@
import unittest
import fundamental_tester_base
from pyplusplus.module_builder import call_policies
-from pyplusplus.module_creator import sort_algorithms
+from pyplusplus.creators_factory import sort_algorithms
class tester_base_t(fundamental_tester_base.fundamental_tester_base_t):
def __init__( self, name, *args ):
Modified: pyplusplus_dev/unittests/exposed_decls_db_tester.py
===================================================================
--- pyplusplus_dev/unittests/exposed_decls_db_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/exposed_decls_db_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -12,7 +12,7 @@
from pygccxml import declarations
from pyplusplus import decl_wrappers
from pyplusplus import code_creators
-from pyplusplus import module_creator
+from pyplusplus import creators_factory
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft
Modified: pyplusplus_dev/unittests/finalizables_tester.py
===================================================================
--- pyplusplus_dev/unittests/finalizables_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/finalizables_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -24,23 +24,23 @@
find = code_creators.creator_finder.find_by_declaration_single
matcher = declarations.match_declaration_t( name='year'
, type=declarations.member_function_t)
- found = find( matcher, mb.module_creator.body.creators )
+ found = find( matcher, mb.code_creator.body.creators )
self.failUnless( found )
self.failUnless( found.is_finalizable() )
found.finalize()
#from now should be only one instances that references year function
- found = find( matcher, mb.module_creator.creators )
+ found = find( matcher, mb.code_creator.creators )
self.failUnless( found )
self.failUnless( not found.is_finalizable() )
matcher = declarations.match_declaration_t( name='whole_class_t'
, type=declarations.class_t)
- found = find( matcher, mb.module_creator.body.creators )
+ found = find( matcher, mb.code_creator.body.creators )
self.failUnless( found )
self.failUnless( found.is_finalizable() )
found.finalize()
#from now should be only one instances that references whole_class_t class
- found = find( matcher, mb.module_creator.creators )
+ found = find( matcher, mb.code_creator.creators )
self.failUnless( found )
self.failUnless( not found.is_finalizable() )
except:
Modified: pyplusplus_dev/unittests/module_properties_tester.py
===================================================================
--- pyplusplus_dev/unittests/module_properties_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/module_properties_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -8,7 +8,7 @@
import unittest
import autoconfig
from pyplusplus import code_creators
-from pyplusplus import module_creator
+from pyplusplus import creators_factory
class tester_t(unittest.TestCase):
def __init__(self, *args ):
Modified: pyplusplus_dev/unittests/ogre_generate_tester.py
===================================================================
--- pyplusplus_dev/unittests/ogre_generate_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/ogre_generate_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -13,7 +13,7 @@
from pygccxml import declarations
from pyplusplus import messages
from pyplusplus import code_creators
-from pyplusplus import module_creator
+from pyplusplus import creators_factory
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft
Modified: pyplusplus_dev/unittests/particle_universe_generate_tester.py
===================================================================
--- pyplusplus_dev/unittests/particle_universe_generate_tester.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/particle_universe_generate_tester.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -13,7 +13,7 @@
from pygccxml import declarations
from pyplusplus import messages
from pyplusplus import code_creators
-from pyplusplus import module_creator
+from pyplusplus import creators_factory
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft
Modified: pyplusplus_dev/unittests/unicode_bug.py
===================================================================
--- pyplusplus_dev/unittests/unicode_bug.py 2008-12-24 20:57:21 UTC (rev 1495)
+++ pyplusplus_dev/unittests/unicode_bug.py 2008-12-24 21:08:35 UTC (rev 1496)
@@ -7,7 +7,7 @@
from pygccxml import parser
from pygccxml import declarations
from pyplusplus import code_creators
-from pyplusplus import module_creator
+from pyplusplus import creators_factory
from pyplusplus import module_builder
from pyplusplus import utils as pypp_utils
from pyplusplus import function_transformers as ft
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 20:57:25
|
Revision: 1495
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1495&view=rev
Author: roman_yakovenko
Date: 2008-12-24 20:57:21 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
making more room for new module builder
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/module_builder/__init__.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
pyplusplus_dev/pyplusplus/module_builder/module_builder.py
Removed Paths:
-------------
pyplusplus_dev/pyplusplus/module_builder/builder.py
pyplusplus_dev/pyplusplus/module_builder/extension_builder.py
Modified: pyplusplus_dev/pyplusplus/module_builder/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/__init__.py 2008-12-24 20:47:08 UTC (rev 1494)
+++ pyplusplus_dev/pyplusplus/module_builder/__init__.py 2008-12-24 20:57:21 UTC (rev 1495)
@@ -12,7 +12,7 @@
U{web site<http://www.language-binding.net>}
"""
-from extension_builder import extension_module_builder_t as module_builder_t
+from boost_python_builder import builder_t as module_builder_t
from ctypes_builder import ctypes_module_builder_t
#aliases for functionality located in pygccxml.parser module
Copied: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py (from rev 1494, pyplusplus_dev/pyplusplus/module_builder/extension_builder.py)
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py (rev 0)
+++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2008-12-24 20:57:21 UTC (rev 1495)
@@ -0,0 +1,418 @@
+# 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 sys
+import time
+import types
+import warnings
+import module_builder
+
+from pygccxml import parser
+from pygccxml import declarations as decls_package
+
+from pyplusplus import utils
+from pyplusplus import _logging_
+from pyplusplus import decl_wrappers
+from pyplusplus import file_writers
+from pyplusplus import code_creators
+from pyplusplus import module_creator as mcreator_package
+
+class builder_t(module_builder.module_builder_t):
+ """
+ This class provides users with simple and intuitive interface to Py++
+ and/or pygccxml functionality. If this is your first attempt to use Py++
+ consider to read tutorials. You can find them on U{web site<http://www.language-binding.net>}.
+ """
+
+ def __init__( self
+ , files
+ , gccxml_path=''
+ , working_directory='.'
+ , include_paths=None
+ , define_symbols=None
+ , undefine_symbols=None
+ , start_with_declarations=None
+ , compilation_mode=None
+ , cache=None
+ , optimize_queries=True
+ , ignore_gccxml_output=False
+ , indexing_suite_version=1
+ , cflags=""
+ , encoding='ascii'
+ , compiler=None):
+ """
+ @param files: list of files, declarations from them you want to export
+ @type files: list of strings or L{file_configuration_t} instances
+
+ @param gccxml_path: path to gccxml binary. If you don't pass this argument,
+ pygccxml parser will try to locate it using you environment PATH variable
+ @type gccxml_path: str
+
+ @param include_paths: additional header files location. You don't have to
+ specify system and standard directories.
+ @type include_paths: list of strings
+
+ @param define_symbols: list of symbols to be defined for preprocessor.
+ @param define_symbols: list of strings
+
+ @param undefine_symbols: list of symbols to be undefined for preprocessor.
+ @param undefine_symbols: list of strings
+
+ @param cflags: Raw string to be added to gccxml command line.
+ """
+ module_builder.module_builder_t.__init__( self, global_ns=None, encoding=encoding )
+
+ gccxml_config = parser.config_t( gccxml_path=gccxml_path
+ , working_directory=working_directory
+ , include_paths=include_paths
+ , define_symbols=define_symbols
+ , undefine_symbols=undefine_symbols
+ , start_with_declarations=start_with_declarations
+ , ignore_gccxml_output=ignore_gccxml_output
+ , cflags=cflags
+ , 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
+ , 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 )
+
+ self.global_ns = self.__parse_declarations( files
+ , gccxml_config
+ , compilation_mode
+ , cache
+ , indexing_suite_version)
+ self.__code_creator = None
+ if optimize_queries:
+ self.run_query_optimizer()
+
+ self.__declarations_code_head = []
+ self.__declarations_code_tail = []
+
+ self.__registrations_code_head = []
+ self.__registrations_code_tail = []
+
+
+
+ def register_module_dependency( self, other_module_generated_code_dir ):
+ """``already_exposed`` solution is pretty good when you mix hand-written
+ modules with Py++ generated. It doesn't work/scale for "true"
+ multi-module development. This is exactly the reason why ``Py++``_
+ offers "semi automatic" solution.
+
+ For every exposed module, ``Py++``_ generates "exposed_decl.pypp.txt" file.
+ This file contains the list of all parsed declarations and whether they
+ were included or excluded. Later, when you work on another module, you
+ can tell ``Py++``_ that the current module depends on the previously
+ generated one. ``Py++``_ will load "exposed_decl.pypp.txt" file and
+ update the declarations.
+ """
+
+ db = utils.exposed_decls_db_t()
+ db.load( other_module_generated_code_dir )
+ db.update_decls( self.global_ns )
+
+
+ def __parse_declarations( self, files, gccxml_config, compilation_mode, cache, indexing_suite_version ):
+ if None is gccxml_config:
+ gccxml_config = parser.config_t()
+ if None is compilation_mode:
+ compilation_mode = parser.COMPILATION_MODE.FILE_BY_FILE
+ start_time = time.clock()
+ self.logger.debug( 'parsing files - started' )
+ reader = parser.project_reader_t( gccxml_config, cache, decl_wrappers.dwfactory_t() )
+ decls = reader.read_files( files, compilation_mode )
+
+ self.logger.debug( 'parsing files - done( %f seconds )' % ( time.clock() - start_time ) )
+ self.logger.debug( 'settings declarations defaults - started' )
+
+ global_ns = decls_package.matcher.get_single(
+ decls_package.namespace_matcher_t( name='::' )
+ , decls )
+ if indexing_suite_version != 1:
+ for cls in global_ns.classes():
+ cls.indexing_suite_version = indexing_suite_version
+ for cls in global_ns.decls(decl_type=decls_package.class_declaration_t):
+ cls.indexing_suite_version = indexing_suite_version
+
+ start_time = time.clock()
+ self.__apply_decls_defaults(decls)
+ self.logger.debug( 'settings declarations defaults - done( %f seconds )'
+ % ( time.clock() - start_time ) )
+ return global_ns
+
+ def __filter_by_location( self, flatten_decls ):
+ 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 ):
+ continue
+ if fpath in self.__parsed_files:
+ continue
+ found = False
+ for pfile in self.__parsed_files:
+ if fpath.endswith( pfile ):
+ found = True
+ break
+ if not found:
+ decl.exclude()
+
+ def __apply_decls_defaults(self, decls):
+ flatten_decls = decls_package.make_flatten( decls )
+ self.__filter_by_location( flatten_decls )
+ call_policies_resolver = mcreator_package.built_in_resolver_t()
+ calldefs = filter( lambda decl: isinstance( decl, decls_package.calldef_t )
+ , flatten_decls )
+ map( lambda calldef: calldef.set_call_policies( call_policies_resolver( calldef ) )
+ , calldefs )
+ mem_vars = filter( lambda decl: isinstance( decl, decls_package.variable_t )
+ and isinstance( decl.parent, decls_package.class_t )
+ , flatten_decls )
+ map( lambda mem_var: mem_var.set_getter_call_policies( call_policies_resolver( mem_var, 'get' ) )
+ , mem_vars )
+ map( lambda mem_var: mem_var.set_setter_call_policies( call_policies_resolver( mem_var, 'set' ) )
+ , mem_vars )
+
+ @property
+ def declarations_code_head( self ):
+ "List of user code, that will be added to the head of the declarations section."
+ return self.__declarations_code_head
+
+ @property
+ def declarations_code_tail( self ):
+ "List of user code, that will be added to the tail of the declarations section."
+ return self.__declarations_code_tail
+
+ @property
+ def registrations_code_head( self ):
+ "List of user code, that will be added to the head of the registrations section."
+ return self.__registrations_code_head
+
+ @property
+ def registrations_code_tail( self ):
+ "List of user code, that will be added to the tail of the registrations section."
+ return self.__registrations_code_tail
+
+ 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
+ , enable_indexing_suite=True
+ , doc_extractor=None):
+ """
+ Creates L{module_t} code creator.
+
+ @param module_name: module name
+ @type module_name: string
+
+ @param boost_python_ns_name: boost::python namespace alias, by default
+ it is 'bp'
+ @type boost_python_ns_name: string
+
+ @param call_policies_resolver_: callable, that will be invoked on every
+ calldef object. It should return call policies.
+ @type call_policies_resolver_: callable
+ @param doc_extractor: callable, that takes as argument reference to declaration
+ 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 = mcreator_package.creator_t( self.global_ns
+ , module_name
+ , boost_python_ns_name
+ , call_policies_resolver_
+ , types_db
+ , target_configuration
+ , enable_indexing_suite
+ , doc_extractor)
+ self.__code_creator = creator.create()
+ self.__code_creator.replace_included_headers(self.__parsed_files)
+ return self.__code_creator
+
+ @property
+ def code_creator( self ):
+ "reference to L{code_creators.module_t} instance"
+ if not self.__code_creator:
+ raise RuntimeError( "self.module is equal to None. Did you forget to call build_code_creator function?" )
+ return self.__code_creator
+
+ def has_code_creator( self ):
+ """
+ Function, that will return True if build_code_creator function has been
+ called and False otherwise
+ """
+ return not ( None is self.__code_creator )
+
+ def add_declaration_code( self, code, tail=True ):
+ if tail:
+ self.__declarations_code_tail.append( code )
+ else:
+ self.__declarations_code_head.append( code )
+
+ def add_registration_code( self, code, tail=True ):
+ if tail:
+ self.__registrations_code_tail.append( code )
+ else:
+ self.__registrations_code_head.append( code )
+
+ def add_constants( self, **keywds ):
+ """adds code that exposes some constants to Python.
+
+ For example:
+ mb.add_constants( version='"1.2.3"' )
+ or
+ mb.add_constants( **{ version:'"1.2.3"' } )
+ will generate next code:
+ boost::python::scope().attr("version") = "1.2.3";
+ """
+ tmpl = 'boost::python::scope().attr("%(name)s") = %(value)s;'
+ for name, value in keywds.items():
+ if not isinstance( value, types.StringTypes ):
+ value = str( value )
+ self.add_registration_code( tmpl % dict( name=name, value=value) )
+
+
+ def __merge_user_code( self ):
+ for code in self.__declarations_code_tail:
+ self.code_creator.add_declaration_code( code, -1 )
+
+ for code in self.__declarations_code_head:
+ self.code_creator.add_declaration_code( code, 0 )
+
+ body = self.code_creator.body
+
+ for code in self.__registrations_code_tail:
+ body.adopt_creator( code_creators.custom_text_t( code ), -1 )
+
+ for code in self.__registrations_code_head:
+ body.adopt_creator( code_creators.custom_text_t( code ), 0 )
+
+
+ def write_module( self, file_name ):
+ """
+ Writes module to single file
+ @param file_name: file name
+ @type file_name: string
+ """
+ self.__merge_user_code()
+ file_writers.write_file( self.code_creator, file_name, encoding=self.encoding )
+
+ def __work_on_unused_files( self, dir_name, written_files, on_unused_file_found ):
+ all_files = os.listdir( dir_name )
+ all_files = map( lambda fname: os.path.join( dir_name, fname ), all_files )
+ all_files = filter( file_writers.has_pypp_extenstion, all_files )
+
+ unused_files = set( all_files ).difference( set( written_files ) )
+ for fpath in unused_files:
+ try:
+ if on_unused_file_found is os.remove:
+ self.logger.info( 'removing file "%s"' % fpath )
+ on_unused_file_found( fpath )
+ except Exception, error:
+ self.logger.exception( "Exception was catched, while executing 'on_unused_file_found' function." )
+
+ def split_module( self
+ , dir_name
+ , huge_classes=None
+ , on_unused_file_found=os.remove
+ , use_files_sum_repository=False):
+ """
+ Writes module to multiple files
+
+ @param dir_name: directory name
+ @type dir_name: string
+
+ @param huge_classes: list that contains reference to classes, that should be split
+
+ @param on_unused_file_found: callable object that represents the action that should be taken on
+ file, which is no more in use
+
+ @use_files_sum_repository: Py++ can generate file, which will contain md5 sum of every generated file.
+ Next time you generate code, md5sum will be loaded from the file and compared.
+ This could speed-up code generation process by 10-15%.
+ """
+ self.__merge_user_code()
+
+ files_sum_repository = None
+ if use_files_sum_repository:
+ cache_file = os.path.join( dir_name, self.code_creator.body.name + '.md5.sum' )
+ files_sum_repository = file_writers.cached_repository_t( cache_file )
+
+ written_files = []
+ if None is huge_classes:
+ written_files = file_writers.write_multiple_files(
+ self.code_creator
+ , dir_name
+ , 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
+ , encoding=self.encoding)
+ self.__work_on_unused_files( dir_name, written_files, on_unused_file_found )
+
+ return written_files
+
+ def balanced_split_module( self
+ , dir_name
+ , number_of_files
+ , on_unused_file_found=os.remove
+ , use_files_sum_repository=False):
+ """
+ Writes module to fixed number of multiple cpp files
+
+ @param number_of_files: the desired number of generated cpp files
+ @type number_of_files: int
+
+ @param dir_name: directory name
+ @type dir_name: string
+
+ @param on_unused_file_found: callable object that represents the action that should be taken on
+ file, which is no more in use
+
+ @use_files_sum_repository: Py++ can generate file, which will contain md5 sum of every generated file.
+ Next time you generate code, md5sum will be loaded from the file and compared.
+ This could speed-up code generation process by 10-15%.
+ """
+ self.__merge_user_code()
+
+ files_sum_repository = None
+ if use_files_sum_repository:
+ cache_file = os.path.join( dir_name, self.code_creator.body.name + '.md5.sum' )
+ files_sum_repository = file_writers.cached_repository_t( cache_file )
+
+ written_files = file_writers.write_balanced_files( self.code_creator
+ , dir_name
+ , number_of_buckets=number_of_files
+ , files_sum_repository=files_sum_repository
+ , encoding=self.encoding)
+
+ self.__work_on_unused_files( dir_name, written_files, on_unused_file_found )
+
+ return written_files
+
+ def _get_BOOST_PYTHON_MAX_ARITY( self ):
+ return decl_wrappers.calldef_t.BOOST_PYTHON_MAX_ARITY
+ def _set_BOOST_PYTHON_MAX_ARITY( self, value ):
+ decl_wrappers.calldef_t.BOOST_PYTHON_MAX_ARITY = value
+ BOOST_PYTHON_MAX_ARITY = property( _get_BOOST_PYTHON_MAX_ARITY, _set_BOOST_PYTHON_MAX_ARITY )
Deleted: pyplusplus_dev/pyplusplus/module_builder/builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/builder.py 2008-12-24 20:47:08 UTC (rev 1494)
+++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2008-12-24 20:57:21 UTC (rev 1495)
@@ -1,311 +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 sys
-
-from pyplusplus import _logging_
-from pyplusplus import decl_wrappers
-
-class base_builder_t(object):
- """
- """
-
- def __init__( self, global_ns=None, encoding='ascii' ):
- """
- """
- object.__init__( self )
- self.logger = _logging_.loggers.module_builder
- self.__encoding = encoding
- self.__global_ns = global_ns
-
- def __get_global_ns( self ):
- if not self.__global_ns:
- raise RuntimeError( "Reference to global namespace declaration was not set." )
- return self.__global_ns
- def __set_global_ns( self, global_ns ):
- self.__global_ns = global_ns
-
- global_ns = property( __get_global_ns, __set_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
- this is done from __init__ method. But there are use-case, when you need
- to disable optimizer at __init__ and run it later.
- """
- self.global_ns.init_optimizer()
-
- def print_declarations(self, decl=None, detailed=True, recursive=True, writer=sys.stdout.write):
- """
- This function will print detailed description of all declarations or
- some specific one.
-
- @param decl: optional, if passed, then only it will be printed
- @type decl: instance of L{decl_wrappers.decl_wrapper_t} class
- """
- if None is decl:
- decl = self.global_ns
- decl_wrappers.print_declarations( decl, detailed, recursive, writer )
-
- #select decl(s) interfaces
- def decl( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.decl( name=name
- , function=function
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def decls( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.decls( name=name
- , function=function
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def class_( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.class_( name=name
- , function=function
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def classes( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.classes( name=name
- , function=function
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def variable( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.variable( name=name
- , function=function
- , type=type
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
- var = variable
-
- def variables( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.variables( name=name
- , function=function
- , type=type
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
- vars = variables
-
- def calldef( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.calldef( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def calldefs( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.calldefs( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def operator( self, name=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.operator( name=name
- , symbol=symbol
- , decl_type=decl_type
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def operators( self, name=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.operators( name=name
- , symbol=symbol
- , decl_type=decl_type
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def member_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.member_function( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
- mem_fun = member_function
-
- def member_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.member_functions( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- mem_funs = member_functions
-
- def constructor( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.constructor( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def constructors( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.constructors( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def member_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.member_operator( name=name
- , symbol=symbol
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def member_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.member_operators( name=name
- , symbol=symbol
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def casting_operator( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.casting_operator( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def casting_operators( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.casting_operators( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- def enumeration( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.enumeration( name=name
- , function=function
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
- enum = enumeration
-
- def enumerations( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.scopedef_t} class documentation"""
- return self.global_ns.enumerations( name=name
- , function=function
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
-
- enums = enumerations
-
- def namespace( self, name=None, function=None, recursive=None ):
- """Please see L{decl_wrappers.namespace_t} class documentation"""
- return self.global_ns.namespace( name=name
- , function=function
- , recursive=recursive )
-
- def namespaces( self, name=None, function=None, recursive=None ):
- """Please see L{decl_wrappers.namespace_t} class documentation"""
- return self.global_ns.namespaces( name=name
- , function=function
- , recursive=recursive )
-
- def free_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.namespace_t} class documentation"""
- return self.global_ns.free_function( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
- free_fun = free_function
-
- def free_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.namespace_t} class documentation"""
- return self.global_ns.free_functions( name=name
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive)
- free_funs = free_functions
-
- def free_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.namespace_t} class documentation"""
- return self.global_ns.free_operator( name=name
- , symbol=symbol
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
-
- def free_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ):
- """Please see L{decl_wrappers.namespace_t} class documentation"""
- return self.global_ns.free_operators( name=name
- , symbol=symbol
- , function=function
- , return_type=return_type
- , arg_types=arg_types
- , header_dir=header_dir
- , header_file=header_file
- , recursive=recursive )
Deleted: pyplusplus_dev/pyplusplus/module_builder/extension_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/extension_builder.py 2008-12-24 20:47:08 UTC (rev 1494)
+++ pyplusplus_dev/pyplusplus/module_builder/extension_builder.py 2008-12-24 20:57:21 UTC (rev 1495)
@@ -1,418 +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 sys
-import time
-import types
-import builder
-import warnings
-
-from pygccxml import parser
-from pygccxml import declarations as decls_package
-
-from pyplusplus import utils
-from pyplusplus import _logging_
-from pyplusplus import decl_wrappers
-from pyplusplus import file_writers
-from pyplusplus import code_creators
-from pyplusplus import module_creator as mcreator_package
-
-class extension_module_builder_t(builder.base_builder_t):
- """
- This class provides users with simple and intuitive interface to Py++
- and/or pygccxml functionality. If this is your first attempt to use Py++
- consider to read tutorials. You can find them on U{web site<http://www.language-binding.net>}.
- """
-
- def __init__( self
- , files
- , gccxml_path=''
- , working_directory='.'
- , include_paths=None
- , define_symbols=None
- , undefine_symbols=None
- , start_with_declarations=None
- , compilation_mode=None
- , cache=None
- , optimize_queries=True
- , ignore_gccxml_output=False
- , indexing_suite_version=1
- , cflags=""
- , encoding='ascii'
- , compiler=None):
- """
- @param files: list of files, declarations from them you want to export
- @type files: list of strings or L{file_configuration_t} instances
-
- @param gccxml_path: path to gccxml binary. If you don't pass this argument,
- pygccxml parser will try to locate it using you environment PATH variable
- @type gccxml_path: str
-
- @param include_paths: additional header files location. You don't have to
- specify system and standard directories.
- @type include_paths: list of strings
-
- @param define_symbols: list of symbols to be defined for preprocessor.
- @param define_symbols: list of strings
-
- @param undefine_symbols: list of symbols to be undefined for preprocessor.
- @param undefine_symbols: list of strings
-
- @param cflags: Raw string to be added to gccxml command line.
- """
- builder.base_builder_t.__init__( self, global_ns=None, encoding=encoding )
-
- gccxml_config = parser.config_t( gccxml_path=gccxml_path
- , working_directory=working_directory
- , include_paths=include_paths
- , define_symbols=define_symbols
- , undefine_symbols=undefine_symbols
- , start_with_declarations=start_with_declarations
- , ignore_gccxml_output=ignore_gccxml_output
- , cflags=cflags
- , 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
- , 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 )
-
- self.global_ns = self.__parse_declarations( files
- , gccxml_config
- , compilation_mode
- , cache
- , indexing_suite_version)
- self.__code_creator = None
- if optimize_queries:
- self.run_query_optimizer()
-
- self.__declarations_code_head = []
- self.__declarations_code_tail = []
-
- self.__registrations_code_head = []
- self.__registrations_code_tail = []
-
-
-
- def register_module_dependency( self, other_module_generated_code_dir ):
- """``already_exposed`` solution is pretty good when you mix hand-written
- modules with Py++ generated. It doesn't work/scale for "true"
- multi-module development. This is exactly the reason why ``Py++``_
- offers "semi automatic" solution.
-
- For every exposed module, ``Py++``_ generates "exposed_decl.pypp.txt" file.
- This file contains the list of all parsed declarations and whether they
- were included or excluded. Later, when you work on another module, you
- can tell ``Py++``_ that the current module depends on the previously
- generated one. ``Py++``_ will load "exposed_decl.pypp.txt" file and
- update the declarations.
- """
-
- db = utils.exposed_decls_db_t()
- db.load( other_module_generated_code_dir )
- db.update_decls( self.global_ns )
-
-
- def __parse_declarations( self, files, gccxml_config, compilation_mode, cache, indexing_suite_version ):
- if None is gccxml_config:
- gccxml_config = parser.config_t()
- if None is compilation_mode:
- compilation_mode = parser.COMPILATION_MODE.FILE_BY_FILE
- start_time = time.clock()
- self.logger.debug( 'parsing files - started' )
- reader = parser.project_reader_t( gccxml_config, cache, decl_wrappers.dwfactory_t() )
- decls = reader.read_files( files, compilation_mode )
-
- self.logger.debug( 'parsing files - done( %f seconds )' % ( time.clock() - start_time ) )
- self.logger.debug( 'settings declarations defaults - started' )
-
- global_ns = decls_package.matcher.get_single(
- decls_package.namespace_matcher_t( name='::' )
- , decls )
- if indexing_suite_version != 1:
- for cls in global_ns.classes():
- cls.indexing_suite_version = indexing_suite_version
- for cls in global_ns.decls(decl_type=decls_package.class_declaration_t):
- cls.indexing_suite_version = indexing_suite_version
-
- start_time = time.clock()
- self.__apply_decls_defaults(decls)
- self.logger.debug( 'settings declarations defaults - done( %f seconds )'
- % ( time.clock() - start_time ) )
- return global_ns
-
- def __filter_by_location( self, flatten_decls ):
- 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 ):
- continue
- if fpath in self.__parsed_files:
- continue
- found = False
- for pfile in self.__parsed_files:
- if fpath.endswith( pfile ):
- found = True
- break
- if not found:
- decl.exclude()
-
- def __apply_decls_defaults(self, decls):
- flatten_decls = decls_package.make_flatten( decls )
- self.__filter_by_location( flatten_decls )
- call_policies_resolver = mcreator_package.built_in_resolver_t()
- calldefs = filter( lambda decl: isinstance( decl, decls_package.calldef_t )
- , flatten_decls )
- map( lambda calldef: calldef.set_call_policies( call_policies_resolver( calldef ) )
- , calldefs )
- mem_vars = filter( lambda decl: isinstance( decl, decls_package.variable_t )
- and isinstance( decl.parent, decls_package.class_t )
- , flatten_decls )
- map( lambda mem_var: mem_var.set_getter_call_policies( call_policies_resolver( mem_var, 'get' ) )
- , mem_vars )
- map( lambda mem_var: mem_var.set_setter_call_policies( call_policies_resolver( mem_var, 'set' ) )
- , mem_vars )
-
- @property
- def declarations_code_head( self ):
- "List of user code, that will be added to the head of the declarations section."
- return self.__declarations_code_head
-
- @property
- def declarations_code_tail( self ):
- "List of user code, that will be added to the tail of the declarations section."
- return self.__declarations_code_tail
-
- @property
- def registrations_code_head( self ):
- "List of user code, that will be added to the head of the registrations section."
- return self.__registrations_code_head
-
- @property
- def registrations_code_tail( self ):
- "List of user code, that will be added to the tail of the registrations section."
- return self.__registrations_code_tail
-
- 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
- , enable_indexing_suite=True
- , doc_extractor=None):
- """
- Creates L{module_t} code creator.
-
- @param module_name: module name
- @type module_name: string
-
- @param boost_python_ns_name: boost::python namespace alias, by default
- it is 'bp'
- @type boost_python_ns_name: string
-
- @param call_policies_resolver_: callable, that will be invoked on every
- calldef object. It should return call policies.
- @type call_policies_resolver_: callable
- @param doc_extractor: callable, that takes as argument reference to declaration
- 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 = mcreator_package.creator_t( self.global_ns
- , module_name
- , boost_python_ns_name
- , call_policies_resolver_
- , types_db
- , target_configuration
- , enable_indexing_suite
- , doc_extractor)
- self.__code_creator = creator.create()
- self.__code_creator.replace_included_headers(self.__parsed_files)
- return self.__code_creator
-
- @property
- def code_creator( self ):
- "reference to L{code_creators.module_t} instance"
- if not self.__code_creator:
- raise RuntimeError( "self.module is equal to None. Did you forget to call build_code_creator function?" )
- return self.__code_creator
-
- def has_code_creator( self ):
- """
- Function, that will return True if build_code_creator function has been
- called and False otherwise
- """
- return not ( None is self.__code_creator )
-
- def add_declaration_code( self, code, tail=True ):
- if tail:
- self.__declarations_code_tail.append( code )
- else:
- self.__declarations_code_head.append( code )
-
- def add_registration_code( self, code, tail=True ):
- if tail:
- self.__registrations_code_tail.append( code )
- else:
- self.__registrations_code_head.append( code )
-
- def add_constants( self, **keywds ):
- """adds code that exposes some constants to Python.
-
- For example:
- mb.add_constants( version='"1.2.3"' )
- or
- mb.add_constants( **{ version:'"1.2.3"' } )
- will generate next code:
- boost::python::scope().attr("version") = "1.2.3";
- """
- tmpl = 'boost::python::scope().attr("%(name)s") = %(value)s;'
- for name, value in keywds.items():
- if not isinstance( value, types.StringTypes ):
- value = str( value )
- self.add_registration_code( tmpl % dict( name=name, value=value) )
-
-
- def __merge_user_code( self ):
- for code in self.__declarations_code_tail:
- self.code_creator.add_declaration_code( code, -1 )
-
- for code in self.__declarations_code_head:
- self.code_creator.add_declaration_code( code, 0 )
-
- body = self.code_creator.body
-
- for code in self.__registrations_code_tail:
- body.adopt_creator( code_creators.custom_text_t( code ), -1 )
-
- for code in self.__registrations_code_head:
- body.adopt_creator( code_creators.custom_text_t( code ), 0 )
-
-
- def write_module( self, file_name ):
- """
- Writes module to single file
- @param file_name: file name
- @type file_name: string
- """
- self.__merge_user_code()
- file_writers.write_file( self.code_creator, file_name, encoding=self.encoding )
-
- def __work_on_unused_files( self, dir_name, written_files, on_unused_file_found ):
- all_files = os.listdir( dir_name )
- all_files = map( lambda fname: os.path.join( dir_name, fname ), all_files )
- all_files = filter( file_writers.has_pypp_extenstion, all_files )
-
- unused_files = set( all_files ).difference( set( written_files ) )
- for fpath in unused_files:
- try:
- if on_unused_file_found is os.remove:
- self.logger.info( 'removing file "%s"' % fpath )
- on_unused_file_found( fpath )
- except Exception, error:
- self.logger.exception( "Exception was catched, while executing 'on_unused_file_found' function." )
-
- def split_module( self
- , dir_name
- , huge_classes=None
- , on_unused_file_found=os.remove
- , use_files_sum_repository=False):
- """
- Writes module to multiple files
-
- @param dir_name: directory name
- @type dir_name: string
-
- @param huge_classes: list that contains reference to classes, that should be split
-
- @param on_unused_file_found: callable object that represents the action that should be taken on
- file, which is no more in use
-
- @use_files_sum_repository: Py++ can generate file, which will contain md5 sum of every generated file.
- Next time you generate code, md5sum will be loaded from the file and compared.
- This could speed-up code generation process by 10-15%.
- """
- self.__merge_user_code()
-
- files_sum_repository = None
- if use_files_sum_repository:
- cache_file = os.path.join( dir_name, self.code_creator.body.name + '.md5.sum' )
- files_sum_repository = file_writers.cached_repository_t( cache_file )
-
- written_files = []
- if None is huge_classes:
- written_files = file_writers.write_multiple_files(
- self.code_creator
- , dir_name
- , 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
- , encoding=self.encoding)
- self.__work_on_unused_files( dir_name, written_files, on_unused_file_found )
-
- return written_files
-
- def balanced_split_module( self
- , dir_name
- , number_of_files
- , on_unused_file_found=os.remove
- , use_files_sum_repository=False):
- """
- Writes module to fixed number of multiple cpp files
-
- @param number_of_files: the desired number of generated cpp files
- @type number_of_files: int
-
- @param dir_name: directory name
- @type dir_name: string
-
- @param on_unused_file_found: callable object that represents the action that should be taken on
- file, which is no more in use
-
- @use_files_sum_repository: Py++ can generate file, which will contain md5 sum of every generated file.
- Next time you generate code, md5sum will be loaded from the file and compared.
- This could speed-up code generation process by 10-15%.
- """
- self.__merge_user_code()
-
- files_sum_repository = None
- if use_files_sum_repository:
- cache_file = os.path.join( dir_name, self.code_creator.body.name + '.md5.sum' )
- files_sum_repository = file_writers.cached_repository_t( cache_file )
-
- written_files = file_writers.write_balanced_files( self.code_creator
- , dir_name
- , number_of_buckets=number_of_files
- , files_sum_repository=files_sum_repository
- , encoding=self.encoding)
-
- self.__work_on_unused_files( dir_name, written_files, on_unused_file_found )
-
- return written_files
-
- def _get_BOOST_PYTHON_MAX_ARITY( self ):
- return decl_wrappers.calldef_t.BOOST_PYTHON_MAX_ARITY
- def _set_BOOST_PYTHON_MAX_ARITY( self, value ):
- decl_wrappers.calldef_t.BOOST_PYTHON_MAX_ARITY = value
- BOOST_PYTHON_MAX_ARITY = property( _get_BOOST_PYTHON_MAX_ARITY, _set_BOOST_PYTHON_MAX_ARITY )
Copied: pyplusplus_dev/pyplusplus/module_builder/module_builder.py (from rev 1494, pyplusplus_dev/pyplusplus/module_builder/builder.py)
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/module_builder.py (rev 0)
+++ pyplusplus_dev/pyplusplus/module_builder/module_builder.py 2008-12-24 20:57:21 UTC (rev 1495)
@@ -0,0 +1,310 @@
+# 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 sys
+
+from pyplusplus import _logging_
+from pyplusplus import decl_wrappers
+
+class module_builder_t(object):
+ """base class for different module builders."""
+
+ def __init__( self, global_ns=None, encoding='ascii' ):
+ """
+ """
+ object.__init__( self )
+ self.logger = _logging_.loggers.module_builder
+ self.__encoding = encoding
+ self.__global_ns = global_ns
+
+ def __get_global_ns( self ):
+ if not self.__global_ns:
+ raise RuntimeError( "Reference to global namespace declaration was not set." )
+ return self.__global_ns
+ def __set_global_ns( self, global_ns ):
+ self.__global_ns = global_ns
+
+ global_ns = property( __get_global_ns, __set_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
+ this is done from __init__ method. But there are use-case, when you need
+ to disable optimizer at __init__ and run it later.
+ """
+ self.global_ns.init_optimizer()
+
+ def print_declarations(self, decl=None, detailed=True, recursive=True, writer=sys....
[truncated message content] |
|
From: <rom...@us...> - 2008-12-24 20:47:12
|
Revision: 1494
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1494&view=rev
Author: roman_yakovenko
Date: 2008-12-24 20:47:08 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
few changes to allow introduction of new module builder class
Modified Paths:
--------------
pyplusplus_dev/environment.py
pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.cpp
pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.h
pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.vcproj
pyplusplus_dev/pyplusplus/cpptypes/mydll/release/mydll.dll
pyplusplus_dev/pyplusplus/module_builder/__init__.py
pyplusplus_dev/pyplusplus/module_builder/builder.py
pyplusplus_dev/pyplusplus/module_builder/extension_builder.py
pyplusplus_dev/unittests/autoconfig.py
Modified: pyplusplus_dev/environment.py
===================================================================
--- pyplusplus_dev/environment.py 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/environment.py 2008-12-24 20:47:08 UTC (rev 1494)
@@ -49,7 +49,19 @@
boost.libs = ['/home/roman/include/libs' ]
boost.include = '/home/roman/boost_svn'
python.include = '/usr/include/python2.5'
+elif 'root' == getpass.getuser():
+ scons.cmd_build = 'scons --file=%s'
+ scons.cmd_clean = 'scons --clean --file=%s'
+
+ if sys.platform == 'win32':
+ scons.suffix = '.pyd'
+ scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope', '-DBOOST_PYTHON_NO_PY_SIGNATURES' ]
+ boost.libs = [ 'd:/dev/boost_svn/bin.v2/libs/python/build/msvc-7.1/release/threading-multi' ]
+ boost.include = 'd:/dev/boost_svn'
+ python.libs = 'e:/python25/libs'
+ python.include = 'e:/python25/include'
+
_my_path = None
try:
import environment_path_helper
Modified: pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.cpp
===================================================================
--- pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.cpp 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.cpp 2008-12-24 20:47:08 UTC (rev 1494)
@@ -38,6 +38,9 @@
return std::auto_ptr<number_t>( new number_t( *this ) );
}
+void do_smth( number_aptr_t& ){
+}
+
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
Modified: pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.h
===================================================================
--- pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.h 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.h 2008-12-24 20:47:08 UTC (rev 1494)
@@ -9,6 +9,7 @@
virtual ~number_t();
void print_it() const;
int get_value() const;
+ int get_value(){ return m_value; }
void set_value(int x);
number_t clone() const;
@@ -18,3 +19,7 @@
};
template class __declspec(dllexport) std::auto_ptr< number_t >;
+
+typedef std::auto_ptr< number_t > number_aptr_t;
+
+void __declspec(dllexport) do_smth( number_aptr_t& );
\ No newline at end of file
Modified: pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.vcproj
===================================================================
--- pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.vcproj 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/pyplusplus/cpptypes/mydll/mydll.vcproj 2008-12-24 20:47:08 UTC (rev 1494)
@@ -118,6 +118,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
+ BrowseInformation="1"
WarningLevel="3"
DebugInformationFormat="3"
/>
@@ -134,6 +135,8 @@
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapExports="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
Modified: pyplusplus_dev/pyplusplus/cpptypes/mydll/release/mydll.dll
===================================================================
(Binary files differ)
Modified: pyplusplus_dev/pyplusplus/module_builder/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/__init__.py 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/pyplusplus/module_builder/__init__.py 2008-12-24 20:47:08 UTC (rev 1494)
@@ -13,6 +13,7 @@
"""
from extension_builder import extension_module_builder_t as module_builder_t
+from ctypes_builder import ctypes_module_builder_t
#aliases for functionality located in pygccxml.parser module
from pygccxml.parser import COMPILATION_MODE
Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/builder.py 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2008-12-24 20:47:08 UTC (rev 1494)
@@ -13,10 +13,7 @@
"""
"""
- def __init__( self
- , global_ns=None
- , encoding='ascii'
- , working_directory='.' ):
+ def __init__( self, global_ns=None, encoding='ascii' ):
"""
"""
object.__init__( self )
@@ -25,8 +22,9 @@
self.__global_ns = global_ns
def __get_global_ns( self ):
+ if not self.__global_ns:
+ raise RuntimeError( "Reference to global namespace declaration was not set." )
return self.__global_ns
-
def __set_global_ns( self, global_ns ):
self.__global_ns = global_ns
Modified: pyplusplus_dev/pyplusplus/module_builder/extension_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/extension_builder.py 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/pyplusplus/module_builder/extension_builder.py 2008-12-24 20:47:08 UTC (rev 1494)
@@ -63,10 +63,7 @@
@param cflags: Raw string to be added to gccxml command line.
"""
- builder.base_builder_t.__init__( self
- , global_ns=None
- , encoding=encoding
- , working_directory=working_directory )
+ builder.base_builder_t.__init__( self, global_ns=None, encoding=encoding )
gccxml_config = parser.config_t( gccxml_path=gccxml_path
, working_directory=working_directory
@@ -78,10 +75,7 @@
, cflags=cflags
, compiler=compiler)
- #may be in future I will add those directories to user_defined_directories
- #to self.__code_creator.
- self.__working_dir = os.path.abspath( working_directory )
-
+ #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
, parser.project_reader_t.get_os_file_names( files ) )
tmp = map( lambda file_: os.path.split( file_ )[0], self.__parsed_files )
@@ -250,11 +244,6 @@
, doc_extractor)
self.__code_creator = creator.create()
self.__code_creator.replace_included_headers(self.__parsed_files)
- #I think I should ask users, what they expect
- #self.__code_creator.user_defined_directories.append( self.__working_dir )
- #map( self.__code_creator.user_defined_directories.append
- # , self.__parsed_dirs )
-
return self.__code_creator
@property
Modified: pyplusplus_dev/unittests/autoconfig.py
===================================================================
--- pyplusplus_dev/unittests/autoconfig.py 2008-12-24 20:44:03 UTC (rev 1493)
+++ pyplusplus_dev/unittests/autoconfig.py 2008-12-24 20:47:08 UTC (rev 1494)
@@ -23,6 +23,24 @@
import pygccxml
+compiler = pygccxml.utils.native_compiler.get_gccxml_compiler()
+print 'GCCXML configured to simulate compiler ', compiler
+gccxml_version = '__GCCXML_09__'
+class cxx_parsers_cfg:
+ keywd = { 'working_directory' : data_directory
+ , 'define_symbols' : [ gccxml_version ]
+ , 'compiler' : compiler
+ , 'gccxml_path': gccxml.executable }
+
+ if 'win' in sys.platform:
+ keywd['define_symbols'].append( '__PYGCCXML_%s__' % compiler.upper() )
+ if 'msvc9' == compiler:
+ keywd['define_symbols'].append( '_HAS_TR1=0' )
+
+ gccxml = pygccxml.parser.gccxml_configuration_t( **keywd )
+
+
+
class scons_config:
libs = []#['boost_python']
libpath = [ python.libs ] + boost.libs
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 20:44:07
|
Revision: 1493
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1493&view=rev
Author: roman_yakovenko
Date: 2008-12-24 20:44:03 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
add convenience function - exported_symbols.load_from_file
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/common_utils.py
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/undname_creator_tester.py
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-24 08:16:07 UTC (rev 1492)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-24 20:44:03 UTC (rev 1493)
@@ -3,6 +3,7 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
+import os
import re
import ctypes
import ctypes.wintypes
@@ -225,3 +226,14 @@
for blob in blobs:
result[ blob ] = undecorate_blob( blob )
return result
+
+ @staticmethod
+ def load_from_file( fname ):
+ ext = os.path.splitext( fname )[1]
+ if '.dll' == ext:
+ return exported_symbols.load_from_dll_file( fname )
+ elif '.map' == ext:
+ return exported_symbols.load_from_map_file( fname )
+ else:
+ raise RuntimeError( "Don't know how to read exported symbols from file '%s'"
+ % fname )
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-12-24 08:16:07 UTC (rev 1492)
+++ pygccxml_dev/unittests/autoconfig.py 2008-12-24 20:44:03 UTC (rev 1493)
@@ -35,7 +35,7 @@
class cxx_parsers_cfg:
keywd = { 'working_directory' : data_directory
- , 'define_symbols' : [ gccxml_version ]#, '_HAS_TR1 0' ]
+ , 'define_symbols' : [ gccxml_version ]
, 'compiler' : compiler }
if 'win' in sys.platform:
Modified: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py 2008-12-24 08:16:07 UTC (rev 1492)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-24 20:44:03 UTC (rev 1493)
@@ -48,7 +48,9 @@
else:
return False
- def __tester_impl( self, symbols ):
+ def __tester_impl( self, fname ):
+ symbols = msvc.exported_symbols.load_from_file( fname )
+
undecorated_blob_names = set()
for blob in symbols.iterkeys():
undname = msvc.undecorate_blob( blob )
@@ -80,14 +82,11 @@
def test_map_file( self ):
map_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.map' )
- symbols = msvc.exported_symbols.load_from_map_file( map_file )
- self.__tester_impl( symbols )
+ self.__tester_impl( map_file )
-
def test_dll_file( self ):
dll_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.dll' )
- symbols = msvc.exported_symbols.load_from_dll_file( dll_file )
- self.__tester_impl( symbols )
+ self.__tester_impl( dll_file )
def create_suite():
suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 08:16:09
|
Revision: 1492
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1492&view=rev
Author: roman_yakovenko
Date: 2008-12-24 08:16:07 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
porting tester for Visual Studio 2003
Modified Paths:
--------------
pygccxml_dev/unittests/undname_creator_tester.py
Modified: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py 2008-12-24 08:12:27 UTC (rev 1491)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-24 08:16:07 UTC (rev 1492)
@@ -26,6 +26,8 @@
# array as function argument
, 'int FA10_i_i(int * const)'
])
+ if 'msvc71' == utils.native_compiler.get_gccxml_compiler():
+ known_issues.add( 'std::auto_ptr<number_t> & std::auto_ptr<number_t>::operator=(std::auto_ptr_ref<number_t>)' )
def __init__(self, *args ):
parser_test_case.parser_test_case_t.__init__( self, *args )
@@ -64,7 +66,7 @@
undecorated_decl_names.difference_update(common)
undecorated_blob_names.difference_update(common)
- if undecorated_blob_names != self.known_issues:
+ if not self.known_issues.issubset( undecorated_blob_names ):
undecorated_blob_names.difference_update( self.known_issues )
msg = [ "undecorate_decl - failed" ]
msg.append( "undecorated_decl_names :" )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-24 08:12:32
|
Revision: 1491
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1491&view=rev
Author: roman_yakovenko
Date: 2008-12-24 08:12:27 +0000 (Wed, 24 Dec 2008)
Log Message:
-----------
integrating "get_exports.py" functionality with pygccxml
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/common_utils.py
Added Paths:
-----------
pygccxml_dev/pygccxml/msvc/get_dll_exported_symbols.py
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 20:54:48 UTC (rev 1490)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-24 08:12:27 UTC (rev 1491)
@@ -185,6 +185,11 @@
undecorate_blob = undname_creator().undecorate_blob
undecorate_decl = undname_creator().undecorated_decl
+import exceptions
+class LicenseWarning( exceptions.UserWarning ):
+ def __init__( self, *args, **keywd ):
+ exceptions.UserWarning.__init__( self, *args, **keywd )
+
class exported_symbols:
map_file_re = re.compile( r' +\d+ (?P<decorated>.+?) \((?P<undecorated>.+)\)$' )
@staticmethod
@@ -206,19 +211,17 @@
@staticmethod
def load_from_dll_file( fname ):
- import get_exports
+ import warnings
+ warnings.warn( '\n'*2 + '-' * 30 + '>>LICENSE WARNING<<' + '-'*30
+ + '\n"load_from_dll_file" functionality uses code licensed under MIT license.'
+ + '\npygccxml project uses Boost Software License, Version 1.0. '
+ + '\nFor more information about this functionality take a look on get_dll_exported_symbols.py file.'
+ + '\n' + '='*79
+ + '\n' * 2
+ , LicenseWarning )
+ import get_dll_exported_symbols
result = {}
- blobs = get_exports.read_export_table( fname )
+ blobs = get_dll_exported_symbols.read_export_table( fname )
for blob in blobs:
result[ blob ] = undecorate_blob( blob )
return result
-
-#~ quick & dirty test
-#~ symbols = exported_symbols.load_from_map_file( r'D:\dev\language-binding\sources\pygccxml_dev\unittests\data\msvc\Release\mydll.map' )
-#~ for decorated, undecorated in symbols.iteritems():
- #~ print '---------------------------------------------------------------------'
- #~ print decorated
- #~ print undecorated
- #~ print undecorate_blob( decorated )
- #~ print '====================================================================='
-
Added: pygccxml_dev/pygccxml/msvc/get_dll_exported_symbols.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/get_dll_exported_symbols.py (rev 0)
+++ pygccxml_dev/pygccxml/msvc/get_dll_exported_symbols.py 2008-12-24 08:12:27 UTC (rev 1491)
@@ -0,0 +1,290 @@
+#The content of this file was contributed by leppton
+# (http://mail.python.org/pipermail/patches/2006-November/020942.html) to ctypes
+# project, under MIT License.
+
+# This example shows how to use ctypes module to read all
+# function names from dll export directory
+
+import os
+if os.name != "nt":
+ raise Exception("Wrong OS")
+
+import ctypes as ctypes
+import ctypes.wintypes as wintypes
+
+def convert_cdef_to_pydef(line):
+ """\
+convert_cdef_to_pydef(line_from_c_header_file) -> python_tuple_string
+'DWORD var_name[LENGTH];' -> '("var_name", DWORD*LENGTH)'
+
+doesn't work for all valid c/c++ declarations"""
+ l = line[:line.find(';')].split()
+ if len(l) != 2:
+ return None
+ type_ = l[0]
+ name = l[1]
+ i = name.find('[')
+ if i != -1:
+ name, brac = name[:i], name[i:][1:-1]
+ return '("%s", %s*%s)'%(name,type_,brac)
+ else:
+ return '("%s", %s)'%(name,type_)
+
+def convert_cdef_to_structure(cdef, name, data_dict=ctypes.__dict__):
+ """\
+convert_cdef_to_structure(struct_definition_from_c_header_file)
+ -> python class derived from ctypes.Structure
+
+limited support for c/c++ syntax"""
+ py_str = '[\n'
+ for line in cdef.split('\n'):
+ field = convert_cdef_to_pydef(line)
+ if field != None:
+ py_str += ' '*4 + field + ',\n'
+ py_str += ']\n'
+
+ pyarr = eval(py_str, data_dict)
+ class ret_val(ctypes.Structure):
+ _fields_ = pyarr
+ ret_val.__name__ = name
+ ret_val.__module__ = None
+ return ret_val
+
+#struct definitions we need to read dll file export table
+winnt = (
+ ('IMAGE_DOS_HEADER', """\
+ WORD e_magic;
+ WORD e_cblp;
+ WORD e_cp;
+ WORD e_crlc;
+ WORD e_cparhdr;
+ WORD e_minalloc;
+ WORD e_maxalloc;
+ WORD e_ss;
+ WORD e_sp;
+ WORD e_csum;
+ WORD e_ip;
+ WORD e_cs;
+ WORD e_lfarlc;
+ WORD e_ovno;
+ WORD e_res[4];
+ WORD e_oemid;
+ WORD e_oeminfo;
+ WORD e_res2[10];
+ LONG e_lfanew;
+"""),
+
+ ('IMAGE_FILE_HEADER', """\
+ WORD Machine;
+ WORD NumberOfSections;
+ DWORD TimeDateStamp;
+ DWORD PointerToSymbolTable;
+ DWORD NumberOfSymbols;
+ WORD SizeOfOptionalHeader;
+ WORD Characteristics;
+"""),
+
+ ('IMAGE_DATA_DIRECTORY', """\
+ DWORD VirtualAddress;
+ DWORD Size;
+"""),
+
+ ('IMAGE_OPTIONAL_HEADER32', """\
+ WORD Magic;
+ BYTE MajorLinkerVersion;
+ BYTE MinorLinkerVersion;
+ DWORD SizeOfCode;
+ DWORD SizeOfInitializedData;
+ DWORD SizeOfUninitializedData;
+ DWORD AddressOfEntryPoint;
+ DWORD BaseOfCode;
+ DWORD BaseOfData;
+ DWORD ImageBase;
+ DWORD SectionAlignment;
+ DWORD FileAlignment;
+ WORD MajorOperatingSystemVersion;
+ WORD MinorOperatingSystemVersion;
+ WORD MajorImageVersion;
+ WORD MinorImageVersion;
+ WORD MajorSubsystemVersion;
+ WORD MinorSubsystemVersion;
+ DWORD Win32VersionValue;
+ DWORD SizeOfImage;
+ DWORD SizeOfHeaders;
+ DWORD CheckSum;
+ WORD Subsystem;
+ WORD DllCharacteristics;
+ DWORD SizeOfStackReserve;
+ DWORD SizeOfStackCommit;
+ DWORD SizeOfHeapReserve;
+ DWORD SizeOfHeapCommit;
+ DWORD LoaderFlags;
+ DWORD NumberOfRvaAndSizes;
+ IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+""",
+ {'IMAGE_NUMBEROF_DIRECTORY_ENTRIES':16}),
+
+ ('IMAGE_NT_HEADERS', """\
+ DWORD Signature;
+ IMAGE_FILE_HEADER FileHeader;
+ IMAGE_OPTIONAL_HEADER32 OptionalHeader;
+"""),
+
+ ('IMAGE_EXPORT_DIRECTORY', """\
+ DWORD Characteristics;
+ DWORD TimeDateStamp;
+ WORD MajorVersion;
+ WORD MinorVersion;
+ DWORD Name;
+ DWORD Base;
+ DWORD NumberOfFunctions;
+ DWORD NumberOfNames;
+ DWORD AddressOfFunctions;
+ DWORD AddressOfNames;
+ DWORD AddressOfNameOrdinals;
+"""),
+ )
+
+#Construct python ctypes.Structures from above definitions
+data_dict = dict(wintypes.__dict__)
+for definition in winnt:
+ name = definition[0]
+ def_str = definition[1]
+ if len(definition) == 3:
+ data_dict.update(definition[2])
+ type_ = convert_cdef_to_structure(def_str, name, data_dict)
+ data_dict[name] = type_
+ globals()[name] = type_
+
+ ptype = ctypes.POINTER(type_)
+ pname = 'P'+name
+ data_dict[pname] = ptype
+ globals()[pname] = ptype
+
+del data_dict
+del winnt
+
+class DllException(Exception):
+ pass
+
+def read_export_table(dll_name, mmap=False, use_kernel=False):
+ """\
+read_export_table(dll_name [,mmap=False [,use_kernel=False]]])
+ -> list of exported names
+
+default is to load dll into memory: dll sections are aligned to
+page boundaries, dll entry points is called, etc...
+
+with mmap=True dll file image is mapped to memory, Relative Virtual
+Addresses (RVAs) must be mapped to real addresses manually
+
+with use_kernel=True direct kernel32.dll calls are used,
+instead of python mmap module
+
+see http://www.windowsitlibrary.com/Content/356/11/1.html
+for details on Portable Executable (PE) file format
+"""
+ if not mmap:
+ dll = ctypes.cdll.LoadLibrary(dll_name)
+ if dll == None:
+ raise DllException("Cant load dll")
+ base_addr = dll._handle
+
+ else:
+ if not use_kernel:
+ fileH = open(dll_name)
+ if fileH == None:
+ raise DllException("Cant load dll")
+ import mmap
+ m = mmap.mmap(fileH.fileno(), 0, None, mmap.ACCESS_READ)
+ # id(m)+8 sucks, is there better way?
+ base_addr = ctypes.cast(id(m)+8, ctypes.POINTER(ctypes.c_int))[0]
+ else:
+ kernel32 = ctypes.windll.kernel32
+ if kernel32 == None:
+ raise DllException("cant load kernel")
+ fileH = kernel32.CreateFileA(dll_name, 0x00120089, 1,0,3,0,0)
+ if fileH == 0:
+ raise DllException("Cant open, errcode = %d"%kernel32.GetLastError())
+ mapH = kernel32.CreateFileMappingW(fileH,0,0x8000002,0,0,0)
+ if mapH == 0:
+ raise DllException("Cant mmap, errocode = %d"%kernel32.GetLastError())
+ base_addr = ctypes.windll.kernel32.MapViewOfFile(mapH, 0x4, 0, 0, 0)
+ if base_addr == 0:
+ raise DllException("Cant mmap(2), errocode = %d"%kernel32.GetLastError())
+
+ dbghelp = ctypes.windll.dbghelp
+ if dbghelp == None:
+ raise DllException("dbghelp.dll not installed")
+ pimage_nt_header = dbghelp.ImageNtHeader(base_addr)
+ if pimage_nt_header == 0:
+ raise DllException("Cant find IMAGE_NT_HEADER")
+
+ #Functions like dbghelp.ImageNtHeader above have no type information
+ #let's make one prototype for extra buzz
+ #PVOID ImageRvaToVa(PIMAGE_NT_HEADERS NtHeaders, PVOID Base,
+ # ULONG Rva, PIMAGE_SECTION_HEADER* LastRvaSection)
+ # we use integers instead of pointers, coz integers are better
+ # for pointer arithmetic
+ prototype = ctypes.WINFUNCTYPE(ctypes.c_int, ctypes.c_int,
+ ctypes.c_int, ctypes.c_int, ctypes.c_int)
+ paramflags = ((1,"NtHeaders",pimage_nt_header),(1,"Base",base_addr),(1,"Rva"),(1,"LastRvaSection",0))
+ ImageRvaToVa = prototype(('ImageRvaToVa', dbghelp), paramflags)
+
+ def cast_rva(rva, type_):
+ va = base_addr + rva
+ if mmap and va > pimage_nt_header:
+ va = ImageRvaToVa(Rva=rva)
+ if va == 0:
+ raise DllException("ImageRvaToVa failed")
+ return ctypes.cast(va, type_)
+
+ if not mmap:
+ dos_header = cast_rva(0, PIMAGE_DOS_HEADER)[0]
+ if dos_header.e_magic != 0x5A4D:
+ raise DllException("IMAGE_DOS_HEADER.e_magic error")
+ nt_header = cast_rva(dos_header.e_lfanew, PIMAGE_NT_HEADERS)[0]
+ else:
+ nt_header = ctypes.cast(pimage_nt_header, PIMAGE_NT_HEADERS)[0]
+ if nt_header.Signature != 0x00004550:
+ raise DllException("IMAGE_NT_HEADERS.Signature error")
+
+ opt_header = nt_header.OptionalHeader
+ if opt_header.Magic != 0x010b:
+ raise DllException("IMAGE_OPTIONAL_HEADERS32.Magic error")
+
+ ret_val = []
+ exports_dd = opt_header.DataDirectory[0]
+ if opt_header.NumberOfRvaAndSizes > 0 or exports_dd != 0:
+ export_dir = cast_rva(exports_dd.VirtualAddress, PIMAGE_EXPORT_DIRECTORY)[0]
+
+ nNames = export_dir.NumberOfNames
+ if nNames > 0:
+ PNamesType = ctypes.POINTER(ctypes.c_int * nNames)
+ names = cast_rva(export_dir.AddressOfNames, PNamesType)[0]
+ for rva in names:
+ name = cast_rva(rva, ctypes.c_char_p).value
+ ret_val.append(name)
+
+ if mmap:
+ if use_kernel:
+ kernel32.UnmapViewOfFile(base_addr)
+ kernel32.CloseHandle(mapH)
+ kernel32.CloseHandle(fileH)
+ else:
+ m.close()
+ fileH.close()
+ return ret_val
+
+
+if __name__ == '__main__':
+ import sys
+ if len(sys.argv) != 2:
+ print 'usage: %s dll_file_name'%sys.argv[0]
+ sys.exit()
+## names = read_export_table(sys.argv[1], mmap=False, use_kernel=False)
+ names = read_export_table(sys.argv[1], mmap=False, use_kernel=False)
+ for name in names:
+ print name
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-23 20:54:53
|
Revision: 1490
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1490&view=rev
Author: roman_yakovenko
Date: 2008-12-23 20:54:48 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
adding few new test cases to test MSVC & GCCXML name mangling interoperability
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/cpptypes.py
pygccxml_dev/pygccxml/msvc/common_utils.py
pygccxml_dev/unittests/data/msvc/mydll.90.vcproj
pygccxml_dev/unittests/data/msvc/mydll.cpp
pygccxml_dev/unittests/data/msvc/mydll.h
pygccxml_dev/unittests/undname_creator_tester.py
Property Changed:
----------------
pygccxml_dev/unittests/data/
Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-12-23 20:54:48 UTC (rev 1490)
@@ -373,7 +373,7 @@
compound_t.__init__( self, base)
def build_decl_string(self, with_defaults=True):
- return 'volatile ' + self.base.build_decl_string(with_defaults)
+ return self.base.build_decl_string(with_defaults) + ' volatile'
def _clone_impl( self ):
return volatile_t( self.base.clone() )
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 20:54:48 UTC (rev 1490)
@@ -79,6 +79,12 @@
__undname = ctypes.windll.dbghelp.UnDecorateSymbolName
__undname.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint]
__clean_ecsu = re.compile( r'(?:(^|\W))(?:(class|enum|struct|union))' )
+ __fundamental_types = (
+ ( 'short unsigned int', 'unsigned short')
+ , ( 'short int', 'short' )
+ , ( 'long int', 'long' )
+ , ( 'long unsigned int', 'unsigned long' )
+ )
def undecorate_blob( self, name, options=None ):
if options is None:
@@ -99,17 +105,30 @@
else:
return s
- def __format_type_as_undecorated( self, type_ ):
+ def __format_type_as_undecorated( self, type_, is_argument ):
result = []
type_ = declarations.remove_alias( type_ )
- result.append( self.__remove_leading_scope( type_.decl_string ) )
+ if declarations.is_array( type_ ):
+ result.append( declarations.array_item_type( type_ ).decl_string )
+ result.append( '*' )
+ if is_argument:
+ result.append( 'const' )
+ else:
+ result.append( self.__remove_leading_scope( type_.decl_string ) )
return ' '.join( result )
+ def __normalize( self, name ):
+ for what, with_ in self.__fundamental_types:
+ name = name.replace( what, with_ )
+ name = name.replace( ', ', ',' )
+ return name
+
def __format_args_as_undecorated( self, argtypes ):
if not argtypes:
return 'void'
else:
- return ','.join( map( self.__format_type_as_undecorated, argtypes ) )
+ formater = lambda type_: self.__format_type_as_undecorated( type_, True )
+ return ','.join( map( formater, argtypes ) )
def __undecorated_calldef( self, calldef ):
calldef_type = calldef.function_type()
@@ -118,8 +137,10 @@
is_mem_fun = isinstance( calldef, declarations.member_calldef_t )
if is_mem_fun and calldef.virtuality != declarations.VIRTUALITY_TYPES.NOT_VIRTUAL:
result.append( 'virtual ' )
+ if is_mem_fun and calldef.has_static:
+ result.append( 'static ' )
if calldef_type.return_type:
- result.append( self.__format_type_as_undecorated( calldef.return_type ) )
+ result.append( self.__format_type_as_undecorated( calldef.return_type, False ) )
result.append( ' ' )
if is_mem_fun:
result.append( self.__remove_leading_scope( calldef.parent.decl_string ) + '::')
@@ -136,11 +157,12 @@
def __undecorated_variable( self, decl ):
result = []
- if decl.type_qualifiers.has_static:
+ is_mem_var = isinstance( decl.parent, declarations.class_t )
+ if is_mem_var and decl.type_qualifiers.has_static:
result.append( 'static ' )
- result.append( self.__format_type_as_undecorated( decl.type ) )
+ result.append( self.__format_type_as_undecorated( decl.type, False ) )
result.append( ' ' )
- if isinstance( decl.parent, declarations.class_t ):
+ if is_mem_var:
result.append( self.__remove_leading_scope( decl.parent.decl_string ) + '::' )
result.append( decl.name )
return ''.join( result )
@@ -150,13 +172,16 @@
result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
options.
"""
+ name = None
if isinstance( decl, declarations.calldef_t ):
- return self.__undecorated_calldef( decl )
+ name = self.__undecorated_calldef( decl )
elif isinstance( decl, declarations.variable_t ):
- return self.__undecorated_variable( decl )
+ name = self.__undecorated_variable( decl )
else:
raise NotImplementedError()
+ return self.__normalize( name )
+
undecorate_blob = undname_creator().undecorate_blob
undecorate_decl = undname_creator().undecorated_decl
@@ -179,6 +204,15 @@
result[ found.group( 'decorated' ) ] = found.group( 'undecorated' )
return result
+ @staticmethod
+ def load_from_dll_file( fname ):
+ import get_exports
+ result = {}
+ blobs = get_exports.read_export_table( fname )
+ for blob in blobs:
+ result[ blob ] = undecorate_blob( blob )
+ return result
+
#~ quick & dirty test
#~ symbols = exported_symbols.load_from_map_file( r'D:\dev\language-binding\sources\pygccxml_dev\unittests\data\msvc\Release\mydll.map' )
#~ for decorated, undecorated in symbols.iteritems():
Property changes on: pygccxml_dev/unittests/data
___________________________________________________________________
Modified: svn:ignore
- *.cache
+ *.cache
*.bak
Modified: pygccxml_dev/unittests/data/msvc/mydll.90.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.90.vcproj 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/data/msvc/mydll.90.vcproj 2008-12-23 20:54:48 UTC (rev 1490)
@@ -45,7 +45,7 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
- UsePrecompiledHeader="2"
+ UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
@@ -118,6 +118,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
+ AssemblerOutput="4"
BrowseInformation="1"
WarningLevel="3"
DebugInformationFormat="3"
Modified: pygccxml_dev/unittests/data/msvc/mydll.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 20:54:48 UTC (rev 1490)
@@ -51,6 +51,36 @@
void* get_pvoid(void*){ return 0;}
void** get_ppvoid(void){return 0;}
+int FA10_i_i(int a[10]){ return 0;}
+int FPi_i(int *a){ return 0;}
+int Fc_i(char bar){ return 0;}
+int Ff_i(float bar){ return 0;}
+int Fg_i(double bar){ return 0;}
+int Fi_i(int bar){ return 0;}
+int Fie_i(int bar, ...){ return 0;}
+int Fii_i(int bar, int goo){ return 0;}
+int Fiii_i(int bar, int goo, int hoo){ return 0;}
+void Fmxmx_v(myclass_t arg1, X arg2, myclass_t arg3, X arg4){}
+void Fmyclass_v(myclass_t m){}
+
+const int Fv_Ci(void){ return 0;}
+long double Fv_Lg(void){ return 0.0;}
+int& Fv_Ri(void){ return my_global_int;}
+signed char Fv_Sc(void){ return 0;}
+unsigned char Fv_Uc(void){ return 0;}
+unsigned int Fv_Ui(void){ return 0;}
+unsigned long Fv_Ul(void){ return 0;}
+unsigned short Fv_Us(void){ return 0;}
+volatile int Fv_Vi(void){ return 0;}
+char Fv_c(void){ return 0;}
+float Fv_f(void){ return 0.0;}
+double Fv_g(void){ return 0.0;}
+int Fv_i(void){ return 0;}
+long Fv_l(void){ return 0;}
+short Fv_s(void){ return 0;}
+void Fv_v(void){ return;}
+
+
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
@@ -69,42 +99,6 @@
/*
-static int myclass::myStaticMember
-const int myclass::myconstStaticMember
-volatile int myclass::myvolatileStaticMember
-x myfnptr;
-int myglobal;
-volatile int myvolatile;
-int myarray[10];
-void **Fv_PPv(void)
-void *Fv_Pv(void)
-int FA10_i_i(int a[10])
-int FPi_i(int *a)
-int Fc_i(char bar)
-int Ff_i(float bar)
-int Fg_i(double bar)
-int Fi_i(int bar)
-int Fie_i(int bar, ...)
-int Fii_i(int bar, int goo)
-int Fiii_i(int bar, int goo, int hoo)
-void Fmxmx_v(myclass arg1, x arg2, myclass arg3, x arg4)
-void Fmyclass_v(myclass m)
-const int Fv_Ci(void)
-long double Fv_Lg(void)
-int& Fv_Ri(void)
-signed char Fv_Sc(void)
-unsigned char Fv_Uc(void)
-unsigned int Fv_Ui(void)
-unsigned long Fv_Ul(void)
-unsigned short Fv_Us(void)
-volatile int Fv_Vi(void)
-char Fv_c(void)
-float Fv_f(void)
-double Fv_g(void)
-int Fv_i(void)
-long Fv_l(void)
-short Fv_s(void)
-void Fv_v(void)
void __cdecl Fv_v_cdecl(void)
void __fastcall Fv_v_fastcall(void)
void __stdcall Fv_v_stdcall(void)
@@ -114,25 +108,8 @@
int Fxxi_i(x fnptr, x fnptr2, x fnptr3, int i)
int Fxxx_i(x fnptr, x fnptr2, x fnptr3)
int Fxyxy_i(x fnptr, y fnptr2, x fnptr3, y fnptr4)
-void myclass::operator delete(void *p)
-int myclass::Fi_i(int bar)
-static int myclass::Fis_i(int bar)
void __cdecl myclass::Fv_v_cdecl(void)
void __fastcall myclass::Fv_v_fastcall(void)
void __stdcall myclass::Fv_v_stdcall(void)
-myclass::myclass(int x)
-myclass::myclass(void)
-int myclass::nested::Fi_i(int bar)
-myclass::nested::nested(void)
-myclass::nested::~nested()
-myclass myclass::operator+(int x)
-myclass myclass::operator++()
-myclass myclass::operator++(int)
-myclass& myclass::operator=(const myclass& from)
-myclass::~myclass()
-int nested::Fi_i(int bar)
-nested::nested(void)
-nested::~nested()
void* myclass::operator new(size_t size)
*/
-
Modified: pygccxml_dev/unittests/data/msvc/mydll.h
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 20:54:48 UTC (rev 1490)
@@ -1,8 +1,9 @@
#pragma once
#include <memory>
+#include <string>
+#include <vector>
-
class __declspec(dllexport) number_t{
public:
number_t();
@@ -41,11 +42,65 @@
class __declspec(dllexport) myclass_t{
public:
+ myclass_t(int x){}
+ myclass_t(void){}
+ virtual ~myclass_t(){}
static int my_static_member;
static const int my_const_static_member;
volatile int my_volatile_member;
do_smth_type* get_do_smth(){ return 0; }
void set_do_smth(do_smth_type*){};
-
-};
\ No newline at end of file
+
+ int Fi_i(int bar){ return 0; }
+ static int Fis_i(int bar){ return 0; }
+
+ myclass_t operator+(int x){ return myclass_t(); }
+ myclass_t operator++(){ return myclass_t(); }
+ myclass_t operator++(int){ return myclass_t(); }
+ myclass_t& operator=(const myclass_t& from){ return *this;}
+
+ struct nested{
+ nested(){}
+ ~nested(){}
+ int Fi_i(int bar){ return 0;}
+ };
+
+ typedef std::vector< std::wstring > wstring_collection_t;
+
+ wstring_collection_t create_wstring_collection(){ return wstring_collection_t(); }
+ void fill_wstring_collection( wstring_collection_t& ){};
+ void print__wstring_collection( const wstring_collection_t& ){}
+
+
+};
+
+struct __declspec(dllexport) X{};
+
+__declspec(dllexport) int FA10_i_i(int a[10]);
+__declspec(dllexport) int FPi_i(int *a);
+__declspec(dllexport) int Fc_i(char bar);
+__declspec(dllexport) int Ff_i(float bar);
+__declspec(dllexport) int Fg_i(double bar);
+__declspec(dllexport) int Fi_i(int bar);
+__declspec(dllexport) int Fie_i(int bar, ...);
+__declspec(dllexport) int Fii_i(int bar, int goo);
+__declspec(dllexport) int Fiii_i(int bar, int goo, int hoo);
+__declspec(dllexport) void Fmxmx_v(myclass_t arg1, X arg2, myclass_t arg3, X arg4);
+__declspec(dllexport) void Fmyclass_v(myclass_t m);
+__declspec(dllexport) const int Fv_Ci(void);
+__declspec(dllexport) long double Fv_Lg(void);
+__declspec(dllexport) int& Fv_Ri(void);
+__declspec(dllexport) signed char Fv_Sc(void);
+__declspec(dllexport) unsigned char Fv_Uc(void);
+__declspec(dllexport) unsigned int Fv_Ui(void);
+__declspec(dllexport) unsigned long Fv_Ul(void);
+__declspec(dllexport) unsigned short Fv_Us(void);
+__declspec(dllexport) volatile int Fv_Vi(void);
+__declspec(dllexport) char Fv_c(void);
+__declspec(dllexport) float Fv_f(void);
+__declspec(dllexport) double Fv_g(void);
+__declspec(dllexport) int Fv_i(void);
+__declspec(dllexport) long Fv_l(void);
+__declspec(dllexport) short Fv_s(void);
+__declspec(dllexport) void Fv_v(void);
Modified: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 20:54:48 UTC (rev 1490)
@@ -19,6 +19,14 @@
global_ns = None
+ known_issues = set([
+ #pointer to functions
+ 'void (** myclass_t::get_do_smth(void))(std::auto_ptr<number_t> &)'
+ , 'void myclass_t::set_do_smth(void (**)(std::auto_ptr<number_t> &))'
+ # array as function argument
+ , 'int FA10_i_i(int * const)'
+ ])
+
def __init__(self, *args ):
parser_test_case.parser_test_case_t.__init__( self, *args )
self.header = r'msvc\mydll.h'
@@ -38,11 +46,7 @@
else:
return False
-
- def test( self ):
- map_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.map' )
- symbols = msvc.exported_symbols.load_from_map_file( map_file )
-
+ def __tester_impl( self, symbols ):
undecorated_blob_names = set()
for blob in symbols.iterkeys():
undname = msvc.undecorate_blob( blob )
@@ -60,17 +64,29 @@
undecorated_decl_names.difference_update(common)
undecorated_blob_names.difference_update(common)
+ if undecorated_blob_names != self.known_issues:
+ undecorated_blob_names.difference_update( self.known_issues )
+ msg = [ "undecorate_decl - failed" ]
+ msg.append( "undecorated_decl_names :" )
+ for i in undecorated_decl_names:
+ msg.append( '\t==>%s<==' % i )
+ msg.append( "undecorated_blob_names :" )
+ for i in undecorated_blob_names:
+ msg.append( '\t==>%s<==' % i )
- msg = [ "undecorate_decl - failed" ]
- msg.append( "undecorated_decl_names :" )
- for i in undecorated_decl_names:
- msg.append( '\t==>%s<==' % i )
- msg.append( "undecorated_blob_names :" )
- for i in undecorated_blob_names:
- msg.append( '\t==>%s<==' % i )
+ self.fail( os.linesep.join(msg) )
- self.fail( os.linesep.join(msg) )
+ def test_map_file( self ):
+ map_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.map' )
+ symbols = msvc.exported_symbols.load_from_map_file( map_file )
+ self.__tester_impl( symbols )
+
+ def test_dll_file( self ):
+ dll_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.dll' )
+ symbols = msvc.exported_symbols.load_from_dll_file( dll_file )
+ self.__tester_impl( symbols )
+
def create_suite():
suite = unittest.TestSuite()
if 'win' in sys.platform:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-23 20:45:27
|
Revision: 1489
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1489&view=rev
Author: roman_yakovenko
Date: 2008-12-23 20:45:17 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
commenting out pdb tests
Modified Paths:
--------------
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/declarations_tester.py
Property Changed:
----------------
pygccxml_dev/pygccxml/msvc/bsc/
pygccxml_dev/pygccxml/msvc/mspdb/
Property changes on: pygccxml_dev/pygccxml/msvc/bsc
___________________________________________________________________
Added: svn:ignore
+ *.pyc
Property changes on: pygccxml_dev/pygccxml/msvc/mspdb
___________________________________________________________________
Added: svn:ignore
+ *.pyc
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-12-23 20:43:00 UTC (rev 1488)
+++ pygccxml_dev/unittests/autoconfig.py 2008-12-23 20:45:17 UTC (rev 1489)
@@ -34,11 +34,16 @@
pygccxml.declarations.class_t.USE_DEMANGLED_AS_NAME = True
class cxx_parsers_cfg:
-
keywd = { 'working_directory' : data_directory
- , 'define_symbols' : [ gccxml_version ]
+ , 'define_symbols' : [ gccxml_version ]#, '_HAS_TR1 0' ]
, 'compiler' : compiler }
+ if 'win' in sys.platform:
+ keywd['define_symbols'].append( '__PYGCCXML_%s__' % compiler.upper() )
+ if 'msvc9' == compiler:
+ keywd['define_symbols'].append( '_HAS_TR1=0' )
+
+
if os.path.exists( os.path.join( gccxml_path, 'gccxml' ) ) \
or os.path.exists( os.path.join( gccxml_path, 'gccxml.exe' ) ):
keywd[ 'gccxml_path'] = gccxml_path
@@ -52,9 +57,9 @@
#~ pdb_loader = mspdb.decl_loader_t( pdb_file )
#~ pdb_loader.read()
-def get_pdb_global_ns():
- if cxx_parsers_cfg.pdb_loader:
- return cxx_parsers_cfg.pdb_loader.global_ns
+#~ def get_pdb_global_ns():
+ #~ if cxx_parsers_cfg.pdb_loader:
+ #~ return cxx_parsers_cfg.pdb_loader.global_ns
#~ try:
#~ import pydsc
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-12-23 20:43:00 UTC (rev 1488)
+++ pygccxml_dev/unittests/core_tester.py 2008-12-23 20:45:17 UTC (rev 1489)
@@ -21,8 +21,8 @@
root = normalize_path( root )
some_path = normalize_path( some_path )
return some_path.startswith( root )
-
+
class core_t( parser_test_case.parser_test_case_t ):
"""Tests core algorithms of GCC-XML and GCC-XML file reader.
Those most white-box testing.
@@ -392,8 +392,8 @@
suite.addTest( unittest.makeSuite(core_all_at_once_no_opt_t))
suite.addTest( unittest.makeSuite(core_file_by_file_t))
suite.addTest( unittest.makeSuite(core_file_by_file_no_opt_t))
- if autoconfig.cxx_parsers_cfg.pdb_loader:
- suite.addTest( unittest.makeSuite(pdb_based_core_tester_t))
+ #~ if autoconfig.cxx_parsers_cfg.pdb_loader:
+ #~ suite.addTest( unittest.makeSuite(pdb_based_core_tester_t))
return suite
def run_suite():
Modified: pygccxml_dev/unittests/declarations_tester.py
===================================================================
--- pygccxml_dev/unittests/declarations_tester.py 2008-12-23 20:43:00 UTC (rev 1488)
+++ pygccxml_dev/unittests/declarations_tester.py 2008-12-23 20:45:17 UTC (rev 1489)
@@ -198,8 +198,8 @@
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(file_by_file_tester_t))
suite.addTest( unittest.makeSuite(all_at_once_tester_t))
- if sys.platform == 'win32' and autoconfig.get_pdb_global_ns():
- suite.addTest( unittest.makeSuite(pdb_based_tester_t))
+ #~ if sys.platform == 'win32' and autoconfig.get_pdb_global_ns():
+ #~ suite.addTest( unittest.makeSuite(pdb_based_tester_t))
return suite
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-23 20:43:03
|
Revision: 1488
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1488&view=rev
Author: roman_yakovenko
Date: 2008-12-23 20:43:00 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
porting tester to MSVC 9.0
Modified Paths:
--------------
pygccxml_dev/unittests/data/remove_template_defaults.hpp
pygccxml_dev/unittests/remove_template_defaults_tester.py
Modified: pygccxml_dev/unittests/data/remove_template_defaults.hpp
===================================================================
--- pygccxml_dev/unittests/data/remove_template_defaults.hpp 2008-12-23 13:27:29 UTC (rev 1487)
+++ pygccxml_dev/unittests/data/remove_template_defaults.hpp 2008-12-23 20:43:00 UTC (rev 1488)
@@ -13,7 +13,7 @@
#else
#include <hash_set>
#include <hash_map>
- #ifdef __GCCXML__
+ #if defined( __GCCXML__ ) && !defined( __PYGCCXML_MSVC9__ )
#define HASH_XXX_NS std
#else
#define HASH_XXX_NS stdext
@@ -31,22 +31,22 @@
template <class T>
struct type {};
-
-namespace vectors{
+
+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{
+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;
@@ -76,7 +76,7 @@
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;
-
+
inline std::map<std::string, int> f2(){}
}
@@ -93,7 +93,7 @@
}
-namespace hash_multisets{
+namespace hash_multisets{
typedef HASH_XXX_NS::hash_multiset< std::vector< int > > mhs_v_int;
typedef HASH_XXX_NS::hash_multiset< std::string > mhs_string;
}
Modified: pygccxml_dev/unittests/remove_template_defaults_tester.py
===================================================================
--- pygccxml_dev/unittests/remove_template_defaults_tester.py 2008-12-23 13:27:29 UTC (rev 1487)
+++ pygccxml_dev/unittests/remove_template_defaults_tester.py 2008-12-23 20:43:00 UTC (rev 1488)
@@ -16,138 +16,139 @@
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 >'
+ 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' )
+ 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 ):
+
+ def test_list( self ):
l_int = self.global_ns.typedef( 'l_int' )
- self.failUnless( 'list< 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 ):
+ def test_deque( self ):
d_v_int = self.global_ns.typedef( 'd_v_int' )
- self.failUnless( 'deque< std::vector< 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 ):
+ def test_queue( self ):
q_int = self.global_ns.typedef( 'q_int' )
- self.failUnless( 'queue< 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 test_priority_queue( self ):
+ def test_priority_queue( self ):
pq_int = self.global_ns.typedef( 'pq_int' )
- self.failUnless( 'priority_queue< 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 ):
+ def test_set( self ):
s_v_int = self.global_ns.typedef( 's_v_int' )
- self.failUnless( 'set< std::vector< 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 ):
+ def test_multiset( self ):
ms_v_int = self.global_ns.typedef( 'ms_v_int' )
- self.failUnless( 'multiset< std::vector< 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 test_map( self ):
+ def test_map( self ):
m_i2d = self.global_ns.typedef( 'm_i2d' )
- self.failUnless( 'map< int, double >'
+ 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 >'
+ 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 > >'
+ 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 ):
+ def test_multimap( self ):
mm_i2d = self.global_ns.typedef( 'mm_i2d' )
- self.failUnless( 'multimap< int, double >'
+ 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 >'
+ 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 > >'
+ 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 test_hash_set( self ):
+ def test_hash_set( self ):
hs_v_int = self.global_ns.typedef( 'hs_v_int' )
- self.failUnless( 'hash_set< std::vector< 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 ) )
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 ):
+ def test_hash_multiset( self ):
mhs_v_int = self.global_ns.typedef( 'mhs_v_int' )
- self.failUnless( 'hash_multiset< std::vector< 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 ):
+ def test_hash_map( self ):
hm_i2d = self.global_ns.typedef( 'hm_i2d' )
- self.failUnless( 'hash_map< int, double >'
+ 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 >'
+ self.failUnless( 'hash_map< std::wstring, double >'
== declarations.hash_map_traits.remove_defaults( hm_wstr2d ) )
- def test_hash_multimap( self ):
+ def test_hash_multimap( self ):
hmm_i2d = self.global_ns.typedef( 'hmm_i2d' )
- self.failUnless( 'hash_multimap< int, double >'
+ 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 >'
+ 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' )
-
- possible_values = (
+ hmm_v_i2mm_wstr2d = self.global_ns.typedef( '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 )
+ , 'hash_multimap< const std::vector< int >, const std::hash_multimap< const std::wstring, double > >'
+ , 'hash_multimap< const std::vector< int >, const stdext::hash_multimap< const std::wstring, double > >' )
+
+ self.failUnless( declarations.hash_multimap_traits.remove_defaults( hmm_v_i2mm_wstr2d )
in possible_values )
def create_suite():
- suite = unittest.TestSuite()
+ suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
return suite
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-23 13:27:32
|
Revision: 1487
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1487&view=rev
Author: roman_yakovenko
Date: 2008-12-23 13:27:29 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
adding another set of tests
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/common_utils.py
pygccxml_dev/unittests/data/msvc/mydll.80.vcproj
pygccxml_dev/unittests/data/msvc/mydll.cpp
pygccxml_dev/unittests/data/msvc/mydll.h
pygccxml_dev/unittests/undname_creator_tester.py
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 08:45:12 UTC (rev 1486)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 13:27:29 UTC (rev 1487)
@@ -111,11 +111,7 @@
else:
return ','.join( map( self.__format_type_as_undecorated, argtypes ) )
- def undecorated_decl(self, calldef):
- """returns string, which contains full function name formatted exactly as
- result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
- options.
- """
+ def __undecorated_calldef( self, calldef ):
calldef_type = calldef.function_type()
result = []
@@ -138,11 +134,34 @@
result.append( 'const' )
return ''.join( result )
+ def __undecorated_variable( self, decl ):
+ result = []
+ if decl.type_qualifiers.has_static:
+ result.append( 'static ' )
+ result.append( self.__format_type_as_undecorated( decl.type ) )
+ result.append( ' ' )
+ if isinstance( decl.parent, declarations.class_t ):
+ result.append( self.__remove_leading_scope( decl.parent.decl_string ) + '::' )
+ result.append( decl.name )
+ return ''.join( result )
+
+ def undecorated_decl(self, decl):
+ """returns string, which contains full function name formatted exactly as
+ result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
+ options.
+ """
+ if isinstance( decl, declarations.calldef_t ):
+ return self.__undecorated_calldef( decl )
+ elif isinstance( decl, declarations.variable_t ):
+ return self.__undecorated_variable( decl )
+ else:
+ raise NotImplementedError()
+
undecorate_blob = undname_creator().undecorate_blob
undecorate_decl = undname_creator().undecorated_decl
class exported_symbols:
- map_file_re = re.compile( r' +\d+ (?P<decorated>.+) \((?P<undecorated>.+)\)$' )
+ map_file_re = re.compile( r' +\d+ (?P<decorated>.+?) \((?P<undecorated>.+)\)$' )
@staticmethod
def load_from_map_file( fname ):
"""returns dictionary { decorated symbol : orignal declaration name }"""
Modified: pygccxml_dev/unittests/data/msvc/mydll.80.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.80.vcproj 2008-12-23 08:45:12 UTC (rev 1486)
+++ pygccxml_dev/unittests/data/msvc/mydll.80.vcproj 2008-12-23 13:27:29 UTC (rev 1487)
@@ -137,6 +137,7 @@
LinkIncremental="1"
GenerateDebugInformation="true"
GenerateMapFile="true"
+ MapFileName="$(TargetDir)$(TargetName).map"
MapExports="true"
SubSystem="2"
OptimizeReferences="2"
Modified: pygccxml_dev/unittests/data/msvc/mydll.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 08:45:12 UTC (rev 1486)
+++ pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 13:27:29 UTC (rev 1487)
@@ -41,6 +41,16 @@
void do_smth( number_aptr_t& ){
}
+
+int myclass_t::my_static_member = 99;
+const int myclass_t::my_const_static_member = 10009;
+int my_global_int = 90;
+volatile int my_volatile_global_variable = 9;
+int my_global_array[10] = {0,1,2,3,4,5,6,7,8,9};
+
+void* get_pvoid(void*){ return 0;}
+void** get_ppvoid(void){return 0;}
+
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
Modified: pygccxml_dev/unittests/data/msvc/mydll.h
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 08:45:12 UTC (rev 1486)
+++ pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 13:27:29 UTC (rev 1487)
@@ -2,6 +2,7 @@
#include <memory>
+
class __declspec(dllexport) number_t{
public:
number_t();
@@ -24,4 +25,27 @@
enum{ auto_ptr_size = sizeof( number_aptr_t ) };
-void __declspec(dllexport) do_smth( number_aptr_t& );
+__declspec(dllexport) void do_smth( number_aptr_t& );
+
+__declspec(dllexport) extern int my_global_int;
+
+typedef void(*do_smth_type)( number_aptr_t& );
+
+__declspec(dllexport) extern volatile int my_volatile_global_variable;
+
+__declspec(dllexport) extern int my_global_array[10];
+
+__declspec(dllexport) void* get_pvoid(void*);
+__declspec(dllexport) void** get_ppvoid(void);
+
+
+class __declspec(dllexport) myclass_t{
+public:
+ static int my_static_member;
+ static const int my_const_static_member;
+ volatile int my_volatile_member;
+
+ do_smth_type* get_do_smth(){ return 0; }
+ void set_do_smth(do_smth_type*){};
+
+};
\ No newline at end of file
Modified: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 08:45:12 UTC (rev 1486)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 13:27:29 UTC (rev 1487)
@@ -30,6 +30,8 @@
tester_t.global_ns.init_optimizer()
def is_included( self, decl ):
+ if not isinstance( decl, ( declarations.calldef_t, declarations.variable_t) ):
+ return False
for suffix in [ self.header, 'memory' ]:
if decl.location.file_name.endswith( suffix ):
return True
@@ -49,7 +51,7 @@
undecorated_blob_names.add( undname )
undecorated_decl_names = set()
- for f in self.global_ns.calldefs(self.is_included):
+ for f in self.global_ns.decls(self.is_included):
undecorated_decl_names.add( msvc.undecorate_decl( f ) )
issuperset = undecorated_decl_names.issuperset( undecorated_blob_names )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-23 08:45:17
|
Revision: 1486
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1486&view=rev
Author: roman_yakovenko
Date: 2008-12-23 08:45:12 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
adding functionality which maps decorated and undecorated names between gccxml and MSVC
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/calldef.py
pygccxml_dev/pygccxml/msvc/__init__.py
pygccxml_dev/pygccxml/msvc/common_utils.py
pygccxml_dev/unittests/data/msvc/mydll.cpp
pygccxml_dev/unittests/data/msvc/mydll.h
pygccxml_dev/unittests/mspdb_playground.py
pygccxml_dev/unittests/test_all.py
Added Paths:
-----------
pygccxml_dev/unittests/data/msvc/mydll.80.vcproj
pygccxml_dev/unittests/undname_creator_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -104,9 +104,7 @@
from calldef import casting_operator_t
from calldef import free_function_t
from calldef import free_operator_t
-from calldef import create_undecorated_name
-
from decl_visitor import decl_visitor_t
from type_visitor import type_visitor_t
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -560,56 +560,3 @@
if decl:
self.__class_types.append( decl )
return self.__class_types
-
-
-def __remove_leading_scope( s ):
- if s and s.startswith( '::' ):
- return s[2:]
- else:
- return s
-
-def __format_type_as_undecorated( type_ ):
- result = []
- type_ = type_traits.remove_alias( type_ )
- base_type_ = type_traits.base_type( type_ )
- base_type_ = type_traits.remove_declarated( base_type_ )
- if type_traits.is_class( base_type_ ) and base_type_.class_type == "struct":
- result.append('struct ')
- result.append( __remove_leading_scope( type_.decl_string ) )
- return ' '.join( result )
-
-def __format_args_as_undecorated( argtypes ):
- if not argtypes:
- return 'void'
- else:
- return ','.join( map( __format_type_as_undecorated, argtypes ) )
-
-def create_undecorated_name(calldef):
- """returns string, which contains full function name formatted exactly as
- result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
- options.
- """
- calldef_type = calldef.function_type()
-
- result = []
- is_mem_fun = isinstance( calldef, member_calldef_t )
- if is_mem_fun and calldef.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL:
- result.append( 'virtual ' )
- if calldef_type.return_type:
- result.append( __format_type_as_undecorated( calldef.return_type ) )
- result.append( ' ' )
- if isinstance( calldef, member_calldef_t ):
- result.append( __remove_leading_scope( calldef.parent.decl_string ) + '::')
-
- result.append( calldef.name )
- if isinstance( calldef, ( constructor_t, destructor_t) ) \
- and templates.is_instantiation( calldef.parent.name ):
- result.append( '<%s>' % ','.join( templates.args( calldef.parent.name ) ) )
-
- result.append( '(%s)' % __format_args_as_undecorated( calldef_type.arguments_types ) )
- if is_mem_fun and calldef.has_const:
- result.append( 'const' )
- return ''.join( result )
-
-
-
Modified: pygccxml_dev/pygccxml/msvc/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/__init__.py 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/pygccxml/msvc/__init__.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -0,0 +1,9 @@
+# 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)
+
+from common_utils import undecorate_blob
+from common_utils import undecorate_decl
+from common_utils import exported_symbols
+from common_utils import UNDECORATE_NAME_OPTIONS
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -1,23 +1,34 @@
+# 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 re
import ctypes
+import ctypes.wintypes
+from .. import declarations
class UNDECORATE_NAME_OPTIONS:
- UNDNAME_COMPLETE = 0
- UNDNAME_NO_LEADING_UNDERSCORES = 1
- UNDNAME_NO_MS_KEYWORDS = 2
- UNDNAME_NO_FUNCTION_RETURNS = 4
- UNDNAME_NO_ALLOCATION_MODEL = 8
- UNDNAME_NO_ALLOCATION_LANGUAGE = 16
- UNDNAME_NO_MS_THISTYPE = 32
- UNDNAME_NO_CV_THISTYPE = 64
- UNDNAME_NO_THISTYPE = 96
- UNDNAME_NO_ACCESS_SPECIFIERS = 128
- UNDNAME_NO_THROW_SIGNATURES = 256
- UNDNAME_NO_MEMBER_TYPE = 512
- UNDNAME_NO_RETURN_UDT_MODEL = 1024
- UNDNAME_32_BIT_DECODE = 2048
- UNDNAME_NAME_ONLY = 4096
- UNDNAME_NO_ARGUMENTS = 8192
- UNDNAME_NO_SPECIAL_SYMS = 16384
+ 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.
+ UNDNAME_NO_FUNCTION_RETURNS = 0x0004 #Disables expansion of return type for primary declaration.
+ UNDNAME_NO_ALLOCATION_MODEL = 0x0008 #Disables expansion of the declaration model.
+ UNDNAME_NO_ALLOCATION_LANGUAGE = 0x0010 #Disables expansion of the declaration language specifier.
+ UNDNAME_RESERVED1 = 0x0020 #RESERVED.
+ UNDNAME_RESERVED2 = 0x0040 #RESERVED.
+ UNDNAME_NO_THISTYPE = 0x0060 #Disables all modifiers on the this type.
+ UNDNAME_NO_ACCESS_SPECIFIERS = 0x0080 #Disables expansion of access specifiers for members.
+ UNDNAME_NO_THROW_SIGNATURES = 0x0100 #Disables expansion of "throw-signatures" for functions and pointers to functions.
+ UNDNAME_NO_MEMBER_TYPE = 0x0200 #Disables expansion of static or virtual members.
+ UNDNAME_NO_RETURN_UDT_MODEL = 0x0400 #Disables expansion of the Microsoft model for UDT returns.
+ UNDNAME_32_BIT_DECODE = 0x0800 #Undecorates 32-bit decorated names.
+ UNDNAME_NAME_ONLY = 0x1000 #Gets only the name for primary declaration; returns just [scope::]name. Expands template params.
+ UNDNAME_TYPE_ONLY = 0x2000 #Input is just a type encoding; composes an abstract declarator.
+ UNDNAME_HAVE_PARAMETERS = 0x4000 #The real template parameters are available.
+ UNDNAME_NO_ECSU = 0x8000 #Suppresses enum/class/struct/union.
+ UNDNAME_NO_IDENT_CHAR_CHECK = 0x10000 #Suppresses check for valid identifier characters.
+ UNDNAME_NO_PTR64 = 0x20000 #Does not include ptr64 in output.
UNDNAME_SCOPES_ONLY = UNDNAME_NO_LEADING_UNDERSCORES \
| UNDNAME_NO_MS_KEYWORDS \
@@ -26,18 +37,135 @@
| UNDNAME_NO_ALLOCATION_LANGUAGE \
| UNDNAME_NO_ACCESS_SPECIFIERS \
| UNDNAME_NO_THROW_SIGNATURES \
- | UNDNAME_NO_MEMBER_TYPE
+ | UNDNAME_NO_MEMBER_TYPE \
+ | UNDNAME_NO_ECSU \
+ | UNDNAME_NO_IDENT_CHAR_CHECK
+ SHORT_UNIQUE_NAME = UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
-undecorate_name_impl = ctypes.windll.dbghelp.UnDecorateSymbolName
-undecorate_name_impl.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint]
+#~ The following code doesn't work - access violation
-def undecorate_name( name, options=None ):
- if options is None:
- options = UNDECORATE_NAME_OPTIONS.UNDNAME_COMPLETE
- buffer = ctypes.create_string_buffer(1024*16)
- res = undecorate_name_impl(name, buffer, ctypes.sizeof(buffer), options)
- if res:
- return str(buffer[:res])
- else:
- return name
+#~__unDName definition was taken from:
+#~http://www.tech-archive.net/Archive/VC/microsoft.public.vc.language/2006-02/msg00754.html
+
+#~ 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
+
+class undname_creator:
+ __undname = ctypes.windll.dbghelp.UnDecorateSymbolName
+ __undname.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint]
+ __clean_ecsu = re.compile( r'(?:(^|\W))(?:(class|enum|struct|union))' )
+
+ def undecorate_blob( self, name, options=None ):
+ if options is None:
+ options = UNDECORATE_NAME_OPTIONS.SHORT_UNIQUE_NAME
+ buffer = ctypes.create_string_buffer(1024*16)
+ res = self.__undname( str(name), buffer, ctypes.sizeof(buffer), options)
+ if res:
+ undname = str(buffer[:res])
+ if UNDECORATE_NAME_OPTIONS.UNDNAME_NO_ECSU & options:
+ undname = self.__clean_ecsu.sub( '', undname )
+ return undname.strip()
+ else:
+ return name
+
+ def __remove_leading_scope( self, s ):
+ if s and s.startswith( '::' ):
+ return s[2:]
+ else:
+ return s
+
+ def __format_type_as_undecorated( self, type_ ):
+ result = []
+ type_ = declarations.remove_alias( type_ )
+ result.append( self.__remove_leading_scope( type_.decl_string ) )
+ return ' '.join( result )
+
+ def __format_args_as_undecorated( self, argtypes ):
+ if not argtypes:
+ return 'void'
+ else:
+ return ','.join( map( self.__format_type_as_undecorated, argtypes ) )
+
+ def undecorated_decl(self, calldef):
+ """returns string, which contains full function name formatted exactly as
+ result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
+ options.
+ """
+ calldef_type = calldef.function_type()
+
+ result = []
+ is_mem_fun = isinstance( calldef, declarations.member_calldef_t )
+ if is_mem_fun and calldef.virtuality != declarations.VIRTUALITY_TYPES.NOT_VIRTUAL:
+ result.append( 'virtual ' )
+ if calldef_type.return_type:
+ result.append( self.__format_type_as_undecorated( calldef.return_type ) )
+ result.append( ' ' )
+ if is_mem_fun:
+ result.append( self.__remove_leading_scope( calldef.parent.decl_string ) + '::')
+
+ result.append( calldef.name )
+ if isinstance( calldef, ( declarations.constructor_t, declarations.destructor_t) ) \
+ and declarations.templates.is_instantiation( calldef.parent.name ):
+ result.append( '<%s>' % ','.join( declarations.templates.args( calldef.parent.name ) ) )
+
+ result.append( '(%s)' % self.__format_args_as_undecorated( calldef_type.arguments_types ) )
+ if is_mem_fun and calldef.has_const:
+ result.append( 'const' )
+ return ''.join( result )
+
+undecorate_blob = undname_creator().undecorate_blob
+undecorate_decl = undname_creator().undecorated_decl
+
+class exported_symbols:
+ map_file_re = re.compile( r' +\d+ (?P<decorated>.+) \((?P<undecorated>.+)\)$' )
+ @staticmethod
+ def load_from_map_file( fname ):
+ """returns dictionary { decorated symbol : orignal declaration name }"""
+ result = {}
+ f = open( fname )
+ exports_started = False
+ for line in f:
+ if not exports_started:
+ exports_started = bool( 'Exports' == line.strip() )
+ if not exports_started:
+ continue
+ line = line.rstrip()
+ found = exported_symbols.map_file_re.match( line )
+ if found:
+ result[ found.group( 'decorated' ) ] = found.group( 'undecorated' )
+ return result
+
+#~ quick & dirty test
+#~ symbols = exported_symbols.load_from_map_file( r'D:\dev\language-binding\sources\pygccxml_dev\unittests\data\msvc\Release\mydll.map' )
+#~ for decorated, undecorated in symbols.iteritems():
+ #~ print '---------------------------------------------------------------------'
+ #~ print decorated
+ #~ print undecorated
+ #~ print undecorate_blob( decorated )
+ #~ print '====================================================================='
+
Added: pygccxml_dev/unittests/data/msvc/mydll.80.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.80.vcproj (rev 0)
+++ pygccxml_dev/unittests/data/msvc/mydll.80.vcproj 2008-12-23 08:45:12 UTC (rev 1486)
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="windows-1255"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="mydll"
+ ProjectGUID="{0B9466BC-60F8-4FC2-A1A9-6A01577690E5}"
+ RootNamespace="mydll"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MYDLL_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MYDLL_EXPORTS"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapExports="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\mydll.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mydll.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Modified: pygccxml_dev/unittests/data/msvc/mydll.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 08:45:12 UTC (rev 1486)
@@ -2,15 +2,15 @@
#include "windows.h"
#include <iostream>
-number_t::number_t()
-: m_value(0)
-{
+number_t::number_t()
+: m_value(0)
+{
// std::cout << "{C++} number_t( 0 )" << std::endl;
}
-number_t::number_t(int value)
-: m_value(value)
+number_t::number_t(int value)
+: m_value(value)
{
// std::cout << "{C++} number_t( " << value << " )" << std::endl;
}
@@ -19,7 +19,7 @@
// std::cout << "{C++} ~number_t()" << std::endl;
}
void number_t::print_it() const {
- std::cout << "{C++} value: " << m_value << std::endl;
+ std::cout << "{C++} value: " << m_value << std::endl;
}
int number_t::get_value() const{
@@ -57,3 +57,72 @@
return TRUE;
}
+
+/*
+static int myclass::myStaticMember
+const int myclass::myconstStaticMember
+volatile int myclass::myvolatileStaticMember
+x myfnptr;
+int myglobal;
+volatile int myvolatile;
+int myarray[10];
+void **Fv_PPv(void)
+void *Fv_Pv(void)
+int FA10_i_i(int a[10])
+int FPi_i(int *a)
+int Fc_i(char bar)
+int Ff_i(float bar)
+int Fg_i(double bar)
+int Fi_i(int bar)
+int Fie_i(int bar, ...)
+int Fii_i(int bar, int goo)
+int Fiii_i(int bar, int goo, int hoo)
+void Fmxmx_v(myclass arg1, x arg2, myclass arg3, x arg4)
+void Fmyclass_v(myclass m)
+const int Fv_Ci(void)
+long double Fv_Lg(void)
+int& Fv_Ri(void)
+signed char Fv_Sc(void)
+unsigned char Fv_Uc(void)
+unsigned int Fv_Ui(void)
+unsigned long Fv_Ul(void)
+unsigned short Fv_Us(void)
+volatile int Fv_Vi(void)
+char Fv_c(void)
+float Fv_f(void)
+double Fv_g(void)
+int Fv_i(void)
+long Fv_l(void)
+short Fv_s(void)
+void Fv_v(void)
+void __cdecl Fv_v_cdecl(void)
+void __fastcall Fv_v_fastcall(void)
+void __stdcall Fv_v_stdcall(void)
+int Fx_i(x fnptr)
+int Fxix_i(x fnptr, int i, x fnptr3)
+int Fxx_i(x fnptr, x fnptr2)
+int Fxxi_i(x fnptr, x fnptr2, x fnptr3, int i)
+int Fxxx_i(x fnptr, x fnptr2, x fnptr3)
+int Fxyxy_i(x fnptr, y fnptr2, x fnptr3, y fnptr4)
+void myclass::operator delete(void *p)
+int myclass::Fi_i(int bar)
+static int myclass::Fis_i(int bar)
+void __cdecl myclass::Fv_v_cdecl(void)
+void __fastcall myclass::Fv_v_fastcall(void)
+void __stdcall myclass::Fv_v_stdcall(void)
+myclass::myclass(int x)
+myclass::myclass(void)
+int myclass::nested::Fi_i(int bar)
+myclass::nested::nested(void)
+myclass::nested::~nested()
+myclass myclass::operator+(int x)
+myclass myclass::operator++()
+myclass myclass::operator++(int)
+myclass& myclass::operator=(const myclass& from)
+myclass::~myclass()
+int nested::Fi_i(int bar)
+nested::nested(void)
+nested::~nested()
+void* myclass::operator new(size_t size)
+*/
+
Modified: pygccxml_dev/unittests/data/msvc/mydll.h
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 08:45:12 UTC (rev 1486)
@@ -22,4 +22,6 @@
typedef std::auto_ptr< number_t > number_aptr_t;
-void __declspec(dllexport) do_smth( number_aptr_t& );
\ No newline at end of file
+enum{ auto_ptr_size = sizeof( number_aptr_t ) };
+
+void __declspec(dllexport) do_smth( number_aptr_t& );
Modified: pygccxml_dev/unittests/mspdb_playground.py
===================================================================
--- pygccxml_dev/unittests/mspdb_playground.py 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/unittests/mspdb_playground.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -8,7 +8,7 @@
from pygccxml.msvc import common_utils as msvc_utils
pdb_file = r'E:\development\language-binding\pyplusplus_dev\pyplusplus\cpptypes\mydll\release\mydll.pdb'
-
+pdb_file = r'D:\AC_SERVER_4_VS2005\libs\Debug\SPDBLib_d.pdb'
reader = mspdb.decl_loader_t( pdb_file )
opt = mspdb.enums.UNDECORATE_NAME_OPTIONS.UNDNAME_SHORT_UNIQUE
opt = 0
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2008-12-22 22:52:20 UTC (rev 1485)
+++ pygccxml_dev/unittests/test_all.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -52,6 +52,7 @@
import function_traits_tester
import better_templates_matcher_tester
import declaration_matcher_tester
+import undname_creator_tester
testers = [
decl_string_tester
@@ -100,6 +101,7 @@
, function_traits_tester
, better_templates_matcher_tester
, declaration_matcher_tester
+ , undname_creator_tester
]
def create_suite():
Added: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py (rev 0)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 08:45:12 UTC (rev 1486)
@@ -0,0 +1,82 @@
+# 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 sys
+import unittest
+import autoconfig
+import parser_test_case
+
+import pprint
+from pygccxml import msvc
+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 = r'msvc\mydll.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 is_included( self, decl ):
+ for suffix in [ self.header, 'memory' ]:
+ if decl.location.file_name.endswith( suffix ):
+ return True
+ else:
+ return False
+
+
+ def test( self ):
+ map_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.map' )
+ symbols = msvc.exported_symbols.load_from_map_file( map_file )
+
+ undecorated_blob_names = set()
+ for blob in symbols.iterkeys():
+ undname = msvc.undecorate_blob( blob )
+ if "`" in undname:
+ continue
+ undecorated_blob_names.add( undname )
+
+ undecorated_decl_names = set()
+ for f in self.global_ns.calldefs(self.is_included):
+ undecorated_decl_names.add( msvc.undecorate_decl( f ) )
+
+ issuperset = undecorated_decl_names.issuperset( undecorated_blob_names )
+ if not issuperset:
+ common = undecorated_decl_names.intersection( undecorated_blob_names )
+
+ undecorated_decl_names.difference_update(common)
+ undecorated_blob_names.difference_update(common)
+
+ msg = [ "undecorate_decl - failed" ]
+ msg.append( "undecorated_decl_names :" )
+ for i in undecorated_decl_names:
+ msg.append( '\t==>%s<==' % i )
+ msg.append( "undecorated_blob_names :" )
+ for i in undecorated_blob_names:
+ msg.append( '\t==>%s<==' % i )
+
+ self.fail( os.linesep.join(msg) )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ if 'win' in sys.platform:
+ 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...> - 2008-12-22 22:59:21
|
Revision: 1484
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1484&view=rev
Author: roman_yakovenko
Date: 2008-12-22 22:11:51 +0000 (Mon, 22 Dec 2008)
Log Message:
-----------
update gccxml
Modified Paths:
--------------
gccxml_bin/v09/win32/bin/gccxml.exe
gccxml_bin/v09/win32/bin/gccxml_cc1plus.exe
gccxml_bin/v09/win32/bin/gccxml_vcconfig.exe
gccxml_bin/v09/win32/share/gccxml-0.9/Intel/find_flags
gccxml_bin/v09/win32/share/gccxml-0.9/MIPSpro/find_flags
gccxml_bin/v09/win32/share/gccxml-0.9/gccxml_config
gccxml_bin/v09/win32/share/man/man1/gccxml.1
Added Paths:
-----------
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/CodeAnalysis/
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/CodeAnalysis/sourceannotations.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/algorithm
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/crtdbg.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/crtdefs.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/crtdefs.h.orig
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/deque
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/eh.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/iosfwd
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/iterator
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/limits
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/list
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/locale
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/memory
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/sal.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/setjmp.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/typeinfo
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/vector
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/vector.orig
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xhash
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xhash.orig
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xlocale
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xlocmes
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xlocmon
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xlocnum
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xlocnum.orig
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xloctime
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xstddef
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xutility
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/xutility.orig
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/yvals.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/yvals.h.orig
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/OAIdl.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/ObjBase.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/PropIdl.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/WinNT.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/ktmtypes.h
gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/PlatformSDK/specstrings_strict.h
Removed Paths:
-------------
gccxml_bin/v09/win32/share/gccxml-0.9/GCC/find_flags
gccxml_bin/v09/win32/share/gccxml-0.9/gccxml_find_flags
Modified: gccxml_bin/v09/win32/bin/gccxml.exe
===================================================================
(Binary files differ)
Modified: gccxml_bin/v09/win32/bin/gccxml_cc1plus.exe
===================================================================
(Binary files differ)
Modified: gccxml_bin/v09/win32/bin/gccxml_vcconfig.exe
===================================================================
(Binary files differ)
Deleted: gccxml_bin/v09/win32/share/gccxml-0.9/GCC/find_flags
===================================================================
--- gccxml_bin/v09/win32/share/gccxml-0.9/GCC/find_flags 2008-12-21 22:28:17 UTC (rev 1483)
+++ gccxml_bin/v09/win32/share/gccxml-0.9/GCC/find_flags 2008-12-22 22:11:51 UTC (rev 1484)
@@ -1,112 +0,0 @@
-#!/bin/sh
-#=============================================================================
-#
-# Program: GCC-XML
-# Module: $RCSfile: find_flags,v $
-# Language: C++
-# Date: $Date: 2008-08-07 15:36:08 $
-# Version: $Revision: 1.23 $
-#
-# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
-# See Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even
-# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the above copyright notices for more information.
-#
-#=============================================================================
-
-# Find the GCC executable name.
-if test "x$1" = "x" ; then
- if test "x${CXX}" = "x" ; then
- CXX=gcc
- fi
-else
- CXX="$1"
- shift
- CXXFLAGS="$@"
-fi
-
-# Find the macro definition options.
-MACROS=`echo "" | ${CXX} -x c++ -E -dM ${CXXFLAGS} - 2>/dev/null |
- sed -n '
-/^#define / {s/#define \([A-Za-z_][A-Za-z0-9_()]*\) \(.*\)/-D\1='\''\2'\''/;p;}
-' |
- awk '
-BEGIN { first=1 }
-/./ { if(first) { printf("%s", $0); first=0 } else { printf(" %s", $0) } }
-'`
-
-# Find the include path options.
-INCLUDES=`
- echo "" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>&1 |
- awk '/^[^ \/].*$/ { if (f) { printf("\n"); exit } }
- /^[ ]*(\/[^ ]*)( \(.*\))?$/ {
- if (f) {
- if (match($1,"/Frameworks")) {
- printf("-F%s ",$1)
- } else {
- printf("-isystem%s ",$1)
- }
- }
- }
- /\#include <\.\.\..*$/ {f=1} ' -
-`
-
-# The support headers are located where this script is.
-SELFPATH=`echo $0 | sed -n '/\//{s/\/find_flags//;p;}'`
-if test "x$SELFPATH" = "x" ; then SELFPATH="." ; fi
-SELFPATH=`cd "$SELFPATH" ; pwd`
-
-# Determine the major version number.
-MAJOR_VERSION=`
-echo "__GNUC__" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>/dev/null |
- sed -n '/^[0-9]/{s/[^0-9]//g;p;}'`
-
-MINOR_VERSION=`
-echo "__GNUC_MINOR__" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>/dev/null |
- sed -n '/^[0-9]/{s/[^0-9]//g;p;}'`
-
-# hack to handle bad gcc 4.0 on RedHat
-if [ "$MAJOR_VERSION" = 4 ]; then
- if echo "$INCLUDES" | grep "c++/3\.4" > /dev/null 2>&1; then
- MAJOR_VERSION=3
- MINOR_VERSION=4
- fi
-fi
-
-# For GCC versions before 3, some special options are needed.
-if [ "$MAJOR_VERSION" -lt 3 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/2.95\" $INCLUDES"
- if [ "$MINOR_VERSION" = 96 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/2.96\" $INCLUDES"
- fi
-elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 3 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/4.3\" $INCLUDES"
- SPECIAL="-include \"gccxml_builtins.h\""
-elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 2 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/4.2\" $INCLUDES"
- SPECIAL="-include \"gccxml_builtins.h\""
-elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 1 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/4.1\" $INCLUDES"
- SPECIAL="-include \"gccxml_builtins.h\""
-elif [ "$MAJOR_VERSION" = 4 -a "$MINOR_VERSION" -ge 0 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/4.0\" $INCLUDES"
- SPECIAL="-include \"gccxml_builtins.h\""
-elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" -ge 4 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/3.4\" $INCLUDES"
- SPECIAL="-include \"gccxml_builtins.h\""
-elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 3 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/3.3\" $INCLUDES"
- SPECIAL="-include \"gccxml_builtins.h\""
-elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 2 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/3.2\" $INCLUDES"
-elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 1 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/3.1\" $INCLUDES"
-elif [ "$MAJOR_VERSION" = 3 -a "$MINOR_VERSION" = 0 ]; then
- INCLUDES="-iwrapper\"$SELFPATH/3.0\" $INCLUDES"
-fi
-
-# Format and print out the options.
-OPTIONS="$MACROS $INCLUDES $SPECIAL"
-echo $OPTIONS
Modified: gccxml_bin/v09/win32/share/gccxml-0.9/Intel/find_flags
===================================================================
--- gccxml_bin/v09/win32/share/gccxml-0.9/Intel/find_flags 2008-12-21 22:28:17 UTC (rev 1483)
+++ gccxml_bin/v09/win32/share/gccxml-0.9/Intel/find_flags 2008-12-22 22:11:51 UTC (rev 1484)
@@ -1,56 +1,56 @@
-#!/bin/sh
-#=============================================================================
-#
-# Program: GCC-XML
-# Module: $RCSfile: find_flags,v $
-# Language: C++
-# Date: $Date: 2005/04/07 12:51:07 $
-# Version: $Revision: 1.5 $
-#
-# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
-# See Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even
-# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the above copyright notices for more information.
-#
-#=============================================================================
-
-# Find the GCC executable name.
-if test "x$1" = "x" ; then
- if test "x${CXX}" = "x" ; then
- CXX=gcc
- fi
-else
- CXX="$1"
- shift
- CXXFLAGS="$@"
-fi
-
-# Find the macro definition options.
-MACROS=`echo "" | ${CXX} -x c++ -E -dM ${CXXFLAGS} - 2>/dev/null |
- sed -n '
-/^#define / {s/#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)/-D\1='\''\2'\''/;p;}
-' |
- awk '
-BEGIN { first=1 }
-/./ { if(first) { printf("%s", $0); first=0 } else { printf(" %s", $0) } }
-'`
-
-# Find the include path options.
-INCLUDES=`
- echo "" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>&1 |
- awk '/^[ \t]*-I\/.* \\\\$/ { printf("%s ",$1) }
- END {printf("\n")}' -
-`
-
-# The support headers are located where this script is.
-SELFPATH=`echo $0 | sed -n '/\//{s/\/find_flags//;p;}'`
-if test "x$SELFPATH" = "x" ; then SELFPATH="." ; fi
-SELFPATH=`cd "$SELFPATH" ; pwd`
-
-INCLUDES="-iwrapper\"$SELFPATH\" $INCLUDES"
-
-# Format and print out the options.
-OPTIONS="$MACROS -D_WCHAR_T $INCLUDES"
-echo $OPTIONS
+#!/bin/sh
+#=============================================================================
+#
+# Program: GCC-XML
+# Module: $RCSfile: find_flags,v $
+# Language: C++
+# Date: $Date: 2005-04-07 12:51:07 $
+# Version: $Revision: 1.5 $
+#
+# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+# See Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even
+# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the above copyright notices for more information.
+#
+#=============================================================================
+
+# Find the GCC executable name.
+if test "x$1" = "x" ; then
+ if test "x${CXX}" = "x" ; then
+ CXX=gcc
+ fi
+else
+ CXX="$1"
+ shift
+ CXXFLAGS="$@"
+fi
+
+# Find the macro definition options.
+MACROS=`echo "" | ${CXX} -x c++ -E -dM ${CXXFLAGS} - 2>/dev/null |
+ sed -n '
+/^#define / {s/#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)/-D\1='\''\2'\''/;p;}
+' |
+ awk '
+BEGIN { first=1 }
+/./ { if(first) { printf("%s", $0); first=0 } else { printf(" %s", $0) } }
+'`
+
+# Find the include path options.
+INCLUDES=`
+ echo "" | ${CXX} -v -x c++ -E ${CXXFLAGS} - 2>&1 |
+ awk '/^[ \t]*-I\/.* \\\\$/ { printf("%s ",$1) }
+ END {printf("\n")}' -
+`
+
+# The support headers are located where this script is.
+SELFPATH=`echo $0 | sed -n '/\//{s/\/find_flags//;p;}'`
+if test "x$SELFPATH" = "x" ; then SELFPATH="." ; fi
+SELFPATH=`cd "$SELFPATH" ; pwd`
+
+INCLUDES="-iwrapper\"$SELFPATH\" $INCLUDES"
+
+# Format and print out the options.
+OPTIONS="$MACROS -D_WCHAR_T $INCLUDES"
+echo $OPTIONS
Modified: gccxml_bin/v09/win32/share/gccxml-0.9/MIPSpro/find_flags
===================================================================
--- gccxml_bin/v09/win32/share/gccxml-0.9/MIPSpro/find_flags 2008-12-21 22:28:17 UTC (rev 1483)
+++ gccxml_bin/v09/win32/share/gccxml-0.9/MIPSpro/find_flags 2008-12-22 22:11:51 UTC (rev 1484)
@@ -1,137 +1,137 @@
-#!/bin/sh
-#=============================================================================
-#
-# Program: GCC-XML
-# Module: $RCSfile: find_flags,v $
-# Language: C++
-# Date: $Date: 2005/08/01 22:11:33 $
-# Version: $Revision: 1.5 $
-#
-# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
-# See Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even
-# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the above copyright notices for more information.
-#
-#=============================================================================
-
-# Find the MIPSPro executable name.
-if test "x$1" = "x" ; then
- if test "x${CXX}" = "x" ; then
- CXX=CC
- fi
-else
- CXX="$1"
- shift
- CXXFLAGS="$@"
-fi
-
-GCCXML_PID="$$"
-TESTFILE="find_flags_temp$GCCXML_PID"
-
-# Construct a test input file that checks for some builtin definitions
-# in the compiler that are not displayed by the -v option. This list
-# was obtained by running "strings /usr/lib32/cmplrs/fecc" and testing
-# for definitions with a giant version of the string below.
-echo "
-#ifdef _BOOL
-D_BOOL _BOOL
-#endif
-#ifdef _EXPLICIT_IS_KEYWORD
-D_EXPLICIT_IS_KEYWORD _EXPLICIT_IS_KEYWORD
-#endif
-#ifdef _LIBC_IN_NAMESPACE_STD_
-D_LIBC_IN_NAMESPACE_STD_ _LIBC_IN_NAMESPACE_STD_
-#endif
-#ifdef _MEMBER_TEMPLATES
-D_MEMBER_TEMPLATES _MEMBER_TEMPLATES
-#endif
-#ifdef _MUTABLE_IS_KEYWORD
-D_MUTABLE_IS_KEYWORD _MUTABLE_IS_KEYWORD
-#endif
-#ifdef _NAMESPACES
-D_NAMESPACES _NAMESPACES
-#endif
-#ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES
-D_PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES
-#endif
-#ifdef _STANDARD_C_PLUS_PLUS
-D_STANDARD_C_PLUS_PLUS _STANDARD_C_PLUS_PLUS
-#endif
-#ifdef _TYPENAME_IS_KEYWORD
-D_TYPENAME_IS_KEYWORD _TYPENAME_IS_KEYWORD
-#endif
-#ifdef _WCHAR_T
-D_WCHAR_T _WCHAR_T
-#endif
-#ifdef _WCHAR_T_IS_KEYWORD
-D_WCHAR_T_IS_KEYWORD _WCHAR_T_IS_KEYWORD
-#endif
-#ifdef __ANSI_CPP__
-D__ANSI_CPP__ __ANSI_CPP__
-#endif
-#ifdef __ARRAY_OPERATORS
-D__ARRAY_OPERATORS __ARRAY_OPERATORS
-#endif
-#ifdef __EDG_ABI_COMPATIBILITY_VERSION
-D__EDG_ABI_COMPATIBILITY_VERSION __EDG_ABI_COMPATIBILITY_VERSION
-#endif
-#ifdef __EDG_RUNTIME_USES_NAMESPACES
-D__EDG_RUNTIME_USES_NAMESPACES __EDG_RUNTIME_USES_NAMESPACES
-#endif
-#ifdef __EDG_VERSION__
-D__EDG_VERSION__ __EDG_VERSION__
-#endif
-#ifdef __EDG__
-D__EDG__ __EDG__
-#endif
-#ifdef __EXCEPTIONS
-D__EXCEPTIONS __EXCEPTIONS
-#endif
-#ifdef __LIBC_MATH_OVERLOAD__
-D__LIBC_MATH_OVERLOAD__ __LIBC_MATH_OVERLOAD__
-#endif
-#ifdef __RTTI
-D__RTTI __RTTI
-#endif
-#ifdef __STDC__
-D__STDC__ __STDC__
-#endif
-" > /tmp/$TESTFILE.cxx
-
-# Find the macro definition options.
-MACROS=`
-${CXX} ${CXXFLAGS} -E -v /tmp/$TESTFILE.cxx 2>&1 |
-sed -n '/_COMPILER_VERSION/{s/ \/tmp\/'$TESTFILE'.cxx.*$//
-s/ -/\\
--/g;p;}' |
-sed -n '/^-D.*$/{s/-D\([^=]*\)=\([^ ]\{1,\} .*\)/-D\1='\''\2'\''/;p;}' |
-sed -n 'H;${g;s/\n/ /g;p;}'`
-
-# Find the internally defined macros.
-LANGSTD=`
-${CXX} ${CXXFLAGS} -E -v /tmp/$TESTFILE.cxx 2>&1 |
-sed -n '/^D/ {s/^D/-D/;s/ /=/;p;}' |
-sed -n 'H;${g;s/\n/ /g;p;}'`
-
-# Find the include path options.
-INCLUDES=`
-${CXX} ${CXXFLAGS} -E -v /tmp/$TESTFILE.cxx 2>&1 |
-sed -n '/_COMPILER_VERSION/{s/ \/tmp\/'$TESTFILE'.cxx.*$//
-s/ -/\\
--/g;p;}' |
-sed -n '/^-I.*$/{p;}' |
-sed -n 'H;${g;s/\n/ /g;p;}'`
-
-# The support headers are located where this script is.
-SELFPATH=`echo $0 | sed -n '/\//{s/\/find_flags//;p;}'`
-if test "x$SELFPATH" = "x" ; then SELFPATH="." ; fi
-SELFPATH=`cd "$SELFPATH" ; pwd`
-INCLUDES="-iwrapper\"$SELFPATH/7.3\" $INCLUDES"
-
-rm -f /tmp/$TESTFILE.cxx
-
-# Format and print out the options.
-OPTIONS="$MACROS $LANGSTD $INCLUDES"
-echo $OPTIONS
+#!/bin/sh
+#=============================================================================
+#
+# Program: GCC-XML
+# Module: $RCSfile: find_flags,v $
+# Language: C++
+# Date: $Date: 2005-08-01 22:11:33 $
+# Version: $Revision: 1.5 $
+#
+# Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+# See Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even
+# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the above copyright notices for more information.
+#
+#=============================================================================
+
+# Find the MIPSPro executable name.
+if test "x$1" = "x" ; then
+ if test "x${CXX}" = "x" ; then
+ CXX=CC
+ fi
+else
+ CXX="$1"
+ shift
+ CXXFLAGS="$@"
+fi
+
+GCCXML_PID="$$"
+TESTFILE="find_flags_temp$GCCXML_PID"
+
+# Construct a test input file that checks for some builtin definitions
+# in the compiler that are not displayed by the -v option. This list
+# was obtained by running "strings /usr/lib32/cmplrs/fecc" and testing
+# for definitions with a giant version of the string below.
+echo "
+#ifdef _BOOL
+D_BOOL _BOOL
+#endif
+#ifdef _EXPLICIT_IS_KEYWORD
+D_EXPLICIT_IS_KEYWORD _EXPLICIT_IS_KEYWORD
+#endif
+#ifdef _LIBC_IN_NAMESPACE_STD_
+D_LIBC_IN_NAMESPACE_STD_ _LIBC_IN_NAMESPACE_STD_
+#endif
+#ifdef _MEMBER_TEMPLATES
+D_MEMBER_TEMPLATES _MEMBER_TEMPLATES
+#endif
+#ifdef _MUTABLE_IS_KEYWORD
+D_MUTABLE_IS_KEYWORD _MUTABLE_IS_KEYWORD
+#endif
+#ifdef _NAMESPACES
+D_NAMESPACES _NAMESPACES
+#endif
+#ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES
+D_PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES
+#endif
+#ifdef _STANDARD_C_PLUS_PLUS
+D_STANDARD_C_PLUS_PLUS _STANDARD_C_PLUS_PLUS
+#endif
+#ifdef _TYPENAME_IS_KEYWORD
+D_TYPENAME_IS_KEYWORD _TYPENAME_IS_KEYWORD
+#endif
+#ifdef _WCHAR_T
+D_WCHAR_T _WCHAR_T
+#endif
+#ifdef _WCHAR_T_IS_KEYWORD
+D_WCHAR_T_IS_KEYWORD _WCHAR_T_IS_KEYWORD
+#endif
+#ifdef __ANSI_CPP__
+D__ANSI_CPP__ __ANSI_CPP__
+#endif
+#ifdef __ARRAY_OPERATORS
+D__ARRAY_OPERATORS __ARRAY_OPERATORS
+#endif
+#ifdef __EDG_ABI_COMPATIBILITY_VERSION
+D__EDG_ABI_COMPATIBILITY_VERSION __EDG_ABI_COMPATIBILITY_VERSION
+#endif
+#ifdef __EDG_RUNTIME_USES_NAMESPACES
+D__EDG_RUNTIME_USES_NAMESPACES __EDG_RUNTIME_USES_NAMESPACES
+#endif
+#ifdef __EDG_VERSION__
+D__EDG_VERSION__ __EDG_VERSION__
+#endif
+#ifdef __EDG__
+D__EDG__ __EDG__
+#endif
+#ifdef __EXCEPTIONS
+D__EXCEPTIONS __EXCEPTIONS
+#endif
+#ifdef __LIBC_MATH_OVERLOAD__
+D__LIBC_MATH_OVERLOAD__ __LIBC_MATH_OVERLOAD__
+#endif
+#ifdef __RTTI
+D__RTTI __RTTI
+#endif
+#ifdef __STDC__
+D__STDC__ __STDC__
+#endif
+" > /tmp/$TESTFILE.cxx
+
+# Find the macro definition options.
+MACROS=`
+${CXX} ${CXXFLAGS} -E -v /tmp/$TESTFILE.cxx 2>&1 |
+sed -n '/_COMPILER_VERSION/{s/ \/tmp\/'$TESTFILE'.cxx.*$//
+s/ -/\\
+-/g;p;}' |
+sed -n '/^-D.*$/{s/-D\([^=]*\)=\([^ ]\{1,\} .*\)/-D\1='\''\2'\''/;p;}' |
+sed -n 'H;${g;s/\n/ /g;p;}'`
+
+# Find the internally defined macros.
+LANGSTD=`
+${CXX} ${CXXFLAGS} -E -v /tmp/$TESTFILE.cxx 2>&1 |
+sed -n '/^D/ {s/^D/-D/;s/ /=/;p;}' |
+sed -n 'H;${g;s/\n/ /g;p;}'`
+
+# Find the include path options.
+INCLUDES=`
+${CXX} ${CXXFLAGS} -E -v /tmp/$TESTFILE.cxx 2>&1 |
+sed -n '/_COMPILER_VERSION/{s/ \/tmp\/'$TESTFILE'.cxx.*$//
+s/ -/\\
+-/g;p;}' |
+sed -n '/^-I.*$/{p;}' |
+sed -n 'H;${g;s/\n/ /g;p;}'`
+
+# The support headers are located where this script is.
+SELFPATH=`echo $0 | sed -n '/\//{s/\/find_flags//;p;}'`
+if test "x$SELFPATH" = "x" ; then SELFPATH="." ; fi
+SELFPATH=`cd "$SELFPATH" ; pwd`
+INCLUDES="-iwrapper\"$SELFPATH/7.3\" $INCLUDES"
+
+rm -f /tmp/$TESTFILE.cxx
+
+# Format and print out the options.
+OPTIONS="$MACROS $LANGSTD $INCLUDES"
+echo $OPTIONS
Added: gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/CodeAnalysis/sourceannotations.h
===================================================================
--- gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/CodeAnalysis/sourceannotations.h (rev 0)
+++ gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/CodeAnalysis/sourceannotations.h 2008-12-22 22:11:51 UTC (rev 1484)
@@ -0,0 +1,289 @@
+#if _MSC_VER >= 1400
+
+#pragma once
+
+#ifndef _M_CEE_SAFE // Source annotation attributes don't work with /clr:safe
+
+#if !defined(_W64)
+#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+#define _W64 __w64
+#else
+#define _W64
+#endif
+#endif
+
+#ifndef _SIZE_T_DEFINED
+#ifdef _WIN64
+typedef unsigned __int64 size_t;
+#else
+typedef _W64 unsigned int size_t;
+#endif
+#define _SIZE_T_DEFINED
+#endif
+
+#ifndef _WCHAR_T_DEFINED
+typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif
+
+
+#pragma push_macro( "SA" )
+#pragma push_macro( "REPEATABLE" )
+
+#ifdef __cplusplus
+#define SA( id ) id
+#define REPEATABLE
+#else // !__cplusplus
+#define SA( id ) SA_##id
+#define REPEATABLE
+#endif // !__cplusplus
+
+#ifdef __cplusplus
+namespace vc_attributes
+{
+#endif // __cplusplus
+
+enum SA( YesNoMaybe )
+{
+ // Choose values that we can detect as invalid if they are or'd together
+ SA( No ) = 0x0fff0001,
+ SA( Maybe ) = 0x0fff0010,
+ SA( Yes ) = 0x0fff0100
+};
+
+typedef enum SA( YesNoMaybe ) SA( YesNoMaybe );
+
+enum SA( AccessType )
+{
+ SA( NoAccess ) = 0,
+ SA( Read ) = 1,
+ SA( Write ) = 2,
+ SA( ReadWrite ) = 3
+};
+
+typedef enum SA( AccessType ) SA( AccessType );
+
+#ifndef SAL_NO_ATTRIBUTE_DECLARATIONS
+
+REPEATABLE
+struct PreAttribute
+{
+#ifdef __cplusplus
+ PreAttribute();
+#endif
+
+ unsigned int Deref;
+ SA( YesNoMaybe ) Valid;
+ SA( YesNoMaybe ) Null;
+ SA( YesNoMaybe ) Tainted;
+ SA( AccessType ) Access;
+ size_t ValidElementsConst;
+ size_t ValidBytesConst;
+ const wchar_t* ValidElements;
+ const wchar_t* ValidBytes;
+ const wchar_t* ValidElementsLength;
+ const wchar_t* ValidBytesLength;
+ size_t WritableElementsConst;
+ size_t WritableBytesConst;
+ const wchar_t* WritableElements;
+ const wchar_t* WritableBytes;
+ const wchar_t* WritableElementsLength;
+ const wchar_t* WritableBytesLength;
+ size_t ElementSizeConst;
+ const wchar_t* ElementSize;
+ SA( YesNoMaybe ) NullTerminated;
+ const wchar_t* Condition;
+};
+
+REPEATABLE
+struct PostAttribute
+{
+#ifdef __cplusplus
+ PostAttribute();
+#endif
+
+ unsigned int Deref;
+ SA( YesNoMaybe ) Valid;
+ SA( YesNoMaybe ) Null;
+ SA( YesNoMaybe ) Tainted;
+ SA( AccessType ) Access;
+ size_t ValidElementsConst;
+ size_t ValidBytesConst;
+ const wchar_t* ValidElements;
+ const wchar_t* ValidBytes;
+ const wchar_t* ValidElementsLength;
+ const wchar_t* ValidBytesLength;
+ size_t WritableElementsConst;
+ size_t WritableBytesConst;
+ const wchar_t* WritableElements;
+ const wchar_t* WritableBytes;
+ const wchar_t* WritableElementsLength;
+ const wchar_t* WritableBytesLength;
+ size_t ElementSizeConst;
+ const wchar_t* ElementSize;
+ SA( YesNoMaybe ) NullTerminated;
+ SA( YesNoMaybe ) MustCheck;
+ const wchar_t* Condition;
+};
+
+struct FormatStringAttribute
+{
+#ifdef __cplusplus
+ FormatStringAttribute();
+#endif
+
+ const wchar_t* Style;
+ const wchar_t* UnformattedAlternative;
+};
+
+REPEATABLE
+struct InvalidCheckAttribute
+{
+#ifdef __cplusplus
+ InvalidCheckAttribute();
+#endif
+
+ long Value;
+};
+
+struct SuccessAttribute
+{
+#ifdef __cplusplus
+ SuccessAttribute();
+#endif
+
+ const wchar_t* Condition;
+};
+
+REPEATABLE
+struct PreBoundAttribute
+{
+#ifdef __cplusplus
+ PreBoundAttribute();
+#endif
+ unsigned int Deref;
+};
+
+REPEATABLE
+struct PostBoundAttribute
+{
+#ifdef __cplusplus
+ PostBoundAttribute();
+#endif
+ unsigned int Deref;
+};
+
+REPEATABLE
+struct PreRangeAttribute
+{
+#ifdef __cplusplus
+ PreRangeAttribute();
+#endif
+ unsigned int Deref;
+ const char* MinVal;
+ const char* MaxVal;
+};
+
+REPEATABLE
+struct PostRangeAttribute
+{
+#ifdef __cplusplus
+ PostRangeAttribute();
+#endif
+ unsigned int Deref;
+ const char* MinVal;
+ const char* MaxVal;
+};
+
+#endif // !SAL_NO_ATTRIBUTE_DECLARATIONS
+
+#ifdef __cplusplus
+}; // namespace vc_attributes
+#endif // __cplusplus
+
+#pragma pop_macro( "REPEATABLE" )
+#pragma pop_macro( "SA" )
+
+#ifdef __cplusplus
+
+#define SA_All All
+#define SA_Class Class
+#define SA_Constructor Constructor
+#define SA_Delegate Delegate
+#define SA_Enum Enum
+#define SA_Event Event
+#define SA_Field Field
+#define SA_GenericParameter GenericParameter
+#define SA_Interface Interface
+#define SA_Method Method
+#define SA_Module Module
+#define SA_Parameter Parameter
+#define SA_Property Property
+#define SA_ReturnValue ReturnValue
+#define SA_Struct Struct
+
+typedef ::vc_attributes::YesNoMaybe SA_YesNoMaybe;
+const ::vc_attributes::YesNoMaybe SA_Yes = ::vc_attributes::Yes;
+const ::vc_attributes::YesNoMaybe SA_No = ::vc_attributes::No;
+const ::vc_attributes::YesNoMaybe SA_Maybe = ::vc_attributes::Maybe;
+
+typedef ::vc_attributes::AccessType SA_AccessType;
+const ::vc_attributes::AccessType SA_NoAccess = ::vc_attributes::NoAccess;
+const ::vc_attributes::AccessType SA_Read = ::vc_attributes::Read;
+const ::vc_attributes::AccessType SA_Write = ::vc_attributes::Write;
+const ::vc_attributes::AccessType SA_ReadWrite = ::vc_attributes::ReadWrite;
+
+#ifndef SAL_NO_ATTRIBUTE_DECLARATIONS
+typedef ::vc_attributes::PreAttribute SA_Pre;
+typedef ::vc_attributes::PostAttribute SA_Post;
+typedef ::vc_attributes::FormatStringAttribute SA_FormatString;
+typedef ::vc_attributes::InvalidCheckAttribute SA_InvalidCheck; /*???*/
+typedef ::vc_attributes::SuccessAttribute SA_Success;
+typedef ::vc_attributes::PreBoundAttribute SA_PreBound;
+typedef ::vc_attributes::PostBoundAttribute SA_PostBound;
+typedef ::vc_attributes::PreRangeAttribute SA_PreRange;
+typedef ::vc_attributes::PostRangeAttribute SA_PostRange;
+#endif //!SAL_NO_ATTRIBUTE_DECLARATIONS
+
+#else // !__cplusplus
+
+typedef struct PreAttribute SA_Pre;
+typedef struct PreAttribute PreAttribute;
+typedef struct PostAttribute SA_Post;
+typedef struct PostAttribute PostAttribute;
+typedef struct FormatStringAttribute SA_FormatString;
+typedef struct InvalidCheckAttribute SA_InvalidCheck; /*???*/
+typedef struct SuccessAttribute SA_Success;
+typedef struct PreBoundAttribute SA_PreBound;
+typedef struct PostBoundAttribute SA_PostBound;
+typedef struct PreRangeAttribute SA_PreRange;
+typedef struct PostRangeAttribute SA_PostRange;
+
+#endif // __cplusplus
+
+#endif // !_M_CEE_SAFE
+
+#ifdef _MANAGED
+
+#ifdef CODE_ANALYSIS
+#define SA_SUPPRESS_MESSAGE( category, id, ... ) [::System::Diagnostics::CodeAnalysis::SuppressMessage( category, id, __VA_ARGS__ )]
+#define CA_SUPPRESS_MESSAGE( ... ) [System::Diagnostics::CodeAnalysis::SuppressMessage( __VA_ARGS__ )]
+#define CA_GLOBAL_SUPPRESS_MESSAGE( ... ) [assembly:System::Diagnostics::CodeAnalysis::SuppressMessage( __VA_ARGS__ )]
+#else // !CODE_ANALYSIS
+#define SA_SUPPRESS_MESSAGE( category, id, ... )
+#define CA_SUPPRESS_MESSAGE( ... )
+#define CA_GLOBAL_SUPPRESS_MESSAGE( ... )
+#endif // !CODE_ANALYSIS
+
+#endif // _MANAGED
+
+// Windows SDK Update Vista Beta2 (June 2006): __analysis_assume defined by specstrings.h
+#ifdef _PREFAST_
+// #define __analysis_assume(expr) __assume(expr)
+#else // !_PREFAST_
+// #define __analysis_assume(expr)
+#endif // _PREFAST_
+
+
+#endif // _MSC_VER >= 1400
+
Added: gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/algorithm
===================================================================
--- gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/algorithm (rev 0)
+++ gccxml_bin/v09/win32/share/gccxml-0.9/Vc9/Include/algorithm 2008-12-22 22:11:51 UTC (rev 1484)
@@ -0,0 +1,5832 @@
+// algorithm standard header
+#pragma once
+#ifndef _ALGORITHM_
+#define _ALGORITHM_
+#ifndef RC_INVOKED
+#include <memory>
+
+#ifdef _MSC_VER
+ #pragma pack(push,_CRT_PACKING)
+ #pragma warning(push,3)
+ #pragma warning(disable: 4244)
+#endif /* _MSC_VER */
+
+/* ------------------------------------------------------------------------ */
+/* Forward declare these now because they are used as non-dependent names. */
+_STDEXT_BEGIN
+template<class _InIt, class _OutIt, class _Ty>
+inline _OutIt unchecked_remove_copy(_InIt _First, _InIt _Last,
+ _OutIt _Dest, const _Ty& _Val);
+template<class _InIt, class _OutIt, class _Pr>
+inline _OutIt unchecked_remove_copy_if(_InIt _First, _InIt _Last,
+ _OutIt _Dest, _Pr _Pred);
+template<class _InIt1, class _InIt2, class _OutIt>
+inline _OutIt unchecked_merge(_InIt1 _First1, _InIt1 _Last1,
+ _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest);
+template<class _InIt1, class _InIt2, class _OutIt, class _Pr>
+inline _OutIt unchecked_merge(_InIt1 _First1, _InIt1 _Last1,
+ _InIt2 _First2, _InIt2 _Last2, _OutIt _Dest,
+ _Pr _Pred);
+template<class _BidIt1, class _BidIt2, class _BidIt3>
+inline _BidIt3 _Unchecked_merge_backward(_BidIt1 _First1, _BidIt1 _Last1,
+ _BidIt2 _First2, _BidIt2 _Last2,
+ _BidIt3 _Dest);
+template<class _BidIt1, class _BidIt2, class _BidIt3, class _Pr>
+inline _BidIt3 _Unchecked_merge_backward(_BidIt1 _First1, _BidIt1 _Last1,
+ _BidIt2 _First2, _BidIt2 _Last2,
+ _BidIt3 _Dest, _Pr _Pred);
+template<class _BidIt, class _OutIt, class _Diff>
+inline void _Unchecked_chunked_merge(_BidIt _First, _BidIt _Last,
+ _OutIt _Dest, _Diff _Chunk,
+ _Diff _Count);
+template<class _BidIt, class _OutIt, class _Diff, class _Pr>
+inline void _Unchecked_chunked_merge(_BidIt _First, _BidIt _Last,
+ _OutIt _Dest, _Diff _Chunk,
+ _Diff _Count, _Pr _Pred);
+_STDEXT_END
+/* ------------------------------------------------------------------------ */
+
+_STD_BEGIN
+
+ // COMMON SORT PARAMETERS
+const int _ISORT_MAX = 32; // maximum size for insertion sort
+
+ // TEMPLATE FUNCTION for_each
+template<class _InIt,
+ class _Fn1> inline
+ _Fn1 for_each(_InIt _First, _InIt _Last, _Fn1 _Func)
+ { // perform function for each element
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Func);
+ _CHECKED_BASE_TYPE(_InIt) _ChkFirst(_CHECKED_BASE(_First));
+ _CHECKED_BASE_TYPE(_InIt) _ChkLast(_CHECKED_BASE(_Last));
+ for (; _ChkFirst != _ChkLast; ++_ChkFirst)
+ _Func(*_ChkFirst);
+ return (_Func);
+ }
+
+ // TEMPLATE FUNCTION find
+template<class _InIt, class _Ty>
+inline
+ _InIt _Find(_InIt _First, _InIt _Last, const _Ty& _Val)
+ { // find first matching _Val
+ _DEBUG_RANGE(_First, _Last);
+ for (; _First != _Last; ++_First)
+ if (*_First == _Val)
+ break;
+ return (_First);
+ }
+
+inline const char *_Find(const char *_First, const char *_Last, int _Val)
+ { // find first char that matches _Val
+ _DEBUG_RANGE(_First, _Last);
+ _First = (const char *)::memchr(_First, _Val, _Last - _First);
+ return (_First == 0 ? _Last : _First);
+ }
+
+inline const signed char *_Find(const signed char *_First,
+ const signed char *_Last, int _Val)
+ { // find first signed char that matches _Val
+ _DEBUG_RANGE(_First, _Last);
+ _First = (const signed char *)::memchr(_First, _Val,
+ _Last - _First);
+ return (_First == 0 ? _Last : _First);
+ }
+
+inline const unsigned char *_Find(const unsigned char *_First,
+ const unsigned char *_Last, int _Val)
+ { // find first unsigned char that matches _Val
+ _DEBUG_RANGE(_First, _Last);
+ _First = (const unsigned char *)::memchr(_First, _Val,
+ _Last - _First);
+ return (_First == 0 ? _Last : _First);
+ }
+
+template<class _InIt, class _Ty>
+inline
+ _InIt find(_InIt _First, _InIt _Last, const _Ty& _Val)
+ { // find first matching _Val
+ _ASSIGN_FROM_BASE(_First,
+ _Find(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Val));
+ return (_First);
+ }
+
+ // TEMPLATE FUNCTION find_if
+template<class _InIt,
+ class _Pr> inline
+ _InIt _Find_if(_InIt _First, _InIt _Last, _Pr _Pred)
+ { // find first satisfying _Pred
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Pred);
+ for (; _First != _Last; ++_First)
+ if (_Pred(*_First))
+ break;
+ return (_First);
+ }
+
+template<class _InIt,
+ class _Pr> inline
+ _InIt find_if(_InIt _First, _InIt _Last, _Pr _Pred)
+ { // find first satisfying _Pred
+ _ASSIGN_FROM_BASE(_First,
+ _Find_if(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Pred));
+ return (_First);
+ }
+
+ // TEMPLATE FUNCTION adjacent_find
+template<class _FwdIt> inline
+ _FwdIt _Adjacent_find(_FwdIt _First, _FwdIt _Last)
+ { // find first matching successor
+ _DEBUG_RANGE(_First, _Last);
+ for (_FwdIt _Firstb; (_Firstb = _First) != _Last && ++_First != _Last; )
+ if (*_Firstb == *_First)
+ return (_Firstb);
+ return (_Last);
+ }
+
+template<class _FwdIt> inline
+ _FwdIt adjacent_find(_FwdIt _First, _FwdIt _Last)
+ { // find first matching successor
+ _ASSIGN_FROM_BASE(_First,
+ _Adjacent_find(_CHECKED_BASE(_First), _CHECKED_BASE(_Last)));
+ return (_First);
+ }
+
+ // TEMPLATE FUNCTION adjacent_find WITH PRED
+template<class _FwdIt,
+ class _Pr> inline
+ _FwdIt _Adjacent_find(_FwdIt _First, _FwdIt _Last, _Pr _Pred)
+ { // find first satisfying _Pred with successor
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Pred);
+ for (_FwdIt _Firstb; (_Firstb = _First) != _Last && ++_First != _Last; )
+ if (_Pred(*_Firstb, *_First))
+ return (_Firstb);
+ return (_Last);
+ }
+
+template<class _FwdIt,
+ class _Pr> inline
+ _FwdIt adjacent_find(_FwdIt _First, _FwdIt _Last, _Pr _Pred)
+ { // find first satisfying _Pred with successor
+ _ASSIGN_FROM_BASE(_First,
+ _Adjacent_find(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Pred));
+ return (_First);
+ }
+
+ // TEMPLATE FUNCTION count
+template<class _InIt,
+ class _Ty> inline
+ typename iterator_traits<_InIt>::difference_type
+ _Count(_InIt _First, _InIt _Last, const _Ty& _Val)
+ { // count elements that match _Val
+ _DEBUG_RANGE(_First, _Last);
+ typename iterator_traits<_InIt>::difference_type _Cnt = 0;
+
+ for (; _First != _Last; ++_First)
+ if (*_First == _Val)
+ ++_Cnt;
+ return (_Cnt);
+ }
+
+template<class _InIt,
+ class _Ty> inline
+ typename iterator_traits<_InIt>::difference_type
+ count(_InIt _First, _InIt _Last, const _Ty& _Val)
+ { // count elements that match _Val
+ return _Count(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Val);
+ }
+
+ // TEMPLATE FUNCTION count_if
+template<class _InIt,
+ class _Pr> inline
+ typename iterator_traits<_InIt>::difference_type
+ _Count_if(_InIt _First, _InIt _Last, _Pr _Pred)
+ { // count elements satisfying _Pred
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Pred);
+ typename iterator_traits<_InIt>::difference_type _Count = 0;
+
+ for (; _First != _Last; ++_First)
+ if (_Pred(*_First))
+ ++_Count;
+ return (_Count);
+ }
+
+template<class _InIt,
+ class _Pr> inline
+ typename iterator_traits<_InIt>::difference_type
+ count_if(_InIt _First, _InIt _Last, _Pr _Pred)
+ { // count elements satisfying _Pred
+ return _Count_if(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Pred);
+ }
+
+ // TEMPLATE FUNCTION search
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Diff1,
+ class _Diff2> inline
+ _FwdIt1 _Search(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Diff1 *, _Diff2 *)
+ { // find first [_First2, _Last2) match
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_RANGE(_First2, _Last2);
+ _Diff1 _Count1 = 0;
+ _Distance(_First1, _Last1, _Count1);
+ _Diff2 _Count2 = 0;
+ _Distance(_First2, _Last2, _Count2);
+
+ for (; _Count2 <= _Count1; ++_First1, --_Count1)
+ { // room for match, try it
+ _FwdIt1 _Mid1 = _First1;
+ for (_FwdIt2 _Mid2 = _First2; ; ++_Mid1, ++_Mid2)
+ if (_Mid2 == _Last2)
+ return (_First1);
+ else if (!(*_Mid1 == *_Mid2))
+ break;
+ }
+ return (_Last1);
+ }
+
+template<class _FwdIt1,
+ class _FwdIt2> inline
+ _FwdIt1 search(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2)
+ { // find first [_First2, _Last2) match
+ _ASSIGN_FROM_BASE(_First1,
+ _Search(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _CHECKED_BASE(_First2), _CHECKED_BASE(_Last2),
+ _Dist_type(_First1), _Dist_type(_First2)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION search WITH PRED
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Diff1,
+ class _Diff2,
+ class _Pr> inline
+ _FwdIt1 _Search(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred, _Diff1 *, _Diff2 *)
+ { // find first [_First2, _Last2) satisfying _Pred
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_RANGE(_First2, _Last2);
+ _DEBUG_POINTER(_Pred);
+ _Diff1 _Count1 = 0;
+ _Distance(_First1, _Last1, _Count1);
+ _Diff2 _Count2 = 0;
+ _Distance(_First2, _Last2, _Count2);
+
+ for (; _Count2 <= _Count1; ++_First1, --_Count1)
+ { // room for match, try it
+ _FwdIt1 _Mid1 = _First1;
+ for (_FwdIt2 _Mid2 = _First2; ; ++_Mid1, ++_Mid2)
+ if (_Mid2 == _Last2)
+ return (_First1);
+ else if (!_Pred(*_Mid1, *_Mid2))
+ break;
+ }
+ return (_Last1);
+ }
+
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Pr> inline
+ _FwdIt1 search(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred)
+ { // find first [_First2, _Last2) satisfying _Pred
+ _ASSIGN_FROM_BASE(_First1,
+ _Search(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _CHECKED_BASE(_First2), _CHECKED_BASE(_Last2), _Pred,
+ _Dist_type(_First1), _Dist_type(_First2)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION search_n
+template<class _FwdIt1,
+ class _Diff2,
+ class _Ty> inline
+ _FwdIt1 _Search_n(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _Diff2 _Count, const _Ty& _Val, forward_iterator_tag)
+ { // find first _Count * _Val match, forward iterators
+ _DEBUG_RANGE(_First1, _Last1);
+
+ if (_Count <= 0)
+ return (_First1);
+
+ for (; _First1 != _Last1; ++_First1)
+ if (*_First1 == _Val)
+ { // found start of possible match, check it out
+ _FwdIt1 _Mid1 = _First1;
+
+ for (_Diff2 _Count1 = _Count; ; )
+ if (--_Count1 == 0)
+ return (_First1); // found rest of match, report it
+ else if (++_Mid1 == _Last1)
+ return (_Last1); // short match at end
+ else if (!(*_Mid1 == _Val))
+ break; // short match not at end
+
+ _First1 = _Mid1; // pick up just beyond failed match
+ }
+ return (_Last1);
+ }
+
+template<class _FwdIt1,
+ class _Diff2,
+ class _Ty> inline
+ _FwdIt1 _Search_n(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _Diff2 _Count, const _Ty& _Val, random_access_iterator_tag)
+ { // find first _Count * _Val match, random-access iterators
+ _DEBUG_RANGE(_First1, _Last1);
+
+ if (_Count <= 0)
+ return (_First1);
+
+ _FwdIt1 _Oldfirst1 = _First1;
+ for (_Diff2 _Inc = 0; _Count <= _Last1 - _Oldfirst1; )
+ { // enough room, look for a match
+ _First1 = _Oldfirst1 + _Inc;
+ if (*_First1 == _Val)
+ { // found part of possible match, check it out
+ _Diff2 _Count1 = _Count;
+ _FwdIt1 _Mid1 = _First1;
+
+ for (; _Oldfirst1 != _First1 && _First1[-1] == _Val; --_First1)
+ --_Count1; // back up over any skipped prefix
+
+ if (_Count1 <= _Last1 - _Mid1)
+ for (; ; ) // enough left, test suffix
+ if (--_Count1 == 0)
+ return (_First1); // found rest of match, report it
+ else if (!(*++_Mid1 == _Val))
+ break; // short match not at end
+
+ _Oldfirst1 = ++_Mid1; // failed match, take small jump
+ _Inc = 0;
+ }
+ else
+ { // no match, take big jump and back up as needed
+ _Oldfirst1 = _First1 + 1;
+ _Inc = _Count - 1;
+ }
+ }
+ return (_Last1);
+ }
+
+template<class _FwdIt1,
+ class _Diff2,
+ class _Ty> inline
+ _FwdIt1 search_n(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _Diff2 _Count, const _Ty& _Val)
+ { // find first _Count * _Val match
+ _ASSIGN_FROM_BASE(_First1,
+ _Search_n(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _Count, _Val,
+ _Iter_cat(_First1)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION search_n WITH PRED
+template<class _FwdIt1,
+ class _Diff2,
+ class _Ty,
+ class _Pr> inline
+ _FwdIt1 _Search_n(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _Diff2 _Count, const _Ty& _Val, _Pr _Pred, forward_iterator_tag)
+ { // find first _Count * _Val satisfying _Pred, forward iterators
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_POINTER(_Pred);
+
+ if (_Count <= 0)
+ return (_First1);
+
+ for (; _First1 != _Last1; ++_First1)
+ if (_Pred(*_First1, _Val))
+ { // found start of possible match, check it out
+ _FwdIt1 _Mid1 = _First1;
+
+ for (_Diff2 _Count1 = _Count; ; )
+ if (--_Count1 == 0)
+ return (_First1); // found rest of match, report it
+ else if (++_Mid1 == _Last1)
+ return (_Last1); // short match at end
+ else if (!_Pred(*_Mid1, _Val))
+ break; // short match not at end
+
+ _First1 = _Mid1; // pick up just beyond failed match
+ }
+ return (_Last1);
+ }
+
+template<class _FwdIt1,
+ class _Diff2,
+ class _Ty,
+ class _Pr> inline
+ _FwdIt1 _Search_n(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _Diff2 _Count, const _Ty& _Val, _Pr _Pred, random_access_iterator_tag)
+ { // find first _Count * _Val satisfying _Pred, random-access iterators
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_POINTER(_Pred);
+
+ if (_Count <= 0)
+ return (_First1);
+
+ _FwdIt1 _Oldfirst1 = _First1;
+ for (; _Count <= _Last1 - _Oldfirst1; )
+ { // enough room, look for a match
+ if (_Pred(*_First1, _Val))
+ { // found part of possible match, check it out
+ _Diff2 _Count1 = _Count;
+ _FwdIt1 _Mid1 = _First1;
+
+ for (; _Oldfirst1 != _First1 && _Pred(_First1[-1], _Val);
+ --_First1)
+ --_Count1; // back up over any skipped prefix
+
+ if (_Count1 <= _Last1 - _Mid1)
+ for (; ; ) // enough left, test suffix
+ if (--_Count1 == 0)
+ return (_First1); // found rest of match, report it
+ else if (!_Pred(*++_Mid1, _Val))
+ break; // short match not at end
+
+ _Oldfirst1 = ++_Mid1; // failed match, take small jump
+ _First1 = _Oldfirst1;
+ }
+ else
+ { // no match, take big jump and back up as needed
+ _Oldfirst1 = _First1 + 1;
+ _First1 += _Count;
+ }
+ }
+ return (_Last1);
+ }
+
+template<class _FwdIt1,
+ class _Diff2,
+ class _Ty,
+ class _Pr> inline
+ _FwdIt1 search_n(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _Diff2 _Count, const _Ty& _Val, _Pr _Pred)
+ { // find first _Count * _Val satisfying _Pred
+ _ASSIGN_FROM_BASE(_First1,
+ _Search_n(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _Count, _Val, _Pred,
+ _Iter_cat(_First1)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION find_end
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Diff1,
+ class _Diff2> inline
+ _FwdIt1 _Find_end(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Diff1 *, _Diff2 *)
+ { // find last [_First2, _Last2) match
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_RANGE(_First2, _Last2);
+ _Diff1 _Count1 = 0;
+ _Distance(_First1, _Last1, _Count1);
+ _Diff2 _Count2 = 0;
+ _Distance(_First2, _Last2, _Count2);
+ _FwdIt1 _Ans = _Last1;
+
+ if (0 < _Count2)
+ for (; _Count2 <= _Count1; ++_First1, --_Count1)
+ { // room for match, try it
+ _FwdIt1 _Mid1 = _First1;
+ for (_FwdIt2 _Mid2 = _First2; ; ++_Mid1)
+ if (!(*_Mid1 == *_Mid2))
+ break;
+ else if (++_Mid2 == _Last2)
+ { // potential answer, save it
+ _Ans = _First1;
+ break;
+ }
+ }
+ return (_Ans);
+ }
+
+template<class _FwdIt1,
+ class _FwdIt2> inline
+ _FwdIt1 find_end(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2)
+ { // find last [_First2, _Last2) match
+ _ASSIGN_FROM_BASE(_First1,
+ _Find_end(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _CHECKED_BASE(_First2), _CHECKED_BASE(_Last2),
+ _Dist_type(_First1), _Dist_type(_First2)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION find_end WITH PRED
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Diff1,
+ class _Diff2,
+ class _Pr> inline
+ _FwdIt1 _Find_end(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred, _Diff1 *, _Diff2 *)
+ { // find last [_First2, _Last2) satisfying _Pred
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_RANGE(_First2, _Last2);
+ _DEBUG_POINTER(_Pred);
+ _Diff1 _Count1 = 0;
+ _Distance(_First1, _Last1, _Count1);
+ _Diff2 _Count2 = 0;
+ _Distance(_First2, _Last2, _Count2);
+ _FwdIt1 _Ans = _Last1;
+
+ if (0 < _Count2)
+ for (; _Count2 <= _Count1; ++_First1, --_Count1)
+ { // room for match, try it
+ _FwdIt1 _Mid1 = _First1;
+ for (_FwdIt2 _Mid2 = _First2; ; ++_Mid1)
+ if (!_Pred(*_Mid1, *_Mid2))
+ break;
+ else if (++_Mid2 == _Last2)
+ { // potential answer, save it
+ _Ans = _First1;
+ break;
+ }
+ }
+ return (_Ans);
+ }
+
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Pr> inline
+ _FwdIt1 find_end(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred)
+ { // find last [_First2, _Last2) satisfying _Pred
+ _ASSIGN_FROM_BASE(_First1,
+ _Find_end(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _CHECKED_BASE(_First2), _CHECKED_BASE(_Last2), _Pred,
+ _Dist_type(_First1), _Dist_type(_First2)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION find_first_of
+template<class _FwdIt1,
+ class _FwdIt2> inline
+ _FwdIt1 _Find_first_of(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2)
+ { // look for one of [_First2, _Last2) that matches element
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_RANGE(_First2, _Last2);
+ for (; _First1 != _Last1; ++_First1)
+ for (_FwdIt2 _Mid2 = _First2; _Mid2 != _Last2; ++_Mid2)
+ if (*_First1 == *_Mid2)
+ return (_First1);
+ return (_First1);
+ }
+
+template<class _FwdIt1,
+ class _FwdIt2> inline
+ _FwdIt1 find_first_of(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2)
+ { // look for one of [_First2, _Last2) that matches element
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_RANGE(_First2, _Last2);
+ _ASSIGN_FROM_BASE(_First1,
+ _Find_first_of(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _CHECKED_BASE(_First2), _CHECKED_BASE(_Last2)));
+ return _First1;
+ }
+
+ // TEMPLATE FUNCTION find_first_of WITH PRED
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Pr> inline
+ _FwdIt1 _Find_first_of(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred)
+ { // look for one of [_First2, _Last2) satisfying _Pred with element
+ _DEBUG_POINTER(_Pred);
+ for (; _First1 != _Last1; ++_First1)
+ for (_FwdIt2 _Mid2 = _First2; _Mid2 != _Last2; ++_Mid2)
+ if (_Pred(*_First1, *_Mid2))
+ return (_First1);
+ return (_First1);
+ }
+
+template<class _FwdIt1,
+ class _FwdIt2,
+ class _Pr> inline
+ _FwdIt1 find_first_of(_FwdIt1 _First1, _FwdIt1 _Last1,
+ _FwdIt2 _First2, _FwdIt2 _Last2, _Pr _Pred)
+ { // look for one of [_First2, _Last2) satisfying _Pred with element
+ _ASSIGN_FROM_BASE(_First1,
+ _Find_first_of(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _CHECKED_BASE(_First2), _CHECKED_BASE(_Last2), _Pred));
+ return (_First1);
+ }
+
+ // TEMPLATE FUNCTION iter_swap
+template<class _FwdIt1,
+ class _FwdIt2> inline
+ void iter_swap(_FwdIt1 _Left, _FwdIt2 _Right)
+ { // swap *_Left and *_Right
+ swap(*_Left, *_Right);
+ }
+
+ // TEMPLATE FUNCTION swap_ranges
+template<class _FwdIt1, class _FwdIt2, class _FwdItCats>
+inline
+ _FwdIt2 _Swap_ranges(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2,
+ _FwdItCats, _Range_checked_iterator_tag)
+ { // swap [_First1, _Last1) with [_First2, ...)
+ _DEBUG_RANGE(_First1, _Last1);
+ for (; _First1 != _Last1; ++_First1, ++_First2)
+ std::iter_swap(_First1, _First2);
+ return (_First2);
+ }
+
+#if _SECURE_SCL
+template<class _FwdIt1, class _FwdIt2>
+inline
+ _FwdIt2 _Swap_ranges(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2,
+ random_access_iterator_tag, _Range_checked_iterator_tag)
+ { // swap [_First1, _Last1) with [_First2, ...)
+ // if _FwdIt2 is range checked, this will make sure there is enough space
+ _FwdIt2 _Result = _First2 + (_Last1 - _First1);
+ _Swap_ranges(_First1, _Last1, _CHECKED_BASE(_First2),
+ forward_iterator_tag(), _Range_checked_iterator_tag());
+ return (_Result);
+ }
+#endif
+
+#if _SECURE_SCL
+
+template<class _FwdIt1, class _FwdIt2>
+inline
+_IF_CHK(_FwdIt2) swap_ranges(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2)
+ {
+ return _Swap_ranges(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2,
+ _Iter_random(_First1, _First2), _STD _Range_checked_iterator_tag());
+ }
+
+template<class _FwdIt1, class _FwdElem2, size_t _Size>
+inline
+_FwdElem2* swap_ranges(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdElem2 (&_First2)[_Size])
+ {
+ return (swap_ranges(_First1, _Last1, _STDEXT make_checked_array_iterator(_First2, _Size)).base());
+ }
+
+template<class _FwdIt1, class _FwdIt2>
+inline
+_SCL_INSECURE_DEPRECATE
+_IF_NOT_CHK(_FwdIt2) swap_ranges(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2)
+ {
+ return _Swap_ranges(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2,
+ _Iter_random(_First1, _First2), _STD _Range_checked_iterator_tag());
+ }
+
+#else
+
+template<class _FwdIt1, class _FwdIt2>
+inline
+ _FwdIt2 swap_ranges(_FwdIt1 _First1, _FwdIt1 _Last1, _FwdIt2 _First2)
+ {
+ return _Swap_ranges(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2,
+ _Iter_random(_First1, _First2), _STD _Range_checked_iterator_tag());
+ }
+
+#endif
+
+ // TEMPLATE FUNCTION transform WITH UNARY OP
+template<class _InIt, class _OutIt, class _Fn1, class _InOutItCat>
+inline
+ _OutIt _Transform(_InIt _First, _InIt _Last, _OutIt _Dest, _Fn1 _Func,
+ _InOutItCat, _Range_checked_iterator_tag)
+ { // transform [_First, _Last) with _Func
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Dest);
+ _DEBUG_POINTER(_Func);
+ for (; _First != _Last; ++_First, ++_Dest)
+ *_Dest = _Func(*_First);
+ return (_Dest);
+ }
+
+#if _SECURE_SCL
+template<class _InIt, class _OutIt, class _Fn1>
+inline
+ _OutIt _Transform(_InIt _First, _InIt _Last, _OutIt _Dest, _Fn1 _Func,
+ random_access_iterator_tag, _Range_checked_iterator_tag)
+ { // transform [_First, _Last) with _Func
+ // for range checked iterators, this will make sure there is enough space
+ _OutIt _Result = _Dest + (_Last - _First);
+ _Transform(_First, _Last, _CHECKED_BASE(_Dest), _Func,
+ forward_iterator_tag(), _Range_checked_iterator_tag());
+ return (_Result);
+ }
+#endif
+
+#if _SECURE_SCL
+
+template<class _InIt, class _OutIt, class _Fn1>
+inline
+_IF_CHK(_OutIt) transform(_InIt _First, _InIt _Last, _OutIt _Dest, _Fn1 _Func)
+ {
+ return _Transform(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Dest, _Func,
+ _Iter_random(_First, _Dest), _STD _Range_checked_iterator_tag());
+ }
+
+template<class _InIt, class _OutElem, class _Fn1, size_t _Size>
+inline
+_OutElem* transform(_InIt _First, _InIt _Last, _OutElem (&_Dest)[_Size], _Fn1 _Func)
+ {
+ return (transform(_First, _Last,
+ _STDEXT make_checked_array_iterator(_Dest, _Size), _Func).base());
+ }
+
+template<class _InIt, class _OutIt, class _Fn1>
+inline
+_SCL_INSECURE_DEPRECATE
+_IF_NOT_CHK(_OutIt) transform(_InIt _First, _InIt _Last, _OutIt _Dest, _Fn1 _Func)
+ {
+ return _Transform(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Dest, _Func,
+ _Iter_random(_First, _Dest), _STD _Range_checked_iterator_tag());
+ }
+
+#else
+
+template<class _InIt, class _OutIt, class _Fn1>
+inline
+ _OutIt transform(_InIt _First, _InIt _Last, _OutIt _Dest, _Fn1 _Func)
+ {
+ return _Transform(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Dest, _Func,
+ _Iter_random(_First, _Dest), _STD _Range_checked_iterator_tag());
+ }
+
+#endif
+
+ // TEMPLATE FUNCTION transform WITH BINARY OP
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2, class _InItCats, class _InOutItCat>
+inline
+ _OutIt _Transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func,
+ _InItCats, _InOutItCat,
+ _Range_checked_iterator_tag, _Range_checked_iterator_tag)
+ { // transform [_First1, _Last1) and [_First2, _Last2) with _Func
+ _DEBUG_RANGE(_First1, _Last1);
+ _DEBUG_POINTER(_Dest);
+ _DEBUG_POINTER(_Func);
+ for (; _First1 != _Last1; ++_First1, ++_First2, ++_Dest)
+ *_Dest = _Func(*_First1, *_First2);
+ return (_Dest);
+ }
+
+#if _SECURE_SCL
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2>
+inline
+ _OutIt _Transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func,
+ random_access_iterator_tag, random_access_iterator_tag,
+ _Range_checked_iterator_tag, _Range_checked_iterator_tag)
+ { // transform [_First1, _Last1) and [_First2, _Last2) with _Func
+ // for range checked iterators, this will make sure there is enough space
+ _InIt2 _Last2 = _First2 + (_Last1 - _First1); (_Last2);
+ _OutIt _Result = _Dest + (_Last1 - _First1);
+ _Transform(_First1, _Last1, _CHECKED_BASE(_First2),
+ _CHECKED_BASE(_Dest), _Func,
+ forward_iterator_tag(), forward_iterator_tag(),
+ _Range_checked_iterator_tag(), _Range_checked_iterator_tag());
+ return _Result;
+ }
+
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2, class _InOutItCat>
+inline
+ _OutIt _Transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func,
+ random_access_iterator_tag, _InOutItCat,
+ _Range_checked_iterator_tag, _Range_checked_iterator_tag)
+ { // transform [_First1, _Last1) and [_First2, _Last2) with _Func
+ // for range checked iterators, this will make sure there is enough space
+ _InIt2 _Last2 = _First2 + (_Last1 - _First1); (_Last2);
+ return _Transform(_First1, _Last1, _CHECKED_BASE(_First2),
+ _Dest, _Func,
+ forward_iterator_tag(), forward_iterator_tag(),
+ _Range_checked_iterator_tag(), _Range_checked_iterator_tag());
+ }
+
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2, class _InItCats>
+inline
+ _OutIt _Transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func,
+ _InItCats, random_access_iterator_tag,
+ _Range_checked_iterator_tag, _Range_checked_iterator_tag)
+ { // transform [_First1, _Last1) and [_First2, _Last2) with _Func
+ // for range checked iterators, this will make sure there is enough space
+ _OutIt _Result = _Dest + (_Last1 - _First1);
+ _Transform(_First1, _Last1, _First2,
+ _CHECKED_BASE(_Dest), _Func,
+ forward_iterator_tag(), forward_iterator_tag(),
+ _Range_checked_iterator_tag(), _Range_checked_iterator_tag());
+ return _Result;
+ }
+#endif
+
+#if _SECURE_SCL
+
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2>
+inline
+_IF_CHK2_(_InIt2, _OutIt, _OutIt) transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func)
+ {
+ return _Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2, _Dest, _Func,
+ _Iter_random(_First1, _First2), _Iter_random(_First1, _Dest),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag());
+ }
+
+template<class _InIt1, class _InElem2, class _OutElem, class _Fn2, size_t _SizeFirst2, size_t _SizeDest>
+inline
+_OutElem* transform(_InIt1 _First1, _InIt1 _Last1, _InElem2 (&_First2)[_SizeFirst2],
+ _OutElem (&_Dest)[_SizeDest], _Fn2 _Func)
+ {
+ return (transform(_First1, _Last1,
+ _STDEXT make_checked_array_iterator(_First2, _SizeFirst2),
+ _STDEXT make_checked_array_iterator(_Dest, _SizeDest),
+ _Func).base());
+ }
+
+template<class _InIt1, class _InIt2, class _OutElem, class _Fn2, size_t _SizeDest>
+inline
+_IF_CHK_(_InIt2, _OutElem*) transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutElem (&_Dest)[_SizeDest], _Fn2 _Func)
+ {
+ return (_Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2,
+ _STDEXT make_checked_array_iterator(_Dest, _SizeDest), _Func,
+ _Iter_random(_First1, _First2), _Iter_cat(_First1),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag()).base());
+ }
+
+template<class _InIt1, class _InIt2, class _OutElem, class _Fn2, size_t _SizeDest>
+inline
+_SCL_INSECURE_DEPRECATE
+_IF_NOT_CHK_(_InIt2, _OutElem*) transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutElem (&_Dest)[_SizeDest], _Fn2 _Func)
+ {
+ return (_Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2,
+ _STDEXT make_checked_array_iterator(_Dest, _SizeDest), _Func,
+ _Iter_random(_First1, _First2), _Iter_cat(_First1),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag()).base());
+ }
+
+template<class _InIt1, class _InElem2, class _OutIt, class _Fn2, size_t _SizeFirst2>
+inline
+_IF_CHK(_OutIt) transform(_InIt1 _First1, _InIt1 _Last1, _InElem2 (&_First2)[_SizeFirst2],
+ _OutIt _Dest, _Fn2 _Func)
+ {
+ return (_Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _STDEXT make_checked_array_iterator(_First2, _SizeFirst2),
+ _Dest, _Func,
+ _Iter_cat(_First1), _Iter_random(_First1, _Dest),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag()));
+ }
+
+template<class _InIt1, class _InElem2, class _OutIt, class _Fn2, size_t _SizeFirst2>
+inline
+_SCL_INSECURE_DEPRECATE
+_IF_NOT_CHK(_OutIt) transform(_InIt1 _First1, _InIt1 _Last1, _InElem2 (&_First2)[_SizeFirst2],
+ _OutIt _Dest, _Fn2 _Func)
+ {
+ return (_Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1),
+ _STDEXT make_checked_array_iterator(_First2, _SizeFirst2),
+ _Dest, _Func,
+ _Iter_cat(_First1), _Iter_random(_First1, _Dest),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag()));
+ }
+
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2>
+inline
+_SCL_INSECURE_DEPRECATE
+_IF_NOT_CHK2_(_InIt2, _OutIt, _OutIt) transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func)
+ {
+ return _Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2, _Dest, _Func,
+ _Iter_random(_First1, _First2), _Iter_random(_First1, _Dest),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag());
+ }
+
+#else
+
+template<class _InIt1, class _InIt2, class _OutIt, class _Fn2>
+inline
+ _OutIt transform(_InIt1 _First1, _InIt1 _Last1, _InIt2 _First2,
+ _OutIt _Dest, _Fn2 _Func)
+ {
+ return _Transform(_CHECKED_BASE(_First1), _CHECKED_BASE(_Last1), _First2, _Dest, _Func,
+ _Iter_random(_First1, _First2), _Iter_random(_First1, _Dest),
+ _STD _Range_checked_iterator_tag(), _STD _Range_checked_iterator_tag());
+ }
+
+#endif
+
+ // TEMPLATE FUNCTION replace
+template<class _FwdIt,
+ class _Ty> inline
+ void _Replace(_FwdIt _First, _FwdIt _Last,
+ const _Ty& _Oldval, const _Ty& _Newval)
+ { // replace each matching _Oldval with _Newval
+ _DEBUG_RANGE(_First, _Last);
+ for (; _First != _Last; ++_First)
+ if (*_First == _Oldval)
+ *_First = _Newval;
+ }
+
+template<class _FwdIt,
+ class _Ty> inline
+ void replace(_FwdIt _First, _FwdIt _Last,
+ const _Ty& _Oldval, const _Ty& _Newval)
+ { // replace each matching _Oldval with _Newval
+ _Replace(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Oldval, _Newval);
+ }
+
+ // TEMPLATE FUNCTION replace_if
+template<class _FwdIt,
+ class _Pr,
+ class _Ty> inline
+ void _Replace_if(_FwdIt _First, _FwdIt _Last, _Pr _Pred, const _Ty& _Val)
+ { // replace each satisfying _Pred with _Val
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Pred);
+ for (; _First != _Last; ++_First)
+ if (_Pred(*_First))
+ *_First = _Val;
+ }
+
+template<class _FwdIt,
+ class _Pr,
+ class _Ty> inline
+ void replace_if(_FwdIt _First, _FwdIt _Last, _Pr _Pred, const _Ty& _Val)
+ { // replace each satisfying _Pred with _Val
+ _Replace_if(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Pred, _Val);
+ }
+
+ // TEMPLATE FUNCTION replace_copy
+template<class _InIt, class _OutIt, class _Ty, class _InOutItCat>
+inline
+ _OutIt _Replace_copy(_InIt _First, _InIt _Last, _OutIt _Dest,
+ const _Ty& _Oldval, const _Ty& _Newval,
+ _InOutItCat, _Range_checked_iterator_tag)
+ { // copy replacing each matching _Oldval with _Newval
+ _DEBUG_RANGE(_First, _Last);
+ _DEBUG_POINTER(_Dest);
+ for (; _First != _Last; ++_First, ++_Dest)
+ *_Dest = *_First == _Oldval ? _Newval : *_First;
+ return (_Dest);
+ }
+
+#if _SECURE_SCL
+template<class _InIt, class _OutIt, class _Ty>
+inline
+ _OutIt _Replace_copy(_InIt _First, _InIt _Last, _OutIt _Dest,
+ const _Ty& _Oldval, const _Ty& _Newval,
+ random_access_iterator_tag, _Range_checked_iterator_tag)
+ { // copy replacing each matching _Oldval with _Newval
+ // for range checked iterators, this will make sure there is enough space
+ _OutIt _Result = _Dest + (_Last - _First);
+ _Replace_copy(_First, _Last, _CHECKED_BASE(_Dest),
+ _Oldval, _Newval,
+ forward_iterator_tag(), _Range_checked_iterator_tag());
+ return (_Result);
+ }
+#endif
+
+#if _SECURE_SCL
+
+template<class _InIt,
+ class _OutIt,
+ class _Ty> inline
+_IF_CHK(_OutIt) replace_copy(_InIt _First, _InIt _Last, _OutIt _Dest,
+ const _Ty& _Oldval, const _Ty& _Newval)
+ { // copy replacing each matching _Oldval with _Newval
+ return _Replace_copy(_CHECKED_BASE(_First), _CHECKED_BASE(_Last), _Dest, _Oldval, _Newval,
+ _Iter_r...
[truncated message content] |
|
From: <rom...@us...> - 2008-12-22 22:52:25
|
Revision: 1485
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1485&view=rev
Author: roman_yakovenko
Date: 2008-12-22 22:52:20 +0000 (Mon, 22 Dec 2008)
Log Message:
-----------
adding ability to format function names, so they will be similar to ones, ctreated by UnDecorateSymbolName
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/calldef.py
pygccxml_dev/pygccxml/msvc/mspdb/enums.py
pygccxml_dev/pygccxml/msvc/mspdb/loader.py
pygccxml_dev/pygccxml/utils/__init__.py
pygccxml_dev/unittests/mspdb_playground.py
Added Paths:
-----------
pygccxml_dev/unittests/data/msvc/
pygccxml_dev/unittests/data/msvc/mydll.90.vcproj
pygccxml_dev/unittests/data/msvc/mydll.cpp
pygccxml_dev/unittests/data/msvc/mydll.h
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2008-12-22 22:11:51 UTC (rev 1484)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2008-12-22 22:52:20 UTC (rev 1485)
@@ -104,7 +104,9 @@
from calldef import casting_operator_t
from calldef import free_function_t
from calldef import free_operator_t
+from calldef import create_undecorated_name
+
from decl_visitor import decl_visitor_t
from type_visitor import type_visitor_t
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2008-12-22 22:11:51 UTC (rev 1484)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2008-12-22 22:52:20 UTC (rev 1485)
@@ -19,6 +19,7 @@
import cpptypes
import algorithm
+import templates
import declaration
import type_traits
import dependencies
@@ -44,11 +45,11 @@
self._name = name
self._default_value = default_value
self._type = type
- self._attributes = attributes
+ self._attributes = attributes
def clone( self, **keywd ):
"""constructs new argument_t instance
-
+
return argument_t( name=keywd.get( 'name', self.name )
, type=keywd.get( 'type', self.type )
, default_value=keywd.get( 'default_value', self.default_value )
@@ -59,7 +60,7 @@
, type=keywd.get( 'type', self.type )
, default_value=keywd.get( 'default_value', self.default_value )
, attributes=keywd.get( 'attributes', self.attributes ) )
-
+
def __str__(self):
if self.ellipsis:
return "..."
@@ -114,7 +115,7 @@
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 ):
@@ -203,7 +204,7 @@
self._does_throw = does_throw
does_throw = property( _get_does_throw, _set_does_throw,
doc="""If False, than function does not throw any exception.
- In this case, function was declared with empty throw
+ In this case, function was declared with empty throw
statement.
""")
@@ -226,9 +227,9 @@
@property
def overloads(self):
"""A list of overloaded "callables" (i.e. other callables with the same name within the same scope.
-
+
@type: list of L{calldef_t}
- """
+ """
if not self.parent:
return []
# finding all functions with the same name
@@ -313,7 +314,7 @@
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" ) )
+ answer.append( report_dependency( self.return_type, hint="return type" ) )
map( lambda arg: answer.append( report_dependency( arg.type ) )
, self.arguments )
map( lambda exception: answer.append( report_dependency( exception, hint="exception" ) )
@@ -506,12 +507,12 @@
if not isinstance( unaliased.base, cpptypes.declarated_t ):
return False
return id(unaliased.base.declaration) == id(self.parent)
-
+
@property
def is_trivial_constructor(self):
return not bool( self.arguments )
-
+
class destructor_t( member_calldef_t ):
"""describes deconstructor declaration"""
def __init__( self, *args, **keywords ):
@@ -541,7 +542,7 @@
free_calldef_t.__init__( self, *args, **keywords )
operator_t.__init__( self, *args, **keywords )
self.__class_types = None
-
+
@property
def class_types( self ):
"""list of class/class declaration types, extracted from the operator arguments"""
@@ -559,3 +560,56 @@
if decl:
self.__class_types.append( decl )
return self.__class_types
+
+
+def __remove_leading_scope( s ):
+ if s and s.startswith( '::' ):
+ return s[2:]
+ else:
+ return s
+
+def __format_type_as_undecorated( type_ ):
+ result = []
+ type_ = type_traits.remove_alias( type_ )
+ base_type_ = type_traits.base_type( type_ )
+ base_type_ = type_traits.remove_declarated( base_type_ )
+ if type_traits.is_class( base_type_ ) and base_type_.class_type == "struct":
+ result.append('struct ')
+ result.append( __remove_leading_scope( type_.decl_string ) )
+ return ' '.join( result )
+
+def __format_args_as_undecorated( argtypes ):
+ if not argtypes:
+ return 'void'
+ else:
+ return ','.join( map( __format_type_as_undecorated, argtypes ) )
+
+def create_undecorated_name(calldef):
+ """returns string, which contains full function name formatted exactly as
+ result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
+ options.
+ """
+ calldef_type = calldef.function_type()
+
+ result = []
+ is_mem_fun = isinstance( calldef, member_calldef_t )
+ if is_mem_fun and calldef.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL:
+ result.append( 'virtual ' )
+ if calldef_type.return_type:
+ result.append( __format_type_as_undecorated( calldef.return_type ) )
+ result.append( ' ' )
+ if isinstance( calldef, member_calldef_t ):
+ result.append( __remove_leading_scope( calldef.parent.decl_string ) + '::')
+
+ result.append( calldef.name )
+ if isinstance( calldef, ( constructor_t, destructor_t) ) \
+ and templates.is_instantiation( calldef.parent.name ):
+ result.append( '<%s>' % ','.join( templates.args( calldef.parent.name ) ) )
+
+ result.append( '(%s)' % __format_args_as_undecorated( calldef_type.arguments_types ) )
+ if is_mem_fun and calldef.has_const:
+ result.append( 'const' )
+ return ''.join( result )
+
+
+
Modified: pygccxml_dev/pygccxml/msvc/mspdb/enums.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/mspdb/enums.py 2008-12-22 22:11:51 UTC (rev 1484)
+++ pygccxml_dev/pygccxml/msvc/mspdb/enums.py 2008-12-22 22:52:20 UTC (rev 1485)
@@ -92,12 +92,11 @@
| UNDNAME_NO_ECSU \
| UNDNAME_NO_IDENT_CHAR_CHECK
- UNDNAME_SHORT_UNIQUE = UNDNAME_NO_LEADING_UNDERSCORES \
- | UNDNAME_NO_MS_KEYWORDS \
- | UNDNAME_NO_ALLOCATION_MODEL \
- | UNDNAME_NO_ALLOCATION_LANGUAGE \
- | UNDNAME_NO_ACCESS_SPECIFIERS \
- | UNDNAME_NO_THROW_SIGNATURES \
- | UNDNAME_NO_MEMBER_TYPE \
- | UNDNAME_NO_ECSU \
- | UNDNAME_NO_IDENT_CHAR_CHECK
+ UNDNAME_SHORT_UNIQUE = UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS
+ #~ UNDNAME_NO_LEADING_UNDERSCORES \
+ #~ | UNDNAME_NO_ALLOCATION_MODEL \
+ #~ | UNDNAME_NO_ALLOCATION_LANGUAGE \
+ #~ | UNDNAME_NO_THROW_SIGNATURES \
+ #~ | UNDNAME_NO_MEMBER_TYPE \
+ #~ | UNDNAME_NO_ECSU \
+ #~ | UNDNAME_NO_IDENT_CHAR_CHECK
Modified: pygccxml_dev/pygccxml/msvc/mspdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/mspdb/loader.py 2008-12-22 22:11:51 UTC (rev 1484)
+++ pygccxml_dev/pygccxml/msvc/mspdb/loader.py 2008-12-22 22:52:20 UTC (rev 1485)
@@ -1,6 +1,5 @@
import os
import re
-import pdb
import sys
import ctypes
import pprint
@@ -89,10 +88,9 @@
for smbl in itertools.imap( as_symbol, as_enum_variant( self.symbols_table._NewEnum ) ):
if smbl.symTag in useless:
continue
- smbl.uname = msvc_utils.undecorate_name( smbl.name, msvc_utils.UNDECORATE_NAME_OPTIONS.UNDNAME_SCOPES_ONLY )
- def smbl_undecorate_name( options=None ):
- return msvc_utils.undecorate_name( smbl.name, options )
- smbl.undecorate_name = smbl_undecorate_name
+ smbl.uname = smbl.get_undecoratedNameEx( enums.UNDECORATE_NAME_OPTIONS.UNDNAME_SHORT_UNIQUE )
+ if smbl.uname is None:
+ smbl.uname = smbl.name
smbls[ smbl.symIndexId ] = smbl
self.logger.info( 'loading symbols(%d) from the file - done', len( smbls ) )
return smbls
@@ -223,8 +221,6 @@
self.logger.debug( 'scanning symbols table - done' )
def __update_decls_tree( self, decl ):
- #~ if decl.name == 'money_base' and isinstance( decl, declarations.class_t ):
- #~ pdb.set_trace()
smbl = decl.dia_symbols[0]
if smbl.classParentId in self.__id2decl:
self.__adopt_declaration( self.__id2decl[smbl.classParentId], decl )
@@ -236,13 +232,14 @@
parent_name = '::' + name_splitter.scope_names[-1]
try:
parent = self.global_ns.decl( parent_name )
- except:
- declarations.print_declarations( self.global_ns )
- print 'identifiers:'
- for index, identifier in enumerate(name_splitter.identifiers):
- print index, ':', identifier
- raise
- self.__adopt_declaration( parent, decl )
+ self.__adopt_declaration( parent, decl )
+ except declarations.matcher.declaration_not_found_t:
+ pass
+ #~ declarations.print_declarations( self.global_ns )
+ #~ print 'identifiers:'
+ #~ for index, identifier in enumerate(name_splitter.identifiers):
+ #~ print index, ':', identifier
+ #~ raise
def __adopt_declaration( self, parent, decl ):
smbl = decl.dia_symbols[0]
@@ -272,10 +269,11 @@
elif enums.CV_access_e.CV_protected == smbl.access:
return declarations.ACCESS_TYPES.PROTECTED
else:
- fully_undecorated_name = smbl.undecorate_name()
- if fully_undecorated_name.startswith( 'private:' ):
+ if not smbl.undecoratedName:
+ return declarations.ACCESS_TYPES.PUBLIC
+ elif smbl.undecoratedName.startswith( 'private:' ):
declarations.ACCESS_TYPES.PRIVATE
- elif fully_undecorated_name.startswith( 'protected:' ):
+ elif smbl.undecoratedName.startswith( 'protected:' ):
declarations.ACCESS_TYPES.PROTECTED
else:
return declarations.ACCESS_TYPES.PUBLIC
@@ -348,7 +346,7 @@
#~ self.__load_enums()
#~ self.__load_vars()
#~ self.__load_typedefs()
- #~ self.__load_calldefs()
+ self.__load_calldefs()
map( self.__normalize_name, self.global_ns.decls(recursive=True) )
self.__join_unnamed_nss( self.global_ns )
self.__remove_empty_nss( self.global_ns )
@@ -538,11 +536,15 @@
return decl
def __load_calldefs( self ):
+ compiler_defined_mmem_funs = [ '__vecDelDtor'
+ ,
+ ]
self.logger.info( 'building function objects' )
is_function = lambda smbl: smbl.symTag == msdia.SymTagFunction
for functions_count, function_smbl in enumerate( itertools.ifilter( is_function, self.symbols.itervalues() ) ):
if function_smbl.classParent and function_smbl.classParentId not in self.public_classes: #what about base classes
continue
+ if
function_decl = self.__create_calldef(function_smbl)
if function_decl:
self.__update_decls_tree( function_decl )
@@ -579,6 +581,8 @@
calldef_type = self.create_type( smbl.type ) #what does happen with constructor?
decl = None
if isinstance( calldef_type, declarations.member_function_type_t ):
+ if isinstance( calldef_type.class_inst, declarations.unknown_t ):
+ return
could_be_static = False
could_be_const = False
if '~' in smbl.uname:
@@ -630,7 +634,6 @@
try:
class_ = self.create_type( smbl.objectPointerType )
class_ = declarations.base_type( class_ )
- #~ pdb.set_trace()
return declarations.member_function_type_t( class_, return_type, args_types )
except:
self.logger.warning( 'unable to find out the type of the object pointer for a class method.' )
Modified: pygccxml_dev/pygccxml/utils/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/utils/__init__.py 2008-12-22 22:11:51 UTC (rev 1484)
+++ pygccxml_dev/pygccxml/utils/__init__.py 2008-12-22 22:52:20 UTC (rev 1485)
@@ -171,6 +171,9 @@
if not compiler:
return None
else:
- return compiler[0] + compiler[1].replace( '.', '' )
+ n = compiler[1].replace( '.', '' )
+ if n.endswith('0'):
+ n = n[:-1]
+ return compiler[0] + n.replace( '.', '' )
Added: pygccxml_dev/unittests/data/msvc/mydll.90.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.90.vcproj (rev 0)
+++ pygccxml_dev/unittests/data/msvc/mydll.90.vcproj 2008-12-22 22:52:20 UTC (rev 1485)
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="mydll"
+ ProjectGUID="{E7A34C45-534F-43A6-AF95-3CA2428619E2}"
+ RootNamespace="mydll"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MYDLL_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MYDLL_EXPORTS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapExports="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\mydll.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\mydll.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: pygccxml_dev/unittests/data/msvc/mydll.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.cpp (rev 0)
+++ pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-22 22:52:20 UTC (rev 1485)
@@ -0,0 +1,59 @@
+#include "mydll.h"
+#include "windows.h"
+#include <iostream>
+
+number_t::number_t()
+: m_value(0)
+{
+// std::cout << "{C++} number_t( 0 )" << std::endl;
+}
+
+
+number_t::number_t(int value)
+: m_value(value)
+{
+// std::cout << "{C++} number_t( " << value << " )" << std::endl;
+}
+
+number_t::~number_t() {
+// std::cout << "{C++} ~number_t()" << std::endl;
+}
+void number_t::print_it() const {
+ std::cout << "{C++} value: " << m_value << std::endl;
+}
+
+int number_t::get_value() const{
+ return m_value;
+}
+
+void number_t::set_value(int x){
+ m_value = x;
+}
+
+number_t number_t::clone() const{
+ return number_t(*this);
+}
+
+std::auto_ptr<number_t> number_t::clone_ptr() const{
+ return std::auto_ptr<number_t>( new number_t( *this ) );
+}
+
+void do_smth( number_aptr_t& ){
+}
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
Added: pygccxml_dev/unittests/data/msvc/mydll.h
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.h (rev 0)
+++ pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-22 22:52:20 UTC (rev 1485)
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <memory>
+
+class __declspec(dllexport) number_t{
+public:
+ number_t();
+ explicit number_t(int value);
+ virtual ~number_t();
+ void print_it() const;
+ int get_value() const;
+ int get_value(){ return m_value; }
+ void set_value(int x);
+
+ number_t clone() const;
+ std::auto_ptr<number_t> clone_ptr() const;
+private:
+ int m_value;
+};
+
+template class __declspec(dllexport) std::auto_ptr< number_t >;
+
+typedef std::auto_ptr< number_t > number_aptr_t;
+
+void __declspec(dllexport) do_smth( number_aptr_t& );
\ No newline at end of file
Modified: pygccxml_dev/unittests/mspdb_playground.py
===================================================================
--- pygccxml_dev/unittests/mspdb_playground.py 2008-12-22 22:11:51 UTC (rev 1484)
+++ pygccxml_dev/unittests/mspdb_playground.py 2008-12-22 22:52:20 UTC (rev 1485)
@@ -11,6 +11,7 @@
reader = mspdb.decl_loader_t( pdb_file )
opt = mspdb.enums.UNDECORATE_NAME_OPTIONS.UNDNAME_SHORT_UNIQUE
+opt = 0
public_smbls = {}
for smbl in reader.public_symbols.iterkeys():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-12-21 22:28:20
|
Revision: 1483
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1483&view=rev
Author: roman_yakovenko
Date: 2008-12-21 22:28:17 +0000 (Sun, 21 Dec 2008)
Log Message:
-----------
adding ability to dump exported classes
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/mspdb/loader.py
pygccxml_dev/unittests/mspdb_playground.py
Modified: pygccxml_dev/pygccxml/msvc/mspdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/mspdb/loader.py 2008-12-21 19:02:08 UTC (rev 1482)
+++ pygccxml_dev/pygccxml/msvc/mspdb/loader.py 2008-12-21 22:28:17 UTC (rev 1483)
@@ -81,7 +81,14 @@
def symbols(self):
self.logger.info( 'loading symbols from the file' )
smbls = {}
+ useless = ( msdia.SymTagAnnotation
+ , msdia.SymTagBlock
+ , msdia.SymTagFuncDebugStart
+ , msdia.SymTagFuncDebugEnd
+ , msdia.SymTagManagedType )
for smbl in itertools.imap( as_symbol, as_enum_variant( self.symbols_table._NewEnum ) ):
+ if smbl.symTag in useless:
+ continue
smbl.uname = msvc_utils.undecorate_name( smbl.name, msvc_utils.UNDECORATE_NAME_OPTIONS.UNDNAME_SCOPES_ONLY )
def smbl_undecorate_name( options=None ):
return msvc_utils.undecorate_name( smbl.name, options )
@@ -92,47 +99,64 @@
@utils.cached
def public_symbols( self ):
- self.logger.info( 'loading public symbols from the file' )
- smbls = {}
+ """dictionary, where key is reference to public symbol, and value is symbol itself"""
+ self.logger.info( 'loading public symbols' )
+ self.logger.info( 'looking for public symbols' )
+ public_smbls = {}
+ undname_flags = enums.UNDECORATE_NAME_OPTIONS.UNDNAME_SHORT_UNIQUE
for smbl in self.symbols.itervalues():
- if not smbl.function:
+ if not smbl.function or not smbl.name or smbl.name.startswith( '__' ):
continue
- if not smbl.name:
+ undecorated_name = smbl.get_undecoratedNameEx( undname_flags )
+ if not undecorated_name:
continue
- undecorated_name = smbl.get_undecoratedNameEx( enums.UNDECORATE_NAME_OPTIONS.UNDNAME_SCOPES_ONLY )
+ for prefix in ( '__', '@', 'type_info::' ):
+ if undecorated_name.startswith( prefix ):
+ break
+ else:
+ assert undecorated_name not in public_smbls
+ public_smbls[ undecorated_name ] = smbl
+ self.logger.info( 'looking for public symbols(%d) - done', len(public_smbls) )
+ self.logger.info( 'mapping public symbols to real symbols')
+ smbls = {}
+ for smbl in self.symbols.itervalues():
+ undecorated_name = smbl.get_undecoratedNameEx( undname_flags )
if not undecorated_name:
continue
- if smbl.name.startswith( '__' ):
+ undecorated_name = undecorated_name.strip()
+ if undecorated_name not in public_smbls:
continue
- if undecorated_name.startswith( '__' ):
- continue
- if undecorated_name.startswith( '@' ):
- continue
- if undecorated_name.startswith( 'type_info::' ):
- continue
- smbls[ smbl.symIndexId ] = smbl
- self.logger.info( 'loading public symbols(%d) from the file - done', len( smbls ) )
+ smbls[ public_smbls[undecorated_name] ] = smbl
+ self.logger.info( 'mapping public symbols(%d) to real symbols - done', len( smbls ) )
+ self.logger.info( 'loading public symbols(%d) - done', len( smbls ) )
return smbls
+ @utils.cached
+ def public_classes( self ):
+ """returns set of public classes, which derives from the set of public symbols"""
+ self.logger.info( 'loading public classes' )
+ classes = {}
+ for smbl in self.public_symbols.itervalues():
+ parent = smbl.classParent
+ while parent:
+ classes[ parent.symIndexId ] = self.symbols[ parent.symIndexId ]
+ parent = parent.classParent
+ self.logger.info( 'loading public classes(%d) - done', len(classes) )
+ return classes
+
def __load_nss(self):
def ns_filter( smbl ):
self.logger.debug( '__load_ns.ns_filter, %s', smbl.uname )
tags = ( msdia.SymTagFunction
, msdia.SymTagBlock
, msdia.SymTagData
- #~ , msdia.SymTagAnnotation
- #~ , msdia.SymTagPublicSymbol
, msdia.SymTagUDT
, msdia.SymTagEnum
- #~ , msdia.SymTagFunctionType
- #~ , msdia.SymTagPointerType
, msdia.SymTagArrayType
, msdia.SymTagBaseType
, msdia.SymTagTypedef
, msdia.SymTagBaseClass
, msdia.SymTagFriend
- #~ , msdia.SymTagFunctionArgType
- #~ , msdia.SymTagUsingNamespace
)
if smbl.symTag not in tags:
self.logger.debug( 'smbl.symTag not in tags, %s', smbl.uname )
@@ -142,9 +166,6 @@
elif not smbl.name:
self.logger.debug( 'not smbl.name, %s', smbl.uname )
return False
- #~ elif '-' in smbl.name:
- #~ self.logger.debug( '"-" in smbl.name, %s', smbl.uname )
- #~ return False
elif smbl.classParent:
parent_smbl = self.symbols[ smbl.classParentId ]
while parent_smbl:
@@ -291,25 +312,6 @@
self.__parent_exist.add( parent_name )
return bool( found )
- def __clear_symbols(self):
- self.logger.info( 'clearing symbols' )
- to_be_deleted = []
- useless_tags = (
- msdia.SymTagAnnotation
- , msdia.SymTagPublicSymbol
- , msdia.SymTagBlock
- , msdia.SymTagFuncDebugStart
- , msdia.SymTagFuncDebugEnd
- )
- for smbl_id, smbl in self.symbols.iteritems():
- if smbl.symTag in useless_tags \
- or ( smbl.symTag == msdia.SymTagData and not self.__is_my_var( smbl ) ):
- to_be_deleted.append( smbl_id )
-
- map( lambda smbl_id: self.symbols.pop( smbl_id ), to_be_deleted )
- self.logger.info( 'clearing symbols(%d) - done', len( to_be_deleted ) )
-
-
def __normalize_name( self, decl ):
if decl.name == '<unnamed-tag>':
decl.name = ''
@@ -333,18 +335,23 @@
map( self.__join_unnamed_nss
, ns_parent.namespaces( recursive=False, allow_empty=True ) )
+ def __remove_empty_nss( self, ns_parent ):
+ for ns in ns_parent.namespaces( recursive=False, allow_empty=True ):
+ self.__remove_empty_nss( ns )
+ if 0 == len( ns.decls( recursive=False, allow_empty=True ) ):
+ ns_parent.remove_declaration( ns )
def read(self):
- self.__clear_symbols()
self.__load_nss()
self.__load_classes()
self.__load_base_classes()
- self.__load_enums()
- self.__load_vars()
- self.__load_typedefs()
- self.__load_calldefs()
+ #~ self.__load_enums()
+ #~ self.__load_vars()
+ #~ self.__load_typedefs()
+ #~ self.__load_calldefs()
map( self.__normalize_name, self.global_ns.decls(recursive=True) )
self.__join_unnamed_nss( self.global_ns )
+ self.__remove_empty_nss( self.global_ns )
#join unnamed namespaces
@property
@@ -400,14 +407,15 @@
def __load_classes( self ):
- classes = {}#unique symbol id : class decl
- is_udt = lambda smbl: smbl.symTag == msdia.SymTagUDT
+ classes = {}
+ #~ is_udt = lambda smbl: smbl.symTag == msdia.SymTagUDT
self.logger.info( 'building udt objects' )
- for udt_smbl in itertools.ifilter( is_udt, self.symbols.itervalues() ):
+ #for udt_smbl in itertools.ifilter( is_udt, self.symbols.itervalues() ):
+ for udt_smbl in self.public_classes.itervalues():
classes[udt_smbl.symIndexId] = self.__create_class(udt_smbl)
self.logger.info( 'building udt objects(%d) - done', len(classes) )
- self.logger.info( 'integrating udt objects with namespaces' )
+ self.logger.info( 'integrating class objects with namespaces' )
does_parent_exists = self.parent_exists_t( self.global_ns, classes, self.__id2decl )
while classes:
to_be_integrated = len( classes )
@@ -431,6 +439,9 @@
base_id = smbl.type.symIndexId
derived_id = smbl.classParentId
+ if base_id not in self.public_classes or derived_id not in self.public_classes:
+ continue
+
hi_base = make_hi( self.__id2decl[base_id]
, self.__guess_access_type( smbl )
, bool( smbl.virtualBaseClass ) )
@@ -530,6 +541,8 @@
self.logger.info( 'building function objects' )
is_function = lambda smbl: smbl.symTag == msdia.SymTagFunction
for functions_count, function_smbl in enumerate( itertools.ifilter( is_function, self.symbols.itervalues() ) ):
+ if function_smbl.classParent and function_smbl.classParentId not in self.public_classes: #what about base classes
+ continue
function_decl = self.__create_calldef(function_smbl)
if function_decl:
self.__update_decls_tree( function_decl )
@@ -562,15 +575,13 @@
def __create_calldef( self, smbl ):
self.logger.debug( 'creating calldef "%s"', smbl.uname )
- #~ if smbl.uname == 'some_function':
- #~ pdb.set_trace()
name_splitter = impl_details.get_name_splitter( smbl.uname )
calldef_type = self.create_type( smbl.type ) #what does happen with constructor?
decl = None
if isinstance( calldef_type, declarations.member_function_type_t ):
could_be_static = False
could_be_const = False
- if smbl.uname.startswith( '~' ):
+ if '~' in smbl.uname:
decl = declarations.destructor_t()
if not decl: #may be operator
decl = self.__guess_operator_type(smbl, calldef_type)
Modified: pygccxml_dev/unittests/mspdb_playground.py
===================================================================
--- pygccxml_dev/unittests/mspdb_playground.py 2008-12-21 19:02:08 UTC (rev 1482)
+++ pygccxml_dev/unittests/mspdb_playground.py 2008-12-21 22:28:17 UTC (rev 1483)
@@ -12,21 +12,37 @@
reader = mspdb.decl_loader_t( pdb_file )
opt = mspdb.enums.UNDECORATE_NAME_OPTIONS.UNDNAME_SHORT_UNIQUE
-d = {}
-for smbl in reader.public_symbols.itervalues():
+public_smbls = {}
+for smbl in reader.public_symbols.iterkeys():
name = smbl.name
undecorated_name = smbl.get_undecoratedNameEx(opt).strip()
if undecorated_name.endswith( ')const' ):
undecorated_name = undecorated_name[ : -len('const')]
- d[ name ] = undecorated_name
- d[ undecorated_name ] = name
+ public_smbls[ name ] = undecorated_name
+ public_smbls[ undecorated_name ] = name
-pprint.pprint( d )
+pprint.pprint( public_smbls )
-#~ reader.read()
-#~ f = file( 'decls.cpp', 'w+' )
-#~ declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
-#~ f.close()
+#~ for smbl in reader.symbols.itervalues():
+ #~ if not smbl.classParent:
+ #~ continue
+ #~ undecorated_name = smbl.get_undecoratedNameEx(opt)
+ #~ if not undecorated_name:
+ #~ continue
+ #~ undecorated_name = undecorated_name.strip()
+ #~ if undecorated_name not in public_smbls:
+ #~ continue
+ #~ print '--------------------------------------'
+ #~ print 'mem fun: ', undecorated_name
+ #~ if smbl.classParent:
+ #~ print 'parent class: ', smbl.classParent.name
+ #~ else:
+ #~ print 'no parent'
+ #~ print '======================================'
+reader.read()
+f = file( 'decls.cpp', 'w+' )
+declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
+f.close()
#~ f = file( 'symbols.txt', 'w+')
#~ for smbl in reader.symbols.itervalues():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|