OLD | NEW |
1 $$ This is a pump file for generating file templates. Pump is a python | 1 $$ This is a pump file for generating file templates. Pump is a python |
2 $$ script that is part of the Google Test suite of utilities. Description | 2 $$ script that is part of the Google Test suite of utilities. Description |
3 $$ can be found here: | 3 $$ can be found here: |
4 $$ | 4 $$ |
5 $$ http://code.google.com/p/googletest/wiki/PumpManual | 5 $$ http://code.google.com/p/googletest/wiki/PumpManual |
6 $$ | 6 $$ |
7 | 7 |
8 #ifndef GIN_FUNCTION_TEMPLATE_H_ | 8 #ifndef GIN_FUNCTION_TEMPLATE_H_ |
9 #define GIN_FUNCTION_TEMPLATE_H_ | 9 #define GIN_FUNCTION_TEMPLATE_H_ |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 ]] | 181 ]] |
182 | 182 |
183 } // namespace internal | 183 } // namespace internal |
184 | 184 |
185 | 185 |
186 // This should be called once per-isolate to initialize the function template | 186 // This should be called once per-isolate to initialize the function template |
187 // system. | 187 // system. |
188 void InitFunctionTemplates(PerIsolateData* isolate_data); | 188 void InitFunctionTemplates(PerIsolateData* isolate_data); |
189 | 189 |
190 | 190 |
191 // This has to be outside the internal namespace because template | |
192 // specializations must be declared in the same namespace as the original | |
193 // template. | |
194 template<> | |
195 struct Converter<internal::CallbackHolderBase*> | |
196 : public WrappableConverter<internal::CallbackHolderBase> {}; | |
197 | |
198 | |
199 // CreateFunctionTemplate creates a v8::FunctionTemplate that will create | 191 // CreateFunctionTemplate creates a v8::FunctionTemplate that will create |
200 // JavaScript functions that execute a provided C++ function or base::Callback. | 192 // JavaScript functions that execute a provided C++ function or base::Callback. |
201 // JavaScript arguments are automatically converted via gin::Converter, as is | 193 // JavaScript arguments are automatically converted via gin::Converter, as is |
202 // the return value of the C++ function, if any. | 194 // the return value of the C++ function, if any. |
203 template<typename Sig> | 195 template<typename Sig> |
204 v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( | 196 v8::Local<v8::FunctionTemplate> CreateFunctionTemplate( |
205 v8::Isolate* isolate, const base::Callback<Sig> callback, | 197 v8::Isolate* isolate, const base::Callback<Sig> callback, |
206 int callback_flags = 0) { | 198 int callback_flags = 0) { |
207 typedef internal::CallbackHolder<Sig> HolderT; | 199 typedef internal::CallbackHolder<Sig> HolderT; |
208 gin::Handle<HolderT> holder = CreateHandle( | 200 gin::Handle<HolderT> holder = CreateHandle( |
209 isolate, new HolderT(callback, callback_flags)); | 201 isolate, new HolderT(callback, callback_flags)); |
210 return v8::FunctionTemplate::New( | 202 return v8::FunctionTemplate::New( |
211 &internal::Dispatcher<Sig>::DispatchToCallback, | 203 &internal::Dispatcher<Sig>::DispatchToCallback, |
212 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); | 204 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); |
213 } | 205 } |
214 | 206 |
215 } // namespace gin | 207 } // namespace gin |
216 | 208 |
217 #endif // GIN_FUNCTION_TEMPLATE_H_ | 209 #endif // GIN_FUNCTION_TEMPLATE_H_ |
OLD | NEW |