[pygccxml-commit] SF.net SVN: pygccxml:[1490] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-12-23 20:54:53
|
Revision: 1490
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1490&view=rev
Author: roman_yakovenko
Date: 2008-12-23 20:54:48 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
adding few new test cases to test MSVC & GCCXML name mangling interoperability
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/cpptypes.py
pygccxml_dev/pygccxml/msvc/common_utils.py
pygccxml_dev/unittests/data/msvc/mydll.90.vcproj
pygccxml_dev/unittests/data/msvc/mydll.cpp
pygccxml_dev/unittests/data/msvc/mydll.h
pygccxml_dev/unittests/undname_creator_tester.py
Property Changed:
----------------
pygccxml_dev/unittests/data/
Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2008-12-23 20:54:48 UTC (rev 1490)
@@ -373,7 +373,7 @@
compound_t.__init__( self, base)
def build_decl_string(self, with_defaults=True):
- return 'volatile ' + self.base.build_decl_string(with_defaults)
+ return self.base.build_decl_string(with_defaults) + ' volatile'
def _clone_impl( self ):
return volatile_t( self.base.clone() )
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-23 20:54:48 UTC (rev 1490)
@@ -79,6 +79,12 @@
__undname = ctypes.windll.dbghelp.UnDecorateSymbolName
__undname.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint]
__clean_ecsu = re.compile( r'(?:(^|\W))(?:(class|enum|struct|union))' )
+ __fundamental_types = (
+ ( 'short unsigned int', 'unsigned short')
+ , ( 'short int', 'short' )
+ , ( 'long int', 'long' )
+ , ( 'long unsigned int', 'unsigned long' )
+ )
def undecorate_blob( self, name, options=None ):
if options is None:
@@ -99,17 +105,30 @@
else:
return s
- def __format_type_as_undecorated( self, type_ ):
+ def __format_type_as_undecorated( self, type_, is_argument ):
result = []
type_ = declarations.remove_alias( type_ )
- result.append( self.__remove_leading_scope( type_.decl_string ) )
+ if declarations.is_array( type_ ):
+ result.append( declarations.array_item_type( type_ ).decl_string )
+ result.append( '*' )
+ if is_argument:
+ result.append( 'const' )
+ else:
+ result.append( self.__remove_leading_scope( type_.decl_string ) )
return ' '.join( result )
+ def __normalize( self, name ):
+ for what, with_ in self.__fundamental_types:
+ name = name.replace( what, with_ )
+ name = name.replace( ', ', ',' )
+ return name
+
def __format_args_as_undecorated( self, argtypes ):
if not argtypes:
return 'void'
else:
- return ','.join( map( self.__format_type_as_undecorated, argtypes ) )
+ formater = lambda type_: self.__format_type_as_undecorated( type_, True )
+ return ','.join( map( formater, argtypes ) )
def __undecorated_calldef( self, calldef ):
calldef_type = calldef.function_type()
@@ -118,8 +137,10 @@
is_mem_fun = isinstance( calldef, declarations.member_calldef_t )
if is_mem_fun and calldef.virtuality != declarations.VIRTUALITY_TYPES.NOT_VIRTUAL:
result.append( 'virtual ' )
+ if is_mem_fun and calldef.has_static:
+ result.append( 'static ' )
if calldef_type.return_type:
- result.append( self.__format_type_as_undecorated( calldef.return_type ) )
+ result.append( self.__format_type_as_undecorated( calldef.return_type, False ) )
result.append( ' ' )
if is_mem_fun:
result.append( self.__remove_leading_scope( calldef.parent.decl_string ) + '::')
@@ -136,11 +157,12 @@
def __undecorated_variable( self, decl ):
result = []
- if decl.type_qualifiers.has_static:
+ is_mem_var = isinstance( decl.parent, declarations.class_t )
+ if is_mem_var and decl.type_qualifiers.has_static:
result.append( 'static ' )
- result.append( self.__format_type_as_undecorated( decl.type ) )
+ result.append( self.__format_type_as_undecorated( decl.type, False ) )
result.append( ' ' )
- if isinstance( decl.parent, declarations.class_t ):
+ if is_mem_var:
result.append( self.__remove_leading_scope( decl.parent.decl_string ) + '::' )
result.append( decl.name )
return ''.join( result )
@@ -150,13 +172,16 @@
result of dbghelp.UnDecorateSymbolName, with UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_ECSU
options.
"""
+ name = None
if isinstance( decl, declarations.calldef_t ):
- return self.__undecorated_calldef( decl )
+ name = self.__undecorated_calldef( decl )
elif isinstance( decl, declarations.variable_t ):
- return self.__undecorated_variable( decl )
+ name = self.__undecorated_variable( decl )
else:
raise NotImplementedError()
+ return self.__normalize( name )
+
undecorate_blob = undname_creator().undecorate_blob
undecorate_decl = undname_creator().undecorated_decl
@@ -179,6 +204,15 @@
result[ found.group( 'decorated' ) ] = found.group( 'undecorated' )
return result
+ @staticmethod
+ def load_from_dll_file( fname ):
+ import get_exports
+ result = {}
+ blobs = get_exports.read_export_table( fname )
+ for blob in blobs:
+ result[ blob ] = undecorate_blob( blob )
+ return result
+
#~ quick & dirty test
#~ symbols = exported_symbols.load_from_map_file( r'D:\dev\language-binding\sources\pygccxml_dev\unittests\data\msvc\Release\mydll.map' )
#~ for decorated, undecorated in symbols.iteritems():
Property changes on: pygccxml_dev/unittests/data
___________________________________________________________________
Modified: svn:ignore
- *.cache
+ *.cache
*.bak
Modified: pygccxml_dev/unittests/data/msvc/mydll.90.vcproj
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.90.vcproj 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/data/msvc/mydll.90.vcproj 2008-12-23 20:54:48 UTC (rev 1490)
@@ -45,7 +45,7 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
- UsePrecompiledHeader="2"
+ UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
@@ -118,6 +118,7 @@
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
+ AssemblerOutput="4"
BrowseInformation="1"
WarningLevel="3"
DebugInformationFormat="3"
Modified: pygccxml_dev/unittests/data/msvc/mydll.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-23 20:54:48 UTC (rev 1490)
@@ -51,6 +51,36 @@
void* get_pvoid(void*){ return 0;}
void** get_ppvoid(void){return 0;}
+int FA10_i_i(int a[10]){ return 0;}
+int FPi_i(int *a){ return 0;}
+int Fc_i(char bar){ return 0;}
+int Ff_i(float bar){ return 0;}
+int Fg_i(double bar){ return 0;}
+int Fi_i(int bar){ return 0;}
+int Fie_i(int bar, ...){ return 0;}
+int Fii_i(int bar, int goo){ return 0;}
+int Fiii_i(int bar, int goo, int hoo){ return 0;}
+void Fmxmx_v(myclass_t arg1, X arg2, myclass_t arg3, X arg4){}
+void Fmyclass_v(myclass_t m){}
+
+const int Fv_Ci(void){ return 0;}
+long double Fv_Lg(void){ return 0.0;}
+int& Fv_Ri(void){ return my_global_int;}
+signed char Fv_Sc(void){ return 0;}
+unsigned char Fv_Uc(void){ return 0;}
+unsigned int Fv_Ui(void){ return 0;}
+unsigned long Fv_Ul(void){ return 0;}
+unsigned short Fv_Us(void){ return 0;}
+volatile int Fv_Vi(void){ return 0;}
+char Fv_c(void){ return 0;}
+float Fv_f(void){ return 0.0;}
+double Fv_g(void){ return 0.0;}
+int Fv_i(void){ return 0;}
+long Fv_l(void){ return 0;}
+short Fv_s(void){ return 0;}
+void Fv_v(void){ return;}
+
+
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
@@ -69,42 +99,6 @@
/*
-static int myclass::myStaticMember
-const int myclass::myconstStaticMember
-volatile int myclass::myvolatileStaticMember
-x myfnptr;
-int myglobal;
-volatile int myvolatile;
-int myarray[10];
-void **Fv_PPv(void)
-void *Fv_Pv(void)
-int FA10_i_i(int a[10])
-int FPi_i(int *a)
-int Fc_i(char bar)
-int Ff_i(float bar)
-int Fg_i(double bar)
-int Fi_i(int bar)
-int Fie_i(int bar, ...)
-int Fii_i(int bar, int goo)
-int Fiii_i(int bar, int goo, int hoo)
-void Fmxmx_v(myclass arg1, x arg2, myclass arg3, x arg4)
-void Fmyclass_v(myclass m)
-const int Fv_Ci(void)
-long double Fv_Lg(void)
-int& Fv_Ri(void)
-signed char Fv_Sc(void)
-unsigned char Fv_Uc(void)
-unsigned int Fv_Ui(void)
-unsigned long Fv_Ul(void)
-unsigned short Fv_Us(void)
-volatile int Fv_Vi(void)
-char Fv_c(void)
-float Fv_f(void)
-double Fv_g(void)
-int Fv_i(void)
-long Fv_l(void)
-short Fv_s(void)
-void Fv_v(void)
void __cdecl Fv_v_cdecl(void)
void __fastcall Fv_v_fastcall(void)
void __stdcall Fv_v_stdcall(void)
@@ -114,25 +108,8 @@
int Fxxi_i(x fnptr, x fnptr2, x fnptr3, int i)
int Fxxx_i(x fnptr, x fnptr2, x fnptr3)
int Fxyxy_i(x fnptr, y fnptr2, x fnptr3, y fnptr4)
-void myclass::operator delete(void *p)
-int myclass::Fi_i(int bar)
-static int myclass::Fis_i(int bar)
void __cdecl myclass::Fv_v_cdecl(void)
void __fastcall myclass::Fv_v_fastcall(void)
void __stdcall myclass::Fv_v_stdcall(void)
-myclass::myclass(int x)
-myclass::myclass(void)
-int myclass::nested::Fi_i(int bar)
-myclass::nested::nested(void)
-myclass::nested::~nested()
-myclass myclass::operator+(int x)
-myclass myclass::operator++()
-myclass myclass::operator++(int)
-myclass& myclass::operator=(const myclass& from)
-myclass::~myclass()
-int nested::Fi_i(int bar)
-nested::nested(void)
-nested::~nested()
void* myclass::operator new(size_t size)
*/
-
Modified: pygccxml_dev/unittests/data/msvc/mydll.h
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-23 20:54:48 UTC (rev 1490)
@@ -1,8 +1,9 @@
#pragma once
#include <memory>
+#include <string>
+#include <vector>
-
class __declspec(dllexport) number_t{
public:
number_t();
@@ -41,11 +42,65 @@
class __declspec(dllexport) myclass_t{
public:
+ myclass_t(int x){}
+ myclass_t(void){}
+ virtual ~myclass_t(){}
static int my_static_member;
static const int my_const_static_member;
volatile int my_volatile_member;
do_smth_type* get_do_smth(){ return 0; }
void set_do_smth(do_smth_type*){};
-
-};
\ No newline at end of file
+
+ int Fi_i(int bar){ return 0; }
+ static int Fis_i(int bar){ return 0; }
+
+ myclass_t operator+(int x){ return myclass_t(); }
+ myclass_t operator++(){ return myclass_t(); }
+ myclass_t operator++(int){ return myclass_t(); }
+ myclass_t& operator=(const myclass_t& from){ return *this;}
+
+ struct nested{
+ nested(){}
+ ~nested(){}
+ int Fi_i(int bar){ return 0;}
+ };
+
+ typedef std::vector< std::wstring > wstring_collection_t;
+
+ wstring_collection_t create_wstring_collection(){ return wstring_collection_t(); }
+ void fill_wstring_collection( wstring_collection_t& ){};
+ void print__wstring_collection( const wstring_collection_t& ){}
+
+
+};
+
+struct __declspec(dllexport) X{};
+
+__declspec(dllexport) int FA10_i_i(int a[10]);
+__declspec(dllexport) int FPi_i(int *a);
+__declspec(dllexport) int Fc_i(char bar);
+__declspec(dllexport) int Ff_i(float bar);
+__declspec(dllexport) int Fg_i(double bar);
+__declspec(dllexport) int Fi_i(int bar);
+__declspec(dllexport) int Fie_i(int bar, ...);
+__declspec(dllexport) int Fii_i(int bar, int goo);
+__declspec(dllexport) int Fiii_i(int bar, int goo, int hoo);
+__declspec(dllexport) void Fmxmx_v(myclass_t arg1, X arg2, myclass_t arg3, X arg4);
+__declspec(dllexport) void Fmyclass_v(myclass_t m);
+__declspec(dllexport) const int Fv_Ci(void);
+__declspec(dllexport) long double Fv_Lg(void);
+__declspec(dllexport) int& Fv_Ri(void);
+__declspec(dllexport) signed char Fv_Sc(void);
+__declspec(dllexport) unsigned char Fv_Uc(void);
+__declspec(dllexport) unsigned int Fv_Ui(void);
+__declspec(dllexport) unsigned long Fv_Ul(void);
+__declspec(dllexport) unsigned short Fv_Us(void);
+__declspec(dllexport) volatile int Fv_Vi(void);
+__declspec(dllexport) char Fv_c(void);
+__declspec(dllexport) float Fv_f(void);
+__declspec(dllexport) double Fv_g(void);
+__declspec(dllexport) int Fv_i(void);
+__declspec(dllexport) long Fv_l(void);
+__declspec(dllexport) short Fv_s(void);
+__declspec(dllexport) void Fv_v(void);
Modified: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 20:45:17 UTC (rev 1489)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-23 20:54:48 UTC (rev 1490)
@@ -19,6 +19,14 @@
global_ns = None
+ known_issues = set([
+ #pointer to functions
+ 'void (** myclass_t::get_do_smth(void))(std::auto_ptr<number_t> &)'
+ , 'void myclass_t::set_do_smth(void (**)(std::auto_ptr<number_t> &))'
+ # array as function argument
+ , 'int FA10_i_i(int * const)'
+ ])
+
def __init__(self, *args ):
parser_test_case.parser_test_case_t.__init__( self, *args )
self.header = r'msvc\mydll.h'
@@ -38,11 +46,7 @@
else:
return False
-
- def test( self ):
- map_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.map' )
- symbols = msvc.exported_symbols.load_from_map_file( map_file )
-
+ def __tester_impl( self, symbols ):
undecorated_blob_names = set()
for blob in symbols.iterkeys():
undname = msvc.undecorate_blob( blob )
@@ -60,17 +64,29 @@
undecorated_decl_names.difference_update(common)
undecorated_blob_names.difference_update(common)
+ if undecorated_blob_names != self.known_issues:
+ undecorated_blob_names.difference_update( self.known_issues )
+ msg = [ "undecorate_decl - failed" ]
+ msg.append( "undecorated_decl_names :" )
+ for i in undecorated_decl_names:
+ msg.append( '\t==>%s<==' % i )
+ msg.append( "undecorated_blob_names :" )
+ for i in undecorated_blob_names:
+ msg.append( '\t==>%s<==' % i )
- msg = [ "undecorate_decl - failed" ]
- msg.append( "undecorated_decl_names :" )
- for i in undecorated_decl_names:
- msg.append( '\t==>%s<==' % i )
- msg.append( "undecorated_blob_names :" )
- for i in undecorated_blob_names:
- msg.append( '\t==>%s<==' % i )
+ self.fail( os.linesep.join(msg) )
- self.fail( os.linesep.join(msg) )
+ def test_map_file( self ):
+ map_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.map' )
+ symbols = msvc.exported_symbols.load_from_map_file( map_file )
+ self.__tester_impl( symbols )
+
+ def test_dll_file( self ):
+ dll_file = os.path.join( autoconfig.data_directory, 'msvc', 'release', 'mydll.dll' )
+ symbols = msvc.exported_symbols.load_from_dll_file( dll_file )
+ self.__tester_impl( symbols )
+
def create_suite():
suite = unittest.TestSuite()
if 'win' in sys.platform:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|