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

Side by Side Diff: base/bind_internal.h

Issue 8728010: Increase Bind/Callback Arity from 6 -> 7. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
OLDNEW
1 // This file was GENERATED by command: 1 // This file was GENERATED by command:
2 // pump.py bind_internal.h.pump 2 // pump.py bind_internal.h.pump
3 // DO NOT EDIT BY HAND!!! 3 // DO NOT EDIT BY HAND!!!
4 4
5 5
6 6
7 // TODO(ajwong): If you create an fully unbound method, is there a way to 7 // TODO(ajwong): If you create an fully unbound method, is there a way to
8 // enforce the first argument must be refcounted? Or do we just say 8 // enforce the first argument must be refcounted? Or do we just say
9 // "oh well"? 9 // "oh well"?
10 // 10 //
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 typename CallbackParamTraits<A4>::ForwardType a4, 545 typename CallbackParamTraits<A4>::ForwardType a4,
546 typename CallbackParamTraits<A5>::ForwardType a5, 546 typename CallbackParamTraits<A5>::ForwardType a5,
547 typename CallbackParamTraits<A6>::ForwardType a6) { 547 typename CallbackParamTraits<A6>::ForwardType a6) {
548 return (object->*method_)(a1, a2, a3, a4, a5, a6); 548 return (object->*method_)(a1, a2, a3, a4, a5, a6);
549 } 549 }
550 550
551 private: 551 private:
552 R (T::*method_)(A1, A2, A3, A4, A5, A6) const; 552 R (T::*method_)(A1, A2, A3, A4, A5, A6) const;
553 }; 553 };
554 554
555 // Function: Arity 7.
556 template <typename R, typename A1, typename A2, typename A3, typename A4,
557 typename A5, typename A6, typename A7>
558 class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6, A7)> {
559 public:
560 typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
561
562 explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7))
563 : function_(function) {
564 }
565
566 R Run(typename CallbackParamTraits<A1>::ForwardType a1,
567 typename CallbackParamTraits<A2>::ForwardType a2,
568 typename CallbackParamTraits<A3>::ForwardType a3,
569 typename CallbackParamTraits<A4>::ForwardType a4,
570 typename CallbackParamTraits<A5>::ForwardType a5,
571 typename CallbackParamTraits<A6>::ForwardType a6,
572 typename CallbackParamTraits<A7>::ForwardType a7) {
573 return function_(a1, a2, a3, a4, a5, a6, a7);
574 }
575
576 private:
577 R (*function_)(A1, A2, A3, A4, A5, A6, A7);
578 };
579
580 // Method: Arity 7.
581 template <typename R, typename T, typename A1, typename A2, typename A3,
582 typename A4, typename A5, typename A6, typename A7>
583 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> {
584 public:
585 typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7);
586 typedef true_type IsMethod;
587
588 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7))
589 : method_(method) {
590 }
591
592 R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
593 typename CallbackParamTraits<A2>::ForwardType a2,
594 typename CallbackParamTraits<A3>::ForwardType a3,
595 typename CallbackParamTraits<A4>::ForwardType a4,
596 typename CallbackParamTraits<A5>::ForwardType a5,
597 typename CallbackParamTraits<A6>::ForwardType a6,
598 typename CallbackParamTraits<A7>::ForwardType a7) {
599 return (object->*method_)(a1, a2, a3, a4, a5, a6, a7);
600 }
601
602 private:
603 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7);
604 };
605
606 // Const Method: Arity 7.
607 template <typename R, typename T, typename A1, typename A2, typename A3,
608 typename A4, typename A5, typename A6, typename A7>
609 class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> {
610 public:
611 typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7);
612 typedef true_type IsMethod;
613
614 explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const)
615 : method_(method) {
616 }
617
618 R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
619 typename CallbackParamTraits<A2>::ForwardType a2,
620 typename CallbackParamTraits<A3>::ForwardType a3,
621 typename CallbackParamTraits<A4>::ForwardType a4,
622 typename CallbackParamTraits<A5>::ForwardType a5,
623 typename CallbackParamTraits<A6>::ForwardType a6,
624 typename CallbackParamTraits<A7>::ForwardType a7) {
625 return (object->*method_)(a1, a2, a3, a4, a5, a6, a7);
626 }
627
628 private:
629 R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const;
630 };
631
555 632
556 // FunctionTraits<> 633 // FunctionTraits<>
557 // 634 //
558 // Breaks a function signature apart into typedefs for easier introspection. 635 // Breaks a function signature apart into typedefs for easier introspection.
559 template <typename Sig> 636 template <typename Sig>
560 struct FunctionTraits; 637 struct FunctionTraits;
561 638
562 template <typename R> 639 template <typename R>
563 struct FunctionTraits<R()> { 640 struct FunctionTraits<R()> {
564 typedef R ReturnType; 641 typedef R ReturnType;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> { 687 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> {
611 typedef R ReturnType; 688 typedef R ReturnType;
612 typedef A1 A1Type; 689 typedef A1 A1Type;
613 typedef A2 A2Type; 690 typedef A2 A2Type;
614 typedef A3 A3Type; 691 typedef A3 A3Type;
615 typedef A4 A4Type; 692 typedef A4 A4Type;
616 typedef A5 A5Type; 693 typedef A5 A5Type;
617 typedef A6 A6Type; 694 typedef A6 A6Type;
618 }; 695 };
619 696
697 template <typename R, typename A1, typename A2, typename A3, typename A4,
698 typename A5, typename A6, typename A7>
699 struct FunctionTraits<R(A1, A2, A3, A4, A5, A6, A7)> {
700 typedef R ReturnType;
701 typedef A1 A1Type;
702 typedef A2 A2Type;
703 typedef A3 A3Type;
704 typedef A4 A4Type;
705 typedef A5 A5Type;
706 typedef A6 A6Type;
707 typedef A7 A7Type;
708 };
709
620 710
621 // ForceVoidReturn<> 711 // ForceVoidReturn<>
622 // 712 //
623 // Set of templates that support forcing the function return type to void. 713 // Set of templates that support forcing the function return type to void.
624 template <typename Sig> 714 template <typename Sig>
625 struct ForceVoidReturn; 715 struct ForceVoidReturn;
626 716
627 template <typename R> 717 template <typename R>
628 struct ForceVoidReturn<R()> { 718 struct ForceVoidReturn<R()> {
629 typedef void(RunType)(); 719 typedef void(RunType)();
(...skipping 24 matching lines...) Expand all
654 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> { 744 struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> {
655 typedef void(RunType)(A1, A2, A3, A4, A5); 745 typedef void(RunType)(A1, A2, A3, A4, A5);
656 }; 746 };
657 747
658 template <typename R, typename A1, typename A2, typename A3, typename A4, 748 template <typename R, typename A1, typename A2, typename A3, typename A4,
659 typename A5, typename A6> 749 typename A5, typename A6>
660 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> { 750 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> {
661 typedef void(RunType)(A1, A2, A3, A4, A5, A6); 751 typedef void(RunType)(A1, A2, A3, A4, A5, A6);
662 }; 752 };
663 753
754 template <typename R, typename A1, typename A2, typename A3, typename A4,
755 typename A5, typename A6, typename A7>
756 struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6, A7)> {
757 typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7);
758 };
759
664 760
665 // FunctorTraits<> 761 // FunctorTraits<>
666 // 762 //
667 // See description at top of file. 763 // See description at top of file.
668 template <typename T> 764 template <typename T>
669 struct FunctorTraits { 765 struct FunctorTraits {
670 typedef RunnableAdapter<T> RunnableType; 766 typedef RunnableAdapter<T> RunnableType;
671 typedef typename RunnableType::RunType RunType; 767 typedef typename RunnableType::RunType RunType;
672 }; 768 };
673 769
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, 1013 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
918 A6 a6) { 1014 A6 a6) {
919 if (!a1.get()) { 1015 if (!a1.get()) {
920 return; 1016 return;
921 } 1017 }
922 1018
923 runnable.Run(a1, a2, a3, a4, a5, a6); 1019 runnable.Run(a1, a2, a3, a4, a5, a6);
924 } 1020 }
925 }; 1021 };
926 1022
1023 template <typename ReturnType, typename Runnable,typename A1, typename A2,
1024 typename A3, typename A4, typename A5, typename A6, typename A7>
1025 struct InvokeHelper<false, ReturnType, Runnable,
1026 void(A1, A2, A3, A4, A5, A6, A7)> {
1027 static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
1028 A5 a5, A6 a6, A7 a7) {
1029 return runnable.Run(a1, a2, a3, a4, a5, a6, a7);
1030 }
1031 };
1032
1033 template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
1034 typename A5, typename A6, typename A7>
1035 struct InvokeHelper<false, void, Runnable,
1036 void(A1, A2, A3, A4, A5, A6, A7)> {
1037 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1038 A6 a6, A7 a7) {
1039 runnable.Run(a1, a2, a3, a4, a5, a6, a7);
1040 }
1041 };
1042
1043 template <typename Runnable, typename A1, typename A2, typename A3,
1044 typename A4, typename A5, typename A6, typename A7>
1045 struct InvokeHelper<true, void, Runnable,
1046 void(A1, A2, A3, A4, A5, A6, A7)> {
1047 static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
1048 A6 a6, A7 a7) {
1049 if (!a1.get()) {
1050 return;
1051 }
1052
1053 runnable.Run(a1, a2, a3, a4, a5, a6, a7);
1054 }
1055 };
1056
927 #if !defined(_MSC_VER) 1057 #if !defined(_MSC_VER)
928 1058
929 template <typename ReturnType, typename Runnable, typename ArgsType> 1059 template <typename ReturnType, typename Runnable, typename ArgsType>
930 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> { 1060 struct InvokeHelper<true, ReturnType, Runnable, ArgsType> {
931 // WeakCalls are only supported for functions with a void return type. 1061 // WeakCalls are only supported for functions with a void return type.
932 // Otherwise, the function result would be undefined if the the WeakPtr<> 1062 // Otherwise, the function result would be undefined if the the WeakPtr<>
933 // is invalidated. 1063 // is invalidated.
934 COMPILE_ASSERT(is_void<ReturnType>::value, 1064 COMPILE_ASSERT(is_void<ReturnType>::value,
935 weak_ptrs_can_only_bind_to_methods_without_return_values); 1065 weak_ptrs_can_only_bind_to_methods_without_return_values);
936 }; 1066 };
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 void(typename Bound1UnwrapTraits::ForwardType, 2041 void(typename Bound1UnwrapTraits::ForwardType,
1912 typename Bound2UnwrapTraits::ForwardType, 2042 typename Bound2UnwrapTraits::ForwardType,
1913 typename Bound3UnwrapTraits::ForwardType, 2043 typename Bound3UnwrapTraits::ForwardType,
1914 typename Bound4UnwrapTraits::ForwardType, 2044 typename Bound4UnwrapTraits::ForwardType,
1915 typename Bound5UnwrapTraits::ForwardType, 2045 typename Bound5UnwrapTraits::ForwardType,
1916 typename Bound6UnwrapTraits::ForwardType)> 2046 typename Bound6UnwrapTraits::ForwardType)>
1917 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6); 2047 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6);
1918 } 2048 }
1919 }; 2049 };
1920 2050
2051 // Arity 7 -> 7.
2052 template <typename StorageType, typename R,typename X1, typename X2,
2053 typename X3, typename X4, typename X5, typename X6, typename X7>
2054 struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2055 typedef R(RunType)(BindStateBase*,
2056 typename CallbackParamTraits<X1>::ForwardType,
2057 typename CallbackParamTraits<X2>::ForwardType,
2058 typename CallbackParamTraits<X3>::ForwardType,
2059 typename CallbackParamTraits<X4>::ForwardType,
2060 typename CallbackParamTraits<X5>::ForwardType,
2061 typename CallbackParamTraits<X6>::ForwardType,
2062 typename CallbackParamTraits<X7>::ForwardType);
2063
2064 typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7);
2065
2066 static R Run(BindStateBase* base,
2067 typename CallbackParamTraits<X1>::ForwardType x1,
2068 typename CallbackParamTraits<X2>::ForwardType x2,
2069 typename CallbackParamTraits<X3>::ForwardType x3,
2070 typename CallbackParamTraits<X4>::ForwardType x4,
2071 typename CallbackParamTraits<X5>::ForwardType x5,
2072 typename CallbackParamTraits<X6>::ForwardType x6,
2073 typename CallbackParamTraits<X7>::ForwardType x7) {
2074 StorageType* storage = static_cast<StorageType*>(base);
2075
2076 // Local references to make debugger stepping easier. If in a debugger,
2077 // you really want to warp ahead and step through the
2078 // InvokeHelper<>::MakeItSo() call below.
2079
2080 return InvokeHelper<StorageType::IsWeakCall::value, R,
2081 typename StorageType::RunnableType,
2082 void(typename CallbackParamTraits<X1>::ForwardType x1,
2083 typename CallbackParamTraits<X2>::ForwardType x2,
2084 typename CallbackParamTraits<X3>::ForwardType x3,
2085 typename CallbackParamTraits<X4>::ForwardType x4,
2086 typename CallbackParamTraits<X5>::ForwardType x5,
2087 typename CallbackParamTraits<X6>::ForwardType x6,
2088 typename CallbackParamTraits<X7>::ForwardType x7)>
2089 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2090 }
2091 };
2092
2093 // Arity 7 -> 6.
2094 template <typename StorageType, typename R,typename X1, typename X2,
2095 typename X3, typename X4, typename X5, typename X6, typename X7>
2096 struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2097 typedef R(RunType)(BindStateBase*,
2098 typename CallbackParamTraits<X2>::ForwardType,
2099 typename CallbackParamTraits<X3>::ForwardType,
2100 typename CallbackParamTraits<X4>::ForwardType,
2101 typename CallbackParamTraits<X5>::ForwardType,
2102 typename CallbackParamTraits<X6>::ForwardType,
2103 typename CallbackParamTraits<X7>::ForwardType);
2104
2105 typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7);
2106
2107 static R Run(BindStateBase* base,
2108 typename CallbackParamTraits<X2>::ForwardType x2,
2109 typename CallbackParamTraits<X3>::ForwardType x3,
2110 typename CallbackParamTraits<X4>::ForwardType x4,
2111 typename CallbackParamTraits<X5>::ForwardType x5,
2112 typename CallbackParamTraits<X6>::ForwardType x6,
2113 typename CallbackParamTraits<X7>::ForwardType x7) {
2114 StorageType* storage = static_cast<StorageType*>(base);
2115
2116 // Local references to make debugger stepping easier. If in a debugger,
2117 // you really want to warp ahead and step through the
2118 // InvokeHelper<>::MakeItSo() call below.
2119 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2120
2121 typename Bound1UnwrapTraits::ForwardType x1 =
2122 Bound1UnwrapTraits::Unwrap(storage->p1_);
2123 return InvokeHelper<StorageType::IsWeakCall::value, R,
2124 typename StorageType::RunnableType,
2125 void(typename Bound1UnwrapTraits::ForwardType,
2126 typename CallbackParamTraits<X2>::ForwardType x2,
2127 typename CallbackParamTraits<X3>::ForwardType x3,
2128 typename CallbackParamTraits<X4>::ForwardType x4,
2129 typename CallbackParamTraits<X5>::ForwardType x5,
2130 typename CallbackParamTraits<X6>::ForwardType x6,
2131 typename CallbackParamTraits<X7>::ForwardType x7)>
2132 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2133 }
2134 };
2135
2136 // Arity 7 -> 5.
2137 template <typename StorageType, typename R,typename X1, typename X2,
2138 typename X3, typename X4, typename X5, typename X6, typename X7>
2139 struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2140 typedef R(RunType)(BindStateBase*,
2141 typename CallbackParamTraits<X3>::ForwardType,
2142 typename CallbackParamTraits<X4>::ForwardType,
2143 typename CallbackParamTraits<X5>::ForwardType,
2144 typename CallbackParamTraits<X6>::ForwardType,
2145 typename CallbackParamTraits<X7>::ForwardType);
2146
2147 typedef R(UnboundRunType)(X3, X4, X5, X6, X7);
2148
2149 static R Run(BindStateBase* base,
2150 typename CallbackParamTraits<X3>::ForwardType x3,
2151 typename CallbackParamTraits<X4>::ForwardType x4,
2152 typename CallbackParamTraits<X5>::ForwardType x5,
2153 typename CallbackParamTraits<X6>::ForwardType x6,
2154 typename CallbackParamTraits<X7>::ForwardType x7) {
2155 StorageType* storage = static_cast<StorageType*>(base);
2156
2157 // Local references to make debugger stepping easier. If in a debugger,
2158 // you really want to warp ahead and step through the
2159 // InvokeHelper<>::MakeItSo() call below.
2160 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2161 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2162
2163 typename Bound1UnwrapTraits::ForwardType x1 =
2164 Bound1UnwrapTraits::Unwrap(storage->p1_);
2165 typename Bound2UnwrapTraits::ForwardType x2 =
2166 Bound2UnwrapTraits::Unwrap(storage->p2_);
2167 return InvokeHelper<StorageType::IsWeakCall::value, R,
2168 typename StorageType::RunnableType,
2169 void(typename Bound1UnwrapTraits::ForwardType,
2170 typename Bound2UnwrapTraits::ForwardType,
2171 typename CallbackParamTraits<X3>::ForwardType x3,
2172 typename CallbackParamTraits<X4>::ForwardType x4,
2173 typename CallbackParamTraits<X5>::ForwardType x5,
2174 typename CallbackParamTraits<X6>::ForwardType x6,
2175 typename CallbackParamTraits<X7>::ForwardType x7)>
2176 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2177 }
2178 };
2179
2180 // Arity 7 -> 4.
2181 template <typename StorageType, typename R,typename X1, typename X2,
2182 typename X3, typename X4, typename X5, typename X6, typename X7>
2183 struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2184 typedef R(RunType)(BindStateBase*,
2185 typename CallbackParamTraits<X4>::ForwardType,
2186 typename CallbackParamTraits<X5>::ForwardType,
2187 typename CallbackParamTraits<X6>::ForwardType,
2188 typename CallbackParamTraits<X7>::ForwardType);
2189
2190 typedef R(UnboundRunType)(X4, X5, X6, X7);
2191
2192 static R Run(BindStateBase* base,
2193 typename CallbackParamTraits<X4>::ForwardType x4,
2194 typename CallbackParamTraits<X5>::ForwardType x5,
2195 typename CallbackParamTraits<X6>::ForwardType x6,
2196 typename CallbackParamTraits<X7>::ForwardType x7) {
2197 StorageType* storage = static_cast<StorageType*>(base);
2198
2199 // Local references to make debugger stepping easier. If in a debugger,
2200 // you really want to warp ahead and step through the
2201 // InvokeHelper<>::MakeItSo() call below.
2202 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2203 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2204 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2205
2206 typename Bound1UnwrapTraits::ForwardType x1 =
2207 Bound1UnwrapTraits::Unwrap(storage->p1_);
2208 typename Bound2UnwrapTraits::ForwardType x2 =
2209 Bound2UnwrapTraits::Unwrap(storage->p2_);
2210 typename Bound3UnwrapTraits::ForwardType x3 =
2211 Bound3UnwrapTraits::Unwrap(storage->p3_);
2212 return InvokeHelper<StorageType::IsWeakCall::value, R,
2213 typename StorageType::RunnableType,
2214 void(typename Bound1UnwrapTraits::ForwardType,
2215 typename Bound2UnwrapTraits::ForwardType,
2216 typename Bound3UnwrapTraits::ForwardType,
2217 typename CallbackParamTraits<X4>::ForwardType x4,
2218 typename CallbackParamTraits<X5>::ForwardType x5,
2219 typename CallbackParamTraits<X6>::ForwardType x6,
2220 typename CallbackParamTraits<X7>::ForwardType x7)>
2221 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2222 }
2223 };
2224
2225 // Arity 7 -> 3.
2226 template <typename StorageType, typename R,typename X1, typename X2,
2227 typename X3, typename X4, typename X5, typename X6, typename X7>
2228 struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2229 typedef R(RunType)(BindStateBase*,
2230 typename CallbackParamTraits<X5>::ForwardType,
2231 typename CallbackParamTraits<X6>::ForwardType,
2232 typename CallbackParamTraits<X7>::ForwardType);
2233
2234 typedef R(UnboundRunType)(X5, X6, X7);
2235
2236 static R Run(BindStateBase* base,
2237 typename CallbackParamTraits<X5>::ForwardType x5,
2238 typename CallbackParamTraits<X6>::ForwardType x6,
2239 typename CallbackParamTraits<X7>::ForwardType x7) {
2240 StorageType* storage = static_cast<StorageType*>(base);
2241
2242 // Local references to make debugger stepping easier. If in a debugger,
2243 // you really want to warp ahead and step through the
2244 // InvokeHelper<>::MakeItSo() call below.
2245 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2246 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2247 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2248 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2249
2250 typename Bound1UnwrapTraits::ForwardType x1 =
2251 Bound1UnwrapTraits::Unwrap(storage->p1_);
2252 typename Bound2UnwrapTraits::ForwardType x2 =
2253 Bound2UnwrapTraits::Unwrap(storage->p2_);
2254 typename Bound3UnwrapTraits::ForwardType x3 =
2255 Bound3UnwrapTraits::Unwrap(storage->p3_);
2256 typename Bound4UnwrapTraits::ForwardType x4 =
2257 Bound4UnwrapTraits::Unwrap(storage->p4_);
2258 return InvokeHelper<StorageType::IsWeakCall::value, R,
2259 typename StorageType::RunnableType,
2260 void(typename Bound1UnwrapTraits::ForwardType,
2261 typename Bound2UnwrapTraits::ForwardType,
2262 typename Bound3UnwrapTraits::ForwardType,
2263 typename Bound4UnwrapTraits::ForwardType,
2264 typename CallbackParamTraits<X5>::ForwardType x5,
2265 typename CallbackParamTraits<X6>::ForwardType x6,
2266 typename CallbackParamTraits<X7>::ForwardType x7)>
2267 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2268 }
2269 };
2270
2271 // Arity 7 -> 2.
2272 template <typename StorageType, typename R,typename X1, typename X2,
2273 typename X3, typename X4, typename X5, typename X6, typename X7>
2274 struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2275 typedef R(RunType)(BindStateBase*,
2276 typename CallbackParamTraits<X6>::ForwardType,
2277 typename CallbackParamTraits<X7>::ForwardType);
2278
2279 typedef R(UnboundRunType)(X6, X7);
2280
2281 static R Run(BindStateBase* base,
2282 typename CallbackParamTraits<X6>::ForwardType x6,
2283 typename CallbackParamTraits<X7>::ForwardType x7) {
2284 StorageType* storage = static_cast<StorageType*>(base);
2285
2286 // Local references to make debugger stepping easier. If in a debugger,
2287 // you really want to warp ahead and step through the
2288 // InvokeHelper<>::MakeItSo() call below.
2289 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2290 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2291 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2292 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2293 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2294
2295 typename Bound1UnwrapTraits::ForwardType x1 =
2296 Bound1UnwrapTraits::Unwrap(storage->p1_);
2297 typename Bound2UnwrapTraits::ForwardType x2 =
2298 Bound2UnwrapTraits::Unwrap(storage->p2_);
2299 typename Bound3UnwrapTraits::ForwardType x3 =
2300 Bound3UnwrapTraits::Unwrap(storage->p3_);
2301 typename Bound4UnwrapTraits::ForwardType x4 =
2302 Bound4UnwrapTraits::Unwrap(storage->p4_);
2303 typename Bound5UnwrapTraits::ForwardType x5 =
2304 Bound5UnwrapTraits::Unwrap(storage->p5_);
2305 return InvokeHelper<StorageType::IsWeakCall::value, R,
2306 typename StorageType::RunnableType,
2307 void(typename Bound1UnwrapTraits::ForwardType,
2308 typename Bound2UnwrapTraits::ForwardType,
2309 typename Bound3UnwrapTraits::ForwardType,
2310 typename Bound4UnwrapTraits::ForwardType,
2311 typename Bound5UnwrapTraits::ForwardType,
2312 typename CallbackParamTraits<X6>::ForwardType x6,
2313 typename CallbackParamTraits<X7>::ForwardType x7)>
2314 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2315 }
2316 };
2317
2318 // Arity 7 -> 1.
2319 template <typename StorageType, typename R,typename X1, typename X2,
2320 typename X3, typename X4, typename X5, typename X6, typename X7>
2321 struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2322 typedef R(RunType)(BindStateBase*,
2323 typename CallbackParamTraits<X7>::ForwardType);
2324
2325 typedef R(UnboundRunType)(X7);
2326
2327 static R Run(BindStateBase* base,
2328 typename CallbackParamTraits<X7>::ForwardType x7) {
2329 StorageType* storage = static_cast<StorageType*>(base);
2330
2331 // Local references to make debugger stepping easier. If in a debugger,
2332 // you really want to warp ahead and step through the
2333 // InvokeHelper<>::MakeItSo() call below.
2334 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2335 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2336 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2337 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2338 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2339 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2340
2341 typename Bound1UnwrapTraits::ForwardType x1 =
2342 Bound1UnwrapTraits::Unwrap(storage->p1_);
2343 typename Bound2UnwrapTraits::ForwardType x2 =
2344 Bound2UnwrapTraits::Unwrap(storage->p2_);
2345 typename Bound3UnwrapTraits::ForwardType x3 =
2346 Bound3UnwrapTraits::Unwrap(storage->p3_);
2347 typename Bound4UnwrapTraits::ForwardType x4 =
2348 Bound4UnwrapTraits::Unwrap(storage->p4_);
2349 typename Bound5UnwrapTraits::ForwardType x5 =
2350 Bound5UnwrapTraits::Unwrap(storage->p5_);
2351 typename Bound6UnwrapTraits::ForwardType x6 =
2352 Bound6UnwrapTraits::Unwrap(storage->p6_);
2353 return InvokeHelper<StorageType::IsWeakCall::value, R,
2354 typename StorageType::RunnableType,
2355 void(typename Bound1UnwrapTraits::ForwardType,
2356 typename Bound2UnwrapTraits::ForwardType,
2357 typename Bound3UnwrapTraits::ForwardType,
2358 typename Bound4UnwrapTraits::ForwardType,
2359 typename Bound5UnwrapTraits::ForwardType,
2360 typename Bound6UnwrapTraits::ForwardType,
2361 typename CallbackParamTraits<X7>::ForwardType x7)>
2362 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2363 }
2364 };
2365
2366 // Arity 7 -> 0.
2367 template <typename StorageType, typename R,typename X1, typename X2,
2368 typename X3, typename X4, typename X5, typename X6, typename X7>
2369 struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
2370 typedef R(RunType)(BindStateBase*);
2371
2372 typedef R(UnboundRunType)();
2373
2374 static R Run(BindStateBase* base) {
2375 StorageType* storage = static_cast<StorageType*>(base);
2376
2377 // Local references to make debugger stepping easier. If in a debugger,
2378 // you really want to warp ahead and step through the
2379 // InvokeHelper<>::MakeItSo() call below.
2380 typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
2381 typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
2382 typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
2383 typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
2384 typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
2385 typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
2386 typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits;
2387
2388 typename Bound1UnwrapTraits::ForwardType x1 =
2389 Bound1UnwrapTraits::Unwrap(storage->p1_);
2390 typename Bound2UnwrapTraits::ForwardType x2 =
2391 Bound2UnwrapTraits::Unwrap(storage->p2_);
2392 typename Bound3UnwrapTraits::ForwardType x3 =
2393 Bound3UnwrapTraits::Unwrap(storage->p3_);
2394 typename Bound4UnwrapTraits::ForwardType x4 =
2395 Bound4UnwrapTraits::Unwrap(storage->p4_);
2396 typename Bound5UnwrapTraits::ForwardType x5 =
2397 Bound5UnwrapTraits::Unwrap(storage->p5_);
2398 typename Bound6UnwrapTraits::ForwardType x6 =
2399 Bound6UnwrapTraits::Unwrap(storage->p6_);
2400 typename Bound7UnwrapTraits::ForwardType x7 =
2401 Bound7UnwrapTraits::Unwrap(storage->p7_);
2402 return InvokeHelper<StorageType::IsWeakCall::value, R,
2403 typename StorageType::RunnableType,
2404 void(typename Bound1UnwrapTraits::ForwardType,
2405 typename Bound2UnwrapTraits::ForwardType,
2406 typename Bound3UnwrapTraits::ForwardType,
2407 typename Bound4UnwrapTraits::ForwardType,
2408 typename Bound5UnwrapTraits::ForwardType,
2409 typename Bound6UnwrapTraits::ForwardType,
2410 typename Bound7UnwrapTraits::ForwardType)>
2411 ::MakeItSo(storage->runnable_, x1, x2, x3, x4, x5, x6, x7);
2412 }
2413 };
2414
1921 2415
1922 // BindState<> 2416 // BindState<>
1923 // 2417 //
1924 // This stores all the state passed into Bind() and is also where most 2418 // This stores all the state passed into Bind() and is also where most
1925 // of the template resolution magic occurs. 2419 // of the template resolution magic occurs.
1926 // 2420 //
1927 // Runnable is the functor we are binding arguments to. 2421 // Runnable is the functor we are binding arguments to.
1928 // RunType is type of the Run() function that the Invoker<> should use. 2422 // RunType is type of the Run() function that the Invoker<> should use.
1929 // Normally, this is the same as the RunType of the Runnable, but it can 2423 // Normally, this is the same as the RunType of the Runnable, but it can
1930 // be different if an adapter like IgnoreResult() has been used. 2424 // be different if an adapter like IgnoreResult() has been used.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 2629
2136 RunnableType runnable_; 2630 RunnableType runnable_;
2137 P1 p1_; 2631 P1 p1_;
2138 P2 p2_; 2632 P2 p2_;
2139 P3 p3_; 2633 P3 p3_;
2140 P4 p4_; 2634 P4 p4_;
2141 P5 p5_; 2635 P5 p5_;
2142 P6 p6_; 2636 P6 p6_;
2143 }; 2637 };
2144 2638
2639 template <typename Runnable, typename RunType, typename P1, typename P2,
2640 typename P3, typename P4, typename P5, typename P6, typename P7>
2641 struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
2642 P7)> : public BindStateBase {
2643 typedef Runnable RunnableType;
2644 typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;
2645 typedef Invoker<7, BindState, RunType> InvokerType;
2646 typedef typename InvokerType::UnboundRunType UnboundRunType;
2647
2648 // Convenience typedefs for bound argument types.
2649 typedef UnwrapTraits<P1> Bound1UnwrapTraits;
2650 typedef UnwrapTraits<P2> Bound2UnwrapTraits;
2651 typedef UnwrapTraits<P3> Bound3UnwrapTraits;
2652 typedef UnwrapTraits<P4> Bound4UnwrapTraits;
2653 typedef UnwrapTraits<P5> Bound5UnwrapTraits;
2654 typedef UnwrapTraits<P6> Bound6UnwrapTraits;
2655 typedef UnwrapTraits<P7> Bound7UnwrapTraits;
2656
2657 BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
2658 const P4& p4, const P5& p5, const P6& p6, const P7& p7)
2659 : runnable_(runnable),
2660 p1_(p1),
2661 p2_(p2),
2662 p3_(p3),
2663 p4_(p4),
2664 p5_(p5),
2665 p6_(p6),
2666 p7_(p7) {
2667 MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
2668 }
2669
2670 virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
2671 P1>::Release(p1_); }
2672
2673 RunnableType runnable_;
2674 P1 p1_;
2675 P2 p2_;
2676 P3 p3_;
2677 P4 p4_;
2678 P5 p5_;
2679 P6 p6_;
2680 P7 p7_;
2681 };
2682
2145 } // namespace internal 2683 } // namespace internal
2146 } // namespace base 2684 } // namespace base
2147 2685
2148 #endif // BASE_BIND_INTERNAL_H_ 2686 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« base/bind.h.pump ('K') | « base/bind.h.pump ('k') | base/bind_internal.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698