summaryrefslogtreecommitdiffstats
path: root/js/src/proxy/DeadObjectProxy.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/proxy/DeadObjectProxy.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/proxy/DeadObjectProxy.cpp')
-rw-r--r--js/src/proxy/DeadObjectProxy.cpp175
1 files changed, 175 insertions, 0 deletions
diff --git a/js/src/proxy/DeadObjectProxy.cpp b/js/src/proxy/DeadObjectProxy.cpp
new file mode 100644
index 000000000..00ca034f3
--- /dev/null
+++ b/js/src/proxy/DeadObjectProxy.cpp
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=8 sts=4 et sw=4 tw=99:
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "proxy/DeadObjectProxy.h"
+
+#include "jsapi.h"
+#include "jsfun.h" // XXXefaust Bug 1064662
+
+#include "proxy/ScriptedProxyHandler.h"
+#include "vm/ProxyObject.h"
+
+using namespace js;
+using namespace js::gc;
+
+static void
+ReportDead(JSContext *cx)
+{
+ JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT);
+}
+
+bool
+DeadObjectProxy::getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id,
+ MutableHandle<PropertyDescriptor> desc) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::defineProperty(JSContext* cx, HandleObject wrapper, HandleId id,
+ Handle<PropertyDescriptor> desc,
+ ObjectOpResult& result) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::ownPropertyKeys(JSContext* cx, HandleObject wrapper,
+ AutoIdVector& props) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::delete_(JSContext* cx, HandleObject wrapper, HandleId id,
+ ObjectOpResult& result) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::getPrototype(JSContext* cx, HandleObject proxy, MutableHandleObject protop) const
+{
+ protop.set(nullptr);
+ return true;
+}
+
+bool
+DeadObjectProxy::getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary,
+ MutableHandleObject protop) const
+{
+ *isOrdinary = false;
+ return true;
+}
+
+bool
+DeadObjectProxy::preventExtensions(JSContext* cx, HandleObject proxy, ObjectOpResult& result) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const
+{
+ // This is kind of meaningless, but dead-object semantics aside,
+ // [[Extensible]] always being true is consistent with other proxy types.
+ *extensible = true;
+ return true;
+}
+
+bool
+DeadObjectProxy::call(JSContext* cx, HandleObject wrapper, const CallArgs& args) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::construct(JSContext* cx, HandleObject wrapper, const CallArgs& args) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl,
+ const CallArgs& args) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v,
+ bool* bp) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::isArray(JSContext* cx, HandleObject obj, JS::IsArrayAnswer* answer) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+const char*
+DeadObjectProxy::className(JSContext* cx, HandleObject wrapper) const
+{
+ return "DeadObject";
+}
+
+JSString*
+DeadObjectProxy::fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const
+{
+ ReportDead(cx);
+ return nullptr;
+}
+
+bool
+DeadObjectProxy::regexp_toShared(JSContext* cx, HandleObject proxy, RegExpGuard* g) const
+{
+ ReportDead(cx);
+ return false;
+}
+
+bool
+DeadObjectProxy::isCallable(JSObject* obj) const
+{
+ static const uint32_t slot = ScriptedProxyHandler::IS_CALLCONSTRUCT_EXTRA;
+ uint32_t callConstruct = obj->as<ProxyObject>().extra(slot).toPrivateUint32();
+ return !!(callConstruct & ScriptedProxyHandler::IS_CALLABLE);
+}
+
+bool
+DeadObjectProxy::isConstructor(JSObject* obj) const
+{
+ static const uint32_t slot = ScriptedProxyHandler::IS_CALLCONSTRUCT_EXTRA;
+ uint32_t callConstruct = obj->as<ProxyObject>().extra(slot).toPrivateUint32();
+ return !!(callConstruct & ScriptedProxyHandler::IS_CONSTRUCTOR);
+}
+
+const char DeadObjectProxy::family = 0;
+const DeadObjectProxy DeadObjectProxy::singleton;
+
+bool
+js::IsDeadProxyObject(JSObject* obj)
+{
+ return IsDerivedProxyObject(obj, &DeadObjectProxy::singleton);
+}