pygccxml-commit Mailing List for C++ Python language bindings (Page 22)
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-06-11 19:44:34
|
Revision: 1333
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1333&view=rev
Author: roman_yakovenko
Date: 2008-06-11 12:44:02 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
adding convenience function: to_list
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py
Modified: pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2008-06-11 19:37:55 UTC (rev 1332)
+++ pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2008-06-11 19:44:02 UTC (rev 1333)
@@ -88,3 +88,9 @@
def __contains__( self, item ):
return item in self.declarations
+
+ def to_list(self):
+ l = []
+ for d in self.declarations:
+ l.append( d )
+ return l
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-11 19:43:20
|
Revision: 1331
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1331&view=rev
Author: roman_yakovenko
Date: 2008-06-11 12:36:58 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
few bug fixes, after upgrading to latest gccxml version
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/compilers.py
Modified: pygccxml_dev/pygccxml/declarations/compilers.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/compilers.py 2008-06-11 19:32:01 UTC (rev 1330)
+++ pygccxml_dev/pygccxml/declarations/compilers.py 2008-06-11 19:36:58 UTC (rev 1331)
@@ -11,6 +11,10 @@
GCC_XML_07 = "GCC-XML 0.7"
GCC_XML_09 = "GCC-XML 0.9"
GCC_XML_09_BUGGY = "GCC-XML 0.9 BUGGY"
+#revision 122:
+#After this fix, all constructors and destructors that exist for a class
+#are dumped whether the user declared them or not. Those that were
+#implicitly declared by the compiler are marked as "artificial".
MSVC_PDB_9 = "MSVC PDB 9.0"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-11 19:31:53
|
Revision: 1330
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1330&view=rev
Author: roman_yakovenko
Date: 2008-06-11 12:32:01 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
few bug fixes, after upgrading to latest gccxml version
Modified Paths:
--------------
pygccxml_dev/unittests/project_reader_correctness_tester.py
Modified: pygccxml_dev/unittests/project_reader_correctness_tester.py
===================================================================
--- pygccxml_dev/unittests/project_reader_correctness_tester.py 2008-06-11 19:21:19 UTC (rev 1329)
+++ pygccxml_dev/unittests/project_reader_correctness_tester.py 2008-06-11 19:32:01 UTC (rev 1330)
@@ -2,26 +2,26 @@
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-
+import os
import unittest
import autoconfig
import parser_test_case
import pygccxml
-from pygccxml.utils import *
-from pygccxml.parser import *
-from pygccxml.declarations import *
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
class tester_t( parser_test_case.parser_test_case_t ):
def __init__(self, *args):
parser_test_case.parser_test_case_t.__init__(self, *args)
self.__files = [
- 'core_ns_join_1.hpp'
+ 'core_types.hpp'
+ , 'core_ns_join_1.hpp'
, 'core_ns_join_2.hpp'
, 'core_ns_join_3.hpp'
, 'core_membership.hpp'
, 'core_class_hierarchy.hpp'
- , 'core_types.hpp'
, 'core_diamand_hierarchy_base.hpp'
, 'core_diamand_hierarchy_derived1.hpp'
, 'core_diamand_hierarchy_derived2.hpp'
@@ -31,13 +31,21 @@
]
def __test_correctness_impl(self, file_name ):
- prj_reader = project_reader_t( self.config )
+ prj_reader = parser.project_reader_t( self.config )
prj_decls = prj_reader.read_files( [file_name]*2
- , compilation_mode=COMPILATION_MODE.FILE_BY_FILE )
- src_reader = source_reader_t( self.config )
+ , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
+ src_reader = parser.source_reader_t( self.config )
src_decls = src_reader.read_file( file_name )
- self.failUnless( src_decls == prj_decls
- , "There is a difference between declarations in file %s." % file_name )
+ if src_decls != prj_decls:
+ s = src_decls[0]
+ p = prj_decls[0]
+ sr = file( os.path.join( autoconfig.build_directory , file_name + '.sr.txt'),'w+' )
+ pr = file( os.path.join( autoconfig.build_directory , file_name + '.pr.txt'), 'w+' )
+ declarations.print_declarations( s, writer=lambda l: sr.write( l + os.linesep ) )
+ declarations.print_declarations( p, writer=lambda l: pr.write( l + os.linesep ) )
+ sr.close()
+ pr.close()
+ self.fail( "There is a difference between declarations in file %s." % file_name )
def test_correctness(self):
for src in self.__files:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-11 19:21:11
|
Revision: 1329
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1329&view=rev
Author: roman_yakovenko
Date: 2008-06-11 12:21:19 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
few bug fixes, after upgrading to latest gccxml version
Modified Paths:
--------------
pygccxml_dev/unittests/source_reader_tester.py
Modified: pygccxml_dev/unittests/source_reader_tester.py
===================================================================
--- pygccxml_dev/unittests/source_reader_tester.py 2008-06-11 19:20:30 UTC (rev 1328)
+++ pygccxml_dev/unittests/source_reader_tester.py 2008-06-11 19:21:19 UTC (rev 1329)
@@ -8,19 +8,27 @@
import parser_test_case
import pygccxml
-from pygccxml.utils import *
-from pygccxml.parser import *
-from pygccxml.declarations import *
+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 = 'declarations_calldef.hpp'
+ self.global_ns = None
+ 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()
+ self.global_ns = tester_t.global_ns
+
def test_compound_argument_type(self):
- reader = source_reader_t( self.config )
- decls = reader.read_file( 'declarations_calldef.hpp' )
- do_smth = find_declaration( decls, type=member_function_t, name='do_smth' )
- self.failUnless( do_smth, "unable to find calldefs_t.do_smth" )
+ do_smth = self.global_ns.calldefs( 'do_smth' )
+ self.failUnless( do_smth, "unable to find do_smth" )
cpptype = do_smth.function_type()
def create_suite():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-11 19:20:23
|
Revision: 1328
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1328&view=rev
Author: roman_yakovenko
Date: 2008-06-11 12:20:30 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
few bug fixes, after upgrading to latest gccxml version
Modified Paths:
--------------
pygccxml_dev/unittests/filters_tester.py
Modified: pygccxml_dev/unittests/filters_tester.py
===================================================================
--- pygccxml_dev/unittests/filters_tester.py 2008-06-11 19:20:02 UTC (rev 1327)
+++ pygccxml_dev/unittests/filters_tester.py 2008-06-11 19:20:30 UTC (rev 1328)
@@ -13,27 +13,33 @@
from pygccxml import declarations
class tester_t( parser_test_case.parser_test_case_t ):
+ global_ns = None
COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE
def __init__(self, *args ):
parser_test_case.parser_test_case_t.__init__( self, *args )
self.header = 'declarations_calldef.hpp'
- self.declarations = None
+ self.global_ns = None
def setUp(self):
- if not self.declarations:
- self.declarations = parser.parse( [self.header], self.config )
+ 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()
+ self.global_ns = tester_t.global_ns
+
def test_regex( self ):
criteria = declarations.regex_matcher_t( 'oper.*'
, lambda decl: decl.name )
- operators = declarations.matcher.find( criteria, self.declarations )
+ operators = declarations.matcher.find( criteria, self.global_ns )
+ operators = filter( lambda d: not d.is_artificial, operators )
self.failUnless( 6 == len(operators) )
def test_access_type( self ):
criteria = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
- public_members = declarations.matcher.find( criteria, self.declarations )
+ public_members = declarations.matcher.find( criteria, self.global_ns )
if '0.9' in public_members[0].compiler:
- #2 empty classes, this compiler doesn't generate constructor and copy constructor
+ public_members = filter( lambda d: not d.is_artificial, public_members )
self.failUnless( 16 == len( public_members ) )
else:
self.failUnless( 20 == len( public_members ) )
@@ -42,10 +48,10 @@
criteria1 = declarations.regex_matcher_t( 'oper.*'
, lambda decl: decl.name )
criteria2 = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
- found = declarations.matcher.find( criteria1 | criteria2, self.declarations )
+ found = declarations.matcher.find( criteria1 | criteria2, self.global_ns )
if '0.9' in found[0].compiler:
- #2 empty classes, this compiler doesn't generate constructor and copy constructor
+ found = filter( lambda d: not d.is_artificial, found )
self.failUnless( 15 <= len( found ) <= 21)
else:
self.failUnless( 19 <= len( found ) <= 25)
@@ -54,13 +60,15 @@
criteria1 = declarations.regex_matcher_t( 'oper.*'
, lambda decl: decl.name )
criteria2 = declarations.access_type_matcher_t( declarations.ACCESS_TYPES.PUBLIC )
- found = declarations.matcher.find( criteria1 & criteria2, self.declarations )
+ found = declarations.matcher.find( criteria1 & criteria2, self.global_ns )
+ found = filter( lambda d: not d.is_artificial, found )
self.failUnless( len( found ) <= 6 )
def test_not_matcher( self ):
criteria1 = declarations.regex_matcher_t( 'oper.*'
, lambda decl: decl.name )
- found = declarations.matcher.find( ~( ~criteria1 ), self.declarations )
+ found = declarations.matcher.find( ~( ~criteria1 ), self.global_ns )
+ found = filter( lambda d: not d.is_artificial, found )
self.failUnless( len( found ) == 6 )
def create_suite():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-11 19:19:56
|
Revision: 1327
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1327&view=rev
Author: roman_yakovenko
Date: 2008-06-11 12:20:02 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
few bug fixes, after upgrading to latest gccxml version
Modified Paths:
--------------
pygccxml_dev/unittests/dependencies_tester.py
Modified: pygccxml_dev/unittests/dependencies_tester.py
===================================================================
--- pygccxml_dev/unittests/dependencies_tester.py 2008-06-05 19:34:47 UTC (rev 1326)
+++ pygccxml_dev/unittests/dependencies_tester.py 2008-06-11 19:20:02 UTC (rev 1327)
@@ -12,16 +12,18 @@
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 = 'include_all.hpp'
self.global_ns = None
- def setUp(self):
- if not self.global_ns:
+ def setUp(self):
+ if not tester_t.global_ns:
decls = parser.parse( [self.header], self.config )
- self.global_ns = declarations.get_global_namespace( decls )
- self.global_ns.init_optimizer()
+ tester_t.global_ns = declarations.get_global_namespace( decls )
+ tester_t.global_ns.init_optimizer()
+ self.global_ns = tester_t.global_ns
def test_variable( self ):
ns_vars = self.global_ns.namespace( '::declarations::variables' )
@@ -43,6 +45,9 @@
cls = ns_vars.class_( 'struct_variables_t' )
dependencies = cls.i_depend_on_them()
if '0.9' in cls.compiler:
+ #GCCXML R122 adds compiler generated constructors/destructors and operator=
+ #to the class, if it has
+ dependencies = filter( lambda d: not d.declaration.is_artificial, dependencies )
self.failUnless( len(dependencies) == 1 )
else:
self.failUnless( len(dependencies) == 2 ) #compiler generated copy constructor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-05 19:34:42
|
Revision: 1326
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1326&view=rev
Author: roman_yakovenko
Date: 2008-06-05 12:34:47 -0700 (Thu, 05 Jun 2008)
Log Message:
-----------
small fixes to update to new version of gccxml
Modified Paths:
--------------
pygccxml_dev/unittests/core_tester.py
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-06-04 17:54:52 UTC (rev 1325)
+++ pygccxml_dev/unittests/core_tester.py 2008-06-05 19:34:47 UTC (rev 1326)
@@ -67,7 +67,9 @@
, 'There are 2 or more instances of ns namespace.' )
def _test_ns_membership(self, ns, enum_name ):
- unnamed_enum = ns.enum( '', recursive=False )
+ unnamed_enum = ns.enum( lambda d: d.name == '' \
+ and d.location.file_name.startswith( autoconfig.data_directory )
+ , recursive=False )
self.failUnless( unnamed_enum in ns.declarations
, "namespace '%s' does not contains unnamed enum." % ns.name )
@@ -256,8 +258,6 @@
if self.global_ns.compiler != compilers.MSVC_PDB_9:
self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
- sf = self.glo
- members_pointers_t
def test_member_variable_type(self):
if self.global_ns.compiler == compilers.MSVC_PDB_9:
return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-04 17:54:52
|
Revision: 1325
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1325&view=rev
Author: roman_yakovenko
Date: 2008-06-04 10:54:52 -0700 (Wed, 04 Jun 2008)
Log Message:
-----------
fixing small spelling error
Modified Paths:
--------------
pyplusplus_dev/docs/links.rest
Modified: pyplusplus_dev/docs/links.rest
===================================================================
--- pyplusplus_dev/docs/links.rest 2008-06-03 05:20:17 UTC (rev 1324)
+++ pyplusplus_dev/docs/links.rest 2008-06-04 17:54:52 UTC (rev 1325)
@@ -78,11 +78,11 @@
----------------------------------
-Libraries inspired by Boost.Python
+Libraries inspired by Boost.Python
----------------------------------
* `Luabind`_ - interfacing C++ and `Lua`_
-
+
.. _`Luabind` : http://www.rasterbar.com/products/luabind/docs.html
.. _`Lua` : http://www.lua.org/
@@ -97,7 +97,7 @@
.. _`Squirrel` : http://wiki.squirrel-lang.org/
-----------------------------
-Projects inspired by Py++ :-)
+Projects inspired by Py++ :-)
-----------------------------
* `PyBindGen`_ - a new project for producing Python extensions
@@ -108,13 +108,13 @@
Blogs
-----
-* http://www.shocksolution.com/math_tools/boost.python/index.html - this site
- contains few usefull Boost.Python examples and tutorials.
+* http://www.shocksolution.com/math_tools/boost.python/index.html - this site
+ contains few useful Boost.Python examples and tutorials.
-------------
Build systems
-------------
-http://www.scons.org/wiki/GCCXMLBuilder - Joseph Lisee shows how to integrate
+http://www.scons.org/wiki/GCCXMLBuilder - Joseph Lisee shows how to integrate
Py++ scripts with Scons.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-03 05:20:11
|
Revision: 1324
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1324&view=rev
Author: roman_yakovenko
Date: 2008-06-02 22:20:17 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
fixing small issue related to unions
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/pyplusplus/messages/warnings_.py
pyplusplus_dev/unittests/data/classes_to_be_exported.hpp
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/data/embeded_to_be_exported.hpp
pyplusplus_dev/unittests/embeded_tester.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-06-02 21:19:07 UTC (rev 1323)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-06-03 05:20:17 UTC (rev 1324)
@@ -337,6 +337,8 @@
if not self.name:
return messages.W1018
#it is possible to do so, but not for unnamed classes defined under namespace.
+ if self.class_type == declarations.CLASS_TYPES.UNION:
+ return messages.W1054
if isinstance( self.parent, declarations.namespace_t ):
return ''
if not self in self.parent.public_members:
Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py
===================================================================
--- pyplusplus_dev/pyplusplus/messages/warnings_.py 2008-06-02 21:19:07 UTC (rev 1323)
+++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2008-06-03 05:20:17 UTC (rev 1324)
@@ -216,6 +216,8 @@
W1053 = warning(
'Py++ will not expose function "%s" - the function has variable-argument list, spicified by ellipsis (...).' )
+W1054 = compilation_error( 'Py++ can not expose unions.' )
+
warnings = globals()
all_warning_msgs = []
Modified: pyplusplus_dev/unittests/data/classes_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/classes_to_be_exported.hpp 2008-06-02 21:19:07 UTC (rev 1323)
+++ pyplusplus_dev/unittests/data/classes_to_be_exported.hpp 2008-06-03 05:20:17 UTC (rev 1324)
@@ -95,6 +95,15 @@
}
+union Word
+{
+ short word;
+ struct
+ {
+ char low, high;
+ };
+};
+
}//classes
namespace pyplusplus{ namespace aliases{
Added: pyplusplus_dev/unittests/data/embeded_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/embeded_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/embeded_to_be_exported.hpp 2008-06-03 05:20:17 UTC (rev 1324)
@@ -0,0 +1,13 @@
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __embeded_to_be_exported_hpp__
+#define __embeded_to_be_exported_hpp__
+
+struct item_t{
+ int i;
+};
+
+#endif//__embeded_to_be_exported_hpp__
Added: pyplusplus_dev/unittests/embeded_tester.py
===================================================================
--- pyplusplus_dev/unittests/embeded_tester.py (rev 0)
+++ pyplusplus_dev/unittests/embeded_tester.py 2008-06-03 05:20:17 UTC (rev 1324)
@@ -0,0 +1,64 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import os
+import sys
+import unittest
+import fundamental_tester_base
+from pyplusplus import code_creators
+from pyplusplus.module_builder.call_policies import *
+
+clone_def_code = """
+
+namespace bpl = boost::python;
+
+bpl::object clone_item( const item_t& item ){
+ std::auto_ptr< item_t > new_item( new item_t() );
+ new_item->i = item.i;
+ return bpl::object( new_item );
+}
+
+"""
+
+clone_reg_code = """
+
+def("clone_item", &clone_item );
+
+ bp::register_ptr_to_python< std::auto_ptr< item_t > >();
+
+"""
+
+
+class tester_t(fundamental_tester_base.fundamental_tester_base_t):
+ EXTENSION_NAME = 'embeded'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def customize(self, mb ):
+ mb.add_declaration_code( clone_def_code )
+ mb.add_registration_code( clone_reg_code, True )
+
+ def run_tests( self, module):
+ item = module.item_t()
+ item.i = 78
+
+ item2 = module.clone_item(item)
+ self.failUnless( item2.i == item.i )
+ self.failUnless( sys.getrefcount( item2 ) == 2 ) #one for boost.python second for current scope
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2008-06-02 21:19:07 UTC (rev 1323)
+++ pyplusplus_dev/unittests/test_all.py 2008-06-03 05:20:17 UTC (rev 1324)
@@ -104,6 +104,7 @@
import split_module_indexing_suite_bug_tester
import inner_tmpl_class_tester
import bug_covariant_returns_tester
+import embeded_tester
testers = [
algorithms_tester
@@ -195,6 +196,7 @@
, split_module_indexing_suite_bug_tester
, inner_tmpl_class_tester
, bug_covariant_returns_tester
+ , embeded_tester
]
class module_runner_t( object ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-06-02 21:19:01
|
Revision: 1323
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1323&view=rev
Author: roman_yakovenko
Date: 2008-06-02 14:19:07 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
small set of improvements
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/core_overloads_1.hpp
pygccxml_dev/unittests/data/core_overloads_2.hpp
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
pygccxml_dev/unittests/parser_test_case.py
pygccxml_dev/unittests/pdb_tester.py
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -274,6 +274,8 @@
msdia.SymTagAnnotation
, msdia.SymTagPublicSymbol
, msdia.SymTagBlock
+ , msdia.SymTagFuncDebugStart
+ , msdia.SymTagFuncDebugEnd
)
for smbl_id, smbl in self.symbols.iteritems():
if smbl.symTag in useless_tags \
@@ -367,9 +369,10 @@
if not isinstance( decl, declarations.typedef_t ):
decl.byte_size = smbl.length
decl.byte_offset = smbl.offset
- decl.mangled = iif( smbl.name, smbl.name, '' )
+ decl.mangled = iif( smbl.get_undecoratedNameEx(0), smbl.name, '' )
decl.demangled = iif( smbl.uname, smbl.uname, '' )
decl.is_artificial = bool( smbl.compilerGenerated )
+ decl.location = declarations.location_t( smbl.lexicalParent.sourceFileName )
def __load_classes( self ):
@@ -504,7 +507,8 @@
is_function = lambda smbl: smbl.symTag == msdia.SymTagFunction
for functions_count, function_smbl in enumerate( itertools.ifilter( is_function, self.symbols.itervalues() ) ):
function_decl = self.__create_calldef(function_smbl)
- self.__update_decls_tree( function_decl )
+ if function_decl:
+ self.__update_decls_tree( function_decl )
self.logger.info( 'building function objects(%d) - done', functions_count )
def __guess_operator_type( self, smbl, operator_type ):
@@ -540,21 +544,31 @@
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( '~' ):
decl = declarations.destructor_t()
if not decl: #may be operator
decl = self.__guess_operator_type(smbl, calldef_type)
+ could_be_static = True
+ could_be_const = True
if not decl: #may be constructor
decl = self.__guess_constructor( smbl, calldef_type )
if not decl:
decl = declarations.member_function_t()
+ could_be_static = True
+ could_be_const = True
if smbl.virtual:
decl.virtuality = iif( smbl.pure
, declarations.VIRTUALITY_TYPES.PURE_VIRTUAL
, declarations.VIRTUALITY_TYPES.VIRTUAL )
+ decl.has_const = bool( could_be_const and smbl.constType )
+ decl.has_static = bool( could_be_static and smbl.isStatic )
else:
decl = self.__guess_operator_type(smbl, calldef_type)
if not decl:
+ if 'instantiate::`dynamic initializer for' in smbl.uname:
+ return #in this case we deal with initializer of some global variable
decl = declarations.free_function_t()
decl.name = smbl.uname
decl.arguments = map( lambda t: declarations.argument_t( type=t )
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/autoconfig.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -41,27 +41,23 @@
pygccxml.declarations.class_t.USE_DEMANGLED_AS_NAME = True
class cxx_parsers_cfg:
- gccxml = pygccxml.parser.gccxml_configuration_t( gccxml_path=gccxml_path
- , working_directory=data_directory
- , define_symbols=[ gccxml_version ]
- , compiler=compiler )
-
+ gccxml = None
+ if os.path.exists( os.path.join( gccxml_path, 'gccxml' ) ) \
+ or os.path.exists( os.path.join( gccxml_path, 'gccxml.exe' ) ):
+ gccxml = pygccxml.parser.gccxml_configuration_t( gccxml_path=gccxml_path
+ , working_directory=data_directory
+ , define_symbols=[ gccxml_version ]
+ , compiler=compiler )
pdb_loader = None
+ if sys.platform == 'win32':
+ from pygccxml.msvc import pdb
+ pdb_file = os.path.join( data_directory, 'msvc_build', 'Debug', 'msvc_build.pdb' )
+ pdb_loader = pdb.decl_loader_t( pdb_file )
+ pdb_loader.read()
- @staticmethod
- def get_pdb_loader():
- if not cxx_parsers_cfg.pdb_loader and sys.platform == 'win32':
- from pygccxml.msvc import pdb
- pdb_file = os.path.join( data_directory, 'msvc_build', 'Debug', 'msvc_build.pdb' )
- cxx_parsers_cfg.pdb_loader = pdb.decl_loader_t( pdb_file )
- cxx_parsers_cfg.pdb_loader.read()
- return cxx_parsers_cfg.pdb_loader
-
-
def get_pdb_global_ns():
- return cxx_parsers_cfg.get_pdb_loader().global_ns
+ return cxx_parsers_cfg.pdb_loader.global_ns
-
#~ try:
#~ import pydsc
#~ pydsc.include( r'D:\pygccxml_sources\sources\pygccxml_dev' )
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/core_tester.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -256,6 +256,8 @@
if self.global_ns.compiler != compilers.MSVC_PDB_9:
self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
+ sf = self.glo
+ members_pointers_t
def test_member_variable_type(self):
if self.global_ns.compiler == compilers.MSVC_PDB_9:
return
@@ -379,13 +381,13 @@
def create_suite():
suite = unittest.TestSuite()
- #~ suite.addTest( unittest.makeSuite(core_all_at_once_t))
- #~ 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 sys.platform == 'win32':
+ if autoconfig.cxx_parsers_cfg.gccxml:
+ suite.addTest( unittest.makeSuite(core_all_at_once_t))
+ 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))
-
return suite
def run_suite():
Modified: pygccxml_dev/unittests/data/core_overloads_1.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_overloads_1.hpp 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/core_overloads_1.hpp 2008-06-02 21:19:07 UTC (rev 1323)
@@ -6,10 +6,12 @@
#ifndef __core_overloads_1_hpp__
#define __core_overloads_1_hpp__
+#include <string>
+
namespace core{ namespace overloads{
-void do_nothing( int );
-void do_nothing( double );
+void do_nothing( std::string );
+void do_nothing( std::wstring );
} }
Modified: pygccxml_dev/unittests/data/core_overloads_2.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_overloads_2.hpp 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/core_overloads_2.hpp 2008-06-02 21:19:07 UTC (rev 1323)
@@ -5,11 +5,12 @@
#ifndef __core_overloads_2_hpp__
#define __core_overloads_2_hpp__
-
+#include <string>
+#include <set>
namespace core{ namespace overloads{
-void do_nothing( bool );
-void do_nothing( float );
+void do_nothing( std::set< std::string > );
+void do_nothing( std::set< std::wstring > );
} }
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-06-02 21:19:07 UTC (rev 1323)
@@ -44,6 +44,16 @@
#include "vector_traits.hpp"
#include "core_types.hpp"
+
+namespace core{ namespace overloads{
+
+void do_nothing( std::string d){ std::cout << d; }
+void do_nothing( std::wstring d){ std::wcout << d; }
+void do_nothing( std::set< std::string > d ){ std::set< std::string >::size_type t = d.size(); }
+void do_nothing( std::set< std::wstring > d ){ std::set< std::wstring >::size_type t = d.size(); }
+
+} }
+
namespace declarations{ namespace variables{
int static_var = 0;
@@ -56,8 +66,12 @@
sizeof(core::types::exception );
}
+void use_core_overloads(){
+ namespace co = core::overloads;
+}
void use_core_types(){
+ use_core_overloads();
core::types::members_pointers_t mem_ptrs;
core::types::typedef_const_int typedef_const_int_ = 0;
core::types::typedef_pointer_int typedef_pointer_int_ = 0;
Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-06-02 21:19:07 UTC (rev 1323)
@@ -41,6 +41,7 @@
/>
<Tool
Name="VCCLCompilerTool"
+ AdditionalOptions="/Iu /n "
Optimization="0"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="..\"
@@ -85,6 +86,7 @@
/>
<Tool
Name="VCBscMakeTool"
+ AdditionalOptions="/Iu /n "
/>
<Tool
Name="VCFxCopTool"
Modified: pygccxml_dev/unittests/parser_test_case.py
===================================================================
--- pygccxml_dev/unittests/parser_test_case.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/parser_test_case.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -14,15 +14,17 @@
from pygccxml.declarations import *
class parser_test_case_t( unittest.TestCase ):
-
+
CXX_PARSER_CFG = None
-
+
def __init__(self, *args):
unittest.TestCase.__init__(self, *args)
if self.CXX_PARSER_CFG:
self.config = self.CXX_PARSER_CFG.clone()
+ elif autoconfig.cxx_parsers_cfg.gccxml:
+ self.config = autoconfig.cxx_parsers_cfg.gccxml.clone()
else:
- self.config = autoconfig.cxx_parsers_cfg.gccxml.clone()
+ pass
def _test_type_composition( self, type, expected_compound, expected_base ):
self.failUnless( isinstance( type, expected_compound)
Modified: pygccxml_dev/unittests/pdb_tester.py
===================================================================
--- pygccxml_dev/unittests/pdb_tester.py 2008-05-27 17:54:15 UTC (rev 1322)
+++ pygccxml_dev/unittests/pdb_tester.py 2008-06-02 21:19:07 UTC (rev 1323)
@@ -38,11 +38,8 @@
reader = pdb.decl_loader_t( self.pdb_file )
print reader.symbols_table.name
reader.read()
- x = []
- declarations.print_declarations( reader.global_ns, writer=x.append )
- x = filter( None, map( lambda l: l.rstrip(), x ) )
f = file( 'decls.cpp', 'w+' )
- f.write( os.linesep.join( x ) )
+ declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
f.close()
f = file( 'symbols.txt', 'w+')
@@ -76,7 +73,19 @@
#~ print undecorated
self.failUnless( msvc_utils.undecorate_name( decorated ) == undecorated )
+ #todo: move to GUI
+ def test_pdbs( self ):
+ for f in filter( lambda f: f.endswith( 'pdb' ), os.listdir( r'E:\pdbs' ) ):
+ try:
+ reader = pdb.decl_loader_t( f )
+ reader.read()
+ f = file( d + '.txt', 'w+' )
+ declarations.print_declarations( reader.global_ns, writer=lambda line: f.write(line+'\n') )
+ f.close()
+ except Exception, error:
+ print 'unable to load pdb file ', f, ' Error: ', str(error)
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-05-27 17:54:10
|
Revision: 1322
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1322&view=rev
Author: roman_yakovenko
Date: 2008-05-27 10:54:15 -0700 (Tue, 27 May 2008)
Log Message:
-----------
implement "abstract" property for PDB parser
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/class_declaration.py
Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-05-25 20:36:02 UTC (rev 1321)
+++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-05-27 17:54:15 UTC (rev 1322)
@@ -13,6 +13,7 @@
"""
import scopedef
+import itertools
import compilers
import algorithm
import declaration
@@ -276,13 +277,28 @@
def _get_is_abstract(self):
if self.compiler == compilers.MSVC_PDB_9:
+ #prevent cyclic dependencies
import calldef
- import matchers #prevent cyclic dependencies
- m = matchers.virtuality_type_matcher_t( calldef.VIRTUALITY_TYPES.PURE_VIRTUAL )
- if self.calldefs( m, recursive=False, allow_empty=True ):
+ import function_traits
+ from matchers import virtuality_type_matcher_t as vtmatcher_t
+ filter_pv = vtmatcher_t( calldef.VIRTUALITY_TYPES.PURE_VIRTUAL )
+ if self.calldefs( filter_pv, recursive=False, allow_empty=True ):
return True
+ filter_npv = vtmatcher_t( calldef.VIRTUALITY_TYPES.VIRTUAL ) \
+ | vtmatcher_t( calldef.VIRTUALITY_TYPES.NOT_VIRTUAL )
+ pv_calldefs = []
+ npv_calldefs = []
+
+ npv_calldefs.extend( self.calldefs( filter_npv, recursive=False, allow_empty=True ) )
for base in self.recursive_bases:
- if base.related_class.calldefs( m, recursive=False, allow_empty=True ):
+ cls = base.related_class
+ pv_calldefs.extend( cls.calldefs( filter_pv, recursive=False, allow_empty=True ) )
+ npv_calldefs.extend( cls.calldefs( filter_npv, recursive=False, allow_empty=True ) )
+
+ for pure_virtual in pv_calldefs:
+ impl_found = filter( lambda f: function_traits.is_same_function( pure_virtual, f )
+ , npv_calldefs )
+ if not impl_found:
return True
return False
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-05-25 20:35:55
|
Revision: 1321
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1321&view=rev
Author: roman_yakovenko
Date: 2008-05-25 13:36:02 -0700 (Sun, 25 May 2008)
Log Message:
-----------
another set of changes to PDB reader
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/class_declaration.py
pygccxml_dev/pygccxml/declarations/decl_printer.py
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/data/core_types.hpp
pygccxml_dev/unittests/data/msvc_build/all.cpp
Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-05-12 18:53:09 UTC (rev 1320)
+++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-05-25 20:36:02 UTC (rev 1321)
@@ -275,7 +275,18 @@
return self._recursive_derived
def _get_is_abstract(self):
- return self._is_abstract
+ if self.compiler == compilers.MSVC_PDB_9:
+ import calldef
+ import matchers #prevent cyclic dependencies
+ m = matchers.virtuality_type_matcher_t( calldef.VIRTUALITY_TYPES.PURE_VIRTUAL )
+ if self.calldefs( m, recursive=False, allow_empty=True ):
+ return True
+ for base in self.recursive_bases:
+ if base.related_class.calldefs( m, recursive=False, allow_empty=True ):
+ return True
+ return False
+ else:
+ return self._is_abstract
def _set_is_abstract( self, is_abstract ):
self._is_abstract = is_abstract
is_abstract = property( _get_is_abstract, _set_is_abstract
Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-05-12 18:53:09 UTC (rev 1320)
+++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-05-25 20:36:02 UTC (rev 1321)
@@ -9,8 +9,9 @@
import os
import sys
+import calldef
+import algorithm
import decl_visitor
-import algorithm
class decl_printer_t( decl_visitor.decl_visitor_t ):
@@ -33,7 +34,7 @@
self.__recursive = recursive
self.__writer = writer
if not self.__writer:
- self.__writer = sys.stdout.write
+ self.__writer = lambda x: sys.stdout.write( x + os.linesep )
def clone(self, increment_level=True):
level = self.__level
@@ -83,20 +84,27 @@
def print_decl_header(self):
header = self.__nice_decl_name( self.__inst ) + ": '%s'" % self.__inst.name
- self.writer( ' ' * self.level * self.INDENT_SIZE + header.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * self.level * self.INDENT_SIZE + header.ljust( self.JUSTIFY ))
if self.__print_details:
curr_level = self.level + 1
if self.__inst.location:
location = 'location: [%s]:%s'%(self.__inst.location.file_name, self.__inst.location.line)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + location + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + location)
artificial = 'artificial: ' + "'%s'" % str(self.__inst.is_artificial)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + artificial.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + artificial.ljust( self.JUSTIFY ))
if self.__inst.attributes:
attributes = 'attributes: %s'%(self.__inst.attributes)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + attributes + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + attributes)
+ if self.__inst.demangled:
+ demangled = 'demangled: %s'%(self.__inst.demangled)
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + demangled)
+ if self.__inst.mangled:
+ mangled = 'mangled: %s'%(self.__inst.mangled)
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + mangled)
- def __get_method_signature(self, decl=None):
+
+ def print_calldef_info(self, decl=None):
""" Returns function signature: [retval, [arg1, ..., argN]]. """
if None is decl:
decl = self.__inst
@@ -106,46 +114,45 @@
retval = decl.return_type.decl_string
args = []
for arg in decl.arguments:
- args.append(arg.type.decl_string)
- return [retval, args]
+ args.append(arg.type.decl_string + ' ' + arg.name)
+ indent = ' ' * (self.level+1) * self.INDENT_SIZE
+ self.writer( indent + "return type: " + str(retval) )
+ self.writer( indent + "arguments type: " + ', '.join(args))
+ if isinstance( decl, calldef.member_calldef_t ):
+ self.writer( indent + "virtual: " + str(decl.virtuality))
+ self.writer( indent + "is const: " + str(decl.has_const))
+ self.writer( indent + "is static: " + str(decl.has_static))
def visit_member_function( self ):
self.print_decl_header()
- self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
- + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+ self.print_calldef_info()
def visit_constructor( self ):
self.print_decl_header()
- self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
- + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+ self.print_calldef_info()
if self.__print_details:
self.writer( ' ' * ( self.level + 1 ) * self.INDENT_SIZE
- + 'copy constructor: ' + str(self.__inst.is_copy_constructor)
- + os.linesep )
+ + 'copy constructor: ' + str(self.__inst.is_copy_constructor) )
def visit_destructor( self ):
self.print_decl_header()
def visit_member_operator( self ):
self.print_decl_header()
- self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
- + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+ self.print_calldef_info()
def visit_casting_operator( self ):
self.print_decl_header()
- self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
- + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+ self.print_calldef_info()
def visit_free_function( self ):
self.print_decl_header()
- self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
- + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+ self.print_calldef_info()
def visit_free_operator( self ):
self.print_decl_header()
- self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
- + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+ self.print_calldef_info()
def visit_class_declaration(self ):
self.print_decl_header()
@@ -154,35 +161,35 @@
self.print_decl_header()
curr_level = self.level + 1
class_type = 'class type: ' + "'%s'" % str(self.__inst.class_type)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + class_type.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + class_type.ljust( self.JUSTIFY ))
if self.__print_details:
byte_size = 'size: %d'%(self.__inst.byte_size)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ))
try:
byte_align = 'align: %d'%(self.__inst.byte_align)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ))
except NotImplementedError:
- self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ))
if self.__inst.aliases:
aliases = map( lambda typedef: typedef.name, self.__inst.aliases )
msg = 'aliases: ' + `aliases`
- self.writer( ' ' * curr_level * self.INDENT_SIZE + msg.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + msg.ljust( self.JUSTIFY ))
def print_hierarchy(hierarchy_type, classes, curr_level):
- self.writer( ' ' * curr_level * self.INDENT_SIZE + hierarchy_type.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + hierarchy_type.ljust( self.JUSTIFY ))
curr_level += 1
for class_ in classes:
class_str = 'class: ' + "'%s'" % str(class_.related_class.decl_string)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + class_str.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + class_str.ljust( self.JUSTIFY ))
access = 'access type: ' + "'%s'" % str(class_.access)
- self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + access.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + access.ljust( self.JUSTIFY ))
if not ( None is class_.is_virtual ):
is_virtual = 'virtual inheritance: ' + "'%s'" % str(class_.is_virtual)
- self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + is_virtual.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + is_virtual.ljust( self.JUSTIFY ))
def print_members(members_type, members, curr_level):
- self.writer( ' ' * curr_level * self.INDENT_SIZE + members_type.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + members_type.ljust( self.JUSTIFY ))
if self.__recursive:
curr_level += 1
for member in members:
@@ -207,7 +214,7 @@
value_level = ' ' * ( curr_level + 1 )* self.INDENT_SIZE
self.writer( os.linesep )
for name, value in self.__inst.values:
- self.writer( value_level + "%s : %s"% (name, value) + os.linesep )
+ self.writer( value_level + "%s : %s"% (name, value))
def visit_namespace(self ):
self.print_decl_header()
@@ -220,7 +227,7 @@
def visit_typedef(self ):
self.print_decl_header()
curr_level = self.level + 1
- self.writer( ' ' * curr_level * self.INDENT_SIZE + 'alias to: ' + self.__inst.type.decl_string + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + 'alias to: ' + self.__inst.type.decl_string)
def visit_variable(self ):
self.print_decl_header()
@@ -228,16 +235,16 @@
self.writer( ' ' * curr_level * self.INDENT_SIZE + 'type: %s value: %s'%(self.__inst.type.decl_string, self.__inst.value) + os.linesep)
if self.__print_details:
byte_size = 'size: %d'%(self.__inst.type.byte_size)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ))
try:
byte_align = 'align: %d'%(self.__inst.type.byte_align)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ))
except NotImplementedError:
- self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ))
byte_offset = 'offset: %d'%(self.__inst.byte_offset)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_offset + os.linesep)
-def print_declarations( decls, detailed=True, recursive=True, writer=sys.stdout.write ):
+def print_declarations( decls, detailed=True, recursive=True, writer=lambda x: sys.stdout.write( x + os.linesep ) ):
""" Print decl tree rooted at each of the included nodes.
decls - either a single decl or a list of decls.
"""
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-12 18:53:09 UTC (rev 1320)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-25 20:36:02 UTC (rev 1321)
@@ -178,6 +178,8 @@
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 )
@@ -208,16 +210,16 @@
self.__id2decl[ smbl.symIndexId ] = decl
else:
for other_decl in already_added:
- for other_smbl in other_decl.dia_symbols:
- if self.__are_symbols_equivalent( other_smbl, smbl ):
- other_decl.dia_symbols.append( smbl )
- self.__id2decl[ smbl.symIndexId ] = other_decl
- return
+ if self.__is_same_smbls( other_decl, decl ):
+ other_decl.dia_symbols.append( smbl )
+ self.__id2decl[ smbl.symIndexId ] = other_decl
+ return
else:
if isinstance( parent, declarations.namespace_t ):
parent.adopt_declaration( decl )
else:
parent.adopt_declaration( decl, self.__guess_access_type( smbl ) )
+ self.__id2decl[ smbl.symIndexId ] = decl
def __guess_access_type( self, smbl ):
if enums.CV_access_e.CV_private == smbl.access:
@@ -327,16 +329,18 @@
def global_ns(self):
return self.__global_ns
- def __are_symbols_equivalent( self, smbl1, smbl2 ):
- result = smbl1.symTag == smbl2.symTag and smbl1.uname == smbl2.uname
- if not result:
- result = self.__dia_session.symsAreEquiv( smbl1, smbl2 )
- if result:
- msg = 'Symbols "%s(%d)" and "%s(%d)" are equivalent.'
+ def __is_same_smbls( self, decl1, decl2 ):
+ if not( decl1.__class__ is decl2.__class__ ):
+ return False
+ if decl1.name == decl2.name:
+ if isinstance( decl1, declarations.calldef_t ):
+ #TODO: well, I will have to fix this someday
+ return False
+ else:
+ return True
else:
- msg = 'Symbols "%s(%d)" and "%s(%d)" are NOT equivalent.'
- self.logger.debug( msg, smbl1.uname, smbl1.symIndexId, smbl2.uname, smbl2.symIndexId )
- return result
+ return False
+ #~ return self.__dia_session.symsAreEquiv( decl1.dia_symbols[0], decl2.dia_symbols[0] )
def __find_udt( self, name ):
self.logger.debug( 'testing whether name( "%s" ) is UDT symbol' % name )
@@ -530,6 +534,8 @@
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
@@ -542,6 +548,10 @@
decl = self.__guess_constructor( smbl, calldef_type )
if not decl:
decl = declarations.member_function_t()
+ if smbl.virtual:
+ decl.virtuality = iif( smbl.pure
+ , declarations.VIRTUALITY_TYPES.PURE_VIRTUAL
+ , declarations.VIRTUALITY_TYPES.VIRTUAL )
else:
decl = self.__guess_operator_type(smbl, calldef_type)
if not decl:
Modified: pygccxml_dev/unittests/data/core_types.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_types.hpp 2008-05-12 18:53:09 UTC (rev 1320)
+++ pygccxml_dev/unittests/data/core_types.hpp 2008-05-25 20:36:02 UTC (rev 1321)
@@ -51,7 +51,12 @@
struct exception{};
struct members_pointers_t{
- int some_function( double ) const throw( exception );
+ int some_function( double hi, int i ){
+ return 0;
+ }
+ int some_function( double hi) const throw( exception ){
+ return 0;
+ };
int m_some_const_member;
int xxx;
};
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-05-12 18:53:09 UTC (rev 1320)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-05-25 20:36:02 UTC (rev 1321)
@@ -93,6 +93,10 @@
core::types::function_ptr function_ptr_ = 0;
core::types::member_function_ptr_t member_function_ptr_ = 0;
+ core::types::members_pointers_t members_pointers_inst;
+ members_pointers_inst.some_function( 0.23 );
+ members_pointers_inst.some_function( 0.23, 11 );
+
}
void use_core_ns_join_3(){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-05-12 18:54:46
|
Revision: 1320
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1320&view=rev
Author: roman_yakovenko
Date: 2008-05-12 11:53:09 -0700 (Mon, 12 May 2008)
Log Message:
-----------
fixing small bug: return types could be same type
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/function_traits.py
pyplusplus_dev/unittests/bug_covariant_returns_tester.py
pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp
Modified: pygccxml_dev/pygccxml/declarations/function_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/function_traits.py 2008-05-11 20:23:01 UTC (rev 1319)
+++ pygccxml_dev/pygccxml/declarations/function_traits.py 2008-05-12 18:53:09 UTC (rev 1320)
@@ -27,6 +27,7 @@
# cv-qualification than the class type in the return type of B::f.
if not f1.__class__ is f2.__class__:
+ #it should be assert
return False #2 different calldef types
if not isinstance( f1, calldef.member_calldef_t ):
#for free functions we compare return types as usual
@@ -58,7 +59,8 @@
if c1.class_type == class_declaration.CLASS_TYPES.UNION \
or c2.class_type == class_declaration.CLASS_TYPES.UNION:
return type_traits.is_same( rt1, rt2 )
- return type_traits.is_base_and_derived( c1, c2 ) \
+ return type_traits.is_same( c1, c2 ) \
+ or type_traits.is_base_and_derived( c1, c2 ) \
or type_traits.is_base_and_derived( c2, c1 )
Modified: pyplusplus_dev/unittests/bug_covariant_returns_tester.py
===================================================================
--- pyplusplus_dev/unittests/bug_covariant_returns_tester.py 2008-05-11 20:23:01 UTC (rev 1319)
+++ pyplusplus_dev/unittests/bug_covariant_returns_tester.py 2008-05-12 18:53:09 UTC (rev 1320)
@@ -21,6 +21,9 @@
def customize(self, mb ):
mb.mem_funs( 'f' ).call_policies = return_value_policy(manage_new_object)
+ mb.decl( 'DObjectState' ).opaque = True
+ saveState = mb.mem_funs( lambda f: f.name == 'saveState' and 'FObjectState' in f.decl_string )
+ saveState.call_policies = return_value_policy(manage_new_object)
def run_tests( self, module):
pass
Modified: pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp 2008-05-11 20:23:01 UTC (rev 1319)
+++ pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp 2008-05-12 18:53:09 UTC (rev 1320)
@@ -32,5 +32,42 @@
}
};
-
+
+
+struct FObjectState {};
+
+struct DObjectState;
+
+
+struct FSerializable {
+public:
+ virtual FObjectState* saveState() const = 0;
+};
+
+struct DSerializable {
+public:
+ virtual DObjectState* saveState() const = 0;
+};
+
+
+class FMachinePart : public FSerializable {
+};
+
+class DMachinePart : public DSerializable {
+};
+
+
+class FComponent : public FMachinePart {
+public:
+ // methods inherited from Serializable interface
+ virtual FObjectState* saveState() const{ return 0; }
+};
+
+
+class DComponent : public DMachinePart {
+public:
+ // methods inherited from Serializable interface
+ virtual DObjectState* saveState() const{ return 0; }
+};
+
#endif//__bug_virtual_functions_overload_to_be_exported_hpp__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-05-11 20:22:54
|
Revision: 1319
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1319&view=rev
Author: roman_yakovenko
Date: 2008-05-11 13:23:01 -0700 (Sun, 11 May 2008)
Log Message:
-----------
adding basic support for functions
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/decl_printer.py
pygccxml_dev/pygccxml/msvc/pdb/enums.py
pygccxml_dev/pygccxml/msvc/pdb/loader.py
Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-05-08 20:05:35 UTC (rev 1318)
+++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-05-11 20:23:01 UTC (rev 1319)
@@ -97,15 +97,18 @@
def __get_method_signature(self, decl=None):
- """ Returns function signature: [retval, [arg1, ..., argN]]. """
- if None is decl:
- decl = self.__inst
- retval = decl.return_type.decl_string
- args = []
- for arg in decl.arguments:
- args.append(arg.type.decl_string)
- return [retval, args]
+ """ Returns function signature: [retval, [arg1, ..., argN]]. """
+ if None is decl:
+ decl = self.__inst
+ retval = None
+ if decl.return_type:
+ retval = decl.return_type.decl_string
+ args = []
+ for arg in decl.arguments:
+ args.append(arg.type.decl_string)
+ return [retval, args]
+
def visit_member_function( self ):
self.print_decl_header()
self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
@@ -113,6 +116,9 @@
def visit_constructor( self ):
self.print_decl_header()
+ self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
+ + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
+
if self.__print_details:
self.writer( ' ' * ( self.level + 1 ) * self.INDENT_SIZE
+ 'copy constructor: ' + str(self.__inst.is_copy_constructor)
@@ -123,15 +129,23 @@
def visit_member_operator( self ):
self.print_decl_header()
+ self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
+ + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
def visit_casting_operator( self ):
self.print_decl_header()
+ self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
+ + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
def visit_free_function( self ):
self.print_decl_header()
+ self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
+ + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
def visit_free_operator( self ):
self.print_decl_header()
+ self.writer( ' ' * (self.level+1) * self.INDENT_SIZE
+ + "Signature: " + str( self.__get_method_signature() ) + os.linesep )
def visit_class_declaration(self ):
self.print_decl_header()
@@ -148,7 +162,7 @@
byte_align = 'align: %d'%(self.__inst.byte_align)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
except NotImplementedError:
- self.writer( ' ' * curr_level * self.INDENT_SIZE + "not implemented".ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ) + os.linesep )
if self.__inst.aliases:
aliases = map( lambda typedef: typedef.name, self.__inst.aliases )
@@ -219,7 +233,7 @@
byte_align = 'align: %d'%(self.__inst.type.byte_align)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
except NotImplementedError:
- self.writer( ' ' * curr_level * self.INDENT_SIZE + "not implemented".ljust( self.JUSTIFY ) + os.linesep )
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + "align: not implemented".ljust( self.JUSTIFY ) + os.linesep )
byte_offset = 'offset: %d'%(self.__inst.byte_offset)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_offset + os.linesep)
Modified: pygccxml_dev/pygccxml/msvc/pdb/enums.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-05-08 20:05:35 UTC (rev 1318)
+++ pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-05-11 20:23:01 UTC (rev 1319)
@@ -45,3 +45,16 @@
nsRegularExpression = nsfRegularExpression | nsfCaseSensitive
nsCaseInRegularExpression = nsfRegularExpression | nsfCaseInsensitive
+
+class DataKind( utils.enum ):
+ DataIsUnknown = 0
+ DataIsLocal = 1
+ DataIsStaticLocal = 2
+ DataIsParam = 3
+ DataIsObjectPtr = 4
+ DataIsFileStatic = 5
+ DataIsGlobal = 6
+ DataIsMember = 7
+ DataIsStaticMember = 8
+ DataIsConstant = 9
+
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-08 20:05:35 UTC (rev 1318)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-11 20:23:01 UTC (rev 1319)
@@ -1,4 +1,5 @@
import os
+import re
import pdb
import sys
import ctypes
@@ -502,23 +503,62 @@
self.__update_decls_tree( function_decl )
self.logger.info( 'building function objects(%d) - done', functions_count )
+ def __guess_operator_type( self, smbl, operator_type ):
+ #assumption: the code deals with correct code
+ if not smbl.uname.startswith( 'operator' ) or smbl.uname == 'operator':
+ return None
+ oper_smbls = ('!', ' ', '*', '%', '&', '(', '+', '-', ',', '/', '|', '~', '[', '^', '=', '<')
+ if smbl.uname[ len( 'operator' ) ] not in oper_smbls:
+ return None
+ if smbl.uname[ len( 'operator' ) ] == ' ' \
+ and smbl.uname not in ['operator new', 'operator delete']:
+ #we have casting operator
+ return declarations.casting_operator_t()
+ if isinstance( operator_type, declarations.member_function_type_t ):
+ return declarations.member_operator_t()
+ else:
+ return declarations.free_operator_t()
+
+ def __guess_constructor( self, smbl, calldef_type ):
+ tmpls = declarations.templates
+ class_ = declarations.remove_declarated( calldef_type.class_inst )
+ if class_.name == smbl.uname \
+ or ( tmpls.is_instantiation( class_.name )
+ and tmpls.name( class_.name ) == smbl.uname ):
+ calldef_type.return_type = None
+ return declarations.constructor_t()
+
def __create_calldef( self, smbl ):
self.logger.debug( 'creating calldef "%s"', smbl.uname )
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 ):
- decl = declarations.member_function_t()
+ if smbl.uname.startswith( '~' ):
+ decl = declarations.destructor_t()
+ if not decl: #may be operator
+ decl = self.__guess_operator_type(smbl, calldef_type)
+ if not decl: #may be constructor
+ decl = self.__guess_constructor( smbl, calldef_type )
+ if not decl:
+ decl = declarations.member_function_t()
else:
- decl = declarations.free_function_t()
+ decl = self.__guess_operator_type(smbl, calldef_type)
+ if not decl:
+ decl = declarations.free_function_t()
decl.name = smbl.uname
decl.arguments = map( lambda t: declarations.argument_t( type=t )
, calldef_type.arguments_types )
+
+ args_smbls = map( as_symbol, smbl.findChildren( msdia.SymTagData, None, 0 ) )
+ args_smbls = filter( lambda smbl: smbl.dataKind == enums.DataKind.DataIsParam, args_smbls )
+
+ for index, arg_smbl in enumerate( args_smbls ):
+ arg_decl = decl.arguments[index]
+ arg_decl.name = arg_smbl.name
+ arg_decl.default_value = arg_smbl.value
decl.return_type = calldef_type.return_type
- #~ args_smbls = smbl.findChildren( msdia.SymTagFunctionArgType, None, 0 )
- #~ args = map( create_arg, itertools.imap(as_symbol, args_smbls) )
- #~ if 'some_function' in smbl.name:
- #~ pdb.set_trace()
self.__update_decl( decl, smbl )
self.logger.debug( 'creating calldef "%s" - done', smbl.uname )
return decl
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-05-08 20:05:42
|
Revision: 1318
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1318&view=rev
Author: roman_yakovenko
Date: 2008-05-08 13:05:35 -0700 (Thu, 08 May 2008)
Log Message:
-----------
fixing covariant returns bug
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/function_traits.py
pygccxml_dev/unittests/data/core_cache.hpp
pygccxml_dev/unittests/test_all.py
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pygccxml_dev/unittests/data/covariant_returns.hpp
pygccxml_dev/unittests/function_traits_tester.py
pyplusplus_dev/unittests/bug_covariant_returns_tester.py
pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp
Modified: pygccxml_dev/pygccxml/declarations/function_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/function_traits.py 2008-05-04 20:45:00 UTC (rev 1317)
+++ pygccxml_dev/pygccxml/declarations/function_traits.py 2008-05-08 20:05:35 UTC (rev 1318)
@@ -9,7 +9,59 @@
import calldef
import type_traits
+import class_declaration
+def is_same_return_type( f1, f2 ):
+ #covariant returns
+ #The return type of an overriding function shall be either identical to the
+ #return type of the overridden function or covariant with the classes of the
+ #functions. If a function D::f overrides a function B::f, the return types
+ #of the functions are covariant if they satisfy the following criteria:
+
+ #* both are pointers to classes or references to classes
+ #* the class in the return type of B::f is the same class as the class in
+ # the return type of D::f or, is an unambiguous direct or indirect base
+ # class of the class in the return type of D::f and is accessible in D
+ #* both pointers or references have the same cv-qualification and the class
+ # type in the return type of D::f has the same cv-qualification as or less
+ # cv-qualification than the class type in the return type of B::f.
+
+ if not f1.__class__ is f2.__class__:
+ return False #2 different calldef types
+ if not isinstance( f1, calldef.member_calldef_t ):
+ #for free functions we compare return types as usual
+ return type_traits.is_same( f1.return_type, f2.return_type)
+ if f1.virtuality == calldef.VIRTUALITY_TYPES.NOT_VIRTUAL \
+ or f2.virtuality == calldef.VIRTUALITY_TYPES.NOT_VIRTUAL:
+ #for non-virtual member functions we compare types as usual
+ return type_traits.is_same( f1.return_type, f2.return_type)
+ rt1 = f1.return_type
+ rt2 = f2.return_type
+ if type_traits.is_pointer( rt1 ) and type_traits.is_pointer( rt2 ):
+ rt1 = type_traits.remove_pointer( rt1 )
+ rt2 = type_traits.remove_pointer( rt2 )
+ elif type_traits.is_reference( rt1 ) and type_traits.is_reference( rt2 ):
+ rt1 = type_traits.remove_reference( rt1 )
+ rt2 = type_traits.remove_reference( rt2 )
+ else:
+ return type_traits.is_same( f1.return_type, f2.return_type)
+ if ( type_traits.is_const( rt1 ) and type_traits.is_const( rt2 ) ) \
+ or ( False == type_traits.is_const( rt1 ) and False == type_traits.is_const( rt2 ) ):
+ rt1 = type_traits.remove_const( rt1 )
+ rt2 = type_traits.remove_const( rt2 )
+ else:
+ return False
+ if not type_traits.is_class( rt1 ) or not type_traits.is_class( rt2 ):
+ return type_traits.is_same( rt1, rt2 )
+ c1 = type_traits.class_traits.get_declaration( rt1 )
+ c2 = type_traits.class_traits.get_declaration( rt2 )
+ if c1.class_type == class_declaration.CLASS_TYPES.UNION \
+ or c2.class_type == class_declaration.CLASS_TYPES.UNION:
+ return type_traits.is_same( rt1, rt2 )
+ return type_traits.is_base_and_derived( c1, c2 ) \
+ or type_traits.is_base_and_derived( c2, c1 )
+
+
def is_same_function( f1, f2 ):
"""returns true if f1 and f2 is same function
@@ -25,7 +77,7 @@
return False
if f1.name != f2.name:
return False
- if not type_traits.is_same( f1.return_type, f2.return_type):
+ if not is_same_return_type( f1, f2 ):
return False
if len( f1.arguments ) != len(f2.arguments):
return False
Modified: pygccxml_dev/unittests/data/core_cache.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_cache.hpp 2008-05-04 20:45:00 UTC (rev 1317)
+++ pygccxml_dev/unittests/data/core_cache.hpp 2008-05-08 20:05:35 UTC (rev 1318)
@@ -22,4 +22,4 @@
#endif//__core_cache_hpp__
-//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
+//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
Added: pygccxml_dev/unittests/data/covariant_returns.hpp
===================================================================
--- pygccxml_dev/unittests/data/covariant_returns.hpp (rev 0)
+++ pygccxml_dev/unittests/data/covariant_returns.hpp 2008-05-08 20:05:35 UTC (rev 1318)
@@ -0,0 +1,36 @@
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __bug_virtual_functions_overload_to_be_exported_hpp__
+#define __bug_virtual_functions_overload_to_be_exported_hpp__
+
+struct data_t {
+ int i;
+};
+
+struct more_data_t : public data_t{
+};
+
+struct algorithm_t{
+ algorithm_t(){};
+ virtual data_t* f(){
+ data_t* d = new data_t();
+ d->i = 0;
+ return d;
+ }
+};
+
+class better_algorithm_t : public algorithm_t{
+public:
+ better_algorithm_t(){};
+ virtual more_data_t* f(){
+ more_data_t* d = new more_data_t();
+ d->i = 1;
+ return d;
+ }
+
+};
+
+#endif//__bug_virtual_functions_overload_to_be_exported_hpp__
Added: pygccxml_dev/unittests/function_traits_tester.py
===================================================================
--- pygccxml_dev/unittests/function_traits_tester.py (rev 0)
+++ pygccxml_dev/unittests/function_traits_tester.py 2008-05-08 20:05:35 UTC (rev 1318)
@@ -0,0 +1,46 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import unittest
+import autoconfig
+import parser_test_case
+
+from pygccxml import utils
+from pygccxml import parser
+from pygccxml import declarations
+
+class tester_t( parser_test_case.parser_test_case_t ):
+
+ global_ns = None
+
+ def __init__(self, *args ):
+ parser_test_case.parser_test_case_t.__init__( self, *args )
+ self.header = 'covariant_returns.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_is_same_function( self ):
+ d = self.global_ns.class_( 'better_algorithm_t' )
+ b = self.global_ns.class_( 'algorithm_t' )
+
+ df = d.mem_fun( 'f' )
+ bf = b.mem_fun( 'f' )
+
+ self.failUnless( id(df) != id(bf) and declarations.is_same_function( df, bf ) )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pygccxml_dev/unittests/test_all.py
===================================================================
--- pygccxml_dev/unittests/test_all.py 2008-05-04 20:45:00 UTC (rev 1317)
+++ pygccxml_dev/unittests/test_all.py 2008-05-08 20:05:35 UTC (rev 1318)
@@ -49,6 +49,7 @@
import type_as_exception_bug_tester
import copy_constructor_tester
import plain_c_tester
+import function_traits_tester
testers = [
decl_string_tester
@@ -94,6 +95,7 @@
, type_as_exception_bug_tester
, copy_constructor_tester
, plain_c_tester
+ , function_traits_tester
]
def create_suite():
Added: pyplusplus_dev/unittests/bug_covariant_returns_tester.py
===================================================================
--- pyplusplus_dev/unittests/bug_covariant_returns_tester.py (rev 0)
+++ pyplusplus_dev/unittests/bug_covariant_returns_tester.py 2008-05-08 20:05:35 UTC (rev 1318)
@@ -0,0 +1,37 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import os
+import sys
+import unittest
+import fundamental_tester_base
+from pyplusplus import code_creators
+from pyplusplus.module_builder.call_policies import *
+
+class tester_t(fundamental_tester_base.fundamental_tester_base_t):
+ EXTENSION_NAME = 'bug_covariant_returns'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def customize(self, mb ):
+ mb.mem_funs( 'f' ).call_policies = return_value_policy(manage_new_object)
+
+ def run_tests( self, module):
+ pass
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Added: pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/bug_covariant_returns_to_be_exported.hpp 2008-05-08 20:05:35 UTC (rev 1318)
@@ -0,0 +1,36 @@
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __bug_virtual_functions_overload_to_be_exported_hpp__
+#define __bug_virtual_functions_overload_to_be_exported_hpp__
+
+struct data_t {
+ int i;
+};
+
+struct more_data_t : public data_t{
+};
+
+struct algorithm_t{
+ algorithm_t(){};
+ virtual data_t* f(){
+ data_t* d = new data_t();
+ d->i = 0;
+ return d;
+ }
+};
+
+class better_algorithm_t : public algorithm_t{
+public:
+ better_algorithm_t(){};
+ virtual more_data_t* f(){
+ more_data_t* d = new more_data_t();
+ d->i = 1;
+ return d;
+ }
+
+};
+
+#endif//__bug_virtual_functions_overload_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2008-05-04 20:45:00 UTC (rev 1317)
+++ pyplusplus_dev/unittests/test_all.py 2008-05-08 20:05:35 UTC (rev 1318)
@@ -103,6 +103,7 @@
import ft_inout_tester
import split_module_indexing_suite_bug_tester
import inner_tmpl_class_tester
+import bug_covariant_returns_tester
testers = [
algorithms_tester
@@ -193,6 +194,7 @@
, override_bug_tester
, split_module_indexing_suite_bug_tester
, inner_tmpl_class_tester
+ , bug_covariant_returns_tester
]
class module_runner_t( object ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-05-04 20:44:54
|
Revision: 1317
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1317&view=rev
Author: roman_yakovenko
Date: 2008-05-04 13:45:00 -0700 (Sun, 04 May 2008)
Log Message:
-----------
adding initial support for function types
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/core_types.hpp
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-30 21:01:30 UTC (rev 1316)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-05-04 20:45:00 UTC (rev 1317)
@@ -313,6 +313,7 @@
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 )
#join unnamed namespaces
@@ -493,6 +494,35 @@
self.logger.debug( 'creating typedef "%s" - done', smbl.uname )
return decl
+ def __load_calldefs( self ):
+ 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() ) ):
+ function_decl = self.__create_calldef(function_smbl)
+ self.__update_decls_tree( function_decl )
+ self.logger.info( 'building function objects(%d) - done', functions_count )
+
+ def __create_calldef( self, smbl ):
+ self.logger.debug( 'creating calldef "%s"', smbl.uname )
+ name_splitter = impl_details.get_name_splitter( smbl.uname )
+ calldef_type = self.create_type( smbl.type ) #what does happen with constructor?
+ if isinstance( calldef_type, declarations.member_function_type_t ):
+ decl = declarations.member_function_t()
+ else:
+ decl = declarations.free_function_t()
+ decl.name = smbl.uname
+ decl.arguments = map( lambda t: declarations.argument_t( type=t )
+ , calldef_type.arguments_types )
+ decl.return_type = calldef_type.return_type
+
+ #~ args_smbls = smbl.findChildren( msdia.SymTagFunctionArgType, None, 0 )
+ #~ args = map( create_arg, itertools.imap(as_symbol, args_smbls) )
+ #~ if 'some_function' in smbl.name:
+ #~ pdb.set_trace()
+ self.__update_decl( decl, smbl )
+ self.logger.debug( 'creating calldef "%s" - done', smbl.uname )
+ return decl
+
def __create_function_type( self, smbl ):
return_type = self.create_type( smbl.type )
args_smbls = smbl.findChildren( msdia.SymTagFunctionArgType, None, 0 )
@@ -501,7 +531,7 @@
try:
class_ = self.create_type( smbl.objectPointerType )
class_ = declarations.base_type( class_ )
- pdb.set_trace()
+ #~ 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/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-04-30 21:01:30 UTC (rev 1316)
+++ pygccxml_dev/unittests/core_tester.py 2008-05-04 20:45:00 UTC (rev 1317)
@@ -253,9 +253,13 @@
, "first argument of function of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \
%( 'double_t', function_type.arguments_types[0].__class__.__name__ ) )
- self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
+ if self.global_ns.compiler != compilers.MSVC_PDB_9:
+ self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
def test_member_variable_type(self):
+ if self.global_ns.compiler == compilers.MSVC_PDB_9:
+ return
+
mv = self.global_ns.decl( decl_type=typedef_t, name='member_variable_ptr_t')
self._test_type_composition( mv.type, pointer_t, member_variable_type_t )
Modified: pygccxml_dev/unittests/data/core_types.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_types.hpp 2008-04-30 21:01:30 UTC (rev 1316)
+++ pygccxml_dev/unittests/data/core_types.hpp 2008-05-04 20:45:00 UTC (rev 1317)
@@ -60,6 +60,8 @@
typedef int (members_pointers_t::*member_variable_ptr_t);
+member_variable_ptr_t member_variable_ptr_ = 0;
+
} }
#endif//__core_types_hpp__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-30 21:01:46
|
Revision: 1316
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1316&view=rev
Author: roman_yakovenko
Date: 2008-04-30 14:01:30 -0700 (Wed, 30 Apr 2008)
Log Message:
-----------
adding support for function types
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-28 15:22:30 UTC (rev 1315)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-30 21:01:30 UTC (rev 1316)
@@ -267,9 +267,14 @@
def __clear_symbols(self):
self.logger.info( 'clearing symbols' )
to_be_deleted = []
+ useless_tags = (
+ msdia.SymTagAnnotation
+ , msdia.SymTagPublicSymbol
+ , msdia.SymTagBlock
+ )
for smbl_id, smbl in self.symbols.iteritems():
- if ( smbl.symTag == msdia.SymTagData and not self.__is_my_var( smbl ) ) \
- or smbl.symTag in ( msdia.SymTagAnnotation, msdia.SymTagPublicSymbol ):
+ 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 )
@@ -301,7 +306,7 @@
def read(self):
- #self.__clear_symbols()
+ self.__clear_symbols()
self.__load_nss()
self.__load_classes()
self.__load_base_classes()
@@ -482,14 +487,28 @@
def __create_typedef( self, smbl ):
self.logger.debug( 'creating typedef "%s"', smbl.uname )
name_splitter = impl_details.get_name_splitter( smbl.uname )
- #~ if name_splitter.name == 'typedef_pointer_int':
- #~ pdb.set_trace()
decl = declarations.typedef_t( name_splitter.name
, self.create_type( smbl.type ) )
self.__update_decl( decl, smbl )
self.logger.debug( 'creating typedef "%s" - done', smbl.uname )
return decl
+ def __create_function_type( self, smbl ):
+ return_type = self.create_type( smbl.type )
+ args_smbls = smbl.findChildren( msdia.SymTagFunctionArgType, None, 0 )
+ args_types = map( self.create_type, itertools.imap(as_symbol, args_smbls) )
+ if smbl.objectPointerType:
+ 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.' )
+ return declarations.unknown_t()
+ else:
+ return declarations.free_function_type_t( return_type, args_types )
+
def create_type( self, smbl ):
#http://msdn2.microsoft.com/en-us/library/s3f49ktz(VS.80).aspx
if smbl.symIndexId in self.__types_cache:
@@ -568,6 +587,10 @@
my_type = declarations.declarated_t( decl )
else:
my_type = declarations.unknown_t()
+ elif msdia.SymTagFunctionArgType == smbl.symTag:
+ my_type = self.create_type( smbl.type )
+ elif msdia.SymTagFunctionType == smbl.symTag:
+ my_type = self.__create_function_type( smbl )
else:
my_type = declarations.unknown_t()
try:
@@ -575,7 +598,12 @@
except AttributeError:
pass
if smbl.constType:
- my_type = declarations.const_t( my_type )
+ if isinstance( my_type, declarations.member_function_type_t ):
+ my_type.has_const = True
+ else:
+ if not isinstance( my_type, declarations.const_t ):
+ my_type = declarations.const_t( my_type )
if smbl.volatileType:
- my_type = declarations.volatile_t( my_type )
+ if not isinstance( my_type, declarations.volatile_t ):
+ my_type = declarations.volatile_t( my_type )
return my_type
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-04-28 15:22:30 UTC (rev 1315)
+++ pygccxml_dev/unittests/core_tester.py 2008-04-30 21:01:30 UTC (rev 1316)
@@ -243,7 +243,6 @@
, "member function type class should be '%s' instead of '%s'" \
% ( members_pointers.decl_string, function_type.class_inst.decl_string ) )
- self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
self.failUnless( isinstance( function_type.return_type, int_t )
, "return function type of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \
%( 'int_t', function_type.return_type.__class__.__name__ ) )
@@ -254,6 +253,8 @@
, "first argument of function of typedef 'member_function_ptr_t' should be '%s' instead of '%s' " \
%( 'double_t', function_type.arguments_types[0].__class__.__name__ ) )
+ self.failUnless( function_type.has_const, " 'member_function_ptr_t' should be const function." )
+
def test_member_variable_type(self):
mv = self.global_ns.decl( decl_type=typedef_t, name='member_variable_ptr_t')
self._test_type_composition( mv.type, pointer_t, member_variable_type_t )
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-28 15:22:30 UTC (rev 1315)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-30 21:01:30 UTC (rev 1316)
@@ -1,3 +1,4 @@
+#include <string>
#include "abstract_classes.hpp"
#include "attributes.hpp"
#include "bit_fields.hpp"
@@ -87,6 +88,11 @@
core::types::member_variable_ptr_t member_variable_ptr_ = 0;
core::types::typedef_EFavoriteDrinks typedef_EFavoriteDrinks_;
+ std::wstring hello_world;
+
+ core::types::function_ptr function_ptr_ = 0;
+ core::types::member_function_ptr_t member_function_ptr_ = 0;
+
}
void use_core_ns_join_3(){
Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-28 15:22:30 UTC (rev 1315)
+++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-30 21:01:30 UTC (rev 1316)
@@ -22,6 +22,7 @@
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
+ WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
@@ -69,6 +70,7 @@
GenerateDebugInformation="true"
GenerateMapFile="true"
MapExports="true"
+ Profile="true"
/>
<Tool
Name="VCALinkTool"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-28 15:22:47
|
Revision: 1315
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1315&view=rev
Author: roman_yakovenko
Date: 2008-04-28 08:22:30 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
adding new test case - inner template class
Modified Paths:
--------------
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/data/inner_tmpl_class_to_be_exported.hpp
pyplusplus_dev/unittests/inner_tmpl_class_tester.py
Added: pyplusplus_dev/unittests/data/inner_tmpl_class_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/inner_tmpl_class_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/inner_tmpl_class_to_be_exported.hpp 2008-04-28 15:22:30 UTC (rev 1315)
@@ -0,0 +1,28 @@
+// Copyright 2004 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __inner_tmpl_class_to_be_exported_hpp__
+#define __inner_tmpl_class_to_be_exported_hpp__
+
+#include <string>
+
+namespace inner_tmpl_class{
+
+struct Outer {
+ template <typename T>
+ struct Inner{
+ Inner(T t_) : t( t_ )
+ {}
+
+ T t;
+ };
+
+ typedef Inner<int> Inner_int;
+ Inner_int f() { return Inner_int(23); }
+};
+
+}
+
+#endif//__inner_tmpl_class_to_be_exported_hpp__
Added: pyplusplus_dev/unittests/inner_tmpl_class_tester.py
===================================================================
--- pyplusplus_dev/unittests/inner_tmpl_class_tester.py (rev 0)
+++ pyplusplus_dev/unittests/inner_tmpl_class_tester.py 2008-04-28 15:22:30 UTC (rev 1315)
@@ -0,0 +1,35 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import os
+import sys
+import unittest
+import fundamental_tester_base
+from pyplusplus import code_creators
+
+class tester_t(fundamental_tester_base.fundamental_tester_base_t):
+ EXTENSION_NAME = 'inner_tmpl_class'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def run_tests( self, module):
+ o = module.Outer()
+ i = o.f()
+ self.failUnless( i.t == 23 )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2008-04-27 20:03:45 UTC (rev 1314)
+++ pyplusplus_dev/unittests/test_all.py 2008-04-28 15:22:30 UTC (rev 1315)
@@ -102,6 +102,7 @@
import balanced_files_tester
import ft_inout_tester
import split_module_indexing_suite_bug_tester
+import inner_tmpl_class_tester
testers = [
algorithms_tester
@@ -191,6 +192,7 @@
, deepcopy_tester
, override_bug_tester
, split_module_indexing_suite_bug_tester
+ , inner_tmpl_class_tester
]
class module_runner_t( object ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-27 20:03:39
|
Revision: 1314
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1314&view=rev
Author: roman_yakovenko
Date: 2008-04-27 13:03:45 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
few small changes in pdb parser
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-23 19:54:42 UTC (rev 1313)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-27 20:03:45 UTC (rev 1314)
@@ -167,6 +167,8 @@
continue #in this case the parent scope is UDT
ns_decl = declarations.namespace_t( name_splitter.name )
ns_decl.compiler = self.COMPILER
+ ns_decl.mangled = ns_decl.name
+ ns_decl.demangled = ns_decl.name
parent_ns.adopt_declaration( ns_decl )
nss[ ns_name ] = ns_decl
self.logger.debug( 'inserting ns "%s" into declarations tree - done', ns_name )
@@ -273,6 +275,31 @@
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 = ''
+ elif decl.name.startswith( '?' ):
+ decl.name = ''
+ elif isinstance( decl, declarations.namespace_t ) and 'anonymous-namespace' in decl.name:
+ decl.name = ''
+ else:
+ pass
+
+ def __join_unnamed_nss( self, ns_parent ):
+ child_nss = ns_parent.namespaces( name='', recursive=False, allow_empty=True )
+ if len(child_nss) > 1:
+ alive_ns = child_nss[0]
+ dead_nss = child_nss[1:]
+ for dead_ns in dead_nss:
+ decls = dead_ns.decls( recursive=False, allow_empty=True )
+ map( dead_ns.remove_declaration, decls )
+ map( alive_ns.adopt_declaration, decls )
+ map( ns_parent.remove_declaration, dead_nss )
+ map( self.__join_unnamed_nss
+ , ns_parent.namespaces( recursive=False, allow_empty=True ) )
+
+
def read(self):
#self.__clear_symbols()
self.__load_nss()
@@ -281,6 +308,9 @@
self.__load_enums()
self.__load_vars()
self.__load_typedefs()
+ map( self.__normalize_name, self.global_ns.decls(recursive=True) )
+ self.__join_unnamed_nss( self.global_ns )
+ #join unnamed namespaces
@property
def dia_global_scope(self):
@@ -460,7 +490,6 @@
self.logger.debug( 'creating typedef "%s" - done', smbl.uname )
return decl
-
def create_type( self, smbl ):
#http://msdn2.microsoft.com/en-us/library/s3f49ktz(VS.80).aspx
if smbl.symIndexId in self.__types_cache:
@@ -479,7 +508,7 @@
if 8 == smbl.length:
my_type = declarations.long_long_int_t()
elif 4 == smbl.length:
- my_type = declarations.long_int_t()
+ my_type = declarations.int_t() #long_int_t
elif 2 == smbl.length:
my_type = declarations.short_int_t()
else:
@@ -506,7 +535,7 @@
elif enums.BasicType.btCurrency == smbl.baseType:
my_type = declarations.unknown_t()
elif enums.BasicType.btDate == smbl.baseType:
- my_type = declarations.unknown_t()
+ my_type = declarations.double_t()
elif enums.BasicType.btVariant == smbl.baseType:
my_type = declarations.unknown_t()
elif enums.BasicType.btComplex == smbl.baseType:
@@ -516,7 +545,7 @@
elif enums.BasicType.btBSTR == smbl.baseType:
my_type = declarations.unknown_t()
elif enums.BasicType.btHresult == smbl.baseType:
- my_type = declarations.unknown_t()
+ my_type = declarations.long_int_t()
else:
my_type = declarations.unknown_t()
elif msdia.SymTagPointerType == smbl.symTag:
@@ -526,11 +555,12 @@
else:
my_type = declarations.pointer_t( base_type )
elif msdia.SymTagArrayType == smbl.symTag:
- bytes = smbl.length
- element_type = self.create_type( smbl.arrayIndexType )
+ element_type = self.create_type( smbl.type )
size = declarations.array_t.SIZE_UNKNOWN
- if bytes and element_type.byte_size:
- size = bytes / element_type.byte_size
+ if smbl.count:
+ size = smbl.count
+ #~ if smbl.length and element_type.byte_size:
+ #~ size = smbl.length / element_type.byte_size
my_type = declarations.array_t( element_type, size )
elif smbl.symTag in ( msdia.SymTagUDT, msdia.SymTagTypedef, msdia.SymTagEnum ):
if smbl.symIndexId in self.__id2decl:
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-04-23 19:54:42 UTC (rev 1313)
+++ pygccxml_dev/unittests/core_tester.py 2008-04-27 20:03:45 UTC (rev 1314)
@@ -84,7 +84,10 @@
def _test_class_membership( self, class_inst, enum_name, access ):
#getting enum through get_members function
- nested_enum1 = class_inst.enum( name=enum_name, function=access_type_matcher_t( access ) )
+ if class_inst.compiler == compilers.MSVC_PDB_9:
+ nested_enum1 = class_inst.enum( name=enum_name )
+ else:
+ nested_enum1 = class_inst.enum( name=enum_name, function=access_type_matcher_t( access ) )
#getting enum through declarations property
nested_enum2 = class_inst.enum( enum_name )
@@ -180,7 +183,7 @@
if self.global_ns.compiler != compilers.MSVC_PDB_9:
self.failIf( errors, pprint.pformat( errors ) )
else:
- self.failUnless( 6 == len( errors ), pprint.pformat( errors ) )
+ self.failUnless( 5 == len( errors ), pprint.pformat( errors ) )
def test_compound_types(self):
typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_const_int' )
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-23 19:54:42 UTC (rev 1313)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-27 20:03:45 UTC (rev 1314)
@@ -83,24 +83,36 @@
core::types::typedef_float typedef_float_;
core::types::typedef_double typedef_double_;
core::types::typedef_long_double typedef_long_double_;
-
+ core::types::typedef_volatile_int typedef_volatile_int_;
core::types::member_variable_ptr_t member_variable_ptr_ = 0;
+ core::types::typedef_EFavoriteDrinks typedef_EFavoriteDrinks_;
}
void use_core_ns_join_3(){
- E31 e31_;
- ns::E32 e32_;
- ns::ns32::E33 e33_;
- ns::E34 e34_;
-}
+ E31 e31_;
+ ns::E32 e32_;
+ ns::ns32::E33 e33_;
+ ns::E34 e34_;
+
+ E11 e11_;
+ E21 e21_;
+ ns::E12 e12_;
+ ns::E22 e22_;
+ ns::ns12::E13 e13_;
+ ns::ns22::E23 e23_;
+}
+
void use_coremembership(){
- namespace cm = core::membership;
- int i = cm::enums_ns::WITHIN_NS_UNNAMED_ENUM;
- i += cm::enums_ns::WITHIN_NS;
- i += cm::WITHIN_UNNAMED_NS_UNNAMED_ENUM;
- i += cm::WITHIN_UNNAMED_NS;
- cm::class_for_nested_enums_t class_for_nested_enums_;
-
+ namespace cm = core::membership;
+ int i = cm::enums_ns::WITHIN_NS_UNNAMED_ENUM;
+ i += cm::enums_ns::WITHIN_NS;
+ i += cm::WITHIN_UNNAMED_NS_UNNAMED_ENUM;
+ i += cm::WITHIN_UNNAMED_NS;
+ cm::class_for_nested_enums_t class_for_nested_enums_;
+
+ i += ::GLOBAL_NS_UNNAMED_ENUM;
+ EGlobal eglobal_;
+
}
Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-23 19:54:42 UTC (rev 1313)
+++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-27 20:03:45 UTC (rev 1314)
@@ -78,7 +78,7 @@
/>
<Tool
Name="VCXDCMakeTool"
- ValidateIntelliSense="false"
+ ValidateIntelliSense="true"
OutputDocumentFile=""
/>
<Tool
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-23 19:54:41
|
Revision: 1313
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1313&view=rev
Author: roman_yakovenko
Date: 2008-04-23 12:54:42 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
few changes related to pdb
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/class_declaration.py
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/msvc_build/all.cpp
Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-04-23 05:56:08 UTC (rev 1312)
+++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-04-23 19:54:42 UTC (rev 1313)
@@ -49,7 +49,7 @@
class hierarchy_info_t( object ):
"""describes class relationship"""
- def __init__(self, related_class=None, access=None, is_virtual=None ):
+ def __init__(self, related_class=None, access=None, is_virtual=False ):
"""creates class that contains partial information about class relationship"""
if related_class:
assert( isinstance( related_class, class_t ) )
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-23 05:56:08 UTC (rev 1312)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-23 19:54:42 UTC (rev 1313)
@@ -452,7 +452,7 @@
def __create_typedef( self, smbl ):
self.logger.debug( 'creating typedef "%s"', smbl.uname )
name_splitter = impl_details.get_name_splitter( smbl.uname )
- #~ if decl.name == 'initialized':
+ #~ if name_splitter.name == 'typedef_pointer_int':
#~ pdb.set_trace()
decl = declarations.typedef_t( name_splitter.name
, self.create_type( smbl.type ) )
@@ -462,6 +462,7 @@
def create_type( self, smbl ):
+ #http://msdn2.microsoft.com/en-us/library/s3f49ktz(VS.80).aspx
if smbl.symIndexId in self.__types_cache:
return self.__types_cache[smbl.symIndexId]
my_type = None
@@ -474,20 +475,34 @@
my_type = declarations.char_t()
elif enums.BasicType.btWChar == smbl.baseType:
my_type = declarations.wchar_t()
- elif enums.BasicType.btInt == smbl.baseType:
- my_type = declarations.int_t()
+ elif smbl.baseType in ( enums.BasicType.btInt, enums.BasicType.btLong ):
+ if 8 == smbl.length:
+ my_type = declarations.long_long_int_t()
+ elif 4 == smbl.length:
+ my_type = declarations.long_int_t()
+ elif 2 == smbl.length:
+ my_type = declarations.short_int_t()
+ else:
+ my_type = declarations.int_t()
elif enums.BasicType.btUInt == smbl.baseType:
- my_type = declarations.unsigned_int_t()
+ if 2 == smbl.length:
+ my_type = declarations.short_unsigned_int_t()
+ else:
+ my_type = declarations.unsigned_int_t()
elif enums.BasicType.btFloat == smbl.baseType:
- my_type = declarations.float_t()
+ if 8 == smbl.length:
+ my_type = declarations.double_t()
+ else:
+ my_type = declarations.float_t()
elif enums.BasicType.btBCD == smbl.baseType:
my_type = declarations.unknown_t()
elif enums.BasicType.btBool == smbl.baseType:
my_type = declarations.bool_t()
- elif enums.BasicType.btLong == smbl.baseType:
- my_type = declarations.long_int_t()
elif enums.BasicType.btULong == smbl.baseType:
- my_type = declarations.long_unsigned_int_t()
+ if 8 == smbl.length:
+ my_type = declarations.long_long_unsigned_int_t()
+ else:
+ my_type = declarations.long_unsigned_int_t()
elif enums.BasicType.btCurrency == smbl.baseType:
my_type = declarations.unknown_t()
elif enums.BasicType.btDate == smbl.baseType:
@@ -504,6 +519,12 @@
my_type = declarations.unknown_t()
else:
my_type = declarations.unknown_t()
+ elif msdia.SymTagPointerType == smbl.symTag:
+ base_type = self.create_type( smbl.type )
+ if smbl.reference:
+ my_type = declarations.reference_t( base_type )
+ else:
+ my_type = declarations.pointer_t( base_type )
elif msdia.SymTagArrayType == smbl.symTag:
bytes = smbl.length
element_type = self.create_type( smbl.arrayIndexType )
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-04-23 05:56:08 UTC (rev 1312)
+++ pygccxml_dev/unittests/autoconfig.py 2008-04-23 19:54:42 UTC (rev 1313)
@@ -59,7 +59,6 @@
def get_pdb_global_ns():
- return None
return cxx_parsers_cfg.get_pdb_loader().global_ns
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-04-23 05:56:08 UTC (rev 1312)
+++ pygccxml_dev/unittests/core_tester.py 2008-04-23 19:54:42 UTC (rev 1313)
@@ -5,6 +5,7 @@
import os
import sys
+import pprint
import unittest
import tempfile
import autoconfig
@@ -114,9 +115,15 @@
self.failUnless( std.mangled, 'mangled name of std namespace should be different from None' )
def _test_is_based_and_derived(self, base, derived, access):
- self.failUnless( hierarchy_info_t( derived, access ) in base.derived
+ dhi_v = hierarchy_info_t( derived, access, True )
+ dhi_not_v = hierarchy_info_t( derived, access, False )
+ self.failUnless( dhi_v in base.derived or dhi_not_v in base.derived
, "base class '%s' doesn't has derived class '%s'" %( base.name, derived.name ) )
- self.failUnless( hierarchy_info_t( base, access ) in derived.bases
+
+ bhi_v = hierarchy_info_t( base, access, True )
+ bhi_not_v = hierarchy_info_t( base, access, False )
+
+ self.failUnless( bhi_v in derived.bases or bhi_not_v in derived.bases
, "derive class '%s' doesn't has base class '%s'" %( derived.name, base.name ) )
def test_class_hierarchy(self):
@@ -158,6 +165,7 @@
def test_fundamental_types(self):
#check whether all build in types could be constructed
+ errors = []
for fundamental_type_name, fundamental_type in FUNDAMENTAL_TYPES.iteritems():
if 'complex' in fundamental_type_name:
continue #I check this in an other tester
@@ -166,9 +174,13 @@
typedef_name = 'typedef_' + fundamental_type_name.replace( ' ', '_' )
typedef = self.global_ns.decl( decl_type=typedef_t, name=typedef_name )
self.failUnless( typedef, "unable to find typedef to build-in type '%s'" % fundamental_type_name )
- self.failUnless( typedef.type.decl_string == fundamental_type.decl_string
- , "there is a difference between typedef base type name('%s') and expected one('%s')" \
+ if typedef.type.decl_string != fundamental_type.decl_string:
+ errors.append( "there is a difference between typedef base type name('%s') and expected one('%s')"
% (typedef.type.decl_string, fundamental_type.decl_string) )
+ if self.global_ns.compiler != compilers.MSVC_PDB_9:
+ self.failIf( errors, pprint.pformat( errors ) )
+ else:
+ self.failUnless( 6 == len( errors ), pprint.pformat( errors ) )
def test_compound_types(self):
typedef_inst = self.global_ns.decl( decl_type=typedef_t, name='typedef_const_int' )
@@ -359,10 +371,10 @@
def create_suite():
suite = unittest.TestSuite()
- suite.addTest( unittest.makeSuite(core_all_at_once_t))
- 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))
+ #~ suite.addTest( unittest.makeSuite(core_all_at_once_t))
+ #~ 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 sys.platform == 'win32':
suite.addTest( unittest.makeSuite(pdb_based_core_tester_t))
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-23 05:56:08 UTC (rev 1312)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-23 19:54:42 UTC (rev 1313)
@@ -59,4 +59,48 @@
void use_core_types(){
core::types::members_pointers_t mem_ptrs;
core::types::typedef_const_int typedef_const_int_ = 0;
-}
\ No newline at end of file
+ core::types::typedef_pointer_int typedef_pointer_int_ = 0;
+ int i = 0;
+ core::types::typedef_reference_int typedef_reference_int_ = i;
+ unsigned int j = 0;
+ core::types::typedef_const_unsigned_int_const_pointer typedef_const_unsigned_int_const_pointer_ = &j;
+ core::types::typedef_void* typedef_void = 0;
+ core::types::typedef_char typedef_char_;
+ core::types::typedef_signed_char typedef_signed_char_;
+ core::types::typedef_unsigned_char typedef_unsigned_char_;
+ core::types::typedef_wchar_t typedef_wchar_t_;
+ core::types::typedef_short_int typedef_short_int_;
+ core::types::typedef_signed_short_int typedef_signed_short_int_;
+ core::types::typedef_short_unsigned_int typedef_short_unsigned_int_;
+ core::types::typedef_bool typedef_bool_;
+ core::types::typedef_int typedef_int_;
+ core::types::typedef_signed_int typedef_signed_int_;
+ core::types::typedef_unsigned_int typedef_unsigned_int_;
+ core::types::typedef_long_int typedef_long_int_;
+ core::types::typedef_long_unsigned_int typedef_long_unsigned_int_;
+ core::types::typedef_long_long_int typedef_long_long_int_;
+ core::types::typedef_long_long_unsigned_int typedef_long_long_unsigned_int_;
+ core::types::typedef_float typedef_float_;
+ core::types::typedef_double typedef_double_;
+ core::types::typedef_long_double typedef_long_double_;
+
+ core::types::member_variable_ptr_t member_variable_ptr_ = 0;
+
+}
+
+void use_core_ns_join_3(){
+ E31 e31_;
+ ns::E32 e32_;
+ ns::ns32::E33 e33_;
+ ns::E34 e34_;
+}
+
+void use_coremembership(){
+ namespace cm = core::membership;
+ int i = cm::enums_ns::WITHIN_NS_UNNAMED_ENUM;
+ i += cm::enums_ns::WITHIN_NS;
+ i += cm::WITHIN_UNNAMED_NS_UNNAMED_ENUM;
+ i += cm::WITHIN_UNNAMED_NS;
+ cm::class_for_nested_enums_t class_for_nested_enums_;
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-23 05:56:01
|
Revision: 1312
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1312&view=rev
Author: roman_yakovenko
Date: 2008-04-22 22:56:08 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
few fixes to problems caused by pdb parser integration
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/cpptypes.py
pygccxml_dev/pygccxml/msvc/config.py
pygccxml_dev/pygccxml/utils/__init__.py
pygccxml_dev/unittests/autoconfig.py
pygccxml_dev/unittests/core_tester.py
Added Paths:
-----------
pygccxml_dev/pygccxml/utils/fs_utils.py
Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-04-22 19:35:17 UTC (rev 1311)
+++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-04-23 05:56:08 UTC (rev 1312)
@@ -17,6 +17,7 @@
self.cache = algorithms_cache.type_algs_cache_t()
self._byte_size = 0
self._byte_align = 0
+ self.compiler = None
def __str__(self):
res = self.decl_string
Modified: pygccxml_dev/pygccxml/msvc/config.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/config.py 2008-04-22 19:35:17 UTC (rev 1311)
+++ pygccxml_dev/pygccxml/msvc/config.py 2008-04-23 05:56:08 UTC (rev 1312)
@@ -1,6 +1,7 @@
import os
import sys
import comtypes
+from .. import utils
import comtypes.client
import _winreg as win_registry
from distutils import msvccompiler
@@ -20,8 +21,12 @@
def get_msvcr_path( self ):
vss_installed = self.__get_installed_vs_dirs()
- #TODO: better algorithm to find the path
- return os.path.join( vss_installed[0], 'vc', 'redist', 'x86', 'microsoft.vc90.crt', 'MSVCR90.DLL' )
+ for f in utils.files_walker( vss_installed, ["*.dll"], ):
+ f_path, f_name = os.path.split( f.upper() )
+ if f_name.startswith( 'MSVCR' ):
+ return f
+ else:
+ raise RuntimeError( 'Unable to find msvcrXX.dll. Search path is: %s' % vss_installed )
def get_msdia_path( self ):
vss_installed = self.__get_installed_vs_dirs()
Modified: pygccxml_dev/pygccxml/utils/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/utils/__init__.py 2008-04-22 19:35:17 UTC (rev 1311)
+++ pygccxml_dev/pygccxml/utils/__init__.py 2008-04-23 05:56:08 UTC (rev 1312)
@@ -12,6 +12,8 @@
import sys
import logging
import tempfile
+from fs_utils import files_walker
+from fs_utils import directories_walker
def _create_logger_( name ):
"""implementation details"""
@@ -151,4 +153,4 @@
return name
else:
raise RuntimeError( 'Unable to find name for value(%d) in enumeration "%s"'
- % ( enum_numeric_value, cls.__name__ ) )
\ No newline at end of file
+ % ( enum_numeric_value, cls.__name__ ) )
Added: pygccxml_dev/pygccxml/utils/fs_utils.py
===================================================================
--- pygccxml_dev/pygccxml/utils/fs_utils.py (rev 0)
+++ pygccxml_dev/pygccxml/utils/fs_utils.py 2008-04-23 05:56:08 UTC (rev 1312)
@@ -0,0 +1,136 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+import os
+from types import *
+
+##If you want include files that doesn't have extension then use filter like '*.'
+
+def _make_list( argument ):
+ if type(argument) in StringTypes:
+ if argument:
+ return [argument]
+ else:
+ return []
+ elif type(argument) is ListType:
+ return argument
+ else:
+ raise TypeError( 'Argument "%s" must be or list of strings or string.' % argument )
+
+class base_files_iterator:
+ def __init__(self, file_exts, is_include_exts = True):
+ self.__file_exts = _make_list( file_exts )
+ self.__is_include_exts = is_include_exts
+
+ def _is_to_skip(self, file_path):
+ if not self.__file_exts:
+ return 0
+ file_ext = os.path.splitext( file_path )[1]
+ if not file_ext:
+ file_ext = '.' + file_ext
+ file_ext = '*' + file_ext
+ if file_ext.lower() in self.__file_exts:
+ return not self.__is_include_exts
+ else:
+ return self.__is_include_exts
+
+ def _subdirectories_and_files(self, directory_path):
+ files, directories = [], []
+ directory_contents = os.listdir(directory_path)
+ for object_name in directory_contents:
+ object_path = os.path.join(directory_path, object_name)
+ if os.path.isfile( object_path ) and not self._is_to_skip( object_path ):
+ files.append( object_path )
+ elif os.path.isdir( object_path ):
+ directories.append( object_path )
+ else:
+ pass
+ return directories, files
+
+ def __iter__(self):
+ raise NotImplementedError
+
+ def next(self):
+ raise NotImplementedError
+
+ def restart(self):
+ raise NotImplementedError
+
+class files_walker(base_files_iterator):
+ def __init__(self, directories, file_ext_filter = '', is_include_filter = True, is_recursive = True):
+ base_files_iterator.__init__(self, file_ext_filter, is_include_filter)
+ self.__directories = _make_list( directories )
+ self.__is_recursive = is_recursive
+ self.__file_generator = None
+
+ def __walk(self):
+ directories = self.__directories[:]
+ while directories:
+ sub_directories, files = self._subdirectories_and_files( directories.pop(0) )
+ if self.__is_recursive:
+ for directory in sub_directories:
+ directories.append( directory )
+ for file_os in files:
+ yield file_os
+
+ def __iter__(self):
+ self.__file_generator = self.__walk()
+ return self
+
+ def next(self):
+ return self.__file_generator.next()
+
+ def restart(self):
+ self.__file_generator = None
+
+
+class directories_walker:
+ def __init__(self, directories, is_recursive = 1):
+ self.__directories = []
+ for root in _make_list( directories ):
+ self.__directories.extend( self.__sub_directories( root ) )
+ self.__is_recursive = is_recursive
+ self.__directory_generator = None
+
+ def __sub_directories(self, directory_path):
+ sub_directories = []
+ directory_contains = os.listdir(directory_path)
+ for object_in_directory in directory_contains:
+ full_path = os.path.join(directory_path, object_in_directory)
+ if os.path.isdir( full_path ):
+ sub_directories.append( full_path )
+ return sub_directories
+
+ def __walk(self):
+ directories = self.__directories[:]
+ for curr_directory in directories:
+ yield curr_directory
+ if self.__is_recursive:
+ for f in directories_walker( [curr_directory], True ):
+ yield f
+
+ def __iter__(self):
+ self.__directory_generator = self.__walk()
+ return self
+
+ def next(self):
+ return self.__directory_generator.next()
+
+ def restart(self):
+ self.__directory_generator = None
+
+
+if '__main__' == __name__:
+ pass
+ #lFileCount = 0
+ #for file_os in files_iterator( r'C:\Program Files\Microsoft Visual Studio\VC98\Include\stlport', ['*.h', '*.'], True, False):
+ #print file_os
+ #lFileCount += 1
+ #print lFileCount
+
+ #~ for directory in directories_iterator( '/home/roman/language-binding', False ):
+ #~ print directory
+ #~ for directory in directories_iterator( '/home/roman/language-binding', True ):
+ #~ print directory
Modified: pygccxml_dev/unittests/autoconfig.py
===================================================================
--- pygccxml_dev/unittests/autoconfig.py 2008-04-22 19:35:17 UTC (rev 1311)
+++ pygccxml_dev/unittests/autoconfig.py 2008-04-23 05:56:08 UTC (rev 1312)
@@ -59,6 +59,7 @@
def get_pdb_global_ns():
+ return None
return cxx_parsers_cfg.get_pdb_loader().global_ns
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-04-22 19:35:17 UTC (rev 1311)
+++ pygccxml_dev/unittests/core_tester.py 2008-04-23 05:56:08 UTC (rev 1312)
@@ -359,10 +359,10 @@
def create_suite():
suite = unittest.TestSuite()
- #~ suite.addTest( unittest.makeSuite(core_all_at_once_t))
- #~ 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))
+ suite.addTest( unittest.makeSuite(core_all_at_once_t))
+ 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 sys.platform == 'win32':
suite.addTest( unittest.makeSuite(pdb_based_core_tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-22 19:35:19
|
Revision: 1311
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1311&view=rev
Author: roman_yakovenko
Date: 2008-04-22 12:35:17 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
adding new files
Added Paths:
-----------
pygccxml_dev/pygccxml/declarations/compilers.py
pygccxml_dev/pygccxml/msvc/pdb/kb.txt
Added: pygccxml_dev/pygccxml/declarations/compilers.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/compilers.py (rev 0)
+++ pygccxml_dev/pygccxml/declarations/compilers.py 2008-04-22 19:35:17 UTC (rev 1311)
@@ -0,0 +1,19 @@
+# Copyright 2004 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+"""
+contains enumeration of all compilers supported by the project
+"""
+
+GCC_XML_06 = "GCC-XML 0.6"
+GCC_XML_07 = "GCC-XML 0.7"
+GCC_XML_09 = "GCC-XML 0.9"
+GCC_XML_09_BUGGY = "GCC-XML 0.9 BUGGY"
+
+MSVC_PDB_9 = "MSVC PDB 9.0"
+
+def on_missing_functionality( compiler, functionality ):
+ raise NotImplementedError( '"%s" compiler doesn\'t support functionality "%s"'
+ % ( compiler, functionality ))
Added: pygccxml_dev/pygccxml/msvc/pdb/kb.txt
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/kb.txt (rev 0)
+++ pygccxml_dev/pygccxml/msvc/pdb/kb.txt 2008-04-22 19:35:17 UTC (rev 1311)
@@ -0,0 +1,17 @@
+url: http://www.hightechtalks.com/visual-studio-net-debugging/re-using-dia-sdk-find-360868.html
+Q: how to find out member variable offset?
+A (By Oleg):
+1. Assuming that you have IDiaSymbol interface pointer for the class (UDT) symbol,
+use IDiaSymbol::findChildren (with SymTagData as the tag) to lookup the field
+with the given name (or all fields).
+
+2. IDiaSymbol::findChildren will give you IDiaEnumSymbols interface, which you can use
+to retrieve IDiaSymbol for the field(s).
+
+3. Using the field's IDiaSymbol interface, call IDiaSymbol::get_locationType to determine
+the location of the field.
+If the location is LocIsThisRel, use IDiaSymbol::get_offset to obtain the offset.
+If the location is LocIsStatic, use IDiaSymbol::get_addressSection and IDiaSymbol::get_addressOffset,
+or IDiaSymbol::get_relativeVirtualAddress, or IDiaSymbol::get_virtualAddress to obtain
+the address of the static member.
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-21 20:14:13
|
Revision: 1310
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1310&view=rev
Author: roman_yakovenko
Date: 2008-04-21 13:14:17 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
adding another set of changes related to PDB parser
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/class_declaration.py
pygccxml_dev/pygccxml/declarations/cpptypes.py
pygccxml_dev/pygccxml/declarations/decl_printer.py
pygccxml_dev/pygccxml/declarations/enumeration.py
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/pygccxml/parser/scanner.py
pygccxml_dev/unittests/core_tester.py
pygccxml_dev/unittests/data/core_types.hpp
pygccxml_dev/unittests/data/declarations_enums.hpp
pygccxml_dev/unittests/data/declarations_variables.hpp
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
pygccxml_dev/unittests/data/typedefs1.hpp
pygccxml_dev/unittests/declarations_tester.py
pygccxml_dev/unittests/pdb_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -6,6 +6,9 @@
"""
contains classes that describe different C++ declarations
"""
+
+import compilers
+
from dependencies import dependency_info_t
from declaration import location_t
from declaration import declaration_t
@@ -189,7 +192,7 @@
from function_traits import is_same_function
all_container_traits = container_traits.container_traits
-"""tuple of all STD container traits classes"""
+"""tuple of all STD container traits classes"""
sequential_container_traits = \
[
Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -13,6 +13,7 @@
"""
import scopedef
+import compilers
import algorithm
import declaration
import dependencies
@@ -48,7 +49,7 @@
class hierarchy_info_t( object ):
"""describes class relationship"""
- def __init__(self, related_class=None, access=None ):
+ def __init__(self, related_class=None, access=None, is_virtual=None ):
"""creates class that contains partial information about class relationship"""
if related_class:
assert( isinstance( related_class, class_t ) )
@@ -56,12 +57,14 @@
if access:
assert( access in ACCESS_TYPES.ALL)
self._access=access
+ self._is_virtual = is_virtual
def __eq__(self, other):
if not isinstance( other, hierarchy_info_t ):
return False
return algorithm.declaration_path( self.related_class ) == algorithm.declaration_path( other.related_class ) \
- and self.access == other.access
+ and self.access == other.access \
+ and self.is_virtual == other.is_virtual
def __ne__( self, other):
return not self.__eq__( other )
@@ -69,8 +72,8 @@
def __lt__(self, other):
if not isinstance( other, self.__class__ ):
return self.__class__.__name__ < other.__class__.__name__
- return ( algorithm.declaration_path( self.related_class ), self.access ) \
- < ( algorithm.declaration_path( other.related_class ), other.access )
+ return ( algorithm.declaration_path( self.related_class ), self.access, self.is_virtual ) \
+ < ( algorithm.declaration_path( other.related_class ), other.access, self.is_virtual )
def _get_related_class(self):
return self._related_class
@@ -90,6 +93,15 @@
access_type = property( _get_access, _set_access
, doc="describes L{hierarchy type<ACCESS_TYPES>}")
+ #TODO: check whether GCC XML support this and if so parser this information
+ def _get_is_virtual(self):
+ return self._is_virtual
+ def _set_is_virtual(self, new_is_virtual):
+ self._is_virtual = new_is_virtual
+ is_virtual = property( _get_is_virtual, _set_is_virtual
+ , doc="indicates whether the inheritance is virtual or not")
+
+
class class_declaration_t( declaration.declaration_t ):
"""describes class declaration"""
def __init__( self, name='' ):
@@ -162,9 +174,9 @@
if tmp.startswith( '::' ):
tmp = tmp[2:]
if '<' not in tmp and '<' in self._name:
- #we have template class, but for some reason demangled
+ #we have template class, but for some reason demangled
#name doesn't contain any template
- #This happens for std::string class, but this breaks
+ #This happens for std::string class, but this breaks
#other cases, because this behaviour is not consistent
self.cache.demangled_name = self._name
return self.cache.demangled_name
@@ -305,6 +317,8 @@
, doc="Size of this class in bytes @type: int")
def _get_byte_align(self):
+ if self.compiler == compilers.MSVC_PDB_9:
+ compilers.on_missing_functionality( self.compiler, "byte align" )
return self._byte_align
def _set_byte_align( self, new_byte_align ):
self._byte_align = new_byte_align
@@ -450,7 +464,7 @@
return None
def _get_partial_name_impl( self ):
- import type_traits #prevent cyclic dependencies
+ import type_traits #prevent cyclic dependencies
if type_traits.is_std_string( self ):
return 'string'
elif type_traits.is_std_wstring( self ):
Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -7,6 +7,7 @@
defines classes, that describe C++ types
"""
+import compilers
import algorithms_cache
class type_t(object):
@@ -42,7 +43,7 @@
@property
def decl_string( self ):
return self.build_decl_string()
-
+
@property
def partial_decl_string( self ):
return self.build_decl_string( False )
@@ -63,6 +64,8 @@
, doc="Size of this type in bytes @type: int")
def _get_byte_align(self):
+ if self.compiler == compilers.MSVC_PDB_9:
+ compilers.on_missing_functionality( self.compiler, "byte align" )
return self._byte_align
def _set_byte_align( self, new_byte_align ):
self._byte_align = new_byte_align
@@ -376,21 +379,21 @@
class restrict_t( compound_t ):
"""represents C{restrict whatever} type"""
-
- #The restrict keyword can be considered an extension to the strict aliasing
- #rule. It allows the programmer to declare that pointers which share the same
- #type (or were otherwise validly created) do not alias eachother. By using
- #restrict the programmer can declare that any loads and stores through the
- #qualified pointer (or through another pointer copied either directly or
- #indirectly from the restricted pointer) are the only loads and stores to
- #the same address during the lifetime of the pointer. In other words, the
+
+ #The restrict keyword can be considered an extension to the strict aliasing
+ #rule. It allows the programmer to declare that pointers which share the same
+ #type (or were otherwise validly created) do not alias eachother. By using
+ #restrict the programmer can declare that any loads and stores through the
+ #qualified pointer (or through another pointer copied either directly or
+ #indirectly from the restricted pointer) are the only loads and stores to
+ #the same address during the lifetime of the pointer. In other words, the
#pointer is not aliased by any pointers other than its own copies.
def __init__( self, base ):
compound_t.__init__( self, base)
def build_decl_string(self, with_defaults=True):
- return '__restrict__ ' + self.base.build_decl_string( with_defaults )
+ return '__restrict__ ' + self.base.build_decl_string( with_defaults )
def _clone_impl( self ):
return restrict_t( self.base.clone() )
@@ -471,12 +474,12 @@
self._arguments_types = new_arguments_types
arguments_types = property( _get_arguments_types, _set_arguments_types
, doc="list of argument L{types<type_t>}")
-
+
@property
def has_ellipsis( self ):
return self.arguments_types and isinstance( self.arguments_types[-1], ellipsis_t )
-
+
class free_function_type_t( type_t, calldef_type_t ):
"""describes free function type"""
NAME_TEMPLATE = '%(return_type)s (*)( %(arguments)s )'
@@ -599,7 +602,7 @@
return self.create_decl_string( self.return_type
, self.class_inst.decl_string
, self.arguments_types
- , self.has_const
+ , self.has_const
, with_defaults)
def _clone_impl( self ):
Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -115,9 +115,9 @@
self.print_decl_header()
if self.__print_details:
self.writer( ' ' * ( self.level + 1 ) * self.INDENT_SIZE
- + 'copy constructor: ' + str(self.__inst.is_copy_constructor)
+ + 'copy constructor: ' + str(self.__inst.is_copy_constructor)
+ os.linesep )
-
+
def visit_destructor( self ):
self.print_decl_header()
@@ -144,8 +144,11 @@
if self.__print_details:
byte_size = 'size: %d'%(self.__inst.byte_size)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ) + os.linesep )
- byte_align = 'align: %d'%(self.__inst.byte_align)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
+ try:
+ byte_align = 'align: %d'%(self.__inst.byte_align)
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
+ except NotImplementedError:
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + "not implemented".ljust( self.JUSTIFY ) + os.linesep )
if self.__inst.aliases:
aliases = map( lambda typedef: typedef.name, self.__inst.aliases )
@@ -158,8 +161,11 @@
for class_ in classes:
class_str = 'class: ' + "'%s'" % str(class_.related_class.decl_string)
self.writer( ' ' * curr_level * self.INDENT_SIZE + class_str.ljust( self.JUSTIFY ) + os.linesep )
- access = 'access: ' + "'%s'" % str(class_.access)
+ access = 'access type: ' + "'%s'" % str(class_.access)
self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + access.ljust( self.JUSTIFY ) + os.linesep )
+ if not ( None is class_.is_virtual ):
+ is_virtual = 'virtual inheritance: ' + "'%s'" % str(class_.is_virtual)
+ self.writer( ' ' * (curr_level + 1)* self.INDENT_SIZE + is_virtual.ljust( self.JUSTIFY ) + os.linesep )
def print_members(members_type, members, curr_level):
self.writer( ' ' * curr_level * self.INDENT_SIZE + members_type.ljust( self.JUSTIFY ) + os.linesep )
@@ -209,8 +215,11 @@
if self.__print_details:
byte_size = 'size: %d'%(self.__inst.type.byte_size)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_size.ljust( self.JUSTIFY ) + os.linesep )
- byte_align = 'align: %d'%(self.__inst.type.byte_align)
- self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
+ try:
+ byte_align = 'align: %d'%(self.__inst.type.byte_align)
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_align.ljust( self.JUSTIFY ) + os.linesep )
+ except NotImplementedError:
+ self.writer( ' ' * curr_level * self.INDENT_SIZE + "not implemented".ljust( self.JUSTIFY ) + os.linesep )
byte_offset = 'offset: %d'%(self.__inst.byte_offset)
self.writer( ' ' * curr_level * self.INDENT_SIZE + byte_offset + os.linesep)
Modified: pygccxml_dev/pygccxml/declarations/enumeration.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/enumeration.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/declarations/enumeration.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -7,9 +7,10 @@
defines class, that describes C++ enum
"""
-import declaration
import copy
import types
+import compilers
+import declaration
class enumeration_t( declaration.declaration_t ):
"""
@@ -37,7 +38,7 @@
# Initialize values via property access
self.values = values
self._byte_size = 0
- self._byte_align = 0
+ self._byte_align = 0
def __eq__(self, other):
if not declaration.declaration_t.__eq__( self, other ):
@@ -127,6 +128,8 @@
, doc="Size of this class in bytes @type: int")
def _get_byte_align(self):
+ if self.compiler == compilers.MSVC_PDB_9:
+ compilers.on_missing_functionality( self.compiler, "byte align" )
return self._byte_align
def _set_byte_align( self, new_byte_align ):
self._byte_align = new_byte_align
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -46,7 +46,7 @@
print 'File: ', f.fileName
class decl_loader_t(object):
- COMPILER = 'MSVC PDB'
+ COMPILER = declarations.compilers.MSVC_PDB_9
def __init__(self, pdb_file_path ):
self.logger = utils.loggers.pdb_reader
self.logger.setLevel(logging.INFO)
@@ -59,6 +59,8 @@
self.logger.debug( 'opening session - done' )
self.__global_ns = declarations.namespace_t( '::' )
self.__global_ns.compiler = self.COMPILER
+ self.__id2decl = {} #cache symIndexId : decl
+ self.__types_cache = {} #smbl id : type
def __find_table(self, name):
valid_names = ( 'Symbols', 'SourceFiles', 'Sections'
@@ -164,6 +166,7 @@
if not parent_ns:
continue #in this case the parent scope is UDT
ns_decl = declarations.namespace_t( name_splitter.name )
+ ns_decl.compiler = self.COMPILER
parent_ns.adopt_declaration( ns_decl )
nss[ ns_name ] = ns_decl
self.logger.debug( 'inserting ns "%s" into declarations tree - done', ns_name )
@@ -173,20 +176,23 @@
def __update_decls_tree( self, decl ):
smbl = decl.dia_symbols[0]
- name_splitter = impl_details.get_name_splitter( smbl.uname )
- if not name_splitter.scope_names:
- self.__adopt_declaration( self.global_ns, decl )
+ if smbl.classParentId in self.__id2decl:
+ self.__adopt_declaration( self.__id2decl[smbl.classParentId], decl )
else:
- 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 )
+ name_splitter = impl_details.get_name_splitter( smbl.uname )
+ if not name_splitter.scope_names:
+ self.__adopt_declaration( self.global_ns, decl )
+ else:
+ 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 )
def __adopt_declaration( self, parent, decl ):
smbl = decl.dia_symbols[0]
@@ -196,11 +202,13 @@
parent.adopt_declaration( decl )
else:
parent.adopt_declaration( decl, self.__guess_access_type( smbl ) )
+ self.__id2decl[ smbl.symIndexId ] = decl
else:
for other_decl in already_added:
for other_smbl in other_decl.dia_symbols:
if self.__are_symbols_equivalent( other_smbl, smbl ):
other_decl.dia_symbols.append( smbl )
+ self.__id2decl[ smbl.symIndexId ] = other_decl
return
else:
if isinstance( parent, declarations.namespace_t ):
@@ -222,41 +230,37 @@
else:
return declarations.ACCESS_TYPES.PUBLIC
- def __load_classes( self ):
- classes = {}#unique symbol id : class decl
- 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() ):
- classes[udt_smbl.symIndexId] = self.__create_class(udt_smbl)
- self.logger.info( 'building udt objects(%d) - done', len(classes) )
+ class parent_exists_t:
+ def __init__( self, global_ns, classes, id2decl ):
+ self.global_ns = global_ns
+ self.classes = classes
+ self.id2decl = id2decl
+ self.__parent_exist = set()
- def does_parent_exist_in_decls_tree( class_decl ):
- class_smbl = class_decl.dia_symbols[0]
- if classes.has_key( class_smbl.classParentId ):
+ def __call__( self, decl ):
+ smbl = decl.dia_symbols[0]
+ if smbl.classParent:
+ if smbl.classParentId in self.id2decl:
+ return True
+ else:
+ return False
+ if self.classes.has_key( smbl.classParentId ):
return False
- name_splitter = impl_details.get_name_splitter( class_smbl.uname )
+ name_splitter = impl_details.get_name_splitter( smbl.uname )
if not name_splitter.scope_names:
return True #global namespace
else:
+ #print "I am here " + '::' + name_splitter.scope_names[-1]
parent_name = '::' + name_splitter.scope_names[-1]
+ if parent_name in self.__parent_exist:
+ return True
found = self.global_ns.decls( parent_name
, decl_type=declarations.scopedef_t
, allow_empty=True
, recursive=True )
+ if found:
+ self.__parent_exist.add( parent_name )
return bool( found )
- self.logger.info( 'integrating udt objects with namespaces' )
- while classes:
- to_be_integrated = len( classes )
- self.logger.info( 'there are %d classes to go', len( classes ) )
- to_be_deleted = filter( does_parent_exist_in_decls_tree, classes.itervalues() )
- map( self.__update_decls_tree, to_be_deleted )
- map( lambda decl: classes.pop( decl.dia_symbols[0].symIndexId )
- , to_be_deleted )
- if not ( to_be_integrated - len( classes ) ):
- for cls in classes.itervalues():
- self.logger.warning( 'unable to integrate class "%s" into declarations tree', cls.dia_symbols[0].uname )
- break
- self.logger.info( 'integrating udt objects with namespaces - done' )
def __clear_symbols(self):
self.logger.info( 'clearing symbols' )
@@ -270,11 +274,13 @@
self.logger.info( 'clearing symbols(%d) - done', len( to_be_deleted ) )
def read(self):
- self.__clear_symbols()
+ #self.__clear_symbols()
self.__load_nss()
self.__load_classes()
+ self.__load_base_classes()
self.__load_enums()
self.__load_vars()
+ self.__load_typedefs()
@property
def dia_global_scope(self):
@@ -317,20 +323,65 @@
def __update_decl( self, decl, smbl ):
decl.dia_symbols = [smbl]
decl.compiler = self.COMPILER
- decl.byte_size = smbl.length
+ if not isinstance( decl, declarations.typedef_t ):
+ decl.byte_size = smbl.length
+ decl.byte_offset = smbl.offset
decl.mangled = iif( smbl.name, smbl.name, '' )
decl.demangled = iif( smbl.uname, smbl.uname, '' )
decl.is_artificial = bool( smbl.compilerGenerated )
+
+ def __load_classes( self ):
+ classes = {}#unique symbol id : class decl
+ 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() ):
+ 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' )
+ does_parent_exists = self.parent_exists_t( self.global_ns, classes, self.__id2decl )
+ while classes:
+ to_be_integrated = len( classes )
+ self.logger.info( 'there are %d classes to go', len( classes ) )
+ to_be_deleted = filter( does_parent_exists, classes.itervalues() )
+ map( self.__update_decls_tree, to_be_deleted )
+ map( lambda decl: classes.pop( decl.dia_symbols[0].symIndexId )
+ , to_be_deleted )
+ if not ( to_be_integrated - len( classes ) ):
+ for cls in classes.itervalues():
+ self.logger.warning( 'unable to integrate class "%s" into declarations tree', cls.dia_symbols[0].uname )
+ break
+ self.logger.info( 'integrating udt objects with namespaces - done' )
+
+ def __load_base_classes( self ):
+ make_hi = declarations.hierarchy_info_t
+ is_base_class = lambda smbl: smbl.symTag == msdia.SymTagBaseClass \
+ and False == smbl.indirectVirtualBaseClass
+ self.logger.info( 'building class hierarchies' )
+ for count, smbl in enumerate( itertools.ifilter( is_base_class, self.symbols.itervalues() ) ):
+ base_id = smbl.type.symIndexId
+ derived_id = smbl.classParentId
+
+ hi_base = make_hi( self.__id2decl[base_id]
+ , self.__guess_access_type( smbl )
+ , bool( smbl.virtualBaseClass ) )
+ self.__id2decl[ derived_id ].bases.append( hi_base )
+
+ hi_derived = make_hi( self.__id2decl[derived_id]
+ , self.__guess_access_type( smbl )
+ , bool( smbl.virtualBaseClass ) )
+ self.__id2decl[ base_id ].derived.append( hi_derived )
+
+ self.logger.info( 'building class hierarchies(%d) - done', count )
+
def __load_enums( self ):
is_enum = lambda smbl: smbl.symTag == msdia.SymTagEnum
self.logger.info( 'building enum objects' )
- enums_count = 0
- for enum_smbl in itertools.ifilter( is_enum, self.symbols.itervalues() ):
+ for enums_count, enum_smbl in enumerate( itertools.ifilter( is_enum, self.symbols.itervalues() ) ):
enum_decl = self.__create_enum(enum_smbl)
if not enum_decl:
continue
- enums_count += 1
self.__update_decls_tree( enum_decl )
self.logger.info( 'building enum objects(%d) - done', enums_count )
@@ -373,13 +424,11 @@
def __load_vars( self ):
self.logger.info( 'building variable objects' )
- vars_count = 0
- for var_smbl in itertools.ifilter( self.__is_my_var, self.symbols.itervalues() ):
+
+ for vars_count, var_smbl in enumerate( itertools.ifilter( self.__is_my_var, self.symbols.itervalues() ) ):
var_decl = self.__create_var(var_smbl)
- if not var_decl:
- continue
- vars_count += 1
- self.__update_decls_tree( var_decl )
+ if var_decl:
+ self.__update_decls_tree( var_decl )
self.logger.info( 'building variable objects(%d) - done', vars_count )
def __create_var( self, smbl ):
@@ -387,14 +436,34 @@
name_splitter = impl_details.get_name_splitter( smbl.uname )
decl = declarations.variable_t( name_splitter.name )
self.__update_decl( decl, smbl )
- #~ if decl.name == 'initialized':
- #~ pdb.set_trace()
decl.type = self.create_type( smbl.type )
decl.value = str(smbl.value)
self.logger.debug( 'creating variable "%s" - done', smbl.uname )
return decl
+ def __load_typedefs( self ):
+ self.logger.info( 'building typedef objects' )
+ is_typedef = lambda smbl: smbl.symTag == msdia.SymTagTypedef
+ for typedefs_count, typedef_smbl in enumerate( itertools.ifilter( is_typedef, self.symbols.itervalues() ) ):
+ typedef_decl = self.__create_typedef(typedef_smbl)
+ self.__update_decls_tree( typedef_decl )
+ self.logger.info( 'building typedef objects(%d) - done', typedefs_count )
+
+ def __create_typedef( self, smbl ):
+ self.logger.debug( 'creating typedef "%s"', smbl.uname )
+ name_splitter = impl_details.get_name_splitter( smbl.uname )
+ #~ if decl.name == 'initialized':
+ #~ pdb.set_trace()
+ decl = declarations.typedef_t( name_splitter.name
+ , self.create_type( smbl.type ) )
+ self.__update_decl( decl, smbl )
+ self.logger.debug( 'creating typedef "%s" - done', smbl.uname )
+ return decl
+
+
def create_type( self, smbl ):
+ if smbl.symIndexId in self.__types_cache:
+ return self.__types_cache[smbl.symIndexId]
my_type = None
if msdia.SymTagBaseType == smbl.symTag:
if enums.BasicType.btNoType == smbl.baseType:
@@ -442,9 +511,18 @@
if bytes and element_type.byte_size:
size = bytes / element_type.byte_size
my_type = declarations.array_t( element_type, size )
+ elif smbl.symTag in ( msdia.SymTagUDT, msdia.SymTagTypedef, msdia.SymTagEnum ):
+ if smbl.symIndexId in self.__id2decl:
+ decl = self.__id2decl[ smbl.symIndexId ]
+ my_type = declarations.declarated_t( decl )
+ else:
+ my_type = declarations.unknown_t()
else:
my_type = declarations.unknown_t()
- my_type.byte_size = smbl.length
+ try:
+ my_type.byte_size = smbl.length
+ except AttributeError:
+ pass
if smbl.constType:
my_type = declarations.const_t( my_type )
if smbl.volatileType:
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -92,12 +92,12 @@
, XML_NN_ENUMERATION : self.__read_enumeration
, XML_NN_ENUMERATION_VALUE : self.__read_enumeration_value
, XML_NN_ARRAY_TYPE : self.__read_array_type
- , XML_NN_CV_QUALIFIED_TYPE : self.__read_cv_qualified_type
+ , XML_NN_CV_QUALIFIED_TYPE : self.__read_cv_qualified_type
, XML_NN_POINTER_TYPE : self.__read_pointer_type
, XML_NN_REFERENCE_TYPE : self.__read_reference_type
- , XML_NN_FUNDAMENTAL_TYPE : self.__read_fundamental_type
+ , XML_NN_FUNDAMENTAL_TYPE : self.__read_fundamental_type
, XML_NN_ARGUMENT : self.__read_argument
- , XML_NN_FUNCTION_TYPE : self.__read_function_type
+ , XML_NN_FUNCTION_TYPE : self.__read_function_type
, XML_NN_METHOD_TYPE : self.__read_method_type
, XML_NN_OFFSET_TYPE : self.__read_offset_type
, XML_NN_TYPEDEF : self.__read_typedef
@@ -132,7 +132,7 @@
assert isinstance( decl_factory, decl_factory_t )
self.__decl_factory = decl_factory
-
+
#mapping from id -> decl
self.__declarations = {}
#list of all read declarations
@@ -141,7 +141,7 @@
self.__enums = []
#mapping from id -> type
self.__types = {}
- #mapping from id -> file
+ #mapping from id -> file
self.__files = {}
#mapping between decl id -> access
self.__access = {}
@@ -149,12 +149,12 @@
self.__inst = None
#mapping from id to members
self.__members = {}
-
+
self.__compiler = None
-
+
def read( self ):
xml.sax.parse( self.gccxml_file, self )
-
+
def endDocument( self ):
#updating membership
members_mapping = {}
@@ -164,34 +164,34 @@
continue
members_mapping[ id( decl ) ] = members
self.__members = members_mapping
-
+
def declarations(self):
return self.__declarations
-
+
def calldefs( self ):
return self.__calldefs
def enums(self):
return self.__enums
-
+
def types(self):
return self.__types
-
+
def files(self):
return self.__files
def access(self):
return self.__access
-
+
def members(self):
return self.__members
def startElementNS(self, name, qname, attrs):
return self.startElement( name[1], attrs )
-
+
def endElementNS(self, name, qname):
return self.endElement( name[1] )
-
+
def startElement(self, name, attrs):
try:
if name not in self.__readers:
@@ -216,7 +216,7 @@
self.__read_mangled( obj, attrs)
self.__read_demangled( obj, attrs)
self.__read_attributes(obj, attrs)
-
+
elif isinstance( obj, type_t ):
self.__types[ element_id ] = obj
self.__read_byte_size(obj, attrs)
@@ -231,7 +231,7 @@
msg = msg + os.linesep + 'Error: %s.' % str( error )
self.logger.error( msg % ( name, pprint.pformat( attrs.keys() ) ) )
raise
-
+
def endElement(self, name):
if name in self.deep_declarations:
self.__inst = None
@@ -242,7 +242,7 @@
def __update_membership(self, attrs):
parent = attrs.get( XML_AN_CONTEXT, None )
if not parent:
- return
+ return
if not self.__members.has_key( parent ):
self.__members[ parent ] = []
self.__members[parent].append( attrs[XML_AN_ID] )
@@ -261,7 +261,7 @@
def __read_demangled( self, decl, attrs ):
decl.demangled = attrs.get( XML_AN_DEMANGLED, None )
-
+
def __read_attributes( self, decl, attrs ):
decl.attributes = attrs.get( XML_AN_ATTRIBUTES, None )
@@ -285,7 +285,7 @@
def __read_root(self, attrs):
pass
-
+
def __read_file( self, attrs ):
return attrs.get( XML_AN_NAME, '' )
@@ -336,7 +336,7 @@
msg = 'unable to find out array size from expression "%s"' % attrs[ XML_AN_MAX ]
warnings.warn( msg )
return array_t( type_, size + 1 )
-
+
def __read_cv_qualified_type( self, attrs ):
if attrs.has_key( XML_AN_CONST ):
return const_t( attrs[XML_AN_TYPE] )
@@ -344,12 +344,12 @@
return volatile_t( attrs[XML_AN_TYPE] )
elif attrs.has_key( XML_AN_RESTRICT ):
return restrict_t( attrs[XML_AN_TYPE] )
- else:
- assert 0
+ else:
+ assert 0
def __read_pointer_type( self, attrs ):
return pointer_t( attrs[XML_AN_TYPE] )
-
+
def __read_reference_type( self, attrs ):
return reference_t( attrs[XML_AN_TYPE] )
@@ -374,13 +374,13 @@
else:
argument = argument_t()
argument.name = attrs.get( XML_AN_NAME, 'arg%d' % len(self.__inst.arguments) )
- argument.type = attrs[XML_AN_TYPE]
+ argument.type = attrs[XML_AN_TYPE]
argument.default_value = attrs.get( XML_AN_DEFAULT, None )
self.__read_attributes( argument, attrs )
if argument.default_value == '<gccxml-cast-expr>':
argument.default_value = None
self.__inst.arguments.append( argument )
-
+
def __read_ellipsis( self, attrs ):
if isinstance( self.__inst, calldef_type_t ):
self.__inst.arguments_types.append( '...' )
@@ -405,10 +405,10 @@
else:
calldef.does_throw = True
calldef.exceptions = throw_stmt.split()
-
- def __read_member_function( self, calldef, attrs, is_declaration ):
+
+ def __read_member_function( self, calldef, attrs, is_declaration ):
self.__read_calldef( calldef, attrs, is_declaration )
- calldef.has_const = attrs.get( XML_AN_CONST, False )
+ calldef.has_const = attrs.get( XML_AN_CONST, False )
if is_declaration:
calldef.has_static = attrs.get( XML_AN_STATIC, False )
if attrs.has_key( XML_AN_PURE_VIRTUAL ):
@@ -418,13 +418,13 @@
else:
calldef.virtuality = VIRTUALITY_TYPES.NOT_VIRTUAL
else:
- calldef.class_inst = attrs[XML_AN_BASE_TYPE]
-
+ calldef.class_inst = attrs[XML_AN_BASE_TYPE]
+
def __read_function_type(self, attrs):
answer = free_function_type_t()
self.__read_calldef( answer, attrs, False )
return answer
-
+
def __read_method_type(self, attrs):
answer = member_function_type_t()
self.__read_member_function( answer, attrs, False )
@@ -434,7 +434,7 @@
return self.__decl_factory.create_typedef( name=attrs.get( XML_AN_NAME, '' ), type=attrs[XML_AN_TYPE])
def __read_variable(self, attrs ):
- type_qualifiers = type_qualifiers_t()
+ type_qualifiers = type_qualifiers_t()
type_qualifiers.has_mutable = attrs.get(XML_AN_MUTABLE, False)
type_qualifiers.has_static = attrs.get(XML_AN_EXTERN, False)
bits = attrs.get( XML_AN_BITS, None )
@@ -466,7 +466,7 @@
self.__read_byte_size(decl, attrs)
self.__read_byte_align(decl, attrs)
return decl
-
+
def __read_class( self, attrs ):
return self.__read_class_impl( CLASS_TYPES.CLASS, attrs )
@@ -480,7 +480,7 @@
operator = self.__decl_factory.create_casting_operator()
self.__read_member_function( operator, attrs, True )
return operator
-
+
def __read_constructor( self, attrs ):
constructor = self.__decl_factory.create_constructor()
self.__read_member_function( constructor, attrs, True )
@@ -490,18 +490,18 @@
gfunction = self.__decl_factory.create_free_function()
self.__read_calldef( gfunction, attrs, True )
return gfunction
-
+
def __read_method(self, attrs):
mfunction = self.__decl_factory.create_member_function()
self.__read_member_function( mfunction, attrs, True )
return mfunction
-
+
def __read_destructor(self, attrs):
destructor = self.__decl_factory.create_destructor()
self.__read_member_function( destructor, attrs, True )
destructor.name = '~' + destructor.name
return destructor
-
+
def __read_free_operator(self, attrs ):
operator = self.__decl_factory.create_free_operator()
self.__read_member_function( operator, attrs, True )
@@ -510,7 +510,7 @@
else:
operator.name = 'operator' + operator.name
return operator
-
+
def __read_member_operator(self, attrs):
operator = self.__decl_factory.create_member_operator()
self.__read_member_function( operator, attrs, True )
@@ -522,18 +522,18 @@
def __read_version(self, attrs):
logger = utils.loggers.cxx_parser
-
+
version = float( attrs.get(XML_AN_CVS_REVISION, 0.6) )
if version is None:
logger.info ( 'GCCXML version - 0.6' )
- version = "0.6"
+ self.__compiler = compilers.GCC_XML_06
elif version <= 1.114:
logger.info ( 'GCCXML version - 0.7' )
- version = "0.7"
+ self.__compiler = compilers.GCC_XML_07
elif version in ( 1.115, 1.116, 1.117 ):
logger.info ( 'GCCXML version - 0.9 BUGGY' )
- version = "0.9"
+ self.__compiler = compilers.GCC_XML_09_BUGGY
else:
logger.info ( 'GCCXML version - 0.9' )
- version = "0.9"
- self.__compiler = "GCC-XML " + version
+ self.__compiler = compilers.GCC_XML_09
+
Modified: pygccxml_dev/unittests/core_tester.py
===================================================================
--- pygccxml_dev/unittests/core_tester.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/core_tester.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -23,30 +23,8 @@
global_ns = None
def __init__(self, *args ):
parser_test_case.parser_test_case_t.__init__( self, *args )
- self.test_files = [ 'core_ns_join_1.hpp'
- , 'core_ns_join_2.hpp'
- , 'core_ns_join_3.hpp'
- , 'core_membership.hpp'
- , 'core_class_hierarchy.hpp'
- , 'core_types.hpp'
- , 'core_diamand_hierarchy_base.hpp'
- , 'core_diamand_hierarchy_derived1.hpp'
- , 'core_diamand_hierarchy_derived2.hpp'
- , 'core_diamand_hierarchy_final_derived.hpp'
- , 'core_overloads_1.hpp'
- , 'core_overloads_2.hpp'
- , 'abstract_classes.hpp'
- ]
self.global_ns = None
- def setUp(self):
- if not core_t.global_ns:
- decls = parse( self.test_files, self.config, self.COMPILATION_MODE )
- core_t.global_ns = pygccxml.declarations.get_global_namespace( decls )
- if self.INIT_OPTIMIZER:
- core_t.global_ns.init_optimizer()
- self.global_ns = core_t.global_ns
-
def test_top_parent(self):
enum = self.global_ns.enum( '::ns::ns32::E33' )
self.failUnless( self.global_ns is enum.top_parent )
@@ -289,9 +267,9 @@
print '\nexpected: '
for x in others:
print str(x)
-
+
self.failUnless( set( do_nothing.overloads ) == set( others )
- , "there is a difference between expected function overloads and existing ones." )
+ , "there is a difference between expected function overloads and existing ones." )
def test_abstract_classes(self):
ns = self.global_ns.namespace( 'abstract_classes' )
@@ -305,50 +283,89 @@
def test_versioning(self):
for d in self.global_ns.decls():
self.failUnless( d.compiler )
-
+
def test_byte_size( self ):
mptrs = self.global_ns.class_( 'members_pointers_t' )
self.failUnless( mptrs.byte_size != 0 )
-
+
def test_byte_align( self ):
mptrs = self.global_ns.class_( 'members_pointers_t' )
- self.failUnless( mptrs.byte_align != 0 )
+ if mptrs.compiler != compilers.MSVC_PDB_9:
+ self.failUnless( mptrs.byte_align != 0 )
def test_byte_offset( self ):
mptrs = self.global_ns.class_( 'members_pointers_t' )
self.failUnless( mptrs.var( 'xxx' ).byte_offset != 0 )
+class pdb_based_core_tester_t( core_t ):
+ def __init__(self, *args ):
+ core_t.__init__( self, *args )
+ self.global_ns = autoconfig.get_pdb_global_ns()
-class core_all_at_once_t( core_t ):
+class core_gccxml_t( core_t ):
+ """Tests core algorithms of GCC-XML and GCC-XML file reader.
+ Those most white-box testing.
+ """
+ global_ns = None
+ def __init__(self, *args ):
+ core_t.__init__( self, *args )
+ self.test_files = [ 'core_ns_join_1.hpp'
+ , 'core_ns_join_2.hpp'
+ , 'core_ns_join_3.hpp'
+ , 'core_membership.hpp'
+ , 'core_class_hierarchy.hpp'
+ , 'core_types.hpp'
+ , 'core_diamand_hierarchy_base.hpp'
+ , 'core_diamand_hierarchy_derived1.hpp'
+ , 'core_diamand_hierarchy_derived2.hpp'
+ , 'core_diamand_hierarchy_final_derived.hpp'
+ , 'core_overloads_1.hpp'
+ , 'core_overloads_2.hpp'
+ , 'abstract_classes.hpp'
+ ]
+ self.global_ns = None
+
+ def setUp(self):
+ if not core_t.global_ns:
+ decls = parse( self.test_files, self.config, self.COMPILATION_MODE )
+ core_t.global_ns = pygccxml.declarations.get_global_namespace( decls )
+ if self.INIT_OPTIMIZER:
+ core_t.global_ns.init_optimizer()
+ self.global_ns = core_t.global_ns
+
+class core_all_at_once_t( core_gccxml_t ):
COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE
INIT_OPTIMIZER = True
def __init__(self, *args):
- core_t.__init__(self, *args)
+ core_gccxml_t.__init__(self, *args)
-class core_all_at_once_no_opt_t( core_t ):
+class core_all_at_once_no_opt_t( core_gccxml_t ):
COMPILATION_MODE = COMPILATION_MODE.ALL_AT_ONCE
INIT_OPTIMIZER = False
def __init__(self, *args):
- core_t.__init__(self, *args)
+ core_gccxml_t.__init__(self, *args)
-class core_file_by_file_t( core_t ):
+class core_file_by_file_t( core_gccxml_t ):
COMPILATION_MODE = COMPILATION_MODE.FILE_BY_FILE
INIT_OPTIMIZER = True
def __init__(self, *args):
- core_t.__init__(self, *args)
+ core_gccxml_t.__init__(self, *args)
-class core_file_by_file_no_opt_t( core_t ):
+class core_file_by_file_no_opt_t( core_gccxml_t ):
COMPILATION_MODE = COMPILATION_MODE.FILE_BY_FILE
INIT_OPTIMIZER = False
def __init__(self, *args):
- core_t.__init__(self, *args)
+ core_gccxml_t.__init__(self, *args)
def create_suite():
suite = unittest.TestSuite()
- suite.addTest( unittest.makeSuite(core_all_at_once_t))
- 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))
+ #~ suite.addTest( unittest.makeSuite(core_all_at_once_t))
+ #~ 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 sys.platform == 'win32':
+ suite.addTest( unittest.makeSuite(pdb_based_core_tester_t))
+
return suite
def run_suite():
Modified: pygccxml_dev/unittests/data/core_types.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_types.hpp 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/data/core_types.hpp 2008-04-21 20:14:17 UTC (rev 1310)
@@ -6,6 +6,11 @@
#ifndef __core_types_hpp__
#define __core_types_hpp__
+#include <iostream>
+
+#define USE_SYMBOL( X ) enum{ x##__LINE__ = sizeof(X) };
+
+
namespace core{ namespace types{
typedef void typedef_void;
@@ -29,6 +34,8 @@
typedef long double typedef_long_double;
typedef const int typedef_const_int;
+USE_SYMBOL( typedef_const_int );
+
typedef int * typedef_pointer_int;
typedef int& typedef_reference_int;
typedef const unsigned int * const typedef_const_unsigned_int_const_pointer;
Modified: pygccxml_dev/unittests/data/declarations_enums.hpp
===================================================================
--- pygccxml_dev/unittests/data/declarations_enums.hpp 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/data/declarations_enums.hpp 2008-04-21 20:14:17 UTC (rev 1310)
@@ -17,6 +17,7 @@
enum EPrivColor{ priv_red, priv_green, priv_blue, priv_black, priv_white };
void do_smth(EPrivColor x){}
+ EColor favorite_color;
};
} }
Modified: pygccxml_dev/unittests/data/declarations_variables.hpp
===================================================================
--- pygccxml_dev/unittests/data/declarations_variables.hpp 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/data/declarations_variables.hpp 2008-04-21 20:14:17 UTC (rev 1310)
@@ -18,6 +18,10 @@
mutable int m_mutable;
};
+struct struct_variables_holder_t{
+ struct_variables_t m_struct_variables;
+};
+
} }
#endif//__declarations_variables_hpp__
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-21 20:14:17 UTC (rev 1310)
@@ -3,6 +3,7 @@
#include "bit_fields.hpp"
#include "complex_types.hpp"
#include "core_cache.hpp"
+#include "core_types.hpp"
#include "core_class_hierarchy.hpp"
#include "core_diamand_hierarchy_base.hpp"
#include "core_diamand_hierarchy_derived1.hpp"
@@ -40,13 +41,22 @@
#include "unnamed_enums_bug2.hpp"
#include "unnamed_ns_bug.hpp"
#include "vector_traits.hpp"
+#include "core_types.hpp"
-namespace declarations{ namespace variables{
-
-int static_var = 0;
+namespace declarations{ namespace variables{
+
+int static_var = 0;
}}
void use_decls(){
declarations::enums::ENumbers enumbers;
declarations::enums::data::EColor ecolor;
+
+ sizeof(core::types::exception );
+}
+
+
+void use_core_types(){
+ core::types::members_pointers_t mem_ptrs;
+ core::types::typedef_const_int typedef_const_int_ = 0;
}
\ No newline at end of file
Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-21 20:14:17 UTC (rev 1310)
@@ -53,6 +53,7 @@
BrowseInformation="1"
WarningLevel="3"
DebugInformationFormat="4"
+ DisableSpecificWarnings="4290;4584;4293;4244;4101"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -77,7 +78,8 @@
/>
<Tool
Name="VCXDCMakeTool"
- ValidateIntelliSense="true"
+ ValidateIntelliSense="false"
+ OutputDocumentFile=""
/>
<Tool
Name="VCBscMakeTool"
Modified: pygccxml_dev/unittests/data/typedefs1.hpp
===================================================================
--- pygccxml_dev/unittests/data/typedefs1.hpp 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/data/typedefs1.hpp 2008-04-21 20:14:17 UTC (rev 1310)
@@ -12,6 +12,8 @@
typedef item_t Item1;
+typedef int my_int_t;
+
}
-#endif//__typedefs1_hpp__
\ No newline at end of file
+#endif//__typedefs1_hpp__
Modified: pygccxml_dev/unittests/declarations_tester.py
===================================================================
--- pygccxml_dev/unittests/declarations_tester.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/declarations_tester.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -49,14 +49,15 @@
% ( expected_value, initialized.value ) )
self._test_type_composition( initialized.type, const_t, long_unsigned_int_t )
- if 'PDB' in self.global_ns.compiler:
- return #TODO find out work around
static_var = initialized = self.global_ns.variable( name='static_var' )
self.failUnless( static_var.type_qualifiers.has_static
, "static_var must have static type qualifier" )
self.failUnless( not static_var.type_qualifiers.has_mutable
, "static_var must not have mutable type qualifier" )
+ if 'PDB' in self.global_ns.compiler:
+ return #TODO find out work around
+
m_mutable = initialized = self.global_ns.variable( name='m_mutable' )
self.failUnless( not m_mutable.type_qualifiers.has_static
, "m_mutable must not have static type qualifier" )
Modified: pygccxml_dev/unittests/pdb_tester.py
===================================================================
--- pygccxml_dev/unittests/pdb_tester.py 2008-04-12 07:52:34 UTC (rev 1309)
+++ pygccxml_dev/unittests/pdb_tester.py 2008-04-21 20:14:17 UTC (rev 1310)
@@ -14,25 +14,25 @@
, 'Debug'
, 'msvc_build.pdb' )
- def __test_splitter_impl( self, name, expected_result ):
+ def __splitter_tester_impl( self, name, expected_result ):
splitter = pdb.impl_details.full_name_splitter_t( name )
self.failUnless( len(splitter.scope_names) == len(expected_result) )
self.failUnless( splitter.scope_names == expected_result )
- def __test_name_splitter(self):
+ def test_name_splitter(self):
name = "std::_Tree<std::_Tmap_traits<engine_objects::ouuid_t,engine_objects::sql_query::parameterized_query::sql_fragment_t,std::less<engine_objects::ouuid_t>,std::allocator<std::pair<engine_objects::ouuid_t const ,engine_objects::sql_query::parameterized_query::sql_fragment_t> >,0> >::const_iterator::operator->"
expected_result = [
'std'
, 'std::_Tree<std::_Tmap_traits<engine_objects::ouuid_t,engine_objects::sql_query::parameterized_query::sql_fragment_t,std::less<engine_objects::ouuid_t>,std::allocator<std::pair<engine_objects::ouuid_t const ,engine_objects::sql_query::parameterized_query::sql_fragment_t> >,0> >', 'std::_Tree<std::_Tmap_traits<engine_objects::ouuid_t,engine_objects::sql_query::parameterized_query::sql_fragment_t,std::less<engine_objects::ouuid_t>,std::allocator<std::pair<engine_objects::ouuid_t const ,engine_objects::sql_query::parameterized_query::sql_fragment_t> >,0> >::const_iterator'
]
- self.__test_splitter_impl( name, expected_result )
+ self.__splitter_tester_impl( name, expected_result )
name = 'boost::reference_wrapper<engine_objects::ops::pathable_t const >::operator engine_objects::ops::pathable_t const &'
expected_result = [
'boost'
, 'boost::reference_wrapper<engine_objects::ops::pathable_t const >'
]
- self.__test_splitter_impl( name, expected_result )
+ self.__splitter_tester_impl( name, expected_result )
def test_create_nss(self):
reader = pdb.decl_loader_t( self.pdb_file )
@@ -45,6 +45,12 @@
f.write( os.linesep.join( x ) )
f.close()
+ f = file( 'symbols.txt', 'w+')
+ for smbl in reader.symbols.itervalues():
+ f.write( smbl.uname )
+ f.write( os.linesep )
+ f.write( '\t' + str(smbl.name) )
+ f.close()
#~ names = []
#~ for d in reader.global_ns.classes():
#~ names.append( '{%s}<=====>{%s}' %( d.demangled, d.mangled ) )
@@ -70,6 +76,7 @@
#~ print undecorated
self.failUnless( msvc_utils.undecorate_name( decorated ) == undecorated )
+
def create_suite():
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-12 07:52:28
|
Revision: 1309
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1309&view=rev
Author: roman_yakovenko
Date: 2008-04-12 00:52:34 -0700 (Sat, 12 Apr 2008)
Log Message:
-----------
adding support for basic types
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/container_traits.py
pygccxml_dev/pygccxml/msvc/pdb/enums.py
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/data/declarations_variables.hpp
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/declarations_tester.py
Modified: pygccxml_dev/pygccxml/declarations/container_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/container_traits.py 2008-04-09 20:52:33 UTC (rev 1308)
+++ pygccxml_dev/pygccxml/declarations/container_traits.py 2008-04-12 07:52:34 UTC (rev 1309)
@@ -18,19 +18,19 @@
std_namespaces = ( 'std', 'stdext', '__gnu_cxx' )
-class defaults_eraser:
+class defaults_eraser:
@staticmethod
def normalize( type_str ):
return type_str.replace( ' ', '' )
@staticmethod
def replace_basic_string( cls_name ):
- strings = {
+ strings = {
'std::string' : ( 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
, 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >' )
, 'std::wstring' : ( 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >'
, 'std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' ) }
-
+
new_name = cls_name
for short_name, long_names in strings.iteritems():
for lname in long_names:
@@ -59,13 +59,13 @@
return answer
@staticmethod
- def erase_call( cls_name ):
- global find_container_traits
+ def erase_call( cls_name ):
+ global find_container_traits
c_traits = find_container_traits( cls_name )
- if not c_traits:
+ if not c_traits:
return cls_name
return c_traits.remove_defaults( cls_name )
-
+
@staticmethod
def erase_recursive( cls_name ):
ri = defaults_eraser.recursive_impl
@@ -85,7 +85,7 @@
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
if 2 != len( c_args ):
- return
+ return
value_type = c_args[0]
tmpl = string.Template( "$container< $value_type, $allocator<$value_type> >" )
tmpl = tmpl.substitute( container=c_name, value_type=value_type, allocator=default_allocator )
@@ -97,37 +97,37 @@
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
if 2 != len( c_args ):
- return
+ return
value_type = c_args[0]
- dc_no_defaults = defaults_eraser.erase_recursive( c_args[1] )
+ dc_no_defaults = defaults_eraser.erase_recursive( c_args[1] )
if defaults_eraser.normalize( dc_no_defaults ) \
!= defaults_eraser.normalize( templates.join( default_container_name, [value_type] ) ):
- return
- return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
+ return
+ return templates.join( c_name, [defaults_eraser.erase_recursive( value_type )] )
@staticmethod
def erase_container_compare( cls_name, default_container_name='std::vector', default_compare='std::less' ):
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
if 3 != len( c_args ):
- return
- dc_no_defaults = defaults_eraser.erase_recursive( c_args[1] )
+ return
+ dc_no_defaults = defaults_eraser.erase_recursive( c_args[1] )
if defaults_eraser.normalize( dc_no_defaults ) \
!= defaults_eraser.normalize( templates.join( default_container_name, [c_args[0]] ) ):
- return
- dcomp_no_defaults = defaults_eraser.erase_recursive( c_args[2] )
+ return
+ dcomp_no_defaults = defaults_eraser.erase_recursive( c_args[2] )
if defaults_eraser.normalize( dcomp_no_defaults ) \
!= defaults_eraser.normalize( templates.join( default_compare, [c_args[0]] ) ):
- return
+ return
value_type = defaults_eraser.erase_recursive( c_args[0] )
- return templates.join( c_name, [value_type] )
+ return templates.join( c_name, [value_type] )
@staticmethod
def erase_compare_allocator( cls_name, default_compare='std::less', default_allocator='std::allocator' ):
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
if 3 != len( c_args ):
- return
+ return
value_type = c_args[0]
tmpl = string.Template( "$container< $value_type, $compare<$value_type>, $allocator<$value_type> >" )
tmpl = tmpl.substitute( container=c_name
@@ -142,10 +142,10 @@
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
if 4 != len( c_args ):
- return
- key_type = c_args[0]
+ return
+ key_type = c_args[0]
mapped_type = c_args[1]
- tmpls = [
+ tmpls = [
string.Template( "$container< $key_type, $mapped_type, $compare<$key_type>, $allocator< std::pair< const $key_type, $mapped_type> > >" )
, string.Template( "$container< $key_type, $mapped_type, $compare<$key_type>, $allocator< std::pair< $key_type const, $mapped_type> > >" )
, string.Template( "$container< $key_type, $mapped_type, $compare<$key_type>, $allocator< std::pair< $key_type, $mapped_type> > >" )]
@@ -166,7 +166,7 @@
cls_name = defaults_eraser.replace_basic_string( cls_name )
c_name, c_args = templates.split( cls_name )
if len( c_args ) < 3:
- return
+ return
default_hash=None
default_less='std::less'
@@ -181,8 +181,8 @@
default_hash='hash'
tmpl = "$container< $value_type, $hash<$value_type >, $equal_to<$value_type >, $allocator<$value_type> >"
else:
- return
-
+ return
+
value_type = c_args[0]
tmpl = string.Template( tmpl )
for ns in std_namespaces:
@@ -205,16 +205,16 @@
default_less='std::less'
default_allocator='std::allocator'
default_equal_to = 'std::equal_to'
-
- tmpl = None
+
+ tmpl = None
key_type = None
mapped_type = None
if 2 < len( c_args ):
- key_type = c_args[0]
+ key_type = c_args[0]
mapped_type = c_args[1]
else:
return
-
+
if 4 == len( c_args ):
default_hash = 'hash_compare'
tmpl = string.Template( "$container< $key_type, $mapped_type, $hash<$key_type, $less<$key_type> >, $allocator< std::pair< const $key_type, $mapped_type> > >" )
@@ -312,23 +312,25 @@
% ( self.name, cls.decl_string ) )
return ref
-
+
def create_traits_class( container_name
, element_type_index
, element_type_typedef
, remove_defaults_=None ):
""" creates concrete container traits class """
+ impl_tmp = container_traits_impl_t( container_name, element_type_index, element_type_typedef )
+
class xxx_traits:
"""extract information from the container"""
- impl = container_traits_impl_t( container_name, element_type_index, element_type_typedef )
-
+ impl = None
+
@staticmethod
def name():
return xxx_traits.impl.name
-
+
@staticmethod
def is_my_case( type ):
"""returns True if type is the container class, otherwise False"""
@@ -345,19 +347,22 @@
return xxx_traits.impl.element_type( type )
@staticmethod
- def remove_defaults( type_or_string ):
- name = None
+ def remove_defaults( type_or_string ):
+ name = None
if not isinstance( type_or_string, types.StringTypes ):
name = xxx_traits.class_declaration( type_or_string ).name
else:
name = type_or_string
if not remove_defaults_:
- return name
+ return name
no_defaults = remove_defaults_( name )
if not no_defaults:
return name
else:
return no_defaults
+
+ xxx_traits.impl = impl_tmp
+
return xxx_traits
list_traits = create_traits_class( 'list', 0, 'value_type', defaults_eraser.erase_allocator )
@@ -394,25 +399,25 @@
, map_traits
, multimap_traits
, hash_map_traits
- , hash_multimap_traits
+ , hash_multimap_traits
, set_traits
- , hash_set_traits
+ , hash_set_traits
, multiset_traits
, hash_multiset_traits )
-"""tuple of all STD container traits classes"""
-
+"""tuple of all STD container traits classes"""
+
def find_container_traits( cls_or_string ):
if isinstance( cls_or_string, types.StringTypes ):
if not templates.is_instantiation( cls_or_string ):
- return None
+ return None
name = templates.name( cls_or_string )
if name.startswith( 'std::' ):
name = name[ len( 'std::' ): ]
- for cls_traits in container_traits:
+ for cls_traits in container_traits:
if cls_traits.name() == name:
- return cls_traits
+ return cls_traits
else:
- for cls_traits in container_traits:
+ for cls_traits in container_traits:
if cls_traits.is_my_case( cls_or_string ):
return cls_traits
Modified: pygccxml_dev/pygccxml/msvc/pdb/enums.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-04-09 20:52:33 UTC (rev 1308)
+++ pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-04-12 07:52:34 UTC (rev 1309)
@@ -9,19 +9,20 @@
btUInt = 7
btFloat = 8
btBCD = 9
- btBool = 1
- btLong = 1
- btULong = 1
- btCurrency = 2
- btDate = 2
- btVariant = 2
- btComplex = 2
- btBit = 2
- btBSTR = 3
+ btBool = 10
+ btLong = 13
+ btULong = 14
+ btCurrency = 25
+ btDate = 26
+ btVariant = 27
+ btComplex = 28
+ btBit = 29
+ btBSTR = 30
btHresult = 31
+
#Adding code, that was not generated for some reason.
class UdtKind(utils.enum):
UdtStruct, UdtClass, UdtUnion = (0, 1, 2)
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-09 20:52:33 UTC (rev 1308)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-12 07:52:34 UTC (rev 1309)
@@ -1,4 +1,5 @@
import os
+import pdb
import sys
import ctypes
import pprint
@@ -57,11 +58,8 @@
self.__dia_session = self.__dia_source.openSession()
self.logger.debug( 'opening session - done' )
self.__global_ns = declarations.namespace_t( '::' )
+ self.__global_ns.compiler = self.COMPILER
- self.__enums = {}
- self.__classes = {}
- self.__typedefs = {}
-
def __find_table(self, name):
valid_names = ( 'Symbols', 'SourceFiles', 'Sections'
, 'SegmentMap', 'InjectedSource', 'FrameData' )
@@ -72,55 +70,13 @@
else:
return None
- def create_type( self, smbl ):
- if msdia.SymTagBaseType == smbl.symTag:
- if enums.BasicType.btNoType == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btVoid == smbl.baseType:
- return declarations.void_t()
- elif enums.BasicType.btChar == smbl.baseType:
- return declarations.char_t()
- elif enums.BasicType.btWChar == smbl.baseType:
- return declarations.wchar_t()
- elif enums.BasicType.btInt == smbl.baseType:
- return declarations.int_t()
- elif enums.BasicType.btUInt == smbl.baseType:
- return declarations.unsigned_int_t()
- elif enums.BasicType.btFloat == smbl.baseType:
- return declarations.float_t()
- elif enums.BasicType.btBCD == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btBool == smbl.baseType:
- return declarations.bool_t()
- elif enums.BasicType.btLong == smbl.baseType:
- return declarations.long_int_t()
- elif enums.BasicType.btULong == smbl.baseType:
- return declarations.long_unsigned_int_t()
- elif enums.BasicType.btCurrency == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btDate == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btVariant == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btComplex == smbl.baseType:
- return declarations.complex_double_t()
- elif enums.BasicType.btBit == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btBSTR == smbl.baseType:
- return declarations.unknown_t()
- elif enums.BasicType.btHresult == smbl.baseType:
- return declarations.unknown_t()
- else:
- return declarations.unknown_t()
- else:
- return declarations.unknown_t()
-
@utils.cached
def symbols_table(self):
return self.__find_table( "Symbols" )
@utils.cached
def symbols(self):
+ self.logger.info( 'loading symbols from the file' )
smbls = {}
for smbl in itertools.imap( as_symbol, as_enum_variant( self.symbols_table._NewEnum ) ):
smbl.uname = msvc_utils.undecorate_name( smbl.name, msvc_utils.UNDECORATE_NAME_OPTIONS.UNDNAME_SCOPES_ONLY )
@@ -128,6 +84,7 @@
return msvc_utils.undecorate_name( smbl.name, options )
smbl.undecorate_name = smbl_undecorate_name
smbls[ smbl.symIndexId ] = smbl
+ self.logger.info( 'loading symbols(%d) from the file - done', len( smbls ) )
return smbls
def __load_nss(self):
@@ -301,7 +258,19 @@
break
self.logger.info( 'integrating udt objects with namespaces - done' )
+ def __clear_symbols(self):
+ self.logger.info( 'clearing symbols' )
+ to_be_deleted = []
+ for smbl_id, smbl in self.symbols.iteritems():
+ if ( smbl.symTag == msdia.SymTagData and not self.__is_my_var( smbl ) ) \
+ or smbl.symTag in ( msdia.SymTagAnnotation, msdia.SymTagPublicSymbol ):
+ 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 read(self):
+ self.__clear_symbols()
self.__load_nss()
self.__load_classes()
self.__load_enums()
@@ -351,6 +320,7 @@
decl.byte_size = smbl.length
decl.mangled = iif( smbl.name, smbl.name, '' )
decl.demangled = iif( smbl.uname, smbl.uname, '' )
+ decl.is_artificial = bool( smbl.compilerGenerated )
def __load_enums( self ):
is_enum = lambda smbl: smbl.symTag == msdia.SymTagEnum
@@ -394,6 +364,8 @@
#I am only interested in global and class variables
if smbl.symTag != msdia.SymTagData:
return False
+ if not smbl.uname:
+ return False
if smbl.classParentId not in self.symbols:
return True #global scope
parent_smbl = self.symbols[ smbl.classParentId ]
@@ -410,17 +382,71 @@
self.__update_decls_tree( var_decl )
self.logger.info( 'building variable objects(%d) - done', vars_count )
- def __create_var( self, var_smbl ):
- self.logger.debug( 'creating variable "%s"', var_smbl.uname )
- name_splitter = impl_details.get_name_splitter( var_smbl.uname )
- if not name_splitter.name:
- return None
- var_decl = declarations.variable_t( name_splitter.name )
- self.__update_decl( var_decl, var_smbl )
+ def __create_var( self, smbl ):
+ self.logger.debug( 'creating variable "%s"', smbl.uname )
+ name_splitter = impl_details.get_name_splitter( smbl.uname )
+ decl = declarations.variable_t( name_splitter.name )
+ self.__update_decl( decl, smbl )
+ #~ if decl.name == 'initialized':
+ #~ pdb.set_trace()
+ decl.type = self.create_type( smbl.type )
+ decl.value = str(smbl.value)
+ self.logger.debug( 'creating variable "%s" - done', smbl.uname )
+ return decl
- var_decl.type = self.create_type( var_smbl.type )
- self.logger.debug( 'creating variable "%s" - done', var_smbl.uname )
- return var_decl
-
-
-
+ def create_type( self, smbl ):
+ my_type = None
+ if msdia.SymTagBaseType == smbl.symTag:
+ if enums.BasicType.btNoType == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btVoid == smbl.baseType:
+ my_type = declarations.void_t()
+ elif enums.BasicType.btChar == smbl.baseType:
+ my_type = declarations.char_t()
+ elif enums.BasicType.btWChar == smbl.baseType:
+ my_type = declarations.wchar_t()
+ elif enums.BasicType.btInt == smbl.baseType:
+ my_type = declarations.int_t()
+ elif enums.BasicType.btUInt == smbl.baseType:
+ my_type = declarations.unsigned_int_t()
+ elif enums.BasicType.btFloat == smbl.baseType:
+ my_type = declarations.float_t()
+ elif enums.BasicType.btBCD == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btBool == smbl.baseType:
+ my_type = declarations.bool_t()
+ elif enums.BasicType.btLong == smbl.baseType:
+ my_type = declarations.long_int_t()
+ elif enums.BasicType.btULong == smbl.baseType:
+ my_type = declarations.long_unsigned_int_t()
+ elif enums.BasicType.btCurrency == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btDate == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btVariant == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btComplex == smbl.baseType:
+ my_type = declarations.complex_double_t()
+ elif enums.BasicType.btBit == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btBSTR == smbl.baseType:
+ my_type = declarations.unknown_t()
+ elif enums.BasicType.btHresult == smbl.baseType:
+ my_type = declarations.unknown_t()
+ else:
+ my_type = declarations.unknown_t()
+ elif msdia.SymTagArrayType == smbl.symTag:
+ bytes = smbl.length
+ element_type = self.create_type( smbl.arrayIndexType )
+ size = declarations.array_t.SIZE_UNKNOWN
+ if bytes and element_type.byte_size:
+ size = bytes / element_type.byte_size
+ my_type = declarations.array_t( element_type, size )
+ else:
+ my_type = declarations.unknown_t()
+ my_type.byte_size = smbl.length
+ if smbl.constType:
+ my_type = declarations.const_t( my_type )
+ if smbl.volatileType:
+ my_type = declarations.volatile_t( my_type )
+ return my_type
Modified: pygccxml_dev/unittests/data/declarations_variables.hpp
===================================================================
--- pygccxml_dev/unittests/data/declarations_variables.hpp 2008-04-09 20:52:33 UTC (rev 1308)
+++ pygccxml_dev/unittests/data/declarations_variables.hpp 2008-04-12 07:52:34 UTC (rev 1309)
@@ -10,6 +10,8 @@
const long unsigned int initialized = 10122004;
int array[255];
+
+//TODO: explain why such variables is not peeked
extern int static_var;
struct struct_variables_t{
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-09 20:52:33 UTC (rev 1308)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-12 07:52:34 UTC (rev 1309)
@@ -41,6 +41,11 @@
#include "unnamed_ns_bug.hpp"
#include "vector_traits.hpp"
+namespace declarations{ namespace variables{
+
+int static_var = 0;
+}}
+
void use_decls(){
declarations::enums::ENumbers enumbers;
declarations::enums::data::EColor ecolor;
Modified: pygccxml_dev/unittests/declarations_tester.py
===================================================================
--- pygccxml_dev/unittests/declarations_tester.py 2008-04-09 20:52:33 UTC (rev 1308)
+++ pygccxml_dev/unittests/declarations_tester.py 2008-04-12 07:52:34 UTC (rev 1309)
@@ -49,6 +49,8 @@
% ( expected_value, initialized.value ) )
self._test_type_composition( initialized.type, const_t, long_unsigned_int_t )
+ if 'PDB' in self.global_ns.compiler:
+ return #TODO find out work around
static_var = initialized = self.global_ns.variable( name='static_var' )
self.failUnless( static_var.type_qualifiers.has_static
, "static_var must have static type qualifier" )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2008-04-09 20:52:28
|
Revision: 1308
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1308&view=rev
Author: roman_yakovenko
Date: 2008-04-09 13:52:33 -0700 (Wed, 09 Apr 2008)
Log Message:
-----------
adding treatment for variables
Modified Paths:
--------------
pygccxml_dev/pygccxml/msvc/pdb/__init__.py
pygccxml_dev/pygccxml/msvc/pdb/enums.py
pygccxml_dev/pygccxml/msvc/pdb/impl_details.py
pygccxml_dev/pygccxml/msvc/pdb/loader.py
pygccxml_dev/unittests/bsc_tester.py
pygccxml_dev/unittests/data/msvc_build/all.cpp
pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
pygccxml_dev/unittests/pdb_tester.py
Modified: pygccxml_dev/pygccxml/msvc/pdb/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/__init__.py 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/pygccxml/msvc/pdb/__init__.py 2008-04-09 20:52:33 UTC (rev 1308)
@@ -12,12 +12,14 @@
from ... import declarations
from .. import config as msvc_cfg
-comtypes_client_gen_dir = comtypes.client.gen_dir
-try:
- comtypes.client.gen_dir = None
- msdia = comtypes.client.GetModule( msvc_cfg.msdia_path )
-finally:
- comtypes.client.gen_dir = comtypes_client_gen_dir
+msdia = comtypes.client.GetModule( msvc_cfg.msdia_path )
+#~ comtypes_client_gen_dir = comtypes.client.gen_dir
+#~ try:
+ #~ comtypes.client.gen_dir = None
+ #~ msdia = comtypes.client.GetModule( msvc_cfg.msdia_path )
+#~ finally:
+ #~ comtypes.client.gen_dir = comtypes_client_gen_dir
+
from loader import decl_loader_t
Modified: pygccxml_dev/pygccxml/msvc/pdb/enums.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/pygccxml/msvc/pdb/enums.py 2008-04-09 20:52:33 UTC (rev 1308)
@@ -1,11 +1,35 @@
+from ... import utils #import utils from pygccxml package
+
+class BasicType(utils.enum):
+ btNoType = 0
+ btVoid = 1
+ btChar = 2
+ btWChar = 3
+ btInt = 6
+ btUInt = 7
+ btFloat = 8
+ btBCD = 9
+ btBool = 1
+ btLong = 1
+ btULong = 1
+ btCurrency = 2
+ btDate = 2
+ btVariant = 2
+ btComplex = 2
+ btBit = 2
+ btBSTR = 3
+ btHresult = 31
+
+
+
#Adding code, that was not generated for some reason.
-class UdtKind:
+class UdtKind(utils.enum):
UdtStruct, UdtClass, UdtUnion = (0, 1, 2)
-class CV_access_e:
+class CV_access_e(utils.enum):
CV_private, CV_protected, CV_public = (1, 2, 3)
-class NameSearchOptions:
+class NameSearchOptions(utils.enum):
nsNone = 0
nsfCaseSensitive = 0x1
nsfCaseInsensitive = 0x2
Modified: pygccxml_dev/pygccxml/msvc/pdb/impl_details.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/impl_details.py 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/pygccxml/msvc/pdb/impl_details.py 2008-04-09 20:52:33 UTC (rev 1308)
@@ -9,14 +9,6 @@
else:
return declarations.CLASS_TYPES.UNION
-def guess_access_type( access_type ):
- if enums.CV_access_e.CV_private == access_type:
- return declarations.ACCESS_TYPES.PRIVATE
- elif enums.CV_access_e.CV_protected == access_type:
- return declarations.ACCESS_TYPES.PROTECTED
- else:
- return declarations.ACCESS_TYPES.PUBLIC
-
class full_name_splitter_t( object ):
def __init__( self, full_name ):
self.__full_name = full_name
Modified: pygccxml_dev/pygccxml/msvc/pdb/loader.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/pygccxml/msvc/pdb/loader.py 2008-04-09 20:52:33 UTC (rev 1308)
@@ -72,6 +72,49 @@
else:
return None
+ def create_type( self, smbl ):
+ if msdia.SymTagBaseType == smbl.symTag:
+ if enums.BasicType.btNoType == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btVoid == smbl.baseType:
+ return declarations.void_t()
+ elif enums.BasicType.btChar == smbl.baseType:
+ return declarations.char_t()
+ elif enums.BasicType.btWChar == smbl.baseType:
+ return declarations.wchar_t()
+ elif enums.BasicType.btInt == smbl.baseType:
+ return declarations.int_t()
+ elif enums.BasicType.btUInt == smbl.baseType:
+ return declarations.unsigned_int_t()
+ elif enums.BasicType.btFloat == smbl.baseType:
+ return declarations.float_t()
+ elif enums.BasicType.btBCD == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btBool == smbl.baseType:
+ return declarations.bool_t()
+ elif enums.BasicType.btLong == smbl.baseType:
+ return declarations.long_int_t()
+ elif enums.BasicType.btULong == smbl.baseType:
+ return declarations.long_unsigned_int_t()
+ elif enums.BasicType.btCurrency == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btDate == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btVariant == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btComplex == smbl.baseType:
+ return declarations.complex_double_t()
+ elif enums.BasicType.btBit == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btBSTR == smbl.baseType:
+ return declarations.unknown_t()
+ elif enums.BasicType.btHresult == smbl.baseType:
+ return declarations.unknown_t()
+ else:
+ return declarations.unknown_t()
+ else:
+ return declarations.unknown_t()
+
@utils.cached
def symbols_table(self):
return self.__find_table( "Symbols" )
@@ -81,6 +124,9 @@
smbls = {}
for smbl in itertools.imap( as_symbol, as_enum_variant( self.symbols_table._NewEnum ) ):
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
smbls[ smbl.symIndexId ] = smbl
return smbls
@@ -89,24 +135,26 @@
self.logger.debug( '__load_ns.ns_filter, %s', smbl.uname )
tags = ( msdia.SymTagFunction
, msdia.SymTagBlock
- #I should skipp data, because it requier different treatment
- #, msdia.SymTagData
- , msdia.SymTagAnnotation
- , msdia.SymTagPublicSymbol
+ , msdia.SymTagData
+ #~ , msdia.SymTagAnnotation
+ #~ , msdia.SymTagPublicSymbol
, msdia.SymTagUDT
, msdia.SymTagEnum
- , msdia.SymTagFunctionType
- , msdia.SymTagPointerType
+ #~ , msdia.SymTagFunctionType
+ #~ , msdia.SymTagPointerType
, msdia.SymTagArrayType
, msdia.SymTagBaseType
, msdia.SymTagTypedef
, msdia.SymTagBaseClass
, msdia.SymTagFriend
- , msdia.SymTagFunctionArgType
- , msdia.SymTagUsingNamespace )
+ #~ , msdia.SymTagFunctionArgType
+ #~ , msdia.SymTagUsingNamespace
+ )
if smbl.symTag not in tags:
self.logger.debug( 'smbl.symTag not in tags, %s', smbl.uname )
return False
+ elif smbl.symTag == msdia.SymTagData and not self.__is_my_var( smbl ):
+ return False
elif not smbl.name:
self.logger.debug( 'not smbl.name, %s', smbl.uname )
return False
@@ -190,7 +238,7 @@
if isinstance( parent, declarations.namespace_t ):
parent.adopt_declaration( decl )
else:
- parent.adopt_declaration( decl, declarations.ACCESS_TYPES.PUBLIC )
+ parent.adopt_declaration( decl, self.__guess_access_type( smbl ) )
else:
for other_decl in already_added:
for other_smbl in other_decl.dia_symbols:
@@ -201,8 +249,22 @@
if isinstance( parent, declarations.namespace_t ):
parent.adopt_declaration( decl )
else:
- parent.adopt_declaration( decl, declarations.ACCESS_TYPES.PUBLIC )
+ parent.adopt_declaration( decl, self.__guess_access_type( smbl ) )
+ def __guess_access_type( self, smbl ):
+ if enums.CV_access_e.CV_private == smbl.access:
+ return declarations.ACCESS_TYPES.PRIVATE
+ 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:' ):
+ declarations.ACCESS_TYPES.PRIVATE
+ elif fully_undecorated_name.startswith( 'protected:' ):
+ declarations.ACCESS_TYPES.PROTECTED
+ else:
+ return declarations.ACCESS_TYPES.PUBLIC
+
def __load_classes( self ):
classes = {}#unique symbol id : class decl
is_udt = lambda smbl: smbl.symTag == msdia.SymTagUDT
@@ -233,10 +295,9 @@
map( self.__update_decls_tree, to_be_deleted )
map( lambda decl: classes.pop( decl.dia_symbols[0].symIndexId )
, to_be_deleted )
- integrated = to_be_integrated - len( classes )
- if not integrated:
+ if not ( to_be_integrated - len( classes ) ):
for cls in classes.itervalues():
- self.logger.debug( 'unable to integrate class "%s"', cls.dia_symbols[0].uname )
+ self.logger.warning( 'unable to integrate class "%s" into declarations tree', cls.dia_symbols[0].uname )
break
self.logger.info( 'integrating udt objects with namespaces - done' )
@@ -244,6 +305,7 @@
self.__load_nss()
self.__load_classes()
self.__load_enums()
+ self.__load_vars()
@property
def dia_global_scope(self):
@@ -283,6 +345,13 @@
self.logger.debug( 'name( "%s" ) is **NOT** UDT symbol' % name )
return None
+ def __update_decl( self, decl, smbl ):
+ decl.dia_symbols = [smbl]
+ decl.compiler = self.COMPILER
+ decl.byte_size = smbl.length
+ decl.mangled = iif( smbl.name, smbl.name, '' )
+ decl.demangled = iif( smbl.uname, smbl.uname, '' )
+
def __load_enums( self ):
is_enum = lambda smbl: smbl.symTag == msdia.SymTagEnum
self.logger.info( 'building enum objects' )
@@ -295,17 +364,12 @@
self.__update_decls_tree( enum_decl )
self.logger.info( 'building enum objects(%d) - done', enums_count )
- def __update_decl_binary_names( self, decl, smbl ):
- decl.mangled = iif( smbl.name, smbl.name, '' )
- decl.demangled = iif( smbl.uname, smbl.uname, '' )
-
def __create_enum( self, enum_smbl ):
name_splitter = impl_details.get_name_splitter( enum_smbl.uname )
self.logger.debug( 'working on enum %s', enum_smbl.uname )
enum_decl = declarations.enumeration_t( name_splitter.name )
- enum_decl.dia_symbols = [ enum_smbl ]
- enum_decl.byte_size = enum_smbl.length
- self.__update_decl_binary_names( enum_decl, enum_smbl )
+ self.__update_decl( enum_decl, enum_smbl )
+
values = enum_smbl.findChildren( msdia.SymTagData, None, 0 )
for v in itertools.imap(as_symbol, values):
if v.classParent.symIndexId != enum_smbl.symIndexId:
@@ -319,18 +383,44 @@
#between those cases
return None
- def __create_typedef( self, typedef_smbl ):
- name_splitter = impl_details.get_name_splitter( typedef_smbl.name )
- typedef_decl = declarations.typedef_t( name_splitter.name )
- typedef_decl.dia_symbols = [ typedef_smbl.symIndexId ]
- return typedef_decl
-
def __create_class( self, class_smbl ):
name_splitter = impl_details.get_name_splitter( class_smbl.uname )
class_decl = declarations.class_t( name_splitter.name )
- class_decl.compiler = self.COMPILER
- class_decl.dia_symbols = [class_smbl]
+ self.__update_decl( class_decl, class_smbl )
class_decl.class_type = impl_details.guess_class_type(class_smbl.udtKind)
- class_decl.byte_size = class_smbl.length
- self.__update_decl_binary_names( class_decl, class_smbl )
return class_decl
+
+ def __is_my_var( self, smbl ):
+ #I am only interested in global and class variables
+ if smbl.symTag != msdia.SymTagData:
+ return False
+ if smbl.classParentId not in self.symbols:
+ return True #global scope
+ parent_smbl = self.symbols[ smbl.classParentId ]
+ return bool( parent_smbl.symTag == msdia.SymTagUDT )
+
+ def __load_vars( self ):
+ self.logger.info( 'building variable objects' )
+ vars_count = 0
+ for var_smbl in itertools.ifilter( self.__is_my_var, self.symbols.itervalues() ):
+ var_decl = self.__create_var(var_smbl)
+ if not var_decl:
+ continue
+ vars_count += 1
+ self.__update_decls_tree( var_decl )
+ self.logger.info( 'building variable objects(%d) - done', vars_count )
+
+ def __create_var( self, var_smbl ):
+ self.logger.debug( 'creating variable "%s"', var_smbl.uname )
+ name_splitter = impl_details.get_name_splitter( var_smbl.uname )
+ if not name_splitter.name:
+ return None
+ var_decl = declarations.variable_t( name_splitter.name )
+ self.__update_decl( var_decl, var_smbl )
+
+ var_decl.type = self.create_type( var_smbl.type )
+ self.logger.debug( 'creating variable "%s" - done', var_smbl.uname )
+ return var_decl
+
+
+
Modified: pygccxml_dev/unittests/bsc_tester.py
===================================================================
--- pygccxml_dev/unittests/bsc_tester.py 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/unittests/bsc_tester.py 2008-04-09 20:52:33 UTC (rev 1308)
@@ -18,13 +18,13 @@
print 'is_case_sensitive', reader.is_case_sensitive
reader.load_instances()
#reader.files
- #reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
- names = []
- for inst in reader.instances:
- names.append( '{%s}<=====>{%s}' % ( inst.name, inst.mangled_name ) )
- names.sort()
- for name in names:
- print name
+ reader.print_classes( )#r'c:\dev\produce_pdb\produce_pdb.cpp')
+ #~ names = []
+ #~ for inst in reader.instances:
+ #~ names.append( '{%s}<=====>{%s}' % ( inst.name, inst.mangled_name ) )
+ #~ names.sort()
+ #~ for name in names:
+ #~ print name
def create_suite():
suite = unittest.TestSuite()
Modified: pygccxml_dev/unittests/data/msvc_build/all.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/unittests/data/msvc_build/all.cpp 2008-04-09 20:52:33 UTC (rev 1308)
@@ -41,7 +41,7 @@
#include "unnamed_ns_bug.hpp"
#include "vector_traits.hpp"
-void use_decls(){
- declarations::enums::ENumbers enumbers;
- declarations::enums::data::EColor ecolor;
+void use_decls(){
+ declarations::enums::ENumbers enumbers;
+ declarations::enums::data::EColor ecolor;
}
\ No newline at end of file
Modified: pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/unittests/data/msvc_build/msvc_build.vcproj 2008-04-09 20:52:33 UTC (rev 1308)
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- InlineFunctionExpansion="1"
+ InlineFunctionExpansion="0"
AdditionalIncludeDirectories="..\"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
@@ -52,7 +52,7 @@
GenerateXMLDocumentationFiles="true"
BrowseInformation="1"
WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Modified: pygccxml_dev/unittests/pdb_tester.py
===================================================================
--- pygccxml_dev/unittests/pdb_tester.py 2008-04-09 17:10:03 UTC (rev 1307)
+++ pygccxml_dev/unittests/pdb_tester.py 2008-04-09 20:52:33 UTC (rev 1308)
@@ -38,8 +38,12 @@
reader = pdb.decl_loader_t( self.pdb_file )
print reader.symbols_table.name
reader.read()
- #f = file( 'decls.cpp', 'w+' )
- declarations.print_declarations( reader.global_ns )#, writer=f.write )
+ x = []
+ declarations.print_declarations( reader.global_ns, writer=x.append )
+ x = filter( None, map( lambda l: l.rstrip(), x ) )
+ f = file( 'decls.cpp', 'w+' )
+ f.write( os.linesep.join( x ) )
+ f.close()
#~ names = []
#~ for d in reader.global_ns.classes():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|