2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// Copyright (c) 2018 GitHub, Inc.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Use of this source code is governed by the MIT license that can be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// found in the LICENSE file.
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-10 16:59:50 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifndef SHELL_COMMON_GIN_HELPER_CONSTRUCTOR_H_
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define SHELL_COMMON_GIN_HELPER_CONSTRUCTOR_H_
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-15 15:30:46 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-15 10:15:23 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "shell/common/gin_helper/function_template.h"
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "shell/common/gin_helper/wrappable_base.h"
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-15 15:30:46 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								namespace gin_helper {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-15 15:30:46 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								namespace internal {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// This set of templates invokes a base::Callback by converting the Arguments
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// into native types. It relies on the function_template.h to provide helper
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// templates.
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*()>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run();
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename P1>
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*(P1)>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P1>::LocalType a1;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!gin_helper::GetNextArgument(args, 0, true, &a1))
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return nullptr;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run(a1);
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename P1, typename P2>
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*(P1, P2)>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P1>::LocalType a1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P2>::LocalType a2;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!gin_helper::GetNextArgument(args, 0, true, &a1) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a2))
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return nullptr;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run(a1, a2);
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename P1, typename P2, typename P3>
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*(P1, P2, P3)>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P1>::LocalType a1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P2>::LocalType a2;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P3>::LocalType a3;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!gin_helper::GetNextArgument(args, 0, true, &a1) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a2) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a3))
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return nullptr;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run(a1, a2, a3);
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename P1, typename P2, typename P3, typename P4>
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*(P1, P2, P3, P4)>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P1>::LocalType a1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P2>::LocalType a2;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P3>::LocalType a3;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P4>::LocalType a4;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!gin_helper::GetNextArgument(args, 0, true, &a1) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a2) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a3) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a4))
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return nullptr;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run(a1, a2, a3, a4);
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename P1, typename P2, typename P3, typename P4, typename P5>
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*(P1, P2, P3, P4, P5)>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P1>::LocalType a1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P2>::LocalType a2;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P3>::LocalType a3;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P4>::LocalType a4;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P5>::LocalType a5;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!gin_helper::GetNextArgument(args, 0, true, &a1) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a2) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a3) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a4) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a5))
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return nullptr;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run(a1, a2, a3, a4, a5);
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename P1,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          typename P2,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          typename P3,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          typename P4,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          typename P5,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          typename P6>
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								inline WrappableBase* InvokeFactory(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    gin::Arguments* args,
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const base::Callback<WrappableBase*(P1, P2, P3, P4, P5, P6)>& callback) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P1>::LocalType a1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P2>::LocalType a2;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P3>::LocalType a3;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P4>::LocalType a4;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P5>::LocalType a5;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  typename CallbackParamTraits<P6>::LocalType a6;
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!gin_helper::GetNextArgument(args, 0, true, &a1) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a2) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a3) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a4) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a5) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      !gin_helper::GetNextArgument(args, 0, false, &a6))
							 | 
						
					
						
							
								
									
										
										
										
											2016-04-25 10:17:39 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return nullptr;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return callback.Run(a1, a2, a3, a4, a5, a6);
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								template <typename Sig>
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-17 23:36:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void InvokeNew(const base::Callback<Sig>& factory,
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-27 11:14:23 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								               v8::Isolate* isolate,
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								               gin_helper::Arguments* args) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-02 17:01:19 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!args->IsConstructCall()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    args->ThrowError("Requires constructor call");
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-17 23:36:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-15 15:30:46 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-02 17:01:19 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  WrappableBase* object;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Don't continue if the constructor throws an exception.
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-10 16:17:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    v8::TryCatch try_catch(isolate);
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-02 17:01:19 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    object = internal::InvokeFactory(args, factory);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (try_catch.HasCaught()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      try_catch.ReThrow();
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-17 23:36:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-30 21:54:29 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-02 17:01:19 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  if (!object)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    args->ThrowError();
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-15 15:30:46 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-17 23:36:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-16 09:50:51 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-02 17:01:19 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}  // namespace internal
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// Create a FunctionTemplate that can be "new"ed in JavaScript.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// It is user's responsibility to ensure this function is called for one type
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// only ONCE in the program's whole lifetime, otherwise we would have memory
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// leak.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								template <typename T, typename Sig>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								v8::Local<v8::Function> CreateConstructor(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    v8::Isolate* isolate,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const base::RepeatingCallback<Sig>& func) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#ifndef NDEBUG
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  static bool called = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  CHECK(!called) << "CreateConstructor can only be called for one type once";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  called = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#endif
							 | 
						
					
						
							
								
									
										
										
										
											2020-07-30 09:17:57 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      isolate, base::BindRepeating(&internal::InvokeNew<Sig>, func));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  templ->InstanceTemplate()->SetInternalFieldCount(1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  T::BuildPrototype(isolate, templ);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return templ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}  // namespace gin_helper
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-15 15:30:46 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-05 18:46:34 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif  // SHELL_COMMON_GIN_HELPER_CONSTRUCTOR_H_
							 |