1. Pypy
  2. Untitled project
  3. pypy

Commits

wlav  committed 731ac16

allow user steering of entry getting

  • Participants
  • Parent commits 99c1280
  • Branches reflex-support

Comments (0)

Files changed (2)

File pypy/module/cppyy/capi/cint_capi.py

View file
     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")

File pypy/module/cppyy/test/test_cint.py

View file
 
         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):
 
         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'])