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

Unified Diff: src/JsValue.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Make read write deal with binary buffers. Created July 6, 2017, 12:19 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
Index: src/JsValue.cpp
===================================================================
--- a/src/JsValue.cpp
+++ b/src/JsValue.cpp
@@ -122,16 +122,22 @@
}
std::string AdblockPlus::JsValue::AsString() const
{
const JsContext context(*jsEngine);
return Utils::FromV8String(UnwrapValue());
}
+std::vector<char> AdblockPlus::JsValue::AsBuffer() const
sergei 2017/07/06 14:14:05 Since there is a buffer type in JS, what about cal
hub 2017/07/06 14:33:31 I'm ok with AsStringBuffer() like we have AsString
+{
+ const JsContext context(*jsEngine);
+ return Utils::BufferFromV8String(UnwrapValue());
+}
+
int64_t AdblockPlus::JsValue::AsInt() const
{
const JsContext context(*jsEngine);
return UnwrapValue()->IntegerValue();
}
bool AdblockPlus::JsValue::AsBool() const
{
@@ -198,16 +204,22 @@
}
void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::string& val)
{
const JsContext context(*jsEngine);
SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val));
}
+void AdblockPlus::JsValue::SetProperty(const std::string& name, const std::vector<char>& val)
hub 2017/07/06 14:33:32 I'll rename it to SetStringProperty then.
sergei 2017/07/07 13:29:27 Could you please rename it?
hub 2017/07/07 13:39:20 Sorry, I had the change shelved by mistake. Curren
+{
+ const JsContext context(*jsEngine);
+ SetProperty(name, Utils::ToV8String(jsEngine->GetIsolate(), val));
+}
+
void AdblockPlus::JsValue::SetProperty(const std::string& name, int64_t val)
{
const JsContext context(*jsEngine);
SetProperty(name, v8::Number::New(jsEngine->GetIsolate(), val));
}
void AdblockPlus::JsValue::SetProperty(const std::string& name, const JsValue& val)
{
« include/AdblockPlus/IFileSystem.h ('K') | « src/JsEngine.cpp ('k') | src/Thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld