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

Unified Diff: include/AdblockPlus/JsEngine.h

Issue 10213003: Make JsEngine::Evaluate() return a wrapper for v8::Value to accessdifferent variable types easily (Closed)
Patch Set: Addressed review comments Created April 17, 2013, 7:56 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | include/AdblockPlus/JsValue.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/JsEngine.h
===================================================================
--- a/include/AdblockPlus/JsEngine.h
+++ b/include/AdblockPlus/JsEngine.h
@@ -1,38 +1,65 @@
#ifndef ADBLOCKPLUS_JS_ENGINE_H
#define ADBLOCKPLUS_JS_ENGINE_H
#include <stdexcept>
#include <string>
#include <v8.h>
+#include <AdblockPlus/JsValue.h>
namespace AdblockPlus
{
class FileSystem;
class WebRequest;
class ErrorCallback;
class JsError : public std::runtime_error
{
public:
explicit JsError(const v8::Handle<v8::Value> exception,
const v8::Handle<v8::Message> message);
};
class JsEngine
{
+ friend class JsValue;
+
public:
JsEngine(FileSystem* const fileReader,
WebRequest* const webRequest,
ErrorCallback* const errorCallback);
- std::string Evaluate(const std::string& source,
+ JsValuePtr Evaluate(const std::string& source,
const std::string& filename = "");
void Load(const std::string& scriptPath);
void Gc();
+ JsValuePtr NewValue(const std::string& val);
+ JsValuePtr NewValue(int64_t val);
+ JsValuePtr NewValue(bool val);
+ inline JsValuePtr NewValue(const char* val)
+ {
+ return NewValue(std::string(val));
+ }
+ inline JsValuePtr NewValue(int val)
+ {
+ return NewValue(static_cast<int64_t>(val));
+ }
+
+ class Context
+ {
+ public:
+ Context(const JsEngine& jsEngine);
+ virtual inline ~Context() {};
+
+ private:
+ const v8::Locker locker;
+ const v8::HandleScope handleScope;
+ const v8::Context::Scope contextScope;
+ };
private:
const FileSystem* const fileSystem;
+ v8::Isolate* isolate;
v8::Persistent<v8::Context> context;
};
}
#endif
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | include/AdblockPlus/JsValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld