OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 | 245 |
246 // Extensions for providing property getters and setters. | 246 // Extensions for providing property getters and setters. |
247 function ObjectDefineGetter(name, fun) { | 247 function ObjectDefineGetter(name, fun) { |
248 if (this == null && !IS_UNDETECTABLE(this)) { | 248 if (this == null && !IS_UNDETECTABLE(this)) { |
249 throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); | 249 throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); |
250 } | 250 } |
251 if (!IS_FUNCTION(fun)) { | 251 if (!IS_FUNCTION(fun)) { |
252 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function'
); | 252 throw new $TypeError('Object.prototype.__defineGetter__: Expecting function'
); |
253 } | 253 } |
254 return %DefineAccessor(ToObject(this), ToString(name), GETTER, fun); | 254 var desc = new PropertyDescriptor(); |
| 255 desc.setGet(fun); |
| 256 desc.setEnumerable(true); |
| 257 desc.setConfigurable(true); |
| 258 DefineOwnProperty(ToObject(this), ToString(name), desc, true); |
255 } | 259 } |
256 | 260 |
257 | 261 |
258 function ObjectLookupGetter(name) { | 262 function ObjectLookupGetter(name) { |
259 if (this == null && !IS_UNDETECTABLE(this)) { | 263 if (this == null && !IS_UNDETECTABLE(this)) { |
260 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); | 264 throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); |
261 } | 265 } |
262 return %LookupAccessor(ToObject(this), ToString(name), GETTER); | 266 return %LookupAccessor(ToObject(this), ToString(name), GETTER); |
263 } | 267 } |
264 | 268 |
265 | 269 |
266 function ObjectDefineSetter(name, fun) { | 270 function ObjectDefineSetter(name, fun) { |
267 if (this == null && !IS_UNDETECTABLE(this)) { | 271 if (this == null && !IS_UNDETECTABLE(this)) { |
268 throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); | 272 throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); |
269 } | 273 } |
270 if (!IS_FUNCTION(fun)) { | 274 if (!IS_FUNCTION(fun)) { |
271 throw new $TypeError( | 275 throw new $TypeError( |
272 'Object.prototype.__defineSetter__: Expecting function'); | 276 'Object.prototype.__defineSetter__: Expecting function'); |
273 } | 277 } |
274 return %DefineAccessor(ToObject(this), ToString(name), SETTER, fun); | 278 var desc = new PropertyDescriptor(); |
| 279 desc.setSet(fun); |
| 280 desc.setEnumerable(true); |
| 281 desc.setConfigurable(true); |
| 282 DefineOwnProperty(ToObject(this), ToString(name), desc, true); |
275 } | 283 } |
276 | 284 |
277 | 285 |
278 function ObjectLookupSetter(name) { | 286 function ObjectLookupSetter(name) { |
279 if (this == null && !IS_UNDETECTABLE(this)) { | 287 if (this == null && !IS_UNDETECTABLE(this)) { |
280 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); | 288 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); |
281 } | 289 } |
282 return %LookupAccessor(ToObject(this), ToString(name), SETTER); | 290 return %LookupAccessor(ToObject(this), ToString(name), SETTER); |
283 } | 291 } |
284 | 292 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 this.enumerable_ = false; | 395 this.enumerable_ = false; |
388 this.hasEnumerable_ = false; | 396 this.hasEnumerable_ = false; |
389 this.configurable_ = false; | 397 this.configurable_ = false; |
390 this.hasConfigurable_ = false; | 398 this.hasConfigurable_ = false; |
391 this.get_ = void 0; | 399 this.get_ = void 0; |
392 this.hasGetter_ = false; | 400 this.hasGetter_ = false; |
393 this.set_ = void 0; | 401 this.set_ = void 0; |
394 this.hasSetter_ = false; | 402 this.hasSetter_ = false; |
395 } | 403 } |
396 | 404 |
| 405 PropertyDescriptor.prototype.__proto__ = null; |
| 406 PropertyDescriptor.prototype.toString = function() { |
| 407 return "[object PropertyDescriptor]"; |
| 408 }; |
397 | 409 |
398 PropertyDescriptor.prototype.setValue = function(value) { | 410 PropertyDescriptor.prototype.setValue = function(value) { |
399 this.value_ = value; | 411 this.value_ = value; |
400 this.hasValue_ = true; | 412 this.hasValue_ = true; |
401 } | 413 } |
402 | 414 |
403 | 415 |
404 PropertyDescriptor.prototype.getValue = function() { | 416 PropertyDescriptor.prototype.getValue = function() { |
405 return this.value_; | 417 return this.value_; |
406 } | 418 } |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 // ---------------------------------------------------------------------------- | 1255 // ---------------------------------------------------------------------------- |
1244 | 1256 |
1245 function SetupFunction() { | 1257 function SetupFunction() { |
1246 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1258 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1247 "bind", FunctionBind, | 1259 "bind", FunctionBind, |
1248 "toString", FunctionToString | 1260 "toString", FunctionToString |
1249 )); | 1261 )); |
1250 } | 1262 } |
1251 | 1263 |
1252 SetupFunction(); | 1264 SetupFunction(); |
OLD | NEW |