Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/typedObjects/utils.js

Issue 6213754488356864: Issue 258 - [Typed objects] Implement a garbage collection mechanism (Closed)
Patch Set: Updated inline documentation Created April 28, 2014, 8:22 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/typedObjects/objectTypes.js ('k') | test/tests/typedObjects.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/typedObjects/utils.js
===================================================================
--- a/lib/typedObjects/utils.js
+++ b/lib/typedObjects/utils.js
@@ -90,19 +90,20 @@ let getViewsForType = exports.getViewsFo
/**
* Defines properties with given name and type on an object.
*
* @param obj object to define properties on
* @param properties object mapping property names to their respective types
* @param viewTypes see getViewsForType()
* @param views see getViewsForType()
* @param [offset] byte array offset at which the properties should start
+ * @param [cleanupValues] array of property/value combinations to be set when the object is created or destroyed
* @return new start offset for additional properties
*/
-exports.defineProperties = function defineProperties(obj, properties, viewTypes, views, offset)
+exports.defineProperties = function defineProperties(obj, properties, viewTypes, views, offset, cleanupValues)
{
offset = offset | 0;
let propList = [];
for (let name in properties)
propList.push([name, properties[name]]);
// Put larger properties first to make sure alignment requirements are met.
@@ -120,15 +121,17 @@ exports.defineProperties = function defi
let viewParams = getViewsForType(type, viewTypes, views);
descriptors[name] = {
get: type.createGetter.apply(type, [offset].concat(viewParams)),
set: type.createSetter.apply(type, [offset].concat(viewParams)),
configurable: false,
enumerable: true
};
offset += type.referenceLength;
+ if (cleanupValues && typeof type.cleanupValue != "undefined")
+ cleanupValues.push([name, type.cleanupValue]);
}
// Define properties
Object.defineProperties(obj, descriptors);
return offset;
};
« no previous file with comments | « lib/typedObjects/objectTypes.js ('k') | test/tests/typedObjects.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld