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

Side by Side Diff: gin/wrappable.h

Issue 1774443002: Replace template_util.h stuff with C++11 <type_traits> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert unrelated whitespace change Created 4 years, 9 months 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
« no previous file with comments | « gin/object_template_builder.h ('k') | google_apis/drive/test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_WRAPPABLE_H_ 5 #ifndef GIN_WRAPPABLE_H_
6 #define GIN_WRAPPABLE_H_ 6 #define GIN_WRAPPABLE_H_
7 7
8 #include <type_traits> 8 #include <type_traits>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/template_util.h"
12 #include "gin/converter.h" 11 #include "gin/converter.h"
13 #include "gin/gin_export.h" 12 #include "gin/gin_export.h"
14 #include "gin/public/wrapper_info.h" 13 #include "gin/public/wrapper_info.h"
15 14
16 namespace gin { 15 namespace gin {
17 16
18 // Wrappable is a base class for C++ objects that have corresponding v8 wrapper 17 // Wrappable is a base class for C++ objects that have corresponding v8 wrapper
19 // objects. To retain a Wrappable object on the stack, use a gin::Handle. 18 // objects. To retain a Wrappable object on the stack, use a gin::Handle.
20 // 19 //
21 // USAGE: 20 // USAGE:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 99
101 private: 100 private:
102 DISALLOW_COPY_AND_ASSIGN(Wrappable); 101 DISALLOW_COPY_AND_ASSIGN(Wrappable);
103 }; 102 };
104 103
105 104
106 // This converter handles any subclass of Wrappable. 105 // This converter handles any subclass of Wrappable.
107 template <typename T> 106 template <typename T>
108 struct Converter<T*, 107 struct Converter<T*,
109 typename std::enable_if< 108 typename std::enable_if<
110 base::is_convertible<T*, WrappableBase*>::value>::type> { 109 std::is_convertible<T*, WrappableBase*>::value>::type> {
111 static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, T* val) { 110 static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, T* val) {
112 return val->GetWrapper(isolate); 111 return val->GetWrapper(isolate);
113 } 112 }
114 113
115 static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, T** out) { 114 static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, T** out) {
116 *out = static_cast<T*>(static_cast<WrappableBase*>( 115 *out = static_cast<T*>(static_cast<WrappableBase*>(
117 internal::FromV8Impl(isolate, val, &T::kWrapperInfo))); 116 internal::FromV8Impl(isolate, val, &T::kWrapperInfo)));
118 return *out != NULL; 117 return *out != NULL;
119 } 118 }
120 }; 119 };
121 120
122 } // namespace gin 121 } // namespace gin
123 122
124 #endif // GIN_WRAPPABLE_H_ 123 #endif // GIN_WRAPPABLE_H_
OLDNEW
« no previous file with comments | « gin/object_template_builder.h ('k') | google_apis/drive/test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698