OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GIN_HANDLE_H_ | 5 #ifndef GIN_HANDLE_H_ |
6 #define GIN_HANDLE_H_ | 6 #define GIN_HANDLE_H_ |
7 | 7 |
8 #include "gin/converter.h" | 8 #include "gin/converter.h" |
9 | 9 |
10 namespace gin { | 10 namespace gin { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 *out = gin::Handle<T>(val, object); | 54 *out = gin::Handle<T>(val, object); |
55 return true; | 55 return true; |
56 } | 56 } |
57 }; | 57 }; |
58 | 58 |
59 // This function is a convenient way to create a handle from a raw pointer | 59 // This function is a convenient way to create a handle from a raw pointer |
60 // without having to write out the type of the object explicitly. | 60 // without having to write out the type of the object explicitly. |
61 template<typename T> | 61 template<typename T> |
62 gin::Handle<T> CreateHandle(v8::Isolate* isolate, T* object) { | 62 gin::Handle<T> CreateHandle(v8::Isolate* isolate, T* object) { |
63 return gin::Handle<T>(object->GetWrapper(isolate), object); | 63 v8::Handle<v8::Object> wrapper = object->GetWrapper(isolate); |
| 64 if (wrapper.IsEmpty()) |
| 65 return gin::Handle<T>(); |
| 66 return gin::Handle<T>(wrapper, object); |
64 } | 67 } |
65 | 68 |
66 } // namespace gin | 69 } // namespace gin |
67 | 70 |
68 #endif // GIN_HANDLE_H_ | 71 #endif // GIN_HANDLE_H_ |
OLD | NEW |