From 428bacbd5597db60633609958b8971289bb70fc5 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 22 Feb 2013 08:14:33 -0800 Subject: [PATCH] Bug 836301 - Hoist enter() into BaseProxyHandler. r=mrbkap --- js/src/jsproxy.cpp | 8 ++++++++ js/src/jsproxy.h | 16 ++++++++++++++++ js/src/jswrapper.cpp | 7 ------- js/src/jswrapper.h | 17 +---------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp index 7d431c9614d1..daf9f1c397e6 100644 --- a/js/src/jsproxy.cpp +++ b/js/src/jsproxy.cpp @@ -60,6 +60,14 @@ BaseProxyHandler::~BaseProxyHandler() { } +bool +BaseProxyHandler::enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, + bool *bp) +{ + *bp = true; + return true; +} + bool BaseProxyHandler::has(JSContext *cx, JSObject *proxy_, jsid id_, bool *bp) { diff --git a/js/src/jsproxy.h b/js/src/jsproxy.h index 0bba56ef8769..0d0b70e1e8b8 100644 --- a/js/src/jsproxy.h +++ b/js/src/jsproxy.h @@ -77,6 +77,22 @@ class JS_FRIEND_API(BaseProxyHandler) { return false; } + /* Policy enforcement traps. + * + * enter() allows the policy to specify whether the caller may perform |act| + * on the proxy's |id| property. In the case when |act| is CALL, |id| is + * generally JSID_VOID. + * + * The |act| parameter to enter() specifies the action being performed. + */ + enum Action { + GET, + SET, + CALL + }; + virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, + bool *bp); + /* ES5 Harmony fundamental proxy traps. */ virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc, unsigned flags) = 0; diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp index 305769f04da8..2fc1c947f07f 100644 --- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -70,13 +70,6 @@ Wrapper::wrappedObject(RawObject wrapper) return GetProxyTargetObject(wrapper); } -bool -Wrapper::enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, bool *bp) -{ - *bp = true; - return true; -} - JS_FRIEND_API(JSObject *) js::UnwrapObject(JSObject *wrapped, bool stopAtOuter, unsigned *flagsp) { diff --git a/js/src/jswrapper.h b/js/src/jswrapper.h index 010b8e1414e6..db03e9f55f49 100644 --- a/js/src/jswrapper.h +++ b/js/src/jswrapper.h @@ -32,11 +32,7 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler bool mSafeToUnwrap; public: - enum Action { - GET, - SET, - CALL - }; + using BaseProxyHandler::Action; enum Flags { CROSS_COMPARTMENT = 1 << 0, @@ -65,17 +61,6 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler return mFlags; } - /* Policy enforcement traps. - * - * enter() allows the policy to specify whether the caller may perform |act| - * on the underlying object's |id| property. In the case when |act| is CALL, - * |id| is generally JSID_VOID. - * - * The |act| parameter to enter() specifies the action being performed. - */ - virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, - bool *bp); - explicit Wrapper(unsigned flags, bool hasPrototype = false); virtual ~Wrapper();