[pypy-svn] r76234 - pypy/branch/reflex-support/pypy/module/cppyy
wlav at codespeak.net
wlav at codespeak.net
Thu Jul 15 12:28:21 CEST 2010
Author: wlav
Date: Thu Jul 15 12:28:20 2010
New Revision: 76234
Modified:
pypy/branch/reflex-support/pypy/module/cppyy/converter.py
pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
Log:
Improved error reporting when an overload fails.
Modified: pypy/branch/reflex-support/pypy/module/cppyy/converter.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/converter.py (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/converter.py Thu Jul 15 12:28:20 2010
@@ -13,6 +13,14 @@
lltype.free(arg, flavor='raw')
+class VoidConverter(TypeConverter):
+ def __init__(self, space, name):
+ self.name = name
+
+ def convert_argument(self, space, w_obj):
+ raise OperationError(space.w_TypeError,
+ space.wrap('no converter available for type "%s"' % self.name))
+
class BoolConverter(TypeConverter):
def convert_argument(self, space, w_obj):
arg = space.c_int_w(w_obj)
@@ -74,6 +82,7 @@
# 3) accept const ref as by value
# 4) accept ref as pointer
# 5) generalized cases (covers basically all user classes)
+ # 6) void converter, which fails on use
try:
return _converters[name]
@@ -85,7 +94,10 @@
if compound == "*":
return InstancePtrConverter(space, cpptype)
- raise OperationError(space.w_TypeError, space.wrap("no clue what %s is" % name))
+ # return a void converter here, so that the class can be build even
+ # when some types are unknown; this overload will simply fail on use
+ return VoidConverter(space, name)
+
_converters["bool"] = BoolConverter()
_converters["int"] = IntConverter()
Modified: pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py (original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/interp_cppyy.py Thu Jul 15 12:28:20 2010
@@ -189,6 +189,7 @@
@jit.unroll_safe
def call(self, cppthis, args_w):
space = self.space
+ errmsg = 'None of the overloads matched:'
for i in range(len(self.functions)):
cppyyfunc = self.functions[i]
try:
@@ -196,10 +197,11 @@
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
+ errmsg += '\n\t'+str(e)
except KeyError:
pass
- # XXX better error reporting
- raise OperationError(space.w_TypeError, space.wrap("none of the overloads matched"))
+
+ raise OperationError(space.w_TypeError, space.wrap(errmsg))
def __repr__(self):
return "W_CPPOverload(%s, %s)" % (self.func_name, self.functions)
More information about the Pypy-commit
mailing list