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

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

Issue 6584950149087232: Issue 1280 - Update v8 (Closed)
Patch Set: Created Oct. 24, 2014, 12:42 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
« no previous file with comments | « createsolution.bat ('k') | include/AdblockPlus/V8ValueHolder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 10 matching lines...) Expand all
21 #include <stdint.h> 21 #include <stdint.h>
22 #include <string> 22 #include <string>
23 #include <vector> 23 #include <vector>
24 #include "tr1_memory.h" 24 #include "tr1_memory.h"
25 #include "V8ValueHolder.h" 25 #include "V8ValueHolder.h"
26 26
27 namespace v8 27 namespace v8
28 { 28 {
29 class Value; 29 class Value;
30 template<class T> class Handle; 30 template<class T> class Handle;
31 template<class T> class Local;
31 } 32 }
32 33
33 namespace AdblockPlus 34 namespace AdblockPlus
34 { 35 {
35 class JsValue; 36 class JsValue;
36 class JsEngine; 37 class JsEngine;
37 38
38 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr; 39 typedef std::tr1::shared_ptr<JsEngine> JsEnginePtr;
39 40
40 /** 41 /**
41 * Shared smart pointer to a `JsValue` instance. 42 * Shared smart pointer to a `JsValue` instance.
42 */ 43 */
43 typedef std::tr1::shared_ptr<JsValue> JsValuePtr; 44 typedef std::tr1::shared_ptr<JsValue> JsValuePtr;
44 45
45 /** 46 /**
46 * List of JavaScript values. 47 * List of JavaScript values.
47 */ 48 */
48 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList; 49 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList;
49 50
50 /** 51 /**
51 * Wrapper for JavaScript values. 52 * Wrapper for JavaScript values.
52 * See `JsEngine` for creating `JsValue` objects. 53 * See `JsEngine` for creating `JsValue` objects.
53 */ 54 */
54 class JsValue 55 class JsValue
55 { 56 {
56 friend class JsEngine;
57 public: 57 public:
58 JsValue(JsValuePtr value); 58 struct Private
59 {
60 private:
61 // allow access to the ctr only JsEngine and don't allow JsEngine to acces s other members.
62 friend class JsEngine;
63 friend class JsValue;
64 struct CtrArg
65 {
66 };
67 };
68 protected:
69 typedef Private::CtrArg PrivateCtrArg;
70 JsValue(const JsValuePtr& value);
71 public:
72 JsValue(const JsEnginePtr& jsEngine, const v8::Handle<v8::Value> value, Priv ateCtrArg);
59 virtual ~JsValue(); 73 virtual ~JsValue();
60 74
61 bool IsUndefined() const; 75 bool IsUndefined() const;
62 bool IsNull() const; 76 bool IsNull() const;
63 bool IsString() const; 77 bool IsString() const;
64 bool IsNumber() const; 78 bool IsNumber() const;
65 bool IsBool() const; 79 bool IsBool() const;
66 bool IsObject() const; 80 bool IsObject() const;
67 bool IsArray() const; 81 bool IsArray() const;
68 bool IsFunction() const; 82 bool IsFunction() const;
(...skipping 18 matching lines...) Expand all
87 101
88 //@{ 102 //@{
89 /** 103 /**
90 * Sets a property value if this is an object (see `IsObject()`). 104 * Sets a property value if this is an object (see `IsObject()`).
91 * @param name Property name. 105 * @param name Property name.
92 * @param val Property value. 106 * @param val Property value.
93 */ 107 */
94 void SetProperty(const std::string& name, const std::string& val); 108 void SetProperty(const std::string& name, const std::string& val);
95 void SetProperty(const std::string& name, int64_t val); 109 void SetProperty(const std::string& name, int64_t val);
96 void SetProperty(const std::string& name, bool val); 110 void SetProperty(const std::string& name, bool val);
97 void SetProperty(const std::string& name, JsValuePtr value); 111 void SetProperty(const std::string& name, const JsValuePtr& value);
98 inline void SetProperty(const std::string& name, const char* val) 112 inline void SetProperty(const std::string& name, const char* val)
99 { 113 {
100 SetProperty(name, std::string(val)); 114 SetProperty(name, std::string(val));
101 } 115 }
102 inline void SetProperty(const std::string& name, int val) 116 inline void SetProperty(const std::string& name, int val)
103 { 117 {
104 SetProperty(name, static_cast<int64_t>(val)); 118 SetProperty(name, static_cast<int64_t>(val));
105 } 119 }
106 //@} 120 //@}
107 121
108 /** 122 /**
109 * Returns the value's class name, e.g.\ _Array_ for arrays 123 * Returns the value's class name, e.g.\ _Array_ for arrays
110 * (see `IsArray()`). 124 * (see `IsArray()`).
111 * Technically, this is the name of the function that was used as a 125 * Technically, this is the name of the function that was used as a
112 * constructor. 126 * constructor.
113 * @return Class name of the value. 127 * @return Class name of the value.
114 */ 128 */
115 std::string GetClass() const; 129 std::string GetClass() const;
116 130
117 /** 131 /**
118 * Invokes the value as a function (see `IsFunction()`). 132 * Invokes the value as a function (see `IsFunction()`).
119 * @param params Optional list of parameters. 133 * @param params Optional list of parameters.
120 * @param thisPtr Optional `this` value. 134 * @param thisPtr Optional `this` value.
121 * @return Value returned by the function. 135 * @return Value returned by the function.
122 */ 136 */
123 JsValuePtr Call(const JsValueList& params = JsValueList(), 137 JsValuePtr Call(const JsValueList& params = JsValueList(),
124 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const; 138 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const;
125 139
140 v8::Local<v8::Value> unwrapValue() const;
141 private:
142 void SetProperty(const std::string& name, const v8::Handle<v8::Value> val);
126 protected: 143 protected:
127 JsValue(JsEnginePtr jsEngine, v8::Handle<v8::Value> value);
128 void SetProperty(const std::string& name, v8::Handle<v8::Value> val);
129
130 JsEnginePtr jsEngine; 144 JsEnginePtr jsEngine;
145 private:
131 V8ValueHolder<v8::Value> value; 146 V8ValueHolder<v8::Value> value;
132 }; 147 };
133 } 148 }
134 149
135 #endif 150 #endif
OLDNEW
« no previous file with comments | « createsolution.bat ('k') | include/AdblockPlus/V8ValueHolder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld