[pygccxml-commit] SF.net SVN: pygccxml:[1509] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-12-28 12:09:53
|
Revision: 1509
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1509&view=rev
Author: roman_yakovenko
Date: 2008-12-28 12:09:49 +0000 (Sun, 28 Dec 2008)
Log Message:
-----------
add handling for "C" functions
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/algorithm.py
pygccxml_dev/pygccxml/msvc/common_utils.py
pygccxml_dev/unittests/data/msvc/mydll.cpp
pygccxml_dev/unittests/data/msvc/mydll.h
pygccxml_dev/unittests/undname_creator_tester.py
Modified: pygccxml_dev/pygccxml/declarations/algorithm.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/algorithm.py 2008-12-27 21:16:17 UTC (rev 1508)
+++ pygccxml_dev/pygccxml/declarations/algorithm.py 2008-12-28 12:09:49 UTC (rev 1509)
@@ -331,4 +331,4 @@
fname = 'visit_' + decl_inst.__class__.__name__[:-2] #removing '_t' from class name
if not hasattr(visitor, fname ):
raise visit_function_has_not_been_found_t( visitor, decl_inst )
- getattr( visitor, fname )()
+ return getattr( visitor, fname )()
Modified: pygccxml_dev/pygccxml/msvc/common_utils.py
===================================================================
--- pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-27 21:16:17 UTC (rev 1508)
+++ pygccxml_dev/pygccxml/msvc/common_utils.py 2008-12-28 12:09:49 UTC (rev 1509)
@@ -199,22 +199,38 @@
exceptions.UserWarning.__init__( self, *args, **keywd )
class exported_symbols:
- map_file_re = re.compile( r' +\d+ (?P<decorated>.+?) \((?P<undecorated>.+)\)$' )
+ map_file_re_c = re.compile( r' +\d+ (?P<internall>.+?)(?:\s+exported name\:\s(?P<name>.*)$)')
+ map_file_re_cpp = re.compile( r' +\d+ (?P<decorated>.+?) \((?P<undecorated>.+)\)$' )
+
@staticmethod
def load_from_map_file( fname ):
"""returns dictionary { decorated symbol : orignal declaration name }"""
result = {}
f = open( fname )
- exports_started = False
+ lines = []
+ was_exports = False
for line in f:
- if not exports_started:
- exports_started = bool( 'Exports' == line.strip() )
- if not exports_started:
- continue
- line = line.rstrip()
- found = exported_symbols.map_file_re.match( line )
+ if was_exports:
+ lines.append( line )
+ elif 'Exports' == line.strip():
+ was_exports = True
+ else:
+ pass
+ index = 0
+ while index < len( lines ):
+ line = lines[index].rstrip()
+ found = exported_symbols.map_file_re_cpp.match( line )
if found:
result[ found.group( 'decorated' ) ] = found.group( 'undecorated' )
+ elif index + 1 < len( lines ):
+ two_lines = line + lines[index+1].rstrip()
+ found = exported_symbols.map_file_re_c.match( two_lines )
+ if found:
+ result[ found.group( 'name' ) ] = found.group( 'name' )
+ index += 1
+ else:
+ pass
+ index += 1
return result
@staticmethod
@@ -244,3 +260,7 @@
else:
raise RuntimeError( "Don't know how to read exported symbols from file '%s'"
% fname )
+
+ @staticmethod
+ def is_c_function( decl, blob, undecorated_blob ):
+ return decl.name == blob == undecorated_blob
Modified: pygccxml_dev/unittests/data/msvc/mydll.cpp
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-27 21:16:17 UTC (rev 1508)
+++ pygccxml_dev/unittests/data/msvc/mydll.cpp 2008-12-28 12:09:49 UTC (rev 1509)
@@ -97,6 +97,9 @@
return TRUE;
}
+int identity( int i){
+ return i;
+}
/*
void __cdecl Fv_v_cdecl(void)
Modified: pygccxml_dev/unittests/data/msvc/mydll.h
===================================================================
--- pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-27 21:16:17 UTC (rev 1508)
+++ pygccxml_dev/unittests/data/msvc/mydll.h 2008-12-28 12:09:49 UTC (rev 1509)
@@ -104,3 +104,7 @@
__declspec(dllexport) long Fv_l(void);
__declspec(dllexport) short Fv_s(void);
__declspec(dllexport) void Fv_v(void);
+
+extern "C"{
+ int __declspec(dllexport) identity( int );
+}
\ No newline at end of file
Modified: pygccxml_dev/unittests/undname_creator_tester.py
===================================================================
--- pygccxml_dev/unittests/undname_creator_tester.py 2008-12-27 21:16:17 UTC (rev 1508)
+++ pygccxml_dev/unittests/undname_creator_tester.py 2008-12-28 12:09:49 UTC (rev 1509)
@@ -15,6 +15,8 @@
from pygccxml import parser
from pygccxml import declarations
+print msvc.undecorate_blob( '?make_flatten@algorithms@reflection@engine_objects@@YAXAEBVinstance_info_t@23@V?$back_insert_iterator@V?$vector@Vinstance_info_t@reflection@engine_objects@@V?$allocator@Vinstance_info_t@reflection@engine_objects@@@std@@@std@@@std@@@Z' )
+
class tester_t( parser_test_case.parser_test_case_t ):
global_ns = None
@@ -50,6 +52,7 @@
def __tester_impl( self, fname ):
symbols = msvc.exported_symbols.load_from_file( fname )
+ self.failUnless( 'identity' in symbols )
undecorated_blob_names = set()
for blob in symbols.iterkeys():
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|