diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-10 18:02:03 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-10 18:02:03 +0000 |
commit | 6edce23f84fe2b88e4dfe8e101b05e60a3646b80 (patch) | |
tree | 5a7ad67cc6f35469d5abab6090fcbd7424da91ba /base/tuple.h | |
parent | a31c66d79a124782bbaa16870bffbc83bdb639f8 (diff) | |
download | chromium_src-6edce23f84fe2b88e4dfe8e101b05e60a3646b80.zip chromium_src-6edce23f84fe2b88e4dfe8e101b05e60a3646b80.tar.gz chromium_src-6edce23f84fe2b88e4dfe8e101b05e60a3646b80.tar.bz2 |
FBTF: Reapplies r55259, the first new IPC definition patch.
This moves MessageWithTuple::Read() back into the main ipc_message_utils.h
header from the private ipc_messsage_utils_impl.h header. In release mode, this
was causing link failures.
BUG=51411
TEST=none
Review URL: http://codereview.chromium.org/3069034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tuple.h')
-rw-r--r-- | base/tuple.h | 264 |
1 files changed, 156 insertions, 108 deletions
diff --git a/base/tuple.h b/base/tuple.h index bcd2ad4..b67d924 100644 --- a/base/tuple.h +++ b/base/tuple.h @@ -52,6 +52,9 @@ struct TupleTraits<P&> { typedef P& ParamType; }; +template <class P> +struct TupleTypes { }; + // Tuple ----------------------------------------------------------------------- // // This set of classes is useful for bundling 0 or more heterogeneous data types @@ -76,9 +79,6 @@ template <class A> struct Tuple1 { public: typedef A TypeA; - typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple; - typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple; - typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple; Tuple1() {} explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {} @@ -91,12 +91,6 @@ struct Tuple2 { public: typedef A TypeA; typedef B TypeB; - typedef Tuple2<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType> ValueTuple; - typedef Tuple2<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType> RefTuple; - typedef Tuple2<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType> ParamTuple; Tuple2() {} Tuple2(typename TupleTraits<A>::ParamType a, @@ -114,15 +108,6 @@ struct Tuple3 { typedef A TypeA; typedef B TypeB; typedef C TypeC; - typedef Tuple3<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType, - typename TupleTraits<C>::ValueType> ValueTuple; - typedef Tuple3<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType, - typename TupleTraits<C>::RefType> RefTuple; - typedef Tuple3<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType, - typename TupleTraits<C>::ParamType> ParamTuple; Tuple3() {} Tuple3(typename TupleTraits<A>::ParamType a, @@ -143,18 +128,6 @@ struct Tuple4 { typedef B TypeB; typedef C TypeC; typedef D TypeD; - typedef Tuple4<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType, - typename TupleTraits<C>::ValueType, - typename TupleTraits<D>::ValueType> ValueTuple; - typedef Tuple4<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType, - typename TupleTraits<C>::RefType, - typename TupleTraits<D>::RefType> RefTuple; - typedef Tuple4<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType, - typename TupleTraits<C>::ParamType, - typename TupleTraits<D>::ParamType> ParamTuple; Tuple4() {} Tuple4(typename TupleTraits<A>::ParamType a, @@ -178,21 +151,6 @@ struct Tuple5 { typedef C TypeC; typedef D TypeD; typedef E TypeE; - typedef Tuple5<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType, - typename TupleTraits<C>::ValueType, - typename TupleTraits<D>::ValueType, - typename TupleTraits<E>::ValueType> ValueTuple; - typedef Tuple5<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType, - typename TupleTraits<C>::RefType, - typename TupleTraits<D>::RefType, - typename TupleTraits<E>::RefType> RefTuple; - typedef Tuple5<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType, - typename TupleTraits<C>::ParamType, - typename TupleTraits<D>::ParamType, - typename TupleTraits<E>::ParamType> ParamTuple; Tuple5() {} Tuple5(typename TupleTraits<A>::ParamType a, @@ -219,24 +177,6 @@ struct Tuple6 { typedef D TypeD; typedef E TypeE; typedef F TypeF; - typedef Tuple6<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType, - typename TupleTraits<C>::ValueType, - typename TupleTraits<D>::ValueType, - typename TupleTraits<E>::ValueType, - typename TupleTraits<F>::ValueType> ValueTuple; - typedef Tuple6<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType, - typename TupleTraits<C>::RefType, - typename TupleTraits<D>::RefType, - typename TupleTraits<E>::RefType, - typename TupleTraits<F>::RefType> RefTuple; - typedef Tuple6<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType, - typename TupleTraits<C>::ParamType, - typename TupleTraits<D>::ParamType, - typename TupleTraits<E>::ParamType, - typename TupleTraits<F>::ParamType> ParamTuple; Tuple6() {} Tuple6(typename TupleTraits<A>::ParamType a, @@ -266,27 +206,6 @@ struct Tuple7 { typedef E TypeE; typedef F TypeF; typedef G TypeG; - typedef Tuple7<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType, - typename TupleTraits<C>::ValueType, - typename TupleTraits<D>::ValueType, - typename TupleTraits<E>::ValueType, - typename TupleTraits<F>::ValueType, - typename TupleTraits<G>::ValueType> ValueTuple; - typedef Tuple7<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType, - typename TupleTraits<C>::RefType, - typename TupleTraits<D>::RefType, - typename TupleTraits<E>::RefType, - typename TupleTraits<F>::RefType, - typename TupleTraits<G>::RefType> RefTuple; - typedef Tuple7<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType, - typename TupleTraits<C>::ParamType, - typename TupleTraits<D>::ParamType, - typename TupleTraits<E>::ParamType, - typename TupleTraits<F>::ParamType, - typename TupleTraits<G>::ParamType> ParamTuple; Tuple7() {} Tuple7(typename TupleTraits<A>::ParamType a, @@ -320,30 +239,6 @@ struct Tuple8 { typedef F TypeF; typedef G TypeG; typedef H TypeH; - typedef Tuple8<typename TupleTraits<A>::ValueType, - typename TupleTraits<B>::ValueType, - typename TupleTraits<C>::ValueType, - typename TupleTraits<D>::ValueType, - typename TupleTraits<E>::ValueType, - typename TupleTraits<F>::ValueType, - typename TupleTraits<G>::ValueType, - typename TupleTraits<H>::ValueType> ValueTuple; - typedef Tuple8<typename TupleTraits<A>::RefType, - typename TupleTraits<B>::RefType, - typename TupleTraits<C>::RefType, - typename TupleTraits<D>::RefType, - typename TupleTraits<E>::RefType, - typename TupleTraits<F>::RefType, - typename TupleTraits<G>::RefType, - typename TupleTraits<H>::RefType> RefTuple; - typedef Tuple8<typename TupleTraits<A>::ParamType, - typename TupleTraits<B>::ParamType, - typename TupleTraits<C>::ParamType, - typename TupleTraits<D>::ParamType, - typename TupleTraits<E>::ParamType, - typename TupleTraits<F>::ParamType, - typename TupleTraits<G>::ParamType, - typename TupleTraits<H>::ParamType> ParamTuple; Tuple8() {} Tuple8(typename TupleTraits<A>::ParamType a, @@ -367,6 +262,159 @@ struct Tuple8 { H h; }; +// Tuple types ---------------------------------------------------------------- +// +// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the +// definitions of class types the tuple takes as parameters. + +template <> +struct TupleTypes< Tuple0 > { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template <class A> +struct TupleTypes< Tuple1<A> > { + typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple; + typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple; + typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple; +}; + +template <class A, class B> +struct TupleTypes< Tuple2<A, B> > { + typedef Tuple2<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType> ValueTuple; +typedef Tuple2<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType> RefTuple; + typedef Tuple2<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType> ParamTuple; +}; + +template <class A, class B, class C> +struct TupleTypes< Tuple3<A, B, C> > { + typedef Tuple3<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType, + typename TupleTraits<C>::ValueType> ValueTuple; +typedef Tuple3<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType, + typename TupleTraits<C>::RefType> RefTuple; + typedef Tuple3<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType, + typename TupleTraits<C>::ParamType> ParamTuple; +}; + +template <class A, class B, class C, class D> +struct TupleTypes< Tuple4<A, B, C, D> > { + typedef Tuple4<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType, + typename TupleTraits<C>::ValueType, + typename TupleTraits<D>::ValueType> ValueTuple; +typedef Tuple4<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType, + typename TupleTraits<C>::RefType, + typename TupleTraits<D>::RefType> RefTuple; + typedef Tuple4<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType, + typename TupleTraits<C>::ParamType, + typename TupleTraits<D>::ParamType> ParamTuple; +}; + +template <class A, class B, class C, class D, class E> +struct TupleTypes< Tuple5<A, B, C, D, E> > { + typedef Tuple5<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType, + typename TupleTraits<C>::ValueType, + typename TupleTraits<D>::ValueType, + typename TupleTraits<E>::ValueType> ValueTuple; +typedef Tuple5<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType, + typename TupleTraits<C>::RefType, + typename TupleTraits<D>::RefType, + typename TupleTraits<E>::RefType> RefTuple; + typedef Tuple5<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType, + typename TupleTraits<C>::ParamType, + typename TupleTraits<D>::ParamType, + typename TupleTraits<E>::ParamType> ParamTuple; +}; + +template <class A, class B, class C, class D, class E, class F> +struct TupleTypes< Tuple6<A, B, C, D, E, F> > { + typedef Tuple6<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType, + typename TupleTraits<C>::ValueType, + typename TupleTraits<D>::ValueType, + typename TupleTraits<E>::ValueType, + typename TupleTraits<F>::ValueType> ValueTuple; +typedef Tuple6<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType, + typename TupleTraits<C>::RefType, + typename TupleTraits<D>::RefType, + typename TupleTraits<E>::RefType, + typename TupleTraits<F>::RefType> RefTuple; + typedef Tuple6<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType, + typename TupleTraits<C>::ParamType, + typename TupleTraits<D>::ParamType, + typename TupleTraits<E>::ParamType, + typename TupleTraits<F>::ParamType> ParamTuple; +}; + +template <class A, class B, class C, class D, class E, class F, class G> +struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > { + typedef Tuple7<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType, + typename TupleTraits<C>::ValueType, + typename TupleTraits<D>::ValueType, + typename TupleTraits<E>::ValueType, + typename TupleTraits<F>::ValueType, + typename TupleTraits<G>::ValueType> ValueTuple; +typedef Tuple7<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType, + typename TupleTraits<C>::RefType, + typename TupleTraits<D>::RefType, + typename TupleTraits<E>::RefType, + typename TupleTraits<F>::RefType, + typename TupleTraits<G>::RefType> RefTuple; + typedef Tuple7<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType, + typename TupleTraits<C>::ParamType, + typename TupleTraits<D>::ParamType, + typename TupleTraits<E>::ParamType, + typename TupleTraits<F>::ParamType, + typename TupleTraits<G>::ParamType> ParamTuple; +}; + +template <class A, class B, class C, class D, class E, class F, class G, + class H> +struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > { + typedef Tuple8<typename TupleTraits<A>::ValueType, + typename TupleTraits<B>::ValueType, + typename TupleTraits<C>::ValueType, + typename TupleTraits<D>::ValueType, + typename TupleTraits<E>::ValueType, + typename TupleTraits<F>::ValueType, + typename TupleTraits<G>::ValueType, + typename TupleTraits<H>::ValueType> ValueTuple; +typedef Tuple8<typename TupleTraits<A>::RefType, + typename TupleTraits<B>::RefType, + typename TupleTraits<C>::RefType, + typename TupleTraits<D>::RefType, + typename TupleTraits<E>::RefType, + typename TupleTraits<F>::RefType, + typename TupleTraits<G>::RefType, + typename TupleTraits<H>::RefType> RefTuple; + typedef Tuple8<typename TupleTraits<A>::ParamType, + typename TupleTraits<B>::ParamType, + typename TupleTraits<C>::ParamType, + typename TupleTraits<D>::ParamType, + typename TupleTraits<E>::ParamType, + typename TupleTraits<F>::ParamType, + typename TupleTraits<G>::ParamType, + typename TupleTraits<H>::ParamType> ParamTuple; +}; + // Tuple creators ------------------------------------------------------------- // // Helper functions for constructing tuples while inferring the template |