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

Side by Side Diff: mojo/public/tools/bindings/generators/cpp_templates/interface_stub_declaration.tmpl

Issue 2403533003: Mojo C++ Bindings: Support custom impl ref types (Closed)
Patch Set: nit, move Created 4 years, 2 months 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
OLDNEW
1 class {{export_attribute}} {{interface.name}}Stub : public NON_EXPORTED_BASE(moj o::MessageReceiverWithResponderStatus) { 1 class {{export_attribute}} {{interface.name}}StubDispatch {
2 public: 2 public:
3 {{interface.name}}Stub(); 3 static bool Accept({{interface.name}}* impl,
4 ~{{interface.name}}Stub() override; 4 mojo::internal::SerializationContext* context,
5 void set_sink({{interface.name}}* sink) { sink_ = sink; } 5 mojo::Message* message);
6 {{interface.name}}* sink() { return sink_; } 6 static bool AcceptWithResponder({{interface.name}}* impl,
7 mojo::internal::SerializationContext* context,
8 mojo::Message* message,
9 mojo::MessageReceiverWithStatus* responder);
10 };
11
12 template <typename ImplRefTraits =
13 mojo::RawPtrImplRefTraits<{{interface.name}}>>
14 class {{interface.name}}Stub
15 : public NON_EXPORTED_BASE(mojo::MessageReceiverWithResponderStatus) {
16 public:
17 using ImplPointerType = typename ImplRefTraits::PointerType;
18
19 {{interface.name}}Stub() {}
20 ~{{interface.name}}Stub() override {}
21
22 void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
23 ImplPointerType& sink() { return sink_; }
24
7 mojo::internal::SerializationContext* serialization_context() { 25 mojo::internal::SerializationContext* serialization_context() {
8 return &serialization_context_; 26 return &serialization_context_;
9 } 27 }
10 28
11 bool Accept(mojo::Message* message) override; 29 bool Accept(mojo::Message* message) override {
12 bool AcceptWithResponder(mojo::Message* message, 30 if (ImplRefTraits::IsNull(sink_))
13 mojo::MessageReceiverWithStatus* responder) override; 31 return false;
32 return {{interface.name}}StubDispatch::Accept(
33 ImplRefTraits::GetRawPointer(&sink_), &serialization_context_, message);
34 }
35
36 bool AcceptWithResponder(
37 mojo::Message* message,
38 mojo::MessageReceiverWithStatus* responder) override {
39 if (ImplRefTraits::IsNull(sink_))
40 return false;
41 return {{interface.name}}StubDispatch::AcceptWithResponder(
42 ImplRefTraits::GetRawPointer(&sink_), &serialization_context_, message,
43 responder);
44 }
14 45
15 private: 46 private:
16 {{interface.name}}* sink_; 47 ImplPointerType sink_;
17 mojo::internal::SerializationContext serialization_context_; 48 mojo::internal::SerializationContext serialization_context_;
18 }; 49 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698