Commit 85748694 authored by Avi Drissman's avatar Avi Drissman

Revert "Update legacy Tuple-using code."

This reverts commit 12f4b983

BUG=440675, 444827

Review URL: https://codereview.chromium.org/826573002

Cr-Commit-Position: refs/heads/master@{#309583}
parent 785a18df
...@@ -124,6 +124,71 @@ struct TupleLeaf { ...@@ -124,6 +124,71 @@ struct TupleLeaf {
T x; T x;
}; };
// For legacy compatibility, we name the first 8 tuple elements "a", "b", ...
// TODO(mdempsky): Update users to use get<N>() (crbug.com/440675).
#define DEFINE_TUPLE_LEAF(N, x) \
template <typename T> \
struct TupleLeaf<N, T> { \
TupleLeaf() {} \
explicit TupleLeaf(typename TupleTraits<T>::ParamType x) : x(x) {} \
\
T& get() { return x; } \
const T& get() const { return x; } \
\
T x; \
}
DEFINE_TUPLE_LEAF(0, a);
DEFINE_TUPLE_LEAF(1, b);
DEFINE_TUPLE_LEAF(2, c);
DEFINE_TUPLE_LEAF(3, d);
DEFINE_TUPLE_LEAF(4, e);
DEFINE_TUPLE_LEAF(5, f);
DEFINE_TUPLE_LEAF(6, g);
DEFINE_TUPLE_LEAF(7, h);
#undef DEFINE_TUPLE_LEAF
// Deprecated compat aliases
// TODO(mdempsky): Update users to just use Tuple instead (crbug.com/440675).
using Tuple0 = Tuple<>;
template <typename A>
using Tuple1 = Tuple<A>;
template <typename A, typename B>
using Tuple2 = Tuple<A, B>;
template <typename A, typename B, typename C>
using Tuple3 = Tuple<A, B, C>;
template <typename A, typename B, typename C, typename D>
using Tuple4 = Tuple<A, B, C, D>;
template <typename A, typename B, typename C, typename D, typename E>
using Tuple5 = Tuple<A, B, C, D, E>;
template <typename A,
typename B,
typename C,
typename D,
typename E,
typename F>
using Tuple6 = Tuple<A, B, C, D, E, F>;
template <typename A,
typename B,
typename C,
typename D,
typename E,
typename F,
typename G>
using Tuple7 = Tuple<A, B, C, D, E, F, G>;
template <typename A,
typename B,
typename C,
typename D,
typename E,
typename F,
typename G,
typename H>
using Tuple8 = Tuple<A, B, C, D, E, F, G, H>;
// Tuple getters -------------------------------------------------------------- // Tuple getters --------------------------------------------------------------
// //
// Allows accessing an arbitrary tuple element by index. // Allows accessing an arbitrary tuple element by index.
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#ifndef CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_ #ifndef CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
#define CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_ #define CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
typedef std::vector<Tuple<SkBitmap, base::FilePath>> DecodedImages; typedef std::vector<Tuple2<SkBitmap, base::FilePath> > DecodedImages;
#endif // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_ #endif // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
...@@ -38,9 +38,9 @@ IPC_STRUCT_TRAITS_END() ...@@ -38,9 +38,9 @@ IPC_STRUCT_TRAITS_END()
#if defined(OS_WIN) #if defined(OS_WIN)
// A vector of filters, each being a Tuple containing a display string (i.e. // A vector of filters, each being a Tuple2 containing a display string (i.e.
// "Text Files") and a filter pattern (i.e. "*.txt"). // "Text Files") and a filter pattern (i.e. "*.txt").
typedef std::vector<Tuple<base::string16, base::string16>> typedef std::vector<Tuple2<base::string16, base::string16> >
GetOpenFileNameFilter; GetOpenFileNameFilter;
IPC_STRUCT_BEGIN(ChromeUtilityMsg_GetSaveFileName_Params) IPC_STRUCT_BEGIN(ChromeUtilityMsg_GetSaveFileName_Params)
......
...@@ -457,7 +457,7 @@ ...@@ -457,7 +457,7 @@
void (T::*func)(P*, TA)) { \ void (T::*func)(P*, TA)) { \
Schema::Param p; \ Schema::Param p; \
if (Read(msg, &p)) { \ if (Read(msg, &p)) { \
(obj->*func)(parameter, get<0>(p)); \ (obj->*func)(parameter, p.a); \
return true; \ return true; \
} \ } \
return false; \ return false; \
...@@ -469,7 +469,7 @@ ...@@ -469,7 +469,7 @@
void (T::*func)(P*, TA, TB)) { \ void (T::*func)(P*, TA, TB)) { \
Schema::Param p; \ Schema::Param p; \
if (Read(msg, &p)) { \ if (Read(msg, &p)) { \
(obj->*func)(parameter, get<0>(p), get<1>(p)); \ (obj->*func)(parameter, p.a, p.b); \
return true; \ return true; \
} \ } \
return false; \ return false; \
...@@ -481,7 +481,7 @@ ...@@ -481,7 +481,7 @@
void (T::*func)(P*, TA, TB, TC)) { \ void (T::*func)(P*, TA, TB, TC)) { \
Schema::Param p; \ Schema::Param p; \
if (Read(msg, &p)) { \ if (Read(msg, &p)) { \
(obj->*func)(parameter, get<0>(p), get<1>(p), get<2>(p)); \ (obj->*func)(parameter, p.a, p.b, p.c); \
return true; \ return true; \
} \ } \
return false; \ return false; \
...@@ -494,7 +494,7 @@ ...@@ -494,7 +494,7 @@
void (T::*func)(P*, TA, TB, TC, TD)) { \ void (T::*func)(P*, TA, TB, TC, TD)) { \
Schema::Param p; \ Schema::Param p; \
if (Read(msg, &p)) { \ if (Read(msg, &p)) { \
(obj->*func)(parameter, get<0>(p), get<1>(p), get<2>(p), get<3>(p)); \ (obj->*func)(parameter, p.a, p.b, p.c, p.d); \
return true; \ return true; \
} \ } \
return false; \ return false; \
...@@ -507,8 +507,7 @@ ...@@ -507,8 +507,7 @@
void (T::*func)(P*, TA, TB, TC, TD, TE)) { \ void (T::*func)(P*, TA, TB, TC, TD, TE)) { \
Schema::Param p; \ Schema::Param p; \
if (Read(msg, &p)) { \ if (Read(msg, &p)) { \
(obj->*func)(parameter, get<0>(p), get<1>(p), get<2>(p), get<3>(p), \ (obj->*func)(parameter, p.a, p.b, p.c, p.d, p.e); \
get<4>(p)); \
return true; \ return true; \
} \ } \
return false; \ return false; \
...@@ -818,18 +817,18 @@ ...@@ -818,18 +817,18 @@
#define IPC_TYPE_OUT_3(t1, t2, t3) t1* arg6, t2* arg7, t3* arg8 #define IPC_TYPE_OUT_3(t1, t2, t3) t1* arg6, t2* arg7, t3* arg8
#define IPC_TYPE_OUT_4(t1, t2, t3, t4) t1* arg6, t2* arg7, t3* arg8, t4* arg9 #define IPC_TYPE_OUT_4(t1, t2, t3, t4) t1* arg6, t2* arg7, t3* arg8, t4* arg9
#define IPC_TUPLE_IN_0() Tuple<> #define IPC_TUPLE_IN_0() Tuple0
#define IPC_TUPLE_IN_1(t1) Tuple<t1> #define IPC_TUPLE_IN_1(t1) Tuple1<t1>
#define IPC_TUPLE_IN_2(t1, t2) Tuple<t1, t2> #define IPC_TUPLE_IN_2(t1, t2) Tuple2<t1, t2>
#define IPC_TUPLE_IN_3(t1, t2, t3) Tuple<t1, t2, t3> #define IPC_TUPLE_IN_3(t1, t2, t3) Tuple3<t1, t2, t3>
#define IPC_TUPLE_IN_4(t1, t2, t3, t4) Tuple<t1, t2, t3, t4> #define IPC_TUPLE_IN_4(t1, t2, t3, t4) Tuple4<t1, t2, t3, t4>
#define IPC_TUPLE_IN_5(t1, t2, t3, t4, t5) Tuple<t1, t2, t3, t4, t5> #define IPC_TUPLE_IN_5(t1, t2, t3, t4, t5) Tuple5<t1, t2, t3, t4, t5>
#define IPC_TUPLE_OUT_0() Tuple<> #define IPC_TUPLE_OUT_0() Tuple0
#define IPC_TUPLE_OUT_1(t1) Tuple<t1&> #define IPC_TUPLE_OUT_1(t1) Tuple1<t1&>
#define IPC_TUPLE_OUT_2(t1, t2) Tuple<t1&, t2&> #define IPC_TUPLE_OUT_2(t1, t2) Tuple2<t1&, t2&>
#define IPC_TUPLE_OUT_3(t1, t2, t3) Tuple<t1&, t2&, t3&> #define IPC_TUPLE_OUT_3(t1, t2, t3) Tuple3<t1&, t2&, t3&>
#define IPC_TUPLE_OUT_4(t1, t2, t3, t4) Tuple<t1&, t2&, t3&, t4&> #define IPC_TUPLE_OUT_4(t1, t2, t3, t4) Tuple4<t1&, t2&, t3&, t4&>
#define IPC_NAME_IN_0() MakeTuple() #define IPC_NAME_IN_0() MakeTuple()
#define IPC_NAME_IN_1(t1) MakeRefTuple(arg1) #define IPC_NAME_IN_1(t1) MakeRefTuple(arg1)
......
...@@ -520,8 +520,8 @@ struct IPC_EXPORT ParamTraits<base::TimeTicks> { ...@@ -520,8 +520,8 @@ struct IPC_EXPORT ParamTraits<base::TimeTicks> {
}; };
template <> template <>
struct ParamTraits<Tuple<>> { struct ParamTraits<Tuple0> {
typedef Tuple<> param_type; typedef Tuple0 param_type;
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
} }
static bool Read(const Message* m, PickleIterator* iter, param_type* r) { static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
...@@ -532,112 +532,112 @@ struct ParamTraits<Tuple<>> { ...@@ -532,112 +532,112 @@ struct ParamTraits<Tuple<>> {
}; };
template <class A> template <class A>
struct ParamTraits<Tuple<A>> { struct ParamTraits< Tuple1<A> > {
typedef Tuple<A> param_type; typedef Tuple1<A> param_type;
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
WriteParam(m, get<0>(p)); WriteParam(m, p.a);
} }
static bool Read(const Message* m, PickleIterator* iter, param_type* r) { static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
return ReadParam(m, iter, &get<0>(*r)); return ReadParam(m, iter, &r->a);
} }
static void Log(const param_type& p, std::string* l) { static void Log(const param_type& p, std::string* l) {
LogParam(get<0>(p), l); LogParam(p.a, l);
} }
}; };
template <class A, class B> template <class A, class B>
struct ParamTraits< Tuple<A, B> > { struct ParamTraits< Tuple2<A, B> > {
typedef Tuple<A, B> param_type; typedef Tuple2<A, B> param_type;
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
WriteParam(m, get<0>(p)); WriteParam(m, p.a);
WriteParam(m, get<1>(p)); WriteParam(m, p.b);
} }
static bool Read(const Message* m, PickleIterator* iter, param_type* r) { static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
return (ReadParam(m, iter, &get<0>(*r)) && return (ReadParam(m, iter, &r->a) &&
ReadParam(m, iter, &get<1>(*r))); ReadParam(m, iter, &r->b));
} }
static void Log(const param_type& p, std::string* l) { static void Log(const param_type& p, std::string* l) {
LogParam(get<0>(p), l); LogParam(p.a, l);
l->append(", "); l->append(", ");
LogParam(get<1>(p), l); LogParam(p.b, l);
} }
}; };
template <class A, class B, class C> template <class A, class B, class C>
struct ParamTraits< Tuple<A, B, C> > { struct ParamTraits< Tuple3<A, B, C> > {
typedef Tuple<A, B, C> param_type; typedef Tuple3<A, B, C> param_type;
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
WriteParam(m, get<0>(p)); WriteParam(m, p.a);
WriteParam(m, get<1>(p)); WriteParam(m, p.b);
WriteParam(m, get<2>(p)); WriteParam(m, p.c);
} }
static bool Read(const Message* m, PickleIterator* iter, param_type* r) { static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
return (ReadParam(m, iter, &get<0>(*r)) && return (ReadParam(m, iter, &r->a) &&
ReadParam(m, iter, &get<1>(*r)) && ReadParam(m, iter, &r->b) &&
ReadParam(m, iter, &get<2>(*r))); ReadParam(m, iter, &r->c));
} }
static void Log(const param_type& p, std::string* l) { static void Log(const param_type& p, std::string* l) {
LogParam(get<0>(p), l); LogParam(p.a, l);
l->append(", "); l->append(", ");
LogParam(get<1>(p), l); LogParam(p.b, l);
l->append(", "); l->append(", ");
LogParam(get<2>(p), l); LogParam(p.c, l);
} }
}; };
template <class A, class B, class C, class D> template <class A, class B, class C, class D>
struct ParamTraits< Tuple<A, B, C, D> > { struct ParamTraits< Tuple4<A, B, C, D> > {
typedef Tuple<A, B, C, D> param_type; typedef Tuple4<A, B, C, D> param_type;
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
WriteParam(m, get<0>(p)); WriteParam(m, p.a);
WriteParam(m, get<1>(p)); WriteParam(m, p.b);
WriteParam(m, get<2>(p)); WriteParam(m, p.c);
WriteParam(m, get<3>(p)); WriteParam(m, p.d);
} }
static bool Read(const Message* m, PickleIterator* iter, param_type* r) { static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
return (ReadParam(m, iter, &get<0>(*r)) && return (ReadParam(m, iter, &r->a) &&
ReadParam(m, iter, &get<1>(*r)) && ReadParam(m, iter, &r->b) &&
ReadParam(m, iter, &get<2>(*r)) && ReadParam(m, iter, &r->c) &&
ReadParam(m, iter, &get<3>(*r))); ReadParam(m, iter, &r->d));
} }
static void Log(const param_type& p, std::string* l) { static void Log(const param_type& p, std::string* l) {
LogParam(get<0>(p), l); LogParam(p.a, l);
l->append(", "); l->append(", ");
LogParam(get<1>(p), l); LogParam(p.b, l);
l->append(", "); l->append(", ");
LogParam(get<2>(p), l); LogParam(p.c, l);
l->append(", "); l->append(", ");
LogParam(get<3>(p), l); LogParam(p.d, l);
} }
}; };
template <class A, class B, class C, class D, class E> template <class A, class B, class C, class D, class E>
struct ParamTraits< Tuple<A, B, C, D, E> > { struct ParamTraits< Tuple5<A, B, C, D, E> > {
typedef Tuple<A, B, C, D, E> param_type; typedef Tuple5<A, B, C, D, E> param_type;
static void Write(Message* m, const param_type& p) { static void Write(Message* m, const param_type& p) {
WriteParam(m, get<0>(p)); WriteParam(m, p.a);
WriteParam(m, get<1>(p)); WriteParam(m, p.b);
WriteParam(m, get<2>(p)); WriteParam(m, p.c);
WriteParam(m, get<3>(p)); WriteParam(m, p.d);
WriteParam(m, get<4>(p)); WriteParam(m, p.e);
} }
static bool Read(const Message* m, PickleIterator* iter, param_type* r) { static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
return (ReadParam(m, iter, &get<0>(*r)) && return (ReadParam(m, iter, &r->a) &&
ReadParam(m, iter, &get<1>(*r)) && ReadParam(m, iter, &r->b) &&
ReadParam(m, iter, &get<2>(*r)) && ReadParam(m, iter, &r->c) &&
ReadParam(m, iter, &get<3>(*r)) && ReadParam(m, iter, &r->d) &&
ReadParam(m, iter, &get<4>(*r))); ReadParam(m, iter, &r->e));
} }
static void Log(const param_type& p, std::string* l) { static void Log(const param_type& p, std::string* l) {
LogParam(get<0>(p), l); LogParam(p.a, l);
l->append(", "); l->append(", ");
LogParam(get<1>(p), l); LogParam(p.b, l);
l->append(", "); l->append(", ");
LogParam(get<2>(p), l); LogParam(p.c, l);
l->append(", "); l->append(", ");
LogParam(get<3>(p), l); LogParam(p.d, l);
l->append(", "); l->append(", ");
LogParam(get<4>(p), l); LogParam(p.e, l);
} }
}; };
...@@ -912,7 +912,7 @@ class SyncMessageSchema { ...@@ -912,7 +912,7 @@ class SyncMessageSchema {
Method func) { Method func) {
Message* reply = SyncMessage::GenerateReply(msg); Message* reply = SyncMessage::GenerateReply(msg);
if (ok) { if (ok) {
Tuple<Message&> t = MakeRefTuple(*reply); Tuple1<Message&> t = MakeRefTuple(*reply);
ConnectMessageAndReply(msg, reply); ConnectMessageAndReply(msg, reply);
DispatchToMethod(obj, func, send_params, &t); DispatchToMethod(obj, func, send_params, &t);
} else { } else {
......
...@@ -145,14 +145,14 @@ size_t CodeGen::Offset(Node target) const { ...@@ -145,14 +145,14 @@ size_t CodeGen::Offset(Node target) const {
// TODO(mdempsky): Move into a general base::Tuple helper library. // TODO(mdempsky): Move into a general base::Tuple helper library.
bool CodeGen::MemoKeyLess::operator()(const MemoKey& lhs, bool CodeGen::MemoKeyLess::operator()(const MemoKey& lhs,
const MemoKey& rhs) const { const MemoKey& rhs) const {
if (get<0>(lhs) != get<0>(rhs)) if (lhs.a != rhs.a)
return get<0>(lhs) < get<0>(rhs); return lhs.a < rhs.a;
if (get<1>(lhs) != get<1>(rhs)) if (lhs.b != rhs.b)
return get<1>(lhs) < get<1>(rhs); return lhs.b < rhs.b;
if (get<2>(lhs) != get<2>(rhs)) if (lhs.c != rhs.c)
return get<2>(lhs) < get<2>(rhs); return lhs.c < rhs.c;
if (get<3>(lhs) != get<3>(rhs)) if (lhs.d != rhs.d)
return get<3>(lhs) < get<3>(rhs); return lhs.d < rhs.d;
return false; return false;
} }
......
...@@ -81,7 +81,7 @@ class SANDBOX_EXPORT CodeGen { ...@@ -81,7 +81,7 @@ class SANDBOX_EXPORT CodeGen {
void Compile(Node head, Program* program); void Compile(Node head, Program* program);
private: private:
using MemoKey = Tuple<uint16_t, uint32_t, Node, Node>; using MemoKey = Tuple4<uint16_t, uint32_t, Node, Node>;
struct MemoKeyLess { struct MemoKeyLess {
bool operator()(const MemoKey& lhs, const MemoKey& rhs) const; bool operator()(const MemoKey& lhs, const MemoKey& rhs) const;
}; };
......
...@@ -56,8 +56,8 @@ HEADER = """\ ...@@ -56,8 +56,8 @@ HEADER = """\
// } // }
// //
// void QuitMessageLoop(int seconds) { // void QuitMessageLoop(int seconds) {
// base::MessageLoop* loop = base::MessageLoop::current(); // MessageLoop* loop = MessageLoop::current();
// loop->PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), // loop->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(),
// 1000 * seconds); // 1000 * seconds);
// } // }
// }; // };
...@@ -202,7 +202,7 @@ struct MutantFunctor { ...@@ -202,7 +202,7 @@ struct MutantFunctor {
} }
inline R operator()() { inline R operator()() {
return impl_->RunWithParams(Tuple<>()); return impl_->RunWithParams(Tuple0());
} }
template <typename Arg1> template <typename Arg1>
...@@ -241,8 +241,8 @@ FOOTER = """\ ...@@ -241,8 +241,8 @@ FOOTER = """\
# Templates for DispatchToMethod/DispatchToFunction functions. # Templates for DispatchToMethod/DispatchToFunction functions.
# template_params - typename P1, typename P2.. typename C1.. # template_params - typename P1, typename P2.. typename C1..
# prebound - Tuple<P1, .. PN> # prebound - TupleN<P1, .. PN>
# calltime - Tuple<C1, .. CN> # calltime - TupleN<C1, .. CN>
# args - p.a, p.b.., c.a, c.b.. # args - p.a, p.b.., c.a, c.b..
DISPATCH_TO_METHOD_TEMPLATE = """\ DISPATCH_TO_METHOD_TEMPLATE = """\
template <typename R, typename T, typename Method, %(template_params)s> template <typename R, typename T, typename Method, %(template_params)s>
...@@ -264,8 +264,8 @@ inline R DispatchToFunction(Function function, ...@@ -264,8 +264,8 @@ inline R DispatchToFunction(Function function,
# Templates for CreateFunctor functions. # Templates for CreateFunctor functions.
# template_params - typename P1, typename P2.. typename C1.. typename X1.. # template_params - typename P1, typename P2.. typename C1.. typename X1..
# prebound - Tuple<P1, .. PN> # prebound - TupleN<P1, .. PN>
# calltime - Tuple<A1, .. AN> # calltime - TupleN<A1, .. AN>
# params - X1,.. , A1, .. # params - X1,.. , A1, ..
# args - const P1& p1 .. # args - const P1& p1 ..
# call_args - p1, p2, p3.. # call_args - p1, p2, p3..
...@@ -305,7 +305,7 @@ def SplitLine(line, width): ...@@ -305,7 +305,7 @@ def SplitLine(line, width):
return (line[:n], line[n + 1:]) return (line[:n], line[n + 1:])
def Wrap(s, width, subsequent_offset): def Wrap(s, width, subsequent_offset=4):
"""Wraps a single line |s| at commas so every line is at most |width| """Wraps a single line |s| at commas so every line is at most |width|
characters long. characters long.
""" """
...@@ -324,8 +324,10 @@ def Clean(s): ...@@ -324,8 +324,10 @@ def Clean(s):
Our simple string formatting/concatenation may introduce extra commas. Our simple string formatting/concatenation may introduce extra commas.
""" """
s = s.replace("<>", "")
s = s.replace(", >", ">") s = s.replace(", >", ">")
s = s.replace(", )", ")") s = s.replace(", )", ")")
s = s.replace(">>", "> >")
return s return s
...@@ -337,13 +339,23 @@ def ExpandPattern(pattern, it): ...@@ -337,13 +339,23 @@ def ExpandPattern(pattern, it):
return [pattern.replace("%", x) for x in it] return [pattern.replace("%", x) for x in it]
def Gen(pattern, n, start): def Gen(pattern, n):
"""Expands pattern replacing '%' with sequential integers starting with start. """Expands pattern replacing '%' with sequential integers.
Expanded patterns will be joined with comma separator. Expanded patterns will be joined with comma separator.
Gen("X%", 3, 1) will return "X1, X2, X3". GenAlphs("X%", 3) will return "X1, X2, X3".
""" """
it = string.hexdigits[start:n + start] it = string.hexdigits[1:n + 1]
return ", ".join(ExpandPattern(pattern, it))
def GenAlpha(pattern, n):
"""Expands pattern replacing '%' with sequential small ASCII letters.
Expanded patterns will be joined with comma separator.
GenAlphs("X%", 3) will return "Xa, Xb, Xc".
"""
it = string.ascii_lowercase[0:n]
return ", ".join(ExpandPattern(pattern, it)) return ", ".join(ExpandPattern(pattern, it))
...@@ -352,7 +364,7 @@ def Merge(a): ...@@ -352,7 +364,7 @@ def Merge(a):
def GenTuple(pattern, n): def GenTuple(pattern, n):
return Clean("Tuple<%s>" % (Gen(pattern, n, 1))) return Clean("Tuple%d<%s>" % (n, Gen(pattern, n)))
def FixCode(s): def FixCode(s):
...@@ -366,12 +378,11 @@ def FixCode(s): ...@@ -366,12 +378,11 @@ def FixCode(s):
def GenerateDispatch(prebound, calltime): def GenerateDispatch(prebound, calltime):
print "\n// %d - %d" % (prebound, calltime) print "\n// %d - %d" % (prebound, calltime)
args = { args = {
"template_params": Merge([Gen("typename P%", prebound, 1), "template_params": Merge([Gen("typename P%", prebound),
Gen("typename C%", calltime, 1)]), Gen("typename C%", calltime)]),
"prebound": GenTuple("P%", prebound), "prebound": GenTuple("P%", prebound),
"calltime": GenTuple("C%", calltime), "calltime": GenTuple("C%", calltime),
"args": Merge([Gen("get<%>(p)", prebound, 0), "args": Merge([GenAlpha("p.%", prebound), GenAlpha("c.%", calltime)]),
Gen("get<%>(c)", calltime, 0)]),
} }
print FixCode(DISPATCH_TO_METHOD_TEMPLATE % args) print FixCode(DISPATCH_TO_METHOD_TEMPLATE % args)
...@@ -383,12 +394,12 @@ def GenerateCreateFunctor(prebound, calltime): ...@@ -383,12 +394,12 @@ def GenerateCreateFunctor(prebound, calltime):
args = { args = {
"calltime": GenTuple("A%", calltime), "calltime": GenTuple("A%", calltime),
"prebound": GenTuple("P%", prebound), "prebound": GenTuple("P%", prebound),
"params": Merge([Gen("X%", prebound, 1), Gen("A%", calltime, 1)]), "params": Merge([Gen("X%", prebound), Gen("A%", calltime)]),
"args": Gen("const P%& p%", prebound, 1), "args": Gen("const P%& p%", prebound),
"call_args": Gen("p%", prebound, 1), "call_args": Gen("p%", prebound),
"template_params": Merge([Gen("typename P%", prebound, 1), "template_params": Merge([Gen("typename P%", prebound),
Gen("typename A%", calltime, 1), Gen("typename A%", calltime),
Gen("typename X%", prebound, 1)]) Gen("typename X%", prebound)])
} }
mutant = FixCode(CREATE_METHOD_FUNCTOR_TEMPLATE % args) mutant = FixCode(CREATE_METHOD_FUNCTOR_TEMPLATE % args)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment