LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 24 matching lines...) Expand all Loading... |
35 { | 35 { |
36 class JsValue; | 36 class JsValue; |
37 class JsEngine; | 37 class JsEngine; |
38 | 38 |
39 typedef std::shared_ptr<JsEngine> JsEnginePtr; | 39 typedef std::shared_ptr<JsEngine> JsEnginePtr; |
40 | 40 |
41 /** | 41 /** |
42 * Shared smart pointer to a `JsValue` instance. | 42 * Shared smart pointer to a `JsValue` instance. |
43 */ | 43 */ |
44 typedef std::shared_ptr<JsValue> JsValuePtr; | 44 typedef std::shared_ptr<JsValue> JsValuePtr; |
| 45 typedef std::shared_ptr<const JsValue> JsConstValuePtr; |
45 | 46 |
46 /** | 47 /** |
47 * List of JavaScript values. | 48 * List of JavaScript values. |
48 */ | 49 */ |
49 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList; | 50 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList; |
| 51 typedef std::vector<AdblockPlus::JsConstValuePtr> JsConstValueList; |
50 | 52 |
51 /** | 53 /** |
52 * Wrapper for JavaScript values. | 54 * Wrapper for JavaScript values. |
53 * See `JsEngine` for creating `JsValue` objects. | 55 * See `JsEngine` for creating `JsValue` objects. |
54 */ | 56 */ |
55 class JsValue | 57 class JsValue |
56 { | 58 { |
57 friend class JsEngine; | 59 friend class JsEngine; |
58 public: | 60 public: |
59 JsValue(JsValue&& src); | 61 JsValue(JsValue&& src); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 * @return Class name of the value. | 116 * @return Class name of the value. |
115 */ | 117 */ |
116 std::string GetClass() const; | 118 std::string GetClass() const; |
117 | 119 |
118 /** | 120 /** |
119 * Invokes the value as a function (see `IsFunction()`). | 121 * Invokes the value as a function (see `IsFunction()`). |
120 * @param params Optional list of parameters. | 122 * @param params Optional list of parameters. |
121 * @param thisPtr Optional `this` value. | 123 * @param thisPtr Optional `this` value. |
122 * @return Value returned by the function. | 124 * @return Value returned by the function. |
123 */ | 125 */ |
124 JsValuePtr Call(const JsValueList& params = JsValueList(), | 126 JsValuePtr Call(const JsConstValueList& params = JsConstValueList(), |
125 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; | 127 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; |
126 | 128 |
127 /** | 129 /** |
128 * Invokes the value as a function (see `IsFunction()`) with single | 130 * Invokes the value as a function (see `IsFunction()`) with single |
129 * parameter. | 131 * parameter. |
130 * @param arg A single required parameter. | 132 * @param arg A single required parameter. |
131 * @return Value returned by the function. | 133 * @return Value returned by the function. |
132 */ | 134 */ |
133 JsValuePtr Call(const JsValue& arg) const; | 135 JsValuePtr Call(const JsConstValuePtr& arg) const; |
134 | 136 |
135 v8::Local<v8::Value> UnwrapValue() const; | 137 v8::Local<v8::Value> UnwrapValue() const; |
136 protected: | 138 protected: |
137 JsEnginePtr jsEngine; | 139 JsEnginePtr jsEngine; |
138 private: | 140 private: |
139 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value); | 141 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value); |
140 void SetProperty(const std::string& name, v8::Handle<v8::Value> val); | 142 void SetProperty(const std::string& name, v8::Handle<v8::Value> val); |
141 std::unique_ptr<v8::Persistent<v8::Value>> value; | 143 std::unique_ptr<v8::Persistent<v8::Value>> value; |
142 }; | 144 }; |
143 } | 145 } |
144 | 146 |
145 #endif | 147 #endif |
LEFT | RIGHT |