OLD | NEW |
---|---|
(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_wrapper.h" | |
6 | |
7 namespace mojo { | |
8 namespace js { | |
9 | |
10 WrapperInfo* WrapperInfo::From(v8::Handle<v8::Object> object) { | |
11 if (object->InternalFieldCount() != kNumberOfInternalFields) | |
12 return NULL; | |
13 return static_cast<WrapperInfo*>( | |
14 object->GetAlignedPointerFromInternalField(kWrapperInfoIndex)); | |
15 } | |
16 | |
17 // Wrapper<int32_t> ----------------------------------------------------------- | |
18 | |
19 v8::Handle<v8::Value> Wrapper<int32_t>::ToObject(v8::Isolate* isolate, | |
20 int32_t native) { | |
21 return v8::Integer::New(native); | |
22 } | |
23 | |
24 int32_t Wrapper<int32_t>::ToNative(v8::Handle<v8::Value> value) { | |
25 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
| |
26 } | |
27 | |
28 // Wrapper<uint32_t> ---------------------------------------------------------- | |
29 | |
30 v8::Handle<v8::Value> Wrapper<uint32_t>::ToObject(v8::Isolate* isolate, | |
31 uint32_t native) { | |
32 return v8::Integer::NewFromUnsigned(native); | |
33 } | |
34 | |
35 uint32_t Wrapper<uint32_t>::ToNative(v8::Handle<v8::Value> value) { | |
36 return value->Uint32Value(); | |
37 } | |
38 | |
39 // Wrapper<uint64_t> ---------------------------------------------------------- | |
40 | |
41 v8::Handle<v8::Value> Wrapper<uint64_t>::ToObject(v8::Isolate* isolate, | |
42 uint64_t native) { | |
43 return v8::Integer::NewFromUnsigned(native); | |
44 } | |
45 | |
46 uint64_t Wrapper<uint64_t>::ToNative(v8::Handle<v8::Value> value) { | |
47 return value->IntegerValue(); | |
48 } | |
49 } // namespace js | |
50 } // mojo | |
OLD | NEW |