OLD | NEW |
1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
2 // pump.py function_template.h.pump | 2 // pump.py function_template.h.pump |
3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
4 | 4 |
5 | 5 |
6 | 6 |
7 #ifndef GIN_FUNCTION_TEMPLATE_H_ | 7 #ifndef GIN_FUNCTION_TEMPLATE_H_ |
8 #define GIN_FUNCTION_TEMPLATE_H_ | 8 #define GIN_FUNCTION_TEMPLATE_H_ |
9 | 9 |
10 // Copyright 2013 The Chromium Authors. All rights reserved. | 10 // Copyright 2013 The Chromium Authors. All rights reserved. |
(...skipping 14 matching lines...) Expand all Loading... |
25 namespace gin { | 25 namespace gin { |
26 | 26 |
27 class PerIsolateData; | 27 class PerIsolateData; |
28 | 28 |
29 enum CreateFunctionTemplateFlags { | 29 enum CreateFunctionTemplateFlags { |
30 HolderIsFirstArgument = 1 << 0, | 30 HolderIsFirstArgument = 1 << 0, |
31 }; | 31 }; |
32 | 32 |
33 namespace internal { | 33 namespace internal { |
34 | 34 |
| 35 // TODO(aa): Move this to base/template_util.h as remove_const. |
35 template<typename T> | 36 template<typename T> |
36 struct CallbackParamTraits { | 37 struct CallbackParamTraits { |
37 typedef T LocalType; | 38 typedef T LocalType; |
38 }; | 39 }; |
39 template<typename T> | 40 template<typename T> |
40 struct CallbackParamTraits<const T&> { | 41 struct CallbackParamTraits<const T&> { |
41 typedef T LocalType; | 42 typedef T LocalType; |
42 }; | 43 }; |
43 template<typename T> | 44 template<typename T> |
44 struct CallbackParamTraits<const T*> { | 45 struct CallbackParamTraits<const T*> { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 }; | 327 }; |
327 | 328 |
328 } // namespace internal | 329 } // namespace internal |
329 | 330 |
330 | 331 |
331 // This should be called once per-isolate to initialize the function template | 332 // This should be called once per-isolate to initialize the function template |
332 // system. | 333 // system. |
333 void InitFunctionTemplates(PerIsolateData* isolate_data); | 334 void InitFunctionTemplates(PerIsolateData* isolate_data); |
334 | 335 |
335 | 336 |
336 // This has to be outside the internal namespace because template | |
337 // specializations must be declared in the same namespace as the original | |
338 // template. | |
339 template<> | |
340 struct Converter<internal::CallbackHolderBase*> | |
341 : public WrappableConverter<internal::CallbackHolderBase> {}; | |
342 | |
343 | |
344 // CreateFunctionTemplate creates a v8::FunctionTemplate that will create | 337 // CreateFunctionTemplate creates a v8::FunctionTemplate that will create |
345 // JavaScript functions that execute a provided C++ function or base::Callback. | 338 // JavaScript functions that execute a provided C++ function or base::Callback. |
346 // JavaScript arguments are automatically converted via gin::Converter, as is | 339 // JavaScript arguments are automatically converted via gin::Converter, as is |
347 // the return value of the C++ function, if any. | 340 // the return value of the C++ function, if any. |
348 template<typename Sig> | 341 template<typename Sig> |
349 v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( | 342 v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( |
350 v8::Isolate* isolate, const base::Callback<Sig> callback, | 343 v8::Isolate* isolate, const base::Callback<Sig> callback, |
351 int callback_flags = 0) { | 344 int callback_flags = 0) { |
352 typedef internal::CallbackHolder<Sig> HolderT; | 345 typedef internal::CallbackHolder<Sig> HolderT; |
353 gin::Handle<HolderT> holder = CreateHandle( | 346 gin::Handle<HolderT> holder = CreateHandle( |
354 isolate, new HolderT(callback, callback_flags)); | 347 isolate, new HolderT(callback, callback_flags)); |
355 return v8::FunctionTemplate::New( | 348 return v8::FunctionTemplate::New( |
356 &internal::Dispatcher<Sig>::DispatchToCallback, | 349 &internal::Dispatcher<Sig>::DispatchToCallback, |
357 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); | 350 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); |
358 } | 351 } |
359 | 352 |
360 } // namespace gin | 353 } // namespace gin |
361 | 354 |
362 #endif // GIN_FUNCTION_TEMPLATE_H_ | 355 #endif // GIN_FUNCTION_TEMPLATE_H_ |
OLD | NEW |