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

Delta Between Two Patch Sets: include/AdblockPlus/JsValue.h

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Rebased. Corrected most of the review issues. Created July 4, 2017, 7:57 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « include/AdblockPlus/JsEngine.h ('k') | libadblockplus.gyp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 #include <AdblockPlus/IFileSystem.h>
27
26 namespace v8 28 namespace v8
27 { 29 {
28 class Value; 30 class Value;
29 class Object; 31 class Object;
30 template<class T> class Local; 32 template<class T> class Local;
31 template<class T> class Global; 33 template<class T> class Global;
32 } 34 }
33 35
34 namespace AdblockPlus 36 namespace AdblockPlus
35 { 37 {
36 class JsValue; 38 class JsValue;
37 class JsEngine; 39 class JsEngine;
38 40
39 typedef std::shared_ptr<JsEngine> JsEnginePtr; 41 typedef std::shared_ptr<JsEngine> JsEnginePtr;
42
43 typedef IFileSystem::IOBuffer StringBuffer;
40 44
41 /** 45 /**
42 * List of JavaScript values. 46 * List of JavaScript values.
43 */ 47 */
44 typedef std::vector<AdblockPlus::JsValue> JsValueList; 48 typedef std::vector<AdblockPlus::JsValue> JsValueList;
45 49
46 /** 50 /**
47 * Wrapper for JavaScript values. 51 * Wrapper for JavaScript values.
48 * See `JsEngine` for creating `JsValue` objects. 52 * See `JsEngine` for creating `JsValue` objects.
49 */ 53 */
(...skipping 10 matching lines...) Expand all
60 64
61 bool IsUndefined() const; 65 bool IsUndefined() const;
62 bool IsNull() const; 66 bool IsNull() const;
63 bool IsString() const; 67 bool IsString() const;
64 bool IsNumber() const; 68 bool IsNumber() const;
65 bool IsBool() const; 69 bool IsBool() const;
66 bool IsObject() const; 70 bool IsObject() const;
67 bool IsArray() const; 71 bool IsArray() const;
68 bool IsFunction() const; 72 bool IsFunction() const;
69 std::string AsString() const; 73 std::string AsString() const;
74 StringBuffer AsStringBuffer() const;
70 int64_t AsInt() const; 75 int64_t AsInt() const;
71 bool AsBool() const; 76 bool AsBool() const;
72 JsValueList AsList() const; 77 JsValueList AsList() const;
73 78
74 /** 79 /**
75 * Returns a list of property names if this is an object (see `IsObject()`). 80 * Returns a list of property names if this is an object (see `IsObject()`).
76 * @return List of property names. 81 * @return List of property names.
77 */ 82 */
78 std::vector<std::string> GetOwnPropertyNames() const; 83 std::vector<std::string> GetOwnPropertyNames() const;
79 84
80 /** 85 /**
81 * Returns a property value if this is an object (see `IsObject()`). 86 * Returns a property value if this is an object (see `IsObject()`).
82 * @param name Property name. 87 * @param name Property name.
83 * @return Property value, undefined (see `IsUndefined()`) if the property 88 * @return Property value, undefined (see `IsUndefined()`) if the property
84 * does not exist. 89 * does not exist.
85 */ 90 */
86 JsValue GetProperty(const std::string& name) const; 91 JsValue GetProperty(const std::string& name) const;
87 92
88 //@{ 93 //@{
89 /** 94 /**
90 * Sets a property value if this is an object (see `IsObject()`). 95 * Sets a property value if this is an object (see `IsObject()`).
91 * @param name Property name. 96 * @param name Property name.
92 * @param val Property value. 97 * @param val Property value.
93 */ 98 */
94 void SetProperty(const std::string& name, const std::string& val); 99 void SetProperty(const std::string& name, const std::string& val);
100 void SetProperty(const std::string& name, const StringBuffer& val);
95 void SetProperty(const std::string& name, int64_t val); 101 void SetProperty(const std::string& name, int64_t val);
96 void SetProperty(const std::string& name, bool val); 102 void SetProperty(const std::string& name, bool val);
97 void SetProperty(const std::string& name, const JsValue& value); 103 void SetProperty(const std::string& name, const JsValue& value);
98 inline void SetProperty(const std::string& name, const char* val) 104 inline void SetProperty(const std::string& name, const char* val)
99 { 105 {
100 SetProperty(name, std::string(val)); 106 SetProperty(name, std::string(val));
101 } 107 }
102 inline void SetProperty(const std::string& name, int val) 108 inline void SetProperty(const std::string& name, int val)
103 { 109 {
104 SetProperty(name, static_cast<int64_t>(val)); 110 SetProperty(name, static_cast<int64_t>(val));
105 } 111 }
106 //@} 112 //@}
113 /**
114 * Sets a property value string if this is an object (see `IsObject()`).
115 * @param name Property name.
116 * @param val Property value as a StringBuffer.
117 */
118 void SetStringBufferProperty(const std::string& name, const StringBuffer& va l);
107 119
108 /** 120 /**
109 * Returns the value's class name, e.g.\ _Array_ for arrays 121 * Returns the value's class name, e.g.\ _Array_ for arrays
110 * (see `IsArray()`). 122 * (see `IsArray()`).
111 * Technically, this is the name of the function that was used as a 123 * Technically, this is the name of the function that was used as a
112 * constructor. 124 * constructor.
113 * @return Class name of the value. 125 * @return Class name of the value.
114 */ 126 */
115 std::string GetClass() const; 127 std::string GetClass() const;
116 128
(...skipping 30 matching lines...) Expand all
147 159
148 // Parameter args is not const because a pointer to its internal arrays is 160 // Parameter args is not const because a pointer to its internal arrays is
149 // passed to v8::Function::Call but the latter does not expect a const point er. 161 // passed to v8::Function::Call but the latter does not expect a const point er.
150 JsValue Call(std::vector<v8::Local<v8::Value>>& args, v8::Local<v8::Object> thisObj) const; 162 JsValue Call(std::vector<v8::Local<v8::Value>>& args, v8::Local<v8::Object> thisObj) const;
151 163
152 std::unique_ptr<v8::Global<v8::Value>> value; 164 std::unique_ptr<v8::Global<v8::Value>> value;
153 }; 165 };
154 } 166 }
155 167
156 #endif 168 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld