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

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

Issue 9884006: Add file name and line number when reporting exceptions (Closed)
Left Patch Set: Created March 15, 2013, 9:33 a.m.
Right Patch Set: Now with free functions Created March 15, 2013, 3:38 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 | « no previous file | src/JsEngine.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 #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 7
8 class ErrorCallback; 8 class ErrorCallback;
9 class FileReader; 9 class FileReader;
10 10
11 namespace AdblockPlus 11 namespace AdblockPlus
12 { 12 {
13 class JsError : public std::runtime_error 13 class JsError : public std::runtime_error
14 { 14 {
15 public: 15 public:
16 JsError(const v8::Handle<v8::Value> exception, 16 JsError(const v8::Handle<v8::Value> exception,
17 const v8::Handle<v8::Message> message);
18 private:
Felix Dahlke 2013/03/15 14:18:15 Mind adding an empty line before private? I know,
19 std::string toString(const v8::Handle<v8::Value> exception,
Felix Dahlke 2013/03/15 14:18:15 We are starting all function/method names with an
Wladimir Palant 2013/03/15 15:27:26 I prefer having this a method for reasons of bette
20 const v8::Handle<v8::Message> message); 17 const v8::Handle<v8::Message> message);
21 }; 18 };
22 19
23 class JsEngine 20 class JsEngine
24 { 21 {
25 public: 22 public:
26 JsEngine(const FileReader* const fileReader, 23 JsEngine(const FileReader* const fileReader,
27 ErrorCallback* const errorCallback); 24 ErrorCallback* const errorCallback);
28 void Evaluate(const char* source, const char* filename = NULL); 25 void Evaluate(const char* source, const char* filename = NULL);
29 void Evaluate(const std::string& source) 26 void Evaluate(const std::string& source)
30 { 27 {
31 Evaluate(source.c_str()); 28 Evaluate(source.c_str());
32 } 29 }
33 void Evaluate(const std::string& source, const std::string& filename) 30 void Evaluate(const std::string& source, const std::string& filename)
34 { 31 {
35 Evaluate(filename.c_str(), source.c_str()); 32 Evaluate(filename.c_str(), source.c_str());
36 } 33 }
37 void Load(const std::string& scriptPath); 34 void Load(const std::string& scriptPath);
38 std::string Call(const std::string& functionName); 35 std::string Call(const std::string& functionName);
39 void Gc(); 36 void Gc();
40 37
41 private: 38 private:
42 const FileReader* const fileReader; 39 const FileReader* const fileReader;
43 v8::Persistent<v8::Context> context; 40 v8::Persistent<v8::Context> context;
44 inline v8::Handle<v8::Script> CompileScript(const char* source, const char* filename); 41 inline v8::Handle<v8::Script> CompileScript(const char* source, const char* filename);
45 }; 42 };
46 } 43 }
47 44
48 #endif 45 #endif
LEFTRIGHT
« no previous file | src/JsEngine.cpp » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld