| 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..74ddc197e2defe43b57ed3a7c05e9e1d492a300e
|
| --- /dev/null
|
| +++ b/mojo/public/bindings/js/v8_wrapper.cc
|
| @@ -0,0 +1,51 @@
|
| +// 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();
|
| +}
|
| +
|
| +// 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
|
| +} // namespace mojo
|
|
|