Ejemplo n.º 1
0
def get_objects(space):
    """Return a list of all app-level objects."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = do_get_objects()
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 2
0
def get_objects(space):
    """Return a list of all app-level objects."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = do_get_objects()
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 3
0
def get_referrers(space, args_w):
    """Return the list of objects that directly refer to any of objs."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = []
    for w_arg in args_w:
        result_w += do_get_referrers(w_arg)
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 4
0
def get_referrers(space, args_w):
    """Return the list of objects that directly refer to any of objs."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = []
    for w_arg in args_w:
        result_w += do_get_referrers(w_arg)
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 5
0
def get_referents(space, args_w):
    """Return a list of objects directly referred to by any of the arguments.
    """
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = []
    for w_obj in args_w:
        gcref = rgc.cast_instance_to_gcref(w_obj)
        _list_w_obj_referents(gcref, result_w)
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 6
0
def get_referents(space, args_w):
    """Return a list of objects directly referred to by any of the arguments.
    """
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = []
    for w_obj in args_w:
        gcref = rgc.cast_instance_to_gcref(w_obj)
        _list_w_obj_referents(gcref, result_w)
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 7
0
 def fn():
     a2 = A()
     if not rgc.has_gcflag_extra():
         return  # cannot test it then
     assert rgc.get_gcflag_extra(a1) == False
     assert rgc.get_gcflag_extra(a2) == False
     rgc.toggle_gcflag_extra(a1)
     assert rgc.get_gcflag_extra(a1) == True
     assert rgc.get_gcflag_extra(a2) == False
     rgc.toggle_gcflag_extra(a2)
     assert rgc.get_gcflag_extra(a1) == True
     assert rgc.get_gcflag_extra(a2) == True
     rgc.toggle_gcflag_extra(a1)
     assert rgc.get_gcflag_extra(a1) == False
     assert rgc.get_gcflag_extra(a2) == True
     rgc.toggle_gcflag_extra(a2)
     assert rgc.get_gcflag_extra(a1) == False
     assert rgc.get_gcflag_extra(a2) == False
Ejemplo n.º 8
0
 def fn():
     a2 = A()
     if not rgc.has_gcflag_extra():
         return     # cannot test it then
     assert rgc.get_gcflag_extra(a1) == False
     assert rgc.get_gcflag_extra(a2) == False
     rgc.toggle_gcflag_extra(a1)
     assert rgc.get_gcflag_extra(a1) == True
     assert rgc.get_gcflag_extra(a2) == False
     rgc.toggle_gcflag_extra(a2)
     assert rgc.get_gcflag_extra(a1) == True
     assert rgc.get_gcflag_extra(a2) == True
     rgc.toggle_gcflag_extra(a1)
     assert rgc.get_gcflag_extra(a1) == False
     assert rgc.get_gcflag_extra(a2) == True
     rgc.toggle_gcflag_extra(a2)
     assert rgc.get_gcflag_extra(a1) == False
     assert rgc.get_gcflag_extra(a2) == False
Ejemplo n.º 9
0
def get_referrers(space, args_w):
    """Return the list of objects that directly refer to any of objs."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    # xxx uses a lot of memory to make the list of all W_Root objects,
    # but it's simpler this way and more correct than the previous
    # version of this code (issue #2612).  It is potentially very slow
    # because each of the n calls to _list_w_obj_referents() could take
    # O(n) time as well, in theory, but I hope in practice the whole
    # thing takes much less than O(n^2).  We could re-add an algorithm
    # that visits most objects only once, if needed...
    all_objects_w = rgc.do_get_objects(try_cast_gcref_to_w_root)
    result_w = []
    for w_obj in all_objects_w:
        refs_w = []
        gcref = rgc.cast_instance_to_gcref(w_obj)
        _list_w_obj_referents(gcref, refs_w)
        for w_arg in args_w:
            if w_arg in refs_w:
                result_w.append(w_obj)
    rgc.assert_no_more_gcflags()
    return space.newlist(result_w)
Ejemplo n.º 10
0
def get_objects(space):
    """Return a list of all app-level objects."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = rgc.do_get_objects(try_cast_gcref_to_w_root)
    return space.newlist(result_w)
Ejemplo n.º 11
0
def get_objects(space):
    """Return a list of all app-level objects."""
    if not rgc.has_gcflag_extra():
        raise missing_operation(space)
    result_w = rgc.do_get_objects(try_cast_gcref_to_w_root)
    return space.newlist(result_w)