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

Side by Side Diff: 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/
Patch Set: Created March 23, 2017, 6:12 p.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
(...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;
sergei 2017/03/23 19:46:06 What about ConstJsValuePtr?
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;
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
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
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(),
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
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 JsValue& 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
OLDNEW

Powered by Google App Engine
This is Rietveld