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

Side by Side Diff: gin/object_template_builder.h

Issue 105743007: Gin: Make it easier to implement Wrappable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « gin/function_template.h.pump ('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 "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 25 matching lines...) Expand all
36 return CreateFunctionTemplate(isolate, callback); 36 return CreateFunctionTemplate(isolate, callback);
37 } 37 }
38 }; 38 };
39 39
40 // Specialization for member function pointers. We need to handle this case 40 // Specialization for member function pointers. We need to handle this case
41 // specially because the first parameter for callbacks to MFP should typically 41 // specially because the first parameter for callbacks to MFP should typically
42 // come from the the JavaScript "this" object the function was called on, not 42 // come from the the JavaScript "this" object the function was called on, not
43 // from the first normal parameter. 43 // from the first normal parameter.
44 template<typename T> 44 template<typename T>
45 struct CallbackTraits<T, typename base::enable_if< 45 struct CallbackTraits<T, typename base::enable_if<
46 base::is_member_function_pointer<T>::value >::type> { 46 base::is_member_function_pointer<T>::value>::type> {
47 static v8::Handle<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate, 47 static v8::Handle<v8::FunctionTemplate> CreateTemplate(v8::Isolate* isolate,
48 T callback) { 48 T callback) {
49 return CreateFunctionTemplate(isolate, base::Bind(callback), 49 return CreateFunctionTemplate(isolate, base::Bind(callback),
50 HolderIsFirstArgument); 50 HolderIsFirstArgument);
51 } 51 }
52 }; 52 };
53 53
54 // This specialization allows people to construct function templates directly if 54 // This specialization allows people to construct function templates directly if
55 // they need to do fancier stuff. 55 // they need to do fancier stuff.
56 template<> 56 template<>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 v8::Isolate* isolate_; 115 v8::Isolate* isolate_;
116 116
117 // ObjectTemplateBuilder should only be used on the stack. 117 // ObjectTemplateBuilder should only be used on the stack.
118 v8::Local<v8::ObjectTemplate> template_; 118 v8::Local<v8::ObjectTemplate> template_;
119 }; 119 };
120 120
121 } // namespace gin 121 } // namespace gin
122 122
123 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_ 123 #endif // GIN_OBJECT_TEMPLATE_BUILDER_H_
OLDNEW
« no previous file with comments | « gin/function_template.h.pump ('k') | gin/wrappable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698