2013-07-03 00:24:32 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=4 sw=4 et tw=80:
|
|
|
|
*
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_jsipc_JavaScriptParent__
|
|
|
|
#define mozilla_jsipc_JavaScriptParent__
|
|
|
|
|
|
|
|
#include "JavaScriptShared.h"
|
|
|
|
#include "mozilla/jsipc/PJavaScriptParent.h"
|
2013-08-21 22:26:57 -07:00
|
|
|
#include "js/Class.h"
|
2013-07-03 00:24:32 -07:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#undef GetClassName
|
|
|
|
#undef GetClassInfo
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace jsipc {
|
|
|
|
|
|
|
|
class JavaScriptParent
|
|
|
|
: public PJavaScriptParent,
|
|
|
|
public JavaScriptShared
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
JavaScriptParent();
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
|
|
|
|
public:
|
2013-07-11 08:23:34 -07:00
|
|
|
// Fundamental proxy traps. These are required.
|
|
|
|
// (The traps should be in the same order like js/src/jsproxy.h)
|
|
|
|
bool preventExtensions(JSContext *cx, JS::HandleObject proxy);
|
2013-07-03 00:24:32 -07:00
|
|
|
bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
2014-04-25 14:11:01 -07:00
|
|
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
2013-07-03 00:24:32 -07:00
|
|
|
bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
2014-04-25 14:11:01 -07:00
|
|
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
2013-07-09 19:45:08 -07:00
|
|
|
bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
|
2013-04-30 10:29:40 -07:00
|
|
|
JS::MutableHandle<JSPropertyDescriptor> desc);
|
2013-09-01 21:51:02 -07:00
|
|
|
bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
|
2013-07-09 19:45:08 -07:00
|
|
|
bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
|
2013-09-01 21:51:02 -07:00
|
|
|
bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
|
2013-07-11 08:23:34 -07:00
|
|
|
|
|
|
|
// Derived proxy traps. Implementing these is useful for perfomance.
|
|
|
|
bool has(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
|
|
|
|
bool hasOwn(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
|
|
|
|
bool get(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver,
|
|
|
|
JS::HandleId id, JS::MutableHandleValue vp);
|
|
|
|
bool set(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver,
|
|
|
|
JS::HandleId id, bool strict, JS::MutableHandleValue vp);
|
2013-09-01 21:51:02 -07:00
|
|
|
bool keys(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
|
2013-07-11 08:23:34 -07:00
|
|
|
// We use "iterate" provided by the base class here.
|
|
|
|
|
|
|
|
// SpiderMonkey Extensions.
|
|
|
|
bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible);
|
|
|
|
bool call(JSContext *cx, JS::HandleObject proxy, const JS::CallArgs &args);
|
2013-07-03 00:24:32 -07:00
|
|
|
bool objectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue);
|
|
|
|
const char* className(JSContext *cx, JS::HandleObject proxy);
|
|
|
|
|
2014-02-05 08:39:59 -08:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2013-07-03 00:24:32 -07:00
|
|
|
void decref();
|
|
|
|
void incref();
|
2014-02-05 08:39:59 -08:00
|
|
|
|
|
|
|
bool active() { return !inactive_; }
|
2013-07-03 00:24:32 -07:00
|
|
|
|
|
|
|
void drop(JSObject *obj);
|
|
|
|
|
|
|
|
static bool IsCPOW(JSObject *obj);
|
|
|
|
|
2013-08-01 16:45:17 -07:00
|
|
|
static nsresult InstanceOf(JSObject *obj, const nsID *id, bool *bp);
|
2013-07-03 00:24:32 -07:00
|
|
|
nsresult instanceOf(JSObject *obj, const nsID *id, bool *bp);
|
|
|
|
|
2013-08-01 16:45:17 -07:00
|
|
|
/*
|
|
|
|
* Check that |obj| is a DOM wrapper whose prototype chain contains
|
|
|
|
* |prototypeID| at depth |depth|.
|
|
|
|
*/
|
2014-02-05 08:39:59 -08:00
|
|
|
static bool DOMInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
|
|
|
|
bool domInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
|
2013-08-01 16:45:17 -07:00
|
|
|
|
2013-06-03 03:14:37 -07:00
|
|
|
mozilla::ipc::IProtocol*
|
|
|
|
CloneProtocol(Channel* aChannel, ProtocolCloneContext* aCtx) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-03 00:24:32 -07:00
|
|
|
protected:
|
|
|
|
JSObject *unwrap(JSContext *cx, ObjectId objId);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp);
|
2013-09-01 21:51:02 -07:00
|
|
|
bool getPropertyNames(JSContext *cx, JS::HandleObject proxy, uint32_t flags,
|
|
|
|
JS::AutoIdVector &props);
|
2013-07-03 00:24:32 -07:00
|
|
|
ObjectId idOf(JSObject *obj);
|
|
|
|
|
|
|
|
// Catastrophic IPC failure.
|
|
|
|
bool ipcfail(JSContext *cx);
|
|
|
|
|
|
|
|
// Check whether a return status is okay, and if not, propagate its error.
|
|
|
|
bool ok(JSContext *cx, const ReturnStatus &status);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uintptr_t refcount_;
|
|
|
|
bool inactive_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // jsipc
|
|
|
|
} // mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_jsipc_JavaScriptWrapper_h__
|
|
|
|
|