OLD | NEW |
1 $$ This is a pump file for generating file templates. Pump is a python | 1 $$ This is a pump file for generating file templates. Pump is a python |
2 $$ script that is part of the Google Test suite of utilities. Description | 2 $$ script that is part of the Google Test suite of utilities. Description |
3 $$ can be found here: | 3 $$ can be found here: |
4 $$ | 4 $$ |
5 $$ http://code.google.com/p/googletest/wiki/PumpManual | 5 $$ http://code.google.com/p/googletest/wiki/PumpManual |
6 $$ | 6 $$ |
7 | 7 |
8 $var MAX_ARITY = 7 | 8 $var MAX_ARITY = 7 |
9 | 9 |
10 // Copyright 2014 The Chromium Authors. All rights reserved. | 10 // Copyright 2014 The Chromium Authors. All rights reserved. |
11 // Use of this source code is governed by a BSD-style license that can be | 11 // Use of this source code is governed by a BSD-style license that can be |
12 // found in the LICENSE file. | 12 // found in the LICENSE file. |
13 | 13 |
14 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ | 14 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ |
15 #define MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ | 15 #define MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ |
16 | 16 |
17 #include "mojo/public/cpp/bindings/lib/callback_internal.h" | 17 #include "mojo/public/cpp/bindings/lib/callback_internal.h" |
18 #include "mojo/public/cpp/bindings/lib/shared_ptr.h" | 18 #include "mojo/public/cpp/bindings/lib/shared_ptr.h" |
| 19 #include "mojo/public/cpp/bindings/lib/template_util.h" |
19 | 20 |
20 namespace mojo { | 21 namespace mojo { |
21 | 22 |
22 template <typename Sig> | 23 template <typename Sig> |
23 class Callback; | 24 class Callback; |
24 | 25 |
25 $range ARITY 0..MAX_ARITY | 26 $range ARITY 0..MAX_ARITY |
26 $for ARITY [[ | 27 $for ARITY [[ |
27 $range ARG 1..ARITY | 28 $range ARG 1..ARITY |
28 | 29 |
(...skipping 16 matching lines...) Expand all Loading... |
45 // be adapted to a Callback using this constructor. | 46 // be adapted to a Callback using this constructor. |
46 template <typename Sink> | 47 template <typename Sink> |
47 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {} | 48 Callback(const Sink& sink) : sink_(new Adapter<Sink>(sink)) {} |
48 | 49 |
49 void Run( | 50 void Run( |
50 $for ARG , | 51 $for ARG , |
51 [[typename internal::Callback_ParamTraits<A$(ARG)>::ForwardType a$(ARG)]])
const { | 52 [[typename internal::Callback_ParamTraits<A$(ARG)>::ForwardType a$(ARG)]])
const { |
52 if (sink_.get()) | 53 if (sink_.get()) |
53 sink_->Run( | 54 sink_->Run( |
54 $for ARG , | 55 $for ARG , |
55 [[internal::Callback_Forward(a$(ARG))]]); | 56 [[internal::Forward(a$(ARG))]]); |
56 } | 57 } |
57 | 58 |
58 private: | 59 private: |
59 template <typename Sink> | 60 template <typename Sink> |
60 struct Adapter : public Runnable { | 61 struct Adapter : public Runnable { |
61 explicit Adapter(const Sink& sink) : sink(sink) {} | 62 explicit Adapter(const Sink& sink) : sink(sink) {} |
62 virtual void Run( | 63 virtual void Run( |
63 $for ARG , | 64 $for ARG , |
64 [[typename internal::Callback_ParamTraits<A$(ARG)>::ForwardType a$(ARG)]
]) const MOJO_OVERRIDE { | 65 [[typename internal::Callback_ParamTraits<A$(ARG)>::ForwardType a$(ARG)]
]) const MOJO_OVERRIDE { |
65 sink.Run( | 66 sink.Run( |
66 $for ARG , | 67 $for ARG , |
67 [[internal::Callback_Forward(a$(ARG))]]); | 68 [[internal::Forward(a$(ARG))]]); |
68 } | 69 } |
69 Sink sink; | 70 Sink sink; |
70 }; | 71 }; |
71 | 72 |
72 internal::SharedPtr<Runnable> sink_; | 73 internal::SharedPtr<Runnable> sink_; |
73 }; | 74 }; |
74 | 75 |
75 ]] $$ for ARITY | 76 ]] $$ for ARITY |
76 | 77 |
77 } // namespace mojo | 78 } // namespace mojo |
78 | 79 |
79 #endif // MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ | 80 #endif // MOJO_PUBLIC_CPP_BINDINGS_CALLBACK_H_ |
OLD | NEW |