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

Side by Side Diff: mojo/public/bindings/sample/generated/sample_service.h

Issue 53173008: Add mojom_bindings_generator.gypi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more rename Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_H_
6 #define MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_H_
7
8 #include "mojo/public/bindings/lib/bindings.h"
9 #include "mojo/public/bindings/lib/message.h"
10
11 namespace sample {
12
13 #pragma pack(push, 1)
14
15 class Bar {
16 public:
17 static Bar* New(mojo::Buffer* buf);
18
19 void set_alpha(uint8_t alpha) { alpha_ = alpha; }
20 void set_beta(uint8_t beta) { beta_ = beta; }
21 void set_gamma(uint8_t gamma) { gamma_ = gamma; }
22
23 uint8_t alpha() const { return alpha_; }
24 uint8_t beta() const { return beta_; }
25 uint8_t gamma() const { return gamma_; }
26
27 private:
28 friend class mojo::internal::ObjectTraits<Bar>;
29
30 Bar();
31 ~Bar(); // NOT IMPLEMENTED
32
33 mojo::internal::StructHeader _header_;
34 uint8_t alpha_;
35 uint8_t beta_;
36 uint8_t gamma_;
37 uint8_t _pad0_[5];
38 };
39 MOJO_COMPILE_ASSERT(sizeof(Bar) == 16, bad_sizeof_Bar);
40
41 #pragma pack(pop)
42
43 #pragma pack(push, 1)
44
45 class Foo {
46 public:
47 static Foo* New(mojo::Buffer* buf);
48
49 void set_x(int32_t x) { x_ = x; }
50 void set_y(int32_t y) { y_ = y; }
51 void set_a(bool a) { a_ = a; }
52 void set_b(bool b) { b_ = b; }
53 void set_c(bool c) { c_ = c; }
54 void set_bar(Bar* bar) { bar_.ptr = bar; }
55 void set_data(mojo::Array<uint8_t>* data) { data_.ptr = data; }
56 void set_extra_bars(mojo::Array<Bar*>* extra_bars) {
57 extra_bars_.ptr = extra_bars;
58 }
59 void set_name(mojo::String* name) {
60 name_.ptr = name;
61 }
62 void set_files(mojo::Array<mojo::Handle>* files) {
63 files_.ptr = files;
64 }
65
66 int32_t x() const { return x_; }
67 int32_t y() const { return y_; }
68 bool a() const { return a_; }
69 bool b() const { return b_; }
70 bool c() const { return c_; }
71 const Bar* bar() const { return bar_.ptr; }
72 const mojo::Array<uint8_t>* data() const { return data_.ptr; }
73 const mojo::Array<Bar*>* extra_bars() const {
74 // NOTE: extra_bars is an optional field!
75 return _header_.num_fields >= 8 ? extra_bars_.ptr : NULL;
76 }
77 const mojo::String* name() const {
78 // NOTE: name is also an optional field!
79 return _header_.num_fields >= 9 ? name_.ptr : NULL;
80 }
81 const mojo::Array<mojo::Handle>* files() const {
82 // NOTE: files is also an optional field!
83 return _header_.num_fields >= 10 ? files_.ptr : NULL;
84 }
85
86 private:
87 friend class mojo::internal::ObjectTraits<Foo>;
88
89 Foo();
90 ~Foo(); // NOT IMPLEMENTED
91
92 mojo::internal::StructHeader _header_;
93 int32_t x_;
94 int32_t y_;
95 uint8_t a_ : 1;
96 uint8_t b_ : 1;
97 uint8_t c_ : 1;
98 uint8_t _pad0_[7];
99 mojo::internal::StructPointer<Bar> bar_;
100 mojo::internal::ArrayPointer<uint8_t> data_;
101 mojo::internal::ArrayPointer<Bar*> extra_bars_;
102 mojo::internal::StringPointer name_;
103 mojo::internal::ArrayPointer<mojo::Handle> files_;
104 };
105 MOJO_COMPILE_ASSERT(sizeof(Foo) == 64, bad_sizeof_Foo);
106
107 #pragma pack(pop)
108
109 class Service;
110 class ServiceProxy;
111 class ServiceStub;
112
113 class ServiceClient;
114 class ServiceClientProxy;
115 class ServiceClientStub;
116
117 class Service {
118 public:
119 typedef ServiceProxy _Proxy;
120 typedef ServiceStub _Stub;
121 typedef ServiceClient _Peer;
122
123 virtual void Frobinate(const Foo* foo, bool baz, mojo::Handle port) = 0;
124 };
125
126 class ServiceClient {
127 public:
128 typedef ServiceClientProxy _Proxy;
129 typedef ServiceClientStub _Stub;
130 typedef Service _Peer;
131
132 virtual void DidFrobinate(int32_t result) = 0;
133 };
134
135 class ServiceProxy : public Service {
136 public:
137 explicit ServiceProxy(mojo::MessageReceiver* receiver);
138
139 virtual void Frobinate(const Foo* Foo, bool baz, mojo::Handle port)
140 MOJO_OVERRIDE;
141
142 private:
143 mojo::MessageReceiver* receiver_;
144 };
145
146 class ServiceClientProxy : public ServiceClient {
147 public:
148 explicit ServiceClientProxy(mojo::MessageReceiver* receiver);
149
150 virtual void DidFrobinate(int32_t result) MOJO_OVERRIDE;
151
152 private:
153 mojo::MessageReceiver* receiver_;
154 };
155
156 class ServiceStub : public Service, public mojo::MessageReceiver {
157 public:
158 virtual bool Accept(mojo::Message* message) MOJO_OVERRIDE;
159 };
160
161 class ServiceClientStub : public ServiceClient, public mojo::MessageReceiver {
162 public:
163 virtual bool Accept(mojo::Message* message) MOJO_OVERRIDE;
164 };
165
166 } // namespace sample
167
168 #endif // MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_H_
OLDNEW
« no previous file with comments | « mojo/public/bindings/parser/mojo_translate.py ('k') | mojo/public/bindings/sample/generated/sample_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698