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

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

Issue 29393589: Issue 5013 - Make more methods const.- introduced JsConstValuePtr and JsConstValueList- JsValue:… (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created March 23, 2017, 6:12 p.m.
Right Patch Set: Rebased on master Created March 24, 2017, 2:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « include/AdblockPlus/FilterEngine.h ('k') | src/FileSystemJsObject.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 typedef std::shared_ptr<const JsValue> JsConstValuePtr;
sergei 2017/03/23 19:46:06 What about ConstJsValuePtr?
46 46
47 /** 47 /**
48 * List of JavaScript values. 48 * List of JavaScript values.
49 */ 49 */
50 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList; 50 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList;
51 typedef std::vector<AdblockPlus::JsConstValuePtr> JsConstValueList; 51 typedef std::vector<AdblockPlus::JsConstValuePtr> JsConstValueList;
sergei 2017/03/23 19:46:06 What about ConstJsValueList?
hub 2017/03/24 13:45:15 To answer about here and above, I feel like ConstJ
sergei 2017/03/24 13:56:47 Agree. Considering Js as a namespace makes sense h
52 52
53 /** 53 /**
54 * Wrapper for JavaScript values. 54 * Wrapper for JavaScript values.
55 * See `JsEngine` for creating `JsValue` objects. 55 * See `JsEngine` for creating `JsValue` objects.
56 */ 56 */
57 class JsValue 57 class JsValue
58 { 58 {
59 friend class JsEngine; 59 friend class JsEngine;
60 public: 60 public:
61 JsValue(JsValue&& src); 61 JsValue(JsValue&& src);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 * @return Class name of the value. 116 * @return Class name of the value.
117 */ 117 */
118 std::string GetClass() const; 118 std::string GetClass() const;
119 119
120 /** 120 /**
121 * Invokes the value as a function (see `IsFunction()`). 121 * Invokes the value as a function (see `IsFunction()`).
122 * @param params Optional list of parameters. 122 * @param params Optional list of parameters.
123 * @param thisPtr Optional `this` value. 123 * @param thisPtr Optional `this` value.
124 * @return Value returned by the function. 124 * @return Value returned by the function.
125 */ 125 */
126 JsValuePtr Call(const JsConstValueList& params = JsConstValueList(), 126 JsValuePtr Call(const JsConstValueList& params = JsConstValueList(),
sergei 2017/03/23 19:46:06 This change is a bit questionable, but I think we
hub 2017/03/24 13:45:15 it is quite essential. The problem boils down to t
sergei 2017/03/24 13:56:47 I rather thought about no replacing the existing m
127 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; 127 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const;
128 128
129 /** 129 /**
130 * Invokes the value as a function (see `IsFunction()`) with single 130 * Invokes the value as a function (see `IsFunction()`) with single
131 * parameter. 131 * parameter.
132 * @param arg A single required parameter. 132 * @param arg A single required parameter.
133 * @return Value returned by the function. 133 * @return Value returned by the function.
134 */ 134 */
135 JsValuePtr Call(const JsValue& arg) const; 135 JsValuePtr Call(const JsConstValuePtr& arg) const;
136 136
137 v8::Local<v8::Value> UnwrapValue() const; 137 v8::Local<v8::Value> UnwrapValue() const;
138 protected: 138 protected:
139 JsEnginePtr jsEngine; 139 JsEnginePtr jsEngine;
140 private: 140 private:
141 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value); 141 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value);
142 void SetProperty(const std::string& name, v8::Handle<v8::Value> val); 142 void SetProperty(const std::string& name, v8::Handle<v8::Value> val);
143 std::unique_ptr<v8::Persistent<v8::Value>> value; 143 std::unique_ptr<v8::Persistent<v8::Value>> value;
144 }; 144 };
145 } 145 }
146 146
147 #endif 147 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld