Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r56020:1fc72bdb1387
Date: 2012-07-09 16:25 -0700
http://bitbucket.org/pypy/pypy/changeset/1fc72bdb1387/
Log: fix (mainly for CINT) to handle __setitem__/__getitem__ ambiguity
diff --git a/pypy/module/cppyy/executor.py b/pypy/module/cppyy/executor.py
--- a/pypy/module/cppyy/executor.py
+++ b/pypy/module/cppyy/executor.py
@@ -390,7 +390,7 @@
pass
compound = helper.compound(name)
- clean_name = helper.clean_type(name)
+ clean_name = capi.c_resolve_name(helper.clean_type(name))
# 1a) clean lookup
try:
diff --git a/pypy/module/cppyy/interp_cppyy.py
b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -460,6 +460,16 @@
capi.c_method_result_type(self, idx))
cppmethod = self._make_cppfunction(pyname, idx)
methods_temp.setdefault(pyname, []).append(cppmethod)
+ # the following covers the case where the only kind of operator[](idx)
+ # returns are the ones that produce non-const references; these can be
+ # used for __getitem__ just as much as for __setitem__, though
+ if not "__getitem__" in methods_temp:
+ try:
+ for m in methods_temp["__setitem__"]:
+ cppmethod = self._make_cppfunction("__getitem__", m.index)
+ methods_temp.setdefault("__getitem__",
[]).append(cppmethod)
+ except KeyError:
+ pass # just means there's no __setitem__ either
for pyname, methods in methods_temp.iteritems():
overload = W_CPPOverload(self.space, self, methods[:])
self.methods[pyname] = overload
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit