Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include/AdblockPlus/JsValue.h

Issue 29451722: Issue 4907 - Update v8 to 5.7.278 in libadblockplus (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: fix support of ARCH=ia32 Created June 2, 2017, 7:19 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef ADBLOCK_PLUS_JS_VALUE_H 18 #ifndef ADBLOCK_PLUS_JS_VALUE_H
19 #define ADBLOCK_PLUS_JS_VALUE_H 19 #define ADBLOCK_PLUS_JS_VALUE_H
20 20
21 #include <stdint.h> 21 #include <stdint.h>
22 #include <string> 22 #include <string>
23 #include <vector> 23 #include <vector>
24 #include <memory> 24 #include <memory>
25 25
26 namespace v8 26 namespace v8
27 { 27 {
28 class Value; 28 class Value;
29 class Object; 29 class Object;
30 template<class T> class Handle;
31 template<class T> class Local; 30 template<class T> class Local;
32 template<class T> class Persistent; 31 template<class T> class Global;
33 } 32 }
34 33
35 namespace AdblockPlus 34 namespace AdblockPlus
36 { 35 {
37 class JsValue; 36 class JsValue;
38 class JsEngine; 37 class JsEngine;
39 38
40 typedef std::shared_ptr<JsEngine> JsEnginePtr; 39 typedef std::shared_ptr<JsEngine> JsEnginePtr;
41 40
42 /** 41 /**
43 * List of JavaScript values. 42 * List of JavaScript values.
44 */ 43 */
45 typedef std::vector<AdblockPlus::JsValue> JsValueList; 44 typedef std::vector<AdblockPlus::JsValue> JsValueList;
46 45
47 /** 46 /**
48 * Wrapper for JavaScript values. 47 * Wrapper for JavaScript values.
49 * See `JsEngine` for creating `JsValue` objects. 48 * See `JsEngine` for creating `JsValue` objects.
50 */ 49 */
51 class JsValue 50 class JsValue
52 { 51 {
53 friend class JsEngine; 52 friend class JsEngine;
54 public: 53 public:
55 JsValue(JsValue&& src); 54 JsValue(JsValue&& src);
56 JsValue(const JsValue& src); 55 JsValue(const JsValue& src);
57 virtual ~JsValue(); 56 virtual ~JsValue();
58 57
59 JsValue& operator=(const JsValue& src); 58 JsValue& operator=(const JsValue& src);
59 JsValue& operator=(JsValue&& src);
60 60
61 bool IsUndefined() const; 61 bool IsUndefined() const;
62 bool IsNull() const; 62 bool IsNull() const;
63 bool IsString() const; 63 bool IsString() const;
64 bool IsNumber() const; 64 bool IsNumber() const;
65 bool IsBool() const; 65 bool IsBool() const;
66 bool IsObject() const; 66 bool IsObject() const;
67 bool IsArray() const; 67 bool IsArray() const;
68 bool IsFunction() const; 68 bool IsFunction() const;
69 std::string AsString() const; 69 std::string AsString() const;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 * @param arg A single required parameter. 135 * @param arg A single required parameter.
136 * @return Value returned by the function. 136 * @return Value returned by the function.
137 */ 137 */
138 JsValue Call(const JsValue& arg) const; 138 JsValue Call(const JsValue& arg) const;
139 139
140 v8::Local<v8::Value> UnwrapValue() const; 140 v8::Local<v8::Value> UnwrapValue() const;
141 141
142 protected: 142 protected:
143 JsEnginePtr jsEngine; 143 JsEnginePtr jsEngine;
144 private: 144 private:
145 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value); 145 JsValue(JsEnginePtr jsEngine, v8::Local<v8::Value> value);
146 void SetProperty(const std::string& name, v8::Handle<v8::Value> val); 146 void SetProperty(const std::string& name, v8::Local<v8::Value> val);
147
147 // Parameter args is not const because a pointer to its internal arrays is 148 // Parameter args is not const because a pointer to its internal arrays is
148 // passed to v8::Function::Call but the latter does not expect a const point er. 149 // passed to v8::Function::Call but the latter does not expect a const point er.
149 JsValue Call(std::vector<v8::Handle<v8::Value>>& args, v8::Local<v8::Object> thisObj) const; 150 JsValue Call(std::vector<v8::Local<v8::Value>>& args, v8::Local<v8::Object> thisObj) const;
150 151
151 std::unique_ptr<v8::Persistent<v8::Value>> value; 152 std::unique_ptr<v8::Global<v8::Value>> value;
152 }; 153 };
153 } 154 }
154 155
155 #endif 156 #endif
OLDNEW
« README.md ('K') | « include/AdblockPlus/JsEngine.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld