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

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

Issue 10213003: Make JsEngine::Evaluate() return a wrapper for v8::Value to accessdifferent variable types easily (Closed)
Left Patch Set: Extended JsValue API to support all FilterEngine functions Created April 13, 2013, 8:42 p.m.
Right Patch Set: Addressed review comments Created April 17, 2013, 7:56 a.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') | include/AdblockPlus/JsValue.h » ('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 #ifndef ADBLOCKPLUS_JS_ENGINE_H 1 #ifndef ADBLOCKPLUS_JS_ENGINE_H
2 #define ADBLOCKPLUS_JS_ENGINE_H 2 #define ADBLOCKPLUS_JS_ENGINE_H
3 3
4 #include <stdexcept> 4 #include <stdexcept>
5 #include <string> 5 #include <string>
6 #include <v8.h> 6 #include <v8.h>
7 #include <AdblockPlus/JsValue.h> 7 #include <AdblockPlus/JsValue.h>
8 8
9 namespace AdblockPlus 9 namespace AdblockPlus
10 { 10 {
11 class FileSystem;
12 class WebRequest;
11 class ErrorCallback; 13 class ErrorCallback;
12 class FileReader;
13 class WebRequest;
14 14
15 class JsError : public std::runtime_error 15 class JsError : public std::runtime_error
16 { 16 {
17 public: 17 public:
18 explicit JsError(const v8::Handle<v8::Value> exception, 18 explicit JsError(const v8::Handle<v8::Value> exception,
19 const v8::Handle<v8::Message> message); 19 const v8::Handle<v8::Message> message);
20 }; 20 };
21 21
22 class JsEngine 22 class JsEngine
23 { 23 {
24 friend class JsValue; 24 friend class JsValue;
25 25
26 public: 26 public:
27 JsEngine(const FileReader* const fileReader, 27 JsEngine(FileSystem* const fileReader,
28 WebRequest* const webRequest, 28 WebRequest* const webRequest,
29 ErrorCallback* const errorCallback); 29 ErrorCallback* const errorCallback);
30 JsValuePtr Evaluate(const std::string& source, 30 JsValuePtr Evaluate(const std::string& source,
31 const std::string& filename = ""); 31 const std::string& filename = "");
32 void Load(const std::string& scriptPath); 32 void Load(const std::string& scriptPath);
33 void Gc(); 33 void Gc();
34 JsValuePtr NewValue(const std::string& val); 34 JsValuePtr NewValue(const std::string& val);
35 JsValuePtr NewValue(int64_t val); 35 JsValuePtr NewValue(int64_t val);
36 JsValuePtr NewValue(bool val); 36 JsValuePtr NewValue(bool val);
37 inline JsValuePtr NewValue(const char* val)
38 {
39 return NewValue(std::string(val));
40 }
41 inline JsValuePtr NewValue(int val)
42 {
43 return NewValue(static_cast<int64_t>(val));
44 }
37 45
38 class Context 46 class Context
39 { 47 {
40 public: 48 public:
41 Context(const JsEngine& jsEngine); 49 Context(const JsEngine& jsEngine);
42 virtual inline ~Context() {}; 50 virtual inline ~Context() {};
43 51
44 private: 52 private:
45 const v8::Locker locker; 53 const v8::Locker locker;
46 const v8::HandleScope handleScope; 54 const v8::HandleScope handleScope;
47 const v8::Context::Scope contextScope; 55 const v8::Context::Scope contextScope;
48 }; 56 };
49 57
50 private: 58 private:
51 const FileReader* const fileReader; 59 const FileSystem* const fileSystem;
52 v8::Isolate* isolate; 60 v8::Isolate* isolate;
53 v8::Persistent<v8::Context> context; 61 v8::Persistent<v8::Context> context;
54 }; 62 };
55 } 63 }
56 64
57 #endif 65 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld