|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=4 sw=4 et tw=80: |
|
3 * |
|
4 * This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #ifndef mozilla_jsipc_JavaScriptChild_h_ |
|
9 #define mozilla_jsipc_JavaScriptChild_h_ |
|
10 |
|
11 #include "JavaScriptShared.h" |
|
12 #include "mozilla/jsipc/PJavaScriptChild.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace jsipc { |
|
16 |
|
17 class JavaScriptChild |
|
18 : public PJavaScriptChild, |
|
19 public JavaScriptShared |
|
20 { |
|
21 public: |
|
22 JavaScriptChild(JSRuntime *rt); |
|
23 ~JavaScriptChild(); |
|
24 |
|
25 bool init(); |
|
26 void trace(JSTracer *trc); |
|
27 |
|
28 bool RecvDropObject(const ObjectId &objId) MOZ_OVERRIDE; |
|
29 |
|
30 bool AnswerPreventExtensions(const ObjectId &objId, ReturnStatus *rs) MOZ_OVERRIDE; |
|
31 bool AnswerGetPropertyDescriptor(const ObjectId &objId, const nsString &id, |
|
32 ReturnStatus *rs, |
|
33 PPropertyDescriptor *out) MOZ_OVERRIDE; |
|
34 bool AnswerGetOwnPropertyDescriptor(const ObjectId &objId, |
|
35 const nsString &id, |
|
36 ReturnStatus *rs, |
|
37 PPropertyDescriptor *out) MOZ_OVERRIDE; |
|
38 bool AnswerDefineProperty(const ObjectId &objId, const nsString &id, |
|
39 const PPropertyDescriptor &flags, |
|
40 ReturnStatus *rs) MOZ_OVERRIDE; |
|
41 bool AnswerDelete(const ObjectId &objId, const nsString &id, |
|
42 ReturnStatus *rs, bool *success) MOZ_OVERRIDE; |
|
43 |
|
44 bool AnswerHas(const ObjectId &objId, const nsString &id, |
|
45 ReturnStatus *rs, bool *bp) MOZ_OVERRIDE; |
|
46 bool AnswerHasOwn(const ObjectId &objId, const nsString &id, |
|
47 ReturnStatus *rs, bool *bp) MOZ_OVERRIDE; |
|
48 bool AnswerGet(const ObjectId &objId, const ObjectId &receiverId, |
|
49 const nsString &id, |
|
50 ReturnStatus *rs, JSVariant *result) MOZ_OVERRIDE; |
|
51 bool AnswerSet(const ObjectId &objId, const ObjectId &receiverId, |
|
52 const nsString &id, const bool &strict, |
|
53 const JSVariant &value, ReturnStatus *rs, JSVariant *result) MOZ_OVERRIDE; |
|
54 |
|
55 bool AnswerIsExtensible(const ObjectId &objId, ReturnStatus *rs, |
|
56 bool *result) MOZ_OVERRIDE; |
|
57 bool AnswerCall(const ObjectId &objId, const nsTArray<JSParam> &argv, |
|
58 ReturnStatus *rs, JSVariant *result, |
|
59 nsTArray<JSParam> *outparams) MOZ_OVERRIDE; |
|
60 bool AnswerObjectClassIs(const ObjectId &objId, const uint32_t &classValue, |
|
61 bool *result) MOZ_OVERRIDE; |
|
62 bool AnswerClassName(const ObjectId &objId, nsString *result) MOZ_OVERRIDE; |
|
63 |
|
64 bool AnswerGetPropertyNames(const ObjectId &objId, const uint32_t &flags, |
|
65 ReturnStatus *rs, nsTArray<nsString> *names) MOZ_OVERRIDE; |
|
66 bool AnswerInstanceOf(const ObjectId &objId, const JSIID &iid, |
|
67 ReturnStatus *rs, bool *instanceof) MOZ_OVERRIDE; |
|
68 bool AnswerDOMInstanceOf(const ObjectId &objId, const int &prototypeID, const int &depth, |
|
69 ReturnStatus *rs, bool *instanceof) MOZ_OVERRIDE; |
|
70 |
|
71 protected: |
|
72 JSObject *unwrap(JSContext *cx, ObjectId id); |
|
73 |
|
74 private: |
|
75 bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp); |
|
76 bool fail(JSContext *cx, ReturnStatus *rs); |
|
77 bool ok(ReturnStatus *rs); |
|
78 |
|
79 private: |
|
80 ObjectId lastId_; |
|
81 JSRuntime *rt_; |
|
82 ObjectIdCache ids_; |
|
83 }; |
|
84 |
|
85 } // mozilla |
|
86 } // jsipc |
|
87 |
|
88 #endif |