OLD | NEW |
| (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_FOO_H_ | |
6 #define MOJO_GENERATED_BINDINGS_SAMPLE_FOO_H_ | |
7 | |
8 #include "mojo/public/bindings/lib/bindings.h" | |
9 | |
10 namespace sample { | |
11 class Bar; | |
12 | |
13 #pragma pack(push, 1) | |
14 | |
15 class Foo { | |
16 public: | |
17 static Foo* New(mojo::Buffer* buf); | |
18 | |
19 void set_x(int32_t x) { x_ = x; } | |
20 void set_y(int32_t y) { y_ = y; } | |
21 void set_a(bool a) { a_ = a; } | |
22 void set_b(bool b) { b_ = b; } | |
23 void set_c(bool c) { c_ = c; } | |
24 void set_bar(Bar* bar) { bar_.ptr = bar; } | |
25 void set_data(mojo::Array<uint8_t>* data) { data_.ptr = data; } | |
26 void set_extra_bars(mojo::Array<Bar*>* extra_bars) { | |
27 extra_bars_.ptr = extra_bars; | |
28 } | |
29 void set_name(mojo::String* name) { | |
30 name_.ptr = name; | |
31 } | |
32 void set_files(mojo::Array<mojo::Handle>* files) { | |
33 files_.ptr = files; | |
34 } | |
35 | |
36 int32_t x() const { return x_; } | |
37 int32_t y() const { return y_; } | |
38 bool a() const { return a_; } | |
39 bool b() const { return b_; } | |
40 bool c() const { return c_; } | |
41 const Bar* bar() const { return bar_.ptr; } | |
42 const mojo::Array<uint8_t>* data() const { return data_.ptr; } | |
43 const mojo::Array<Bar*>* extra_bars() const { | |
44 // NOTE: extra_bars is an optional field! | |
45 return _header_.num_fields >= 8 ? extra_bars_.ptr : NULL; | |
46 } | |
47 const mojo::String* name() const { | |
48 // NOTE: name is also an optional field! | |
49 return _header_.num_fields >= 9 ? name_.ptr : NULL; | |
50 } | |
51 const mojo::Array<mojo::Handle>* files() const { | |
52 // NOTE: files is also an optional field! | |
53 return _header_.num_fields >= 10 ? files_.ptr : NULL; | |
54 } | |
55 | |
56 private: | |
57 friend class mojo::internal::ObjectTraits<Foo>; | |
58 | |
59 Foo(); | |
60 ~Foo(); // NOT IMPLEMENTED | |
61 | |
62 mojo::internal::StructHeader _header_; | |
63 int32_t x_; | |
64 int32_t y_; | |
65 uint8_t a_ : 1; | |
66 uint8_t b_ : 1; | |
67 uint8_t c_ : 1; | |
68 uint8_t _pad0_[7]; | |
69 mojo::internal::StructPointer<Bar> bar_; | |
70 mojo::internal::ArrayPointer<uint8_t> data_; | |
71 mojo::internal::ArrayPointer<Bar*> extra_bars_; | |
72 mojo::internal::StringPointer name_; | |
73 mojo::internal::ArrayPointer<mojo::Handle> files_; | |
74 }; | |
75 MOJO_COMPILE_ASSERT(sizeof(Foo) == 64, bad_sizeof_Foo); | |
76 | |
77 #pragma pack(pop) | |
78 | |
79 } // namespace sample | |
80 | |
81 #endif // MOJO_GENERATED_BINDINGS_SAMPLE_FOO_H_ | |
OLD | NEW |