Mercurial > spidermonkey-playground
changeset 31:d5087fb2367d
Added more to SafeWrapper.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 22 Jun 2009 13:29:45 -0700 |
parents | 82d800f2dcfc |
children | bda50240b295 |
files | tcb.js |
diffstat | 1 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tcb.js Mon Jun 22 13:17:34 2009 -0700 +++ b/tcb.js Mon Jun 22 13:29:45 2009 -0700 @@ -128,10 +128,15 @@ case "__parent__": return null; default: + // TODO: This will bypass any getters/setters. return this._maybeWrap(lookupProperty(wrappee, id)); } }, + addProperty: function() { + throw new Error("Can't add properties to this object."); + }, + setProperty: function() { throw new Error("Can't set properties on this object."); }, @@ -140,6 +145,32 @@ throw new Error("Can't delete properties on this object."); }, + equality: function(wrappee, wrapper, other) { + return wrappee == other; + }, + + enumerate: function() { + throw new Error("Enumeration is not implemented."); + }, + + iteratorObject: function(wrappee, wrapper, keysOnly) { + if (keysOnly) { + function keyIterator() { + // TODO: Is this secure? + for (name in wrappee) + yield name; + } + return keyIterator(); + } else { + function keyValueIterator() { + // TODO: Is this secure? + for (name in wrappee) + yield [name, wrappee[name]]; + } + return keyValueIterator(); + } + }, + _callOrConstruct: function(wrapee, wrapper, thisObj, args) { if (typeof(this._wrappee) == "function") { var wrappedArgs = [];