Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Side by Side Diff: mojo/public/bindings/js/v8_string.cc

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style nits Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/public/bindings/js/v8_string.h"
6
7 namespace mojo {
8 namespace js {
9
10 v8::Handle<v8::String> Wrapper<std::string>::ToObject(v8::Isolate* isolate,
11 std::string native) {
12 return v8::String::NewFromUtf8(isolate,
13 native.data(),
14 v8::String::kNormalString,
15 native.length());
16 }
17
18 std::string Wrapper<std::string>::ToNative(v8::Handle<v8::Value> value) {
19 if (!value->IsString())
20 return std::string();
21 v8::Handle<v8::String> string = v8::Handle<v8::String>::Cast(value);
22 int length = string->Utf8Length();
23 std::string result;
24 result.resize(length);
25 string->WriteUtf8(&result[0], length, NULL, v8::String::NO_NULL_TERMINATION);
26 return result;
27 }
28
29 } // namespace js
30 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698