diff -r 7849fef47f04 js/src/jsproxy.cpp --- a/js/src/jsproxy.cpp Mon Aug 20 08:54:34 2012 +0200 +++ b/js/src/jsproxy.cpp Mon Aug 20 08:55:55 2012 +0200 @@ -1018,16 +1018,155 @@ ScriptedIndirectProxyHandler::defaultVal * This function is only here to prevent bug 757063. It will be removed when * the direct proxy refactor is complete. */ return BaseProxyHandler::defaultValue(cx, proxy, hint, vp); } ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton; +static JSObject * +GetDirectProxyHandlerObject(JSObject *proxy) +{ + return GetProxyExtra(proxy, 0).toObjectOrNull(); +} + +/* Derived class for all scripted direct proxy handlers. */ +class ScriptedDirectProxyHandler : public DirectProxyHandler { + public: + ScriptedDirectProxyHandler(); + virtual ~ScriptedDirectProxyHandler(); + + /* ES5 Harmony fundamental proxy traps. */ + virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, + PropertyDescriptor *desc) MOZ_OVERRIDE; + virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, + PropertyDescriptor *desc) MOZ_OVERRIDE; + virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, + PropertyDescriptor *desc) MOZ_OVERRIDE; + virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props); + virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE; + virtual bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE; + + /* ES5 Harmony derived proxy traps. */ + virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE; + virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE; + virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, + Value *vp) MOZ_OVERRIDE; + virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, + Value *vp) MOZ_OVERRIDE; + virtual bool keys(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE; + virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp) MOZ_OVERRIDE; + + static ScriptedDirectProxyHandler singleton; +}; + +static int sScriptedDirectProxyHandlerFamily = 0; + +ScriptedDirectProxyHandler::ScriptedDirectProxyHandler() + : DirectProxyHandler(&sScriptedDirectProxyHandlerFamily) +{ +} + +ScriptedDirectProxyHandler::~ScriptedDirectProxyHandler() +{ +} + +bool +ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, + bool set, PropertyDescriptor *desc) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, + bool set, PropertyDescriptor *desc) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsid id, + PropertyDescriptor *desc) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, JSObject *proxy, + AutoIdVector &props) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, + Value *vp) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, + bool strict, Value *vp) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::keys(JSContext *cx, JSObject *proxy, AutoIdVector &props) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +bool +ScriptedDirectProxyHandler::iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp) +{ + JS_NOT_REACHED("not yet implemented"); + return false; +} + +ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton; + #define INVOKE_ON_PROTOTYPE(cx, handler, proxy, protoCall) \ JS_BEGIN_MACRO \ JSObject *proto; \ if (!handler->getPrototypeOf(cx, proxy, &proto)) \ return false; \ if (!proto) \ return true; \ assertSameCompartment(cx, proxy, proto); \