2014-05-17 03:40:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 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_JavaScriptBase_h__
|
|
|
|
#define mozilla_jsipc_JavaScriptBase_h__
|
|
|
|
|
2014-05-17 03:40:36 +04:00
|
|
|
#include "WrapperAnswer.h"
|
2014-05-17 03:40:36 +04:00
|
|
|
#include "WrapperOwner.h"
|
|
|
|
#include "mozilla/dom/DOMTypes.h"
|
|
|
|
#include "mozilla/jsipc/PJavaScript.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace jsipc {
|
|
|
|
|
|
|
|
template<class Base>
|
2014-05-17 03:40:36 +04:00
|
|
|
class JavaScriptBase : public WrapperOwner, public WrapperAnswer, public Base
|
2014-05-17 03:40:36 +04:00
|
|
|
{
|
2014-05-17 03:40:36 +04:00
|
|
|
typedef WrapperAnswer Answer;
|
2014-05-17 03:40:36 +04:00
|
|
|
|
|
|
|
public:
|
2014-09-01 05:10:16 +04:00
|
|
|
explicit JavaScriptBase(JSRuntime *rt)
|
2014-05-17 03:40:37 +04:00
|
|
|
: JavaScriptShared(rt),
|
|
|
|
WrapperOwner(rt),
|
|
|
|
WrapperAnswer(rt)
|
|
|
|
{}
|
|
|
|
virtual ~JavaScriptBase() {}
|
|
|
|
|
2014-05-17 03:40:36 +04:00
|
|
|
virtual void ActorDestroy(WrapperOwner::ActorDestroyReason why) {
|
|
|
|
WrapperOwner::ActorDestroy(why);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IPC handlers ***/
|
|
|
|
|
2014-10-22 10:59:09 +04:00
|
|
|
bool RecvPreventExtensions(const uint64_t &objId, ReturnStatus *rs) {
|
|
|
|
return Answer::RecvPreventExtensions(ObjectId::deserialize(objId), rs);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvGetPropertyDescriptor(const uint64_t &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs,
|
|
|
|
PPropertyDescriptor *out) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvGetPropertyDescriptor(ObjectId::deserialize(objId), id, rs, out);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvGetOwnPropertyDescriptor(const uint64_t &objId,
|
2014-10-07 13:29:02 +04:00
|
|
|
const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs,
|
|
|
|
PPropertyDescriptor *out) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvGetOwnPropertyDescriptor(ObjectId::deserialize(objId), id, rs, out);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvDefineProperty(const uint64_t &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
const PPropertyDescriptor &flags,
|
|
|
|
ReturnStatus *rs) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvDefineProperty(ObjectId::deserialize(objId), id, flags, rs);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvDelete(const uint64_t &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *success) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvDelete(ObjectId::deserialize(objId), id, rs, success);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvHas(const uint64_t &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *bp) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvHas(ObjectId::deserialize(objId), id, rs, bp);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvHasOwn(const uint64_t &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *bp) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvHasOwn(ObjectId::deserialize(objId), id, rs, bp);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvGet(const uint64_t &objId, const ObjectVariant &receiverVar,
|
2014-10-07 13:29:02 +04:00
|
|
|
const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, JSVariant *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvGet(ObjectId::deserialize(objId), receiverVar, id, rs, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvSet(const uint64_t &objId, const ObjectVariant &receiverVar,
|
2014-10-07 13:29:02 +04:00
|
|
|
const JSIDVariant &id, const bool &strict,
|
2014-05-17 03:40:36 +04:00
|
|
|
const JSVariant &value, ReturnStatus *rs, JSVariant *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvSet(ObjectId::deserialize(objId), receiverVar, id, strict, value, rs, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvIsExtensible(const uint64_t &objId, ReturnStatus *rs,
|
2014-05-17 03:40:36 +04:00
|
|
|
bool *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvIsExtensible(ObjectId::deserialize(objId), rs, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvCallOrConstruct(const uint64_t &objId, const nsTArray<JSParam> &argv,
|
2014-07-01 04:50:58 +04:00
|
|
|
const bool &construct, ReturnStatus *rs, JSVariant *result,
|
|
|
|
nsTArray<JSParam> *outparams) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvCallOrConstruct(ObjectId::deserialize(objId), argv, construct, rs, result, outparams);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvHasInstance(const uint64_t &objId, const JSVariant &v, ReturnStatus *rs, bool *bp) {
|
|
|
|
return Answer::RecvHasInstance(ObjectId::deserialize(objId), v, rs, bp);
|
2014-09-11 04:15:40 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvObjectClassIs(const uint64_t &objId, const uint32_t &classValue,
|
2014-05-17 03:40:36 +04:00
|
|
|
bool *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvObjectClassIs(ObjectId::deserialize(objId), classValue, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvClassName(const uint64_t &objId, nsString *result) {
|
|
|
|
return Answer::RecvClassName(ObjectId::deserialize(objId), result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvRegExpToShared(const uint64_t &objId, ReturnStatus *rs, nsString *source, uint32_t *flags) {
|
|
|
|
return Answer::RecvRegExpToShared(ObjectId::deserialize(objId), rs, source, flags);
|
2014-10-01 19:22:15 +04:00
|
|
|
}
|
2014-05-17 03:40:36 +04:00
|
|
|
|
2014-09-27 04:52:45 +04:00
|
|
|
bool RecvGetPropertyKeys(const uint64_t &objId, const uint32_t &flags,
|
2014-10-16 20:39:38 +04:00
|
|
|
ReturnStatus *rs, nsTArray<JSIDVariant> *ids) {
|
|
|
|
return Answer::RecvGetPropertyKeys(ObjectId::deserialize(objId), flags, rs, ids);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvInstanceOf(const uint64_t &objId, const JSIID &iid,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *instanceof) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvInstanceOf(ObjectId::deserialize(objId), iid, rs, instanceof);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvDOMInstanceOf(const uint64_t &objId, const int &prototypeID, const int &depth,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *instanceof) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Answer::RecvDOMInstanceOf(ObjectId::deserialize(objId), prototypeID, depth, rs, instanceof);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvIsCallable(const uint64_t &objId, bool *result) {
|
|
|
|
return Answer::RecvIsCallable(ObjectId::deserialize(objId), result);
|
2014-09-25 15:13:29 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool RecvIsConstructor(const uint64_t &objId, bool *result) {
|
|
|
|
return Answer::RecvIsConstructor(ObjectId::deserialize(objId), result);
|
2014-09-25 15:13:29 +04:00
|
|
|
}
|
|
|
|
|
2014-09-25 15:13:29 +04:00
|
|
|
bool RecvDropObject(const uint64_t &objId) {
|
|
|
|
return Answer::RecvDropObject(ObjectId::deserialize(objId));
|
2014-05-17 03:40:37 +04:00
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:36 +04:00
|
|
|
/*** Dummy call handlers ***/
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
bool SendDropObject(const ObjectId &objId) {
|
2014-09-25 15:13:29 +04:00
|
|
|
return Base::SendDropObject(objId.serialize());
|
2014-05-17 03:40:37 +04:00
|
|
|
}
|
2014-10-22 10:59:09 +04:00
|
|
|
bool SendPreventExtensions(const ObjectId &objId, ReturnStatus *rs) {
|
|
|
|
return Base::SendPreventExtensions(objId.serialize(), rs);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendGetPropertyDescriptor(const ObjectId &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs,
|
|
|
|
PPropertyDescriptor *out) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendGetPropertyDescriptor(objId.serialize(), id, rs, out);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendGetOwnPropertyDescriptor(const ObjectId &objId,
|
2014-10-07 13:29:02 +04:00
|
|
|
const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs,
|
|
|
|
PPropertyDescriptor *out) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendGetOwnPropertyDescriptor(objId.serialize(), id, rs, out);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendDefineProperty(const ObjectId &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
const PPropertyDescriptor &flags,
|
|
|
|
ReturnStatus *rs) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendDefineProperty(objId.serialize(), id, flags, rs);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendDelete(const ObjectId &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *success) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendDelete(objId.serialize(), id, rs, success);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendHas(const ObjectId &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *bp) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendHas(objId.serialize(), id, rs, bp);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendHasOwn(const ObjectId &objId, const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *bp) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendHasOwn(objId.serialize(), id, rs, bp);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendGet(const ObjectId &objId, const ObjectVariant &receiverVar,
|
2014-10-07 13:29:02 +04:00
|
|
|
const JSIDVariant &id,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, JSVariant *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendGet(objId.serialize(), receiverVar, id, rs, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendSet(const ObjectId &objId, const ObjectVariant &receiverVar,
|
2014-10-07 13:29:02 +04:00
|
|
|
const JSIDVariant &id, const bool &strict,
|
2014-05-17 03:40:36 +04:00
|
|
|
const JSVariant &value, ReturnStatus *rs, JSVariant *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendSet(objId.serialize(), receiverVar, id, strict, value, rs, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendIsExtensible(const ObjectId &objId, ReturnStatus *rs,
|
2014-05-17 03:40:36 +04:00
|
|
|
bool *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendIsExtensible(objId.serialize(), rs, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendCallOrConstruct(const ObjectId &objId, const nsTArray<JSParam> &argv,
|
2014-07-01 04:50:58 +04:00
|
|
|
const bool &construct, ReturnStatus *rs, JSVariant *result,
|
|
|
|
nsTArray<JSParam> *outparams) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendCallOrConstruct(objId.serialize(), argv, construct, rs, result, outparams);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendHasInstance(const ObjectId &objId, const JSVariant &v, ReturnStatus *rs, bool *bp) {
|
|
|
|
return Base::SendHasInstance(objId.serialize(), v, rs, bp);
|
2014-09-11 04:15:40 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendObjectClassIs(const ObjectId &objId, const uint32_t &classValue,
|
2014-05-17 03:40:36 +04:00
|
|
|
bool *result) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendObjectClassIs(objId.serialize(), classValue, result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendClassName(const ObjectId &objId, nsString *result) {
|
|
|
|
return Base::SendClassName(objId.serialize(), result);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendRegExpToShared(const ObjectId &objId, ReturnStatus *rs,
|
2014-10-01 19:22:15 +04:00
|
|
|
nsString *source, uint32_t *flags) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendRegExpToShared(objId.serialize(), rs, source, flags);
|
2014-10-01 19:22:15 +04:00
|
|
|
}
|
|
|
|
|
2014-09-27 04:52:45 +04:00
|
|
|
bool SendGetPropertyKeys(const ObjectId &objId, const uint32_t &flags,
|
2014-10-16 20:39:38 +04:00
|
|
|
ReturnStatus *rs, nsTArray<JSIDVariant> *ids) {
|
|
|
|
return Base::SendGetPropertyKeys(objId.serialize(), flags, rs, ids);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendInstanceOf(const ObjectId &objId, const JSIID &iid,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *instanceof) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendInstanceOf(objId.serialize(), iid, rs, instanceof);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendDOMInstanceOf(const ObjectId &objId, const int &prototypeID, const int &depth,
|
2014-05-17 03:40:36 +04:00
|
|
|
ReturnStatus *rs, bool *instanceof) {
|
2014-10-08 08:32:45 +04:00
|
|
|
return Base::SendDOMInstanceOf(objId.serialize(), prototypeID, depth, rs, instanceof);
|
2014-05-17 03:40:36 +04:00
|
|
|
}
|
2014-05-17 03:40:37 +04:00
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendIsCallable(const ObjectId &objId, bool *result) {
|
|
|
|
return Base::SendIsCallable(objId.serialize(), result);
|
2014-09-25 15:13:29 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 08:32:45 +04:00
|
|
|
bool SendIsConstructor(const ObjectId &objId, bool *result) {
|
|
|
|
return Base::SendIsConstructor(objId.serialize(), result);
|
2014-09-25 15:13:29 +04:00
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
/* The following code is needed to suppress a bogus MSVC warning (C4250). */
|
|
|
|
|
|
|
|
virtual bool toObjectVariant(JSContext *cx, JSObject *obj, ObjectVariant *objVarp) {
|
|
|
|
return WrapperOwner::toObjectVariant(cx, obj, objVarp);
|
|
|
|
}
|
|
|
|
virtual JSObject *fromObjectVariant(JSContext *cx, ObjectVariant objVar) {
|
|
|
|
return WrapperOwner::fromObjectVariant(cx, objVar);
|
|
|
|
}
|
2014-05-17 03:40:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace jsipc
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|