Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r59980:731ac16e881f
Date: 2013-01-11 15:11 -0800
http://bitbucket.org/pypy/pypy/changeset/731ac16e881f/
Log: allow user steering of entry getting
diff --git a/pypy/module/cppyy/capi/cint_capi.py
b/pypy/module/cppyy/capi/cint_capi.py
--- a/pypy/module/cppyy/capi/cint_capi.py
+++ b/pypy/module/cppyy/capi/cint_capi.py
@@ -188,19 +188,26 @@
if not space.is_true(w_branch):
raise OperationError(space.w_AttributeError, args_w[0])
activate_branch(space, w_branch)
+
+ # figure out from where we're reading
+ entry = space.int_w(space.call_method(w_self, "GetReadEntry"))
+ if entry == -1:
+ entry = 0
+
+ # setup cache structure
w_klassname = space.call_method(w_branch, "GetClassName")
if space.is_true(w_klassname):
# some instance
klass = interp_cppyy.scope_byname(space, space.str_w(w_klassname))
w_obj = klass.construct()
space.call_method(w_branch, "SetObject", w_obj)
- space.call_method(w_branch, "GetEntry", space.wrap(0))
+ space.call_method(w_branch, "GetEntry", space.wrap(entry))
space.setattr(w_self, args_w[0], w_obj)
return w_obj
else:
# builtin data
w_leaf = space.call_method(w_self, "GetLeaf", args_w[0])
- space.call_method(w_branch, "GetEntry", space.wrap(0))
+ space.call_method(w_branch, "GetEntry", space.wrap(entry))
# location
w_address = space.call_method(w_leaf, "GetValuePointer")
diff --git a/pypy/module/cppyy/test/test_cint.py
b/pypy/module/cppyy/test/test_cint.py
--- a/pypy/module/cppyy/test/test_cint.py
+++ b/pypy/module/cppyy/test/test_cint.py
@@ -335,6 +335,7 @@
mytree.Branch("my_bool", ba, "my_bool/O")
mytree.Branch("my_int", ia, "my_int/I")
+ mytree.Branch("my_int2", ia, "my_int2/I")
mytree.Branch("my_double", da, "my_double/D")
for i in range(self.N):
@@ -367,6 +368,21 @@
f.Close()
+ def test09_user_read_builtin(self):
+ """Test user-directed reading of builtins"""
+
+ from cppyy import gbl
+ from cppyy.gbl import TFile
+
+ f = TFile(self.fname)
+ mytree = f.Get(self.tname)
+
+ # note, this is an old, annoted tree from test08
+ for i in range(3, mytree.GetEntriesFast()):
+ mytree.GetEntry(i)
+ assert mytree.my_int == i+1
+ assert mytree.my_int2 == i+1
+
class AppTestRegression:
spaceconfig = dict(usemodules=['cppyy'])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit