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_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 Loading... |
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 Loading... |
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_ |
OLD | NEW |