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

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

Issue 10213003: Make JsEngine::Evaluate() return a wrapper for v8::Value to accessdifferent variable types easily (Closed)
Patch Set: Extended JsValue API to support all FilterEngine functions Created April 13, 2013, 8: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 | « include/AdblockPlus/JsEngine.h ('k') | lib/api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #ifndef ADBLOCKPLUS_JS_VALUE_H
2 #define ADBLOCKPLUS_JS_VALUE_H
3
4 #include <vector>
5 #include <v8.h>
6 #ifdef _MSC_VER
7 #include <memory>
8 #else
9 #include <tr1/memory>
10 #endif
11
12 namespace AdblockPlus
13 {
14 class JsEngine;
15 class JsValue;
16
17 typedef std::tr1::shared_ptr<JsValue> JsValuePtr;
18 typedef std::vector<AdblockPlus::JsValuePtr> JsValueList;
19
20 class JsValue
21 {
22 friend class JsEngine;
23 friend class JsObject;
24 public:
25 virtual ~JsValue();
26
27 bool IsUndefined() const;
28 bool IsNull() const;
29 bool IsString() const;
30 bool IsNumber() const;
31 bool IsBool() const;
32 bool IsObject() const;
33 bool IsArray() const;
34 bool IsFunction() const;
35 std::string AsString() const;
36 int64_t AsInt() const;
37 bool AsBool() const;
38 JsValueList AsList() const;
39 JsValuePtr GetProperty(const std::string& name) const;
40 void SetProperty(const std::string& name, const std::string& val);
41 void SetProperty(const std::string& name, int64_t val);
42 void SetProperty(const std::string& name, bool val);
43 void inline SetProperty(const std::string& name, const char* val)
44 {
45 SetProperty(name, std::string(val));
46 }
47 std::string GetClassName() const;
48 JsValuePtr Call(const JsValueList& params = JsValueList(),
49 AdblockPlus::JsValuePtr thisPtr = AdblockPlus::JsValuePtr()) const;
50 protected:
51 JsValue(JsEngine& jsEngine, v8::Handle<v8::Value> value);
52 void SetProperty(const std::string& name, v8::Handle<v8::Value> val);
53
54 JsEngine& jsEngine;
55 v8::Persistent<v8::Value> value;
56 };
57 }
58
59 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | lib/api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld