| Index: src/Utils.cpp |
| =================================================================== |
| --- a/src/Utils.cpp |
| +++ b/src/Utils.cpp |
| @@ -30,22 +30,38 @@ |
| { |
| v8::String::Utf8Value stringValue(value); |
| if (stringValue.length()) |
| return std::string(*stringValue, stringValue.length()); |
| else |
| return std::string(); |
| } |
| +StringBuffer Utils::StringBufferFromV8String(const v8::Handle<v8::Value>& value) |
| +{ |
| + v8::String::Utf8Value stringValue(value); |
| + if (stringValue.length()) |
| + return IFileSystem::IOBuffer(*stringValue, *stringValue + stringValue.length()); |
| + else |
| + return IFileSystem::IOBuffer(); |
| +} |
| + |
| v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string& str) |
| { |
| return v8::String::NewFromUtf8(isolate, str.c_str(), |
| v8::String::NewStringType::kNormalString, str.length()); |
| } |
| +v8::Local<v8::String> Utils::StringBufferToV8String(v8::Isolate* isolate, const StringBuffer& str) |
| +{ |
| + return v8::String::NewFromUtf8(isolate, |
| + reinterpret_cast<const char*>(str.data()), |
| + v8::String::NewStringType::kNormalString, str.size()); |
| +} |
| + |
| void Utils::ThrowExceptionInJS(v8::Isolate* isolate, const std::string& str) |
| { |
| isolate->ThrowException(Utils::ToV8String(isolate, str)); |
| } |
| #ifdef _WIN32 |
| std::wstring Utils::ToUtf16String(const std::string& str) |
| { |