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

Unified Diff: lib/typedObjects/references.js

Issue 5656302898380800: Issue 260 - [Typed objects] Implement type inheritance (Closed)
Patch Set: Renamed isinstance to isInstance Created May 2, 2014, 7:13 p.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') | lib/typedObjects/utils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/typedObjects/references.js
===================================================================
--- a/lib/typedObjects/references.js
+++ b/lib/typedObjects/references.js
@@ -16,45 +16,46 @@
*/
"use strict";
let {nextPow2, defineProperties} = require("typedObjects/utils");
let {uint16, int16, uint32} = require("typedObjects/primitiveTypes");
let {fixedPropertyDescriptor} = require("typedObjects/utils");
-function calculateSize(propList)
+function calculateSize(properties)
{
let result = 0;
- for (let i = 0, l = propList.length | 0; i < l; i++)
- result += propList[i][1].referenceLength;
- return nextPow2(result);
+ for (let name in properties)
+ result += properties[name].referenceLength | 0;
+ return nextPow2(result) | 0;
}
-function getViewTypes(propList)
+function getViewTypes(properties)
{
let result = [];
- for (let i = 0, l = propList.length | 0; i < l; i++)
+ for (let name in properties)
{
- let requiredViews = propList[i][1].viewTypes;
- for (let j = 0, ll = requiredViews.length | 0; j < ll; j++)
- if (result.indexOf(requiredViews[j]) < 0)
- result.push(requiredViews[j]);
+ let requiredViews = properties[name].viewTypes;
+ for (let i = 0, l = requiredViews.length | 0; i < l; i++)
+ if (result.indexOf(requiredViews[i]) < 0)
+ result.push(requiredViews[i]);
}
return result;
}
-let TypedReference_properties = [
- ["targetBufferIndex", int16],
- ["targetByteOffset", uint32]
-];
+let TypedReference_properties = {
+ targetBufferIndex: int16,
+ targetByteOffset: uint32
+};
-let Reference_properties = [
- ["typeId", int16]
-].concat(TypedReference_properties);
+let Reference_properties = {
+ __proto__: TypedReference_properties,
+ typeId: int16
+};
/**
* Helper class to read/write properties referencing other objects. bufferIndex
* and byteOffset properties of the reference need to be set in order to use it.
*
* @param types list of registered object types used to resolve typeId
* @param views list of views corresponding to Reference.viewTypes
*/
« no previous file with comments | « lib/typedObjects/objectTypes.js ('k') | lib/typedObjects/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld