1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# Copyright 2013 The Chromium Authors. All rights reserved. 2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# found in the LICENSE file. 4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)class RetainingEdge(object): 6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) """Data structure for representing a retainer relationship between objects. 7d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) Attributes: 9d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) from_object_id: int, id of the object which is the start point of this 10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) RetainingEdge. Used when the corresponding LiveHeapObject object is not 11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) yet contstructed. 12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) to_object_id: int, id of the object which is the end point of this 13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) RetainingEdge. Used when the corresponding LiveHeapObject object is not 14d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) yet contstructed. 15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) from_object: LiveHeapObject, the start point of this RetainingEdge. 16d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) to_object: LiveHeapObject, the end point of this RetainingEdge. 17d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) type_string: str, the type of the RetainingEdge. 18d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) name_string: str, the JavaScript attribute name this RetainingEdge 19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) represents. 20d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) """ 21d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 22d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) def __init__(self, from_object_id, to_object_id, type_string, name_string): 23d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) """Initializes the RetainingEdge object. 24d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 25d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) Args: 26d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) from_object_id: int, id of the object which is the start point of this 27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) RetainingEdge. Used when the corresponding LiveHeapObject object is 28d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) not yet contstructed. 29d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) to_object_id: int, id of the object which is the end point of this 30d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) RetainingEdge. Used when the corresponding LiveHeapObject object is 31d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) not yet contstructed. 32d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) type_string: str, the type of the RetainingEdge. 33d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) name_string: str, the JavaScript attribute name this RetainingEdge 34d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) represents. 35d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) """ 36d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.from_object_id = from_object_id 37d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.to_object_id = to_object_id 38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.from_object = {} 39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.to_object = {} 40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.type_string = type_string 41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.name_string = name_string 42d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 43d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) def SetFromObject(self, obj): 44d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.from_object = obj 45d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return self 46d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 47d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) def SetToObject(self, obj): 48d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) self.to_object = obj 49d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return self 50d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 51d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) def __str__(self): 52d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) return 'RetainingEdge(' + self.type_string + ' ' + self.name_string + ')' 53