- add sources.
[platform/framework/web/crosswalk.git] / src / mojo / public / bindings / sample / generated / sample_service_serialization.h
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_SERIALIZATION_H_
6 #define MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_SERIALIZATION_H_
7
8 #include <string.h>
9
10 #include "mojo/public/bindings/lib/bindings_serialization.h"
11 #include "mojo/public/bindings/sample/generated/sample_foo_serialization.h"
12 #include "mojo/public/bindings/sample/generated/sample_service.h"
13
14 namespace sample {
15 namespace internal {
16
17 const uint32_t kService_Frobinate_Name = 1;
18
19 #pragma pack(push, 1)
20
21 class Service_Frobinate_Params {
22  public:
23   static Service_Frobinate_Params* New(mojo::Buffer* buf);
24
25   void set_foo(Foo* foo) { foo_.ptr = foo; }
26   void set_baz(bool baz) { baz_ = baz; }
27   void set_port(mojo::Handle port) { port_ = port; }
28
29   const Foo* foo() const { return foo_.ptr; }
30   bool baz() const { return baz_; }
31   mojo::Handle port() const {
32     // NOTE: port is an optional field!
33     return _header_.num_fields >= 3 ? port_ : mojo::kInvalidHandle;
34   }
35
36  private:
37   friend class mojo::internal::ObjectTraits<Service_Frobinate_Params>;
38
39   Service_Frobinate_Params();
40   ~Service_Frobinate_Params();  // NOT IMPLEMENTED
41
42   mojo::internal::StructHeader _header_;
43   mojo::internal::StructPointer<Foo> foo_;
44   uint8_t baz_ : 1;
45   uint8_t _pad0_[3];
46   mojo::Handle port_;
47 };
48 MOJO_COMPILE_ASSERT(sizeof(Service_Frobinate_Params) == 24,
49                     bad_sizeof_Service_Frobinate_Params);
50
51 #pragma pack(pop)
52
53 }  // namespace internal
54 }  // namespace sample
55
56 namespace mojo {
57 namespace internal {
58
59 template <>
60 class ObjectTraits<sample::internal::Service_Frobinate_Params> {
61  public:
62   static void EncodePointersAndHandles(
63       sample::internal::Service_Frobinate_Params* params,
64       std::vector<mojo::Handle>* handles);
65   static bool DecodePointersAndHandles(
66       sample::internal::Service_Frobinate_Params* params,
67       const mojo::Message& message);
68 };
69
70 }  // namespace internal
71 }  // namespace mojo
72
73 #endif  // MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_SERIALIZATION_H_