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