Update of /cvsroot/pygccxml/source/pyplusplus/experimental
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21842
Modified Files:
pypp_api.py
Log Message:
Extended the check for missing policies by a 'sanity check' that reports functions that probably won't work in Python (functions that take pointer or reference args to fundamental C++ types)
Index: pypp_api.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/pypp_api.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** pypp_api.py 28 Mar 2006 12:13:24 -0000 1.13
--- pypp_api.py 6 Apr 2006 09:25:38 -0000 1.14
***************
*** 407,418 ****
# Check for missing policies...
if self.mVerbose:
! print "Checking policies..."
creators = code_creators.make_flatten(self.mExtModule)
fmfunctions = filter(lambda creator: isinstance(creator, code_creators.function_t), creators)
missing_flag = False
for creator in fmfunctions:
if not creator.call_policies:
print "Missing policy:", declarations.full_name(creator.declaration)
missing_flag = True
if missing_flag:
print "*** Aborting because of missing policies!"
--- 407,426 ----
# Check for missing policies...
if self.mVerbose:
! print "Sanity check..."
creators = code_creators.make_flatten(self.mExtModule)
fmfunctions = filter(lambda creator: isinstance(creator, code_creators.function_t), creators)
missing_flag = False
+ sanity_failed = []
for creator in fmfunctions:
if not creator.call_policies:
print "Missing policy:", declarations.full_name(creator.declaration)
missing_flag = True
+ if not self._declSanityCheck(creator.declaration):
+ sanity_failed.append(creator.declaration)
+ if len(sanity_failed)>0:
+ print "***Warning*** The following %d declarations may produce code that compiles, but"%len(sanity_failed)
+ print "that does not have the desired effect in Python:"
+ for decl in sanity_failed:
+ print " ",decl
if missing_flag:
print "*** Aborting because of missing policies!"
***************
*** 536,539 ****
--- 544,562 ----
return content
+ # _declSanityCheck
+ def _declSanityCheck(self, decl):
+ """Check if a declaration will produce code that won't work in Python.
+ """
+ # Check if there's a pointer or reference to a fundamental type among the args...
+ args = getattr(decl, "arguments")
+ for arg in args:
+ t = arg.type
+ if isinstance(t, declarations.pointer_t) or isinstance(t, declarations.array_t) or isinstance(t, declarations.reference_t):
+ if isinstance(t.base, declarations.fundamental_t) and not (isinstance(t.base, declarations.char_t) or isinstance(t.base, declarations.unsigned_char_t)):
+ return False
+
+ return True
+
+
# _time2str
def _time2str(self, t):
|