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

Unified Diff: mojo/public/bindings/js/v8_wrapper.cc

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: spelling 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/bindings/js/v8_wrapper.cc
diff --git a/mojo/public/bindings/js/v8_wrapper.cc b/mojo/public/bindings/js/v8_wrapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f39f714380422cb7f0817887c812670a9de03ee2
--- /dev/null
+++ b/mojo/public/bindings/js/v8_wrapper.cc
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/bindings/js/v8_wrapper.h"
+
+namespace mojo {
+namespace js {
+
+WrapperInfo* WrapperInfo::From(v8::Handle<v8::Object> object) {
+ if (object->InternalFieldCount() != kNumberOfInternalFields)
+ return NULL;
+ return static_cast<WrapperInfo*>(
+ object->GetAlignedPointerFromInternalField(kWrapperInfoIndex));
+}
+
+// Wrapper<int32_t> -----------------------------------------------------------
+
+v8::Handle<v8::Value> Wrapper<int32_t>::ToObject(v8::Isolate* isolate,
+ int32_t native) {
+ return v8::Integer::New(native);
+}
+
+int32_t Wrapper<int32_t>::ToNative(v8::Handle<v8::Value> value) {
+ return value->Int32Value();
Aaron Boodman 2013/11/09 08:26:02 You probably want some way for this method to indi
abarth-chromium 2013/11/09 08:52:37 As written, the conversion can't really fail. If
Aaron Boodman 2013/11/09 21:12:12 For number it can't fail, but for, e.g., mojo::Han
+}
+
+// Wrapper<uint32_t> ----------------------------------------------------------
+
+v8::Handle<v8::Value> Wrapper<uint32_t>::ToObject(v8::Isolate* isolate,
+ uint32_t native) {
+ return v8::Integer::NewFromUnsigned(native);
+}
+
+uint32_t Wrapper<uint32_t>::ToNative(v8::Handle<v8::Value> value) {
+ return value->Uint32Value();
+}
+
+// Wrapper<uint64_t> ----------------------------------------------------------
+
+v8::Handle<v8::Value> Wrapper<uint64_t>::ToObject(v8::Isolate* isolate,
+ uint64_t native) {
+ return v8::Integer::NewFromUnsigned(native);
+}
+
+uint64_t Wrapper<uint64_t>::ToNative(v8::Handle<v8::Value> value) {
+ return value->IntegerValue();
+}
+} // namespace js
+} // mojo
« mojo/public/bindings/js/v8_wrapper.h ('K') | « mojo/public/bindings/js/v8_wrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698