def test_pass_opaque_pointer_via_callback(self): eating_callback = self.eating_callback() TP = lltype.Ptr(lltype.GcStruct('X', ('x', lltype.Signed))) struct = lltype.malloc(TP.TO) # gc structure struct.x = 8 def g(i): return get_keepalive_object(i, TP).x pos = register_keepalive(struct) assert _keeper_for_type(TP).stuff_to_keepalive[pos] is struct del struct res = eating_callback(pos, g) unregister_keepalive(pos, TP) assert res == 8
def test_pass_opaque_pointer_via_callback(self): eating_callback = self.eating_callback() TP = lltype.Ptr(lltype.GcStruct('X', ('x', lltype.Signed))) struct = lltype.malloc(TP.TO) # gc structure struct.x = 8 def g(i): return get_keepalive_object(i, TP).x pos = register_keepalive(struct) assert _keeper_for_type(TP).stuff_to_keepalive[pos] is struct del struct res = eating_callback(pos, g) unregister_keepalive(pos, TP) assert res == 8