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

Side by Side Diff: gin/object_template_builder.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 | « extensions/common/permissions/base_set_operators.h ('k') | gin/wrappable.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_OBJECT_TEMPLATE_BUILDER_H_ 5 #ifndef GIN_OBJECT_TEMPLATE_BUILDER_H_
6 #define GIN_OBJECT_TEMPLATE_BUILDER_H_ 6 #define GIN_OBJECT_TEMPLATE_BUILDER_H_
7 7
8 #include <type_traits> 8 #include <type_traits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/template_util.h"
14 #include "gin/converter.h" 13 #include "gin/converter.h"
15 #include "gin/function_template.h" 14 #include "gin/function_template.h"
16 #include "gin/gin_export.h" 15 #include "gin/gin_export.h"
17 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
18 17
19 namespace gin { 18 namespace gin {
20 19
21 namespace { 20 namespace {
22 21
23 // Base template - used only for non-member function pointers. Other types 22 // Base template - used only for non-member function pointers. Other types
(...skipping 26 matching lines...) Expand all
50 } 49 }
51 }; 50 };
52 51
53 // Specialization for member function pointers. We need to handle this case 52 // Specialization for member function pointers. We need to handle this case
54 // specially because the first parameter for callbacks to MFP should typically 53 // specially because the first parameter for callbacks to MFP should typically
55 // come from the the JavaScript "this" object the function was called on, not 54 // come from the the JavaScript "this" object the function was called on, not
56 // from the first normal parameter. 55 // from the first normal parameter.
57 template <typename T> 56 template <typename T>
58 struct CallbackTraits< 57 struct CallbackTraits<
59 T, 58 T,
60 typename std::enable_if<base::is_member_function_pointer<T>::value>::type> { 59 typename std::enable_if<std::is_member_function_pointer<T>::value>::type> {
61 static v8::Local<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate, 60 static v8::Local<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate,
62 T callback) { 61 T callback) {
63 return CreateFunctionTemplate(isolate, base::Bind(callback), 62 return CreateFunctionTemplate(isolate, base::Bind(callback),
64 HolderIsFirstArgument); 63 HolderIsFirstArgument);
65 } 64 }
66 static void SetAsFunctionHandler(v8::Isolate* isolate, 65 static void SetAsFunctionHandler(v8::Isolate* isolate,
67 v8::Local<v8::ObjectTemplate> tmpl, 66 v8::Local<v8::ObjectTemplate> tmpl,
68 T callback) { 67 T callback) {
69 CreateFunctionHandler( 68 CreateFunctionHandler(
70 isolate, tmpl, base::Bind(callback), HolderIsFirstArgument); 69 isolate, tmpl, base::Bind(callback), HolderIsFirstArgument);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 141
143 v8::Isolate* isolate_; 142 v8::Isolate* isolate_;
144 143
145 // ObjectTemplateBuilder should only be used on the stack. 144 // ObjectTemplateBuilder should only be used on the stack.
146 v8::Local<v8::ObjectTemplate> template_; 145 v8::Local<v8::ObjectTemplate> template_;
147 }; 146 };
148 147
149 } // namespace gin 148 } // namespace gin
150 149
151 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_ 150 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_
OLDNEW
« no previous file with comments | « extensions/common/permissions/base_set_operators.h ('k') | gin/wrappable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698