| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 let {ceilLog2, defineProperties} = require("typedObjects/utils"); | 20 let {nextPow2, defineProperties} = require("typedObjects/utils"); |
| 21 let {uint16, int16, uint32} = require("typedObjects/primitiveTypes"); | 21 let {uint16, int16, uint32} = require("typedObjects/primitiveTypes"); |
| 22 let {fixedPropertyDescriptor} = require("typedObjects/utils"); | 22 let {fixedPropertyDescriptor} = require("typedObjects/utils"); |
| 23 | 23 |
| 24 function calculateSize(propList) | 24 function calculateSize(propList) |
| 25 { | 25 { |
| 26 let result = 0; | 26 let result = 0; |
| 27 for (let i = 0, l = propList.length | 0; i < l; i++) | 27 for (let i = 0, l = propList.length | 0; i < l; i++) |
| 28 result += propList[i][1].referenceLength; | 28 result += propList[i][1].referenceLength; |
| 29 return ceilLog2(result); | 29 return nextPow2(result); |
| 30 } | 30 } |
| 31 | 31 |
| 32 function getViewTypes(propList) | 32 function getViewTypes(propList) |
| 33 { | 33 { |
| 34 let result = []; | 34 let result = []; |
| 35 for (let i = 0, l = propList.length | 0; i < l; i++) | 35 for (let i = 0, l = propList.length | 0; i < l; i++) |
| 36 { | 36 { |
| 37 let requiredViews = propList[i][1].viewTypes; | 37 let requiredViews = propList[i][1].viewTypes; |
| 38 for (let j = 0, ll = requiredViews.length | 0; j < ll; j++) | 38 for (let j = 0, ll = requiredViews.length | 0; j < ll; j++) |
| 39 if (result.indexOf(requiredViews[j]) < 0) | 39 if (result.indexOf(requiredViews[j]) < 0) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 { | 94 { |
| 95 let result = Object.create(Reference.prototype, { | 95 let result = Object.create(Reference.prototype, { |
| 96 typeInfo: fixedPropertyDescriptor(typeInfo), | 96 typeInfo: fixedPropertyDescriptor(typeInfo), |
| 97 }); | 97 }); |
| 98 defineProperties(result, TypedReference_properties, TypedReference.viewTypes,
views, 0); | 98 defineProperties(result, TypedReference_properties, TypedReference.viewTypes,
views, 0); |
| 99 return result; | 99 return result; |
| 100 } | 100 } |
| 101 TypedReference.byteLength = calculateSize(TypedReference_properties); | 101 TypedReference.byteLength = calculateSize(TypedReference_properties); |
| 102 TypedReference.viewTypes = Object.freeze(getViewTypes(TypedReference_properties)
); | 102 TypedReference.viewTypes = Object.freeze(getViewTypes(TypedReference_properties)
); |
| 103 exports.TypedReference = TypedReference; | 103 exports.TypedReference = TypedReference; |
| LEFT | RIGHT |