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

Unified Diff: include/AdblockPlus/JsValue.h

Issue 10213003: Make JsEngine::Evaluate() return a wrapper for v8::Value to accessdifferent variable types easily (Closed)
Patch Set: Created April 12, 2013, 2:55 p.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/JsEngine.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/JsValue.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/include/AdblockPlus/JsValue.h
@@ -0,0 +1,43 @@
+#ifndef ADBLOCKPLUS_JS_VALUE_H
+#define ADBLOCKPLUS_JS_VALUE_H
+
+#include <v8.h>
+
+namespace AdblockPlus
+{
+ class JsEngine;
+ class JsValue;
+
+ typedef std::tr1::shared_ptr<JsValue> JsValuePtr;
Wladimir Palant 2013/04/13 20:44:21 I only realized now that I didn't include tr1/memo
+
+ class JsValue
+ {
+ friend class JsEngine;
+ public:
+ virtual ~JsValue();
+
+ bool IsUndefined() const;
+ bool IsNull() const;
+ bool IsString() const;
+ bool IsNumber() const;
+ bool IsBool() const;
+ bool IsObject() const;
+ std::string AsString() const;
+ int64_t AsInt() const;
+ bool AsBool() const;
+ JsValuePtr GetProperty(const std::string& name) const;
+ void SetProperty(const std::string& name, const std::string& val);
+ void SetProperty(const std::string& name, int64_t val);
+ void SetProperty(const std::string& name, bool val);
+ protected:
+ JsValue(v8::Isolate* isolate, v8::Handle<v8::Context> context,
+ v8::Handle<v8::Value> value);
+ void SetProperty(const std::string& name, v8::Handle<v8::Value> val);
+
+ v8::Isolate* isolate;
+ v8::Persistent<v8::Context> context;
+ v8::Persistent<v8::Value> value;
+ };
+}
+
+#endif
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld