LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 * List of JavaScript values. | 47 * List of JavaScript values. |
48 */ | 48 */ |
49 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList; | 49 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList; |
50 | 50 |
51 /** | 51 /** |
52 * Wrapper for JavaScript values. | 52 * Wrapper for JavaScript values. |
53 * See `JsEngine` for creating `JsValue` objects. | 53 * See `JsEngine` for creating `JsValue` objects. |
54 */ | 54 */ |
55 class JsValue | 55 class JsValue |
56 { | 56 { |
| 57 friend class JsEngine; |
57 public: | 58 public: |
58 struct Private | |
59 { | |
60 private: | |
61 // allow access to the ctr only JsEngine and don't allow JsEngine to acces
s other members. | |
62 friend class JsEngine; | |
63 friend class JsValue; | |
64 struct CtrArg | |
65 { | |
66 }; | |
67 }; | |
68 protected: | |
69 typedef Private::CtrArg PrivateCtrArg; | |
70 JsValue(const JsValuePtr& value); | |
71 public: | |
72 JsValue(const JsEnginePtr& jsEngine, const v8::Handle<v8::Value> value, Priv
ateCtrArg); | |
73 virtual ~JsValue(); | 59 virtual ~JsValue(); |
74 | 60 |
75 bool IsUndefined() const; | 61 bool IsUndefined() const; |
76 bool IsNull() const; | 62 bool IsNull() const; |
77 bool IsString() const; | 63 bool IsString() const; |
78 bool IsNumber() const; | 64 bool IsNumber() const; |
79 bool IsBool() const; | 65 bool IsBool() const; |
80 bool IsObject() const; | 66 bool IsObject() const; |
81 bool IsArray() const; | 67 bool IsArray() const; |
82 bool IsFunction() const; | 68 bool IsFunction() const; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 116 |
131 /** | 117 /** |
132 * Invokes the value as a function (see `IsFunction()`). | 118 * Invokes the value as a function (see `IsFunction()`). |
133 * @param params Optional list of parameters. | 119 * @param params Optional list of parameters. |
134 * @param thisPtr Optional `this` value. | 120 * @param thisPtr Optional `this` value. |
135 * @return Value returned by the function. | 121 * @return Value returned by the function. |
136 */ | 122 */ |
137 JsValuePtr Call(const JsValueList& params = JsValueList(), | 123 JsValuePtr Call(const JsValueList& params = JsValueList(), |
138 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; | 124 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; |
139 | 125 |
140 v8::Local<v8::Value> unwrapValue() const; | 126 v8::Local<v8::Value> UnwrapValue() const; |
141 private: | |
142 void SetProperty(const std::string& name, const v8::Handle<v8::Value> val); | |
143 protected: | 127 protected: |
| 128 JsValue(JsValuePtr value); |
144 JsEnginePtr jsEngine; | 129 JsEnginePtr jsEngine; |
145 private: | 130 private: |
| 131 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value); |
| 132 void SetProperty(const std::string& name, v8::Handle<v8::Value> val); |
146 V8ValueHolder<v8::Value> value; | 133 V8ValueHolder<v8::Value> value; |
147 }; | 134 }; |
148 } | 135 } |
149 | 136 |
150 #endif | 137 #endif |
LEFT | RIGHT |