OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var nativeDeepCopy = requireNative('utils').deepCopy; | 5 var nativeDeepCopy = requireNative('utils').deepCopy; |
6 var schemaRegistry = requireNative('schema_registry'); | 6 var schemaRegistry = requireNative('schema_registry'); |
7 var CHECK = requireNative('logging').CHECK; | 7 var CHECK = requireNative('logging').CHECK; |
8 var DCHECK = requireNative('logging').DCHECK; | 8 var DCHECK = requireNative('logging').DCHECK; |
9 var WARNING = requireNative('logging').WARNING; | 9 var WARNING = requireNative('logging').WARNING; |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 * functions: ?Array<string>, | 100 * functions: ?Array<string>, |
101 * properties: ?Array<string>, | 101 * properties: ?Array<string>, |
102 * readonly: ?Array<string>}} exposed The names of properties on the | 102 * readonly: ?Array<string>}} exposed The names of properties on the |
103 * implementation class to be exposed. |superclass| represents the | 103 * implementation class to be exposed. |superclass| represents the |
104 * constructor of the class to be used as the superclass of the exposed | 104 * constructor of the class to be used as the superclass of the exposed |
105 * class; |functions| represents the names of functions which should be | 105 * class; |functions| represents the names of functions which should be |
106 * delegated to the implementation; |properties| are gettable/settable | 106 * delegated to the implementation; |properties| are gettable/settable |
107 * properties and |readonly| are read-only properties. | 107 * properties and |readonly| are read-only properties. |
108 */ | 108 */ |
109 function expose(publicClass, privateClass, exposed) { | 109 function expose(publicClass, privateClass, exposed) { |
110 DCHECK(!(privateClass.prototype instanceof $Object.self)); | |
111 | |
112 $Object.setPrototypeOf(exposed, null); | 110 $Object.setPrototypeOf(exposed, null); |
113 | 111 |
114 // This should be called by publicClass. | 112 // This should be called by publicClass. |
115 privates(publicClass).constructPrivate = function(self, args) { | 113 privates(publicClass).constructPrivate = function(self, args) { |
116 if (!(self instanceof publicClass)) { | 114 if (!(self instanceof publicClass)) { |
117 throw new Error('Please use "new ' + publicClass.name + '"'); | 115 throw new Error('Please use "new ' + publicClass.name + '"'); |
118 } | 116 } |
119 // The "instanceof publicClass" check can easily be spoofed, so we check | 117 // The "instanceof publicClass" check can easily be spoofed, so we check |
120 // whether the private impl is already set before continuing. | 118 // whether the private impl is already set before continuing. |
121 var privateSelf = privates(self); | 119 var privateSelf = privates(self); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 }); | 229 }); |
232 } | 230 } |
233 | 231 |
234 exports.$set('forEach', forEach); | 232 exports.$set('forEach', forEach); |
235 exports.$set('loadTypeSchema', loadTypeSchema); | 233 exports.$set('loadTypeSchema', loadTypeSchema); |
236 exports.$set('lookup', lookup); | 234 exports.$set('lookup', lookup); |
237 exports.$set('defineProperty', defineProperty); | 235 exports.$set('defineProperty', defineProperty); |
238 exports.$set('expose', expose); | 236 exports.$set('expose', expose); |
239 exports.$set('deepCopy', deepCopy); | 237 exports.$set('deepCopy', deepCopy); |
240 exports.$set('promise', promise); | 238 exports.$set('promise', promise); |
OLD | NEW |