/work/obj-fuzz/dist/include/mozilla/dom/GamepadMessageUtils.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_gamepad_GamepadMessageUtils_h |
8 | | #define mozilla_dom_gamepad_GamepadMessageUtils_h |
9 | | |
10 | | #include "ipc/IPCMessageUtils.h" |
11 | | #include "mozilla/dom/GamepadBinding.h" |
12 | | #include "mozilla/dom/GamepadPoseState.h" |
13 | | #include "mozilla/dom/GamepadServiceType.h" |
14 | | |
15 | | namespace IPC { |
16 | | |
17 | | template<> |
18 | | struct ParamTraits<mozilla::dom::GamepadMappingType> : |
19 | | public ContiguousEnumSerializer<mozilla::dom::GamepadMappingType, |
20 | | mozilla::dom::GamepadMappingType(0), |
21 | | mozilla::dom::GamepadMappingType( |
22 | | mozilla::dom::GamepadMappingType::EndGuard_)> {}; |
23 | | |
24 | | template<> |
25 | | struct ParamTraits<mozilla::dom::GamepadHand> : |
26 | | public ContiguousEnumSerializer<mozilla::dom::GamepadHand, |
27 | | mozilla::dom::GamepadHand(0), |
28 | | mozilla::dom::GamepadHand( |
29 | | mozilla::dom::GamepadHand::EndGuard_)> {}; |
30 | | |
31 | | template<> |
32 | | struct ParamTraits<mozilla::dom::GamepadServiceType> : |
33 | | public ContiguousEnumSerializer<mozilla::dom::GamepadServiceType, |
34 | | mozilla::dom::GamepadServiceType(0), |
35 | | mozilla::dom::GamepadServiceType( |
36 | | mozilla::dom::GamepadServiceType::NumGamepadServiceType)> {}; |
37 | | |
38 | | template<> |
39 | | struct ParamTraits<mozilla::dom::GamepadCapabilityFlags> : |
40 | | public BitFlagsEnumSerializer<mozilla::dom::GamepadCapabilityFlags, |
41 | | mozilla::dom::GamepadCapabilityFlags::Cap_All> {}; |
42 | | |
43 | | template <> |
44 | | struct ParamTraits<mozilla::dom::GamepadPoseState> |
45 | | { |
46 | | typedef mozilla::dom::GamepadPoseState paramType; |
47 | | |
48 | | static void Write(Message* aMsg, const paramType& aParam) |
49 | 0 | { |
50 | 0 | WriteParam(aMsg, aParam.flags); |
51 | 0 | WriteParam(aMsg, aParam.orientation[0]); |
52 | 0 | WriteParam(aMsg, aParam.orientation[1]); |
53 | 0 | WriteParam(aMsg, aParam.orientation[2]); |
54 | 0 | WriteParam(aMsg, aParam.orientation[3]); |
55 | 0 | WriteParam(aMsg, aParam.position[0]); |
56 | 0 | WriteParam(aMsg, aParam.position[1]); |
57 | 0 | WriteParam(aMsg, aParam.position[2]); |
58 | 0 | WriteParam(aMsg, aParam.angularVelocity[0]); |
59 | 0 | WriteParam(aMsg, aParam.angularVelocity[1]); |
60 | 0 | WriteParam(aMsg, aParam.angularVelocity[2]); |
61 | 0 | WriteParam(aMsg, aParam.angularAcceleration[0]); |
62 | 0 | WriteParam(aMsg, aParam.angularAcceleration[1]); |
63 | 0 | WriteParam(aMsg, aParam.angularAcceleration[2]); |
64 | 0 | WriteParam(aMsg, aParam.linearVelocity[0]); |
65 | 0 | WriteParam(aMsg, aParam.linearVelocity[1]); |
66 | 0 | WriteParam(aMsg, aParam.linearVelocity[2]); |
67 | 0 | WriteParam(aMsg, aParam.linearAcceleration[0]); |
68 | 0 | WriteParam(aMsg, aParam.linearAcceleration[1]); |
69 | 0 | WriteParam(aMsg, aParam.linearAcceleration[2]); |
70 | 0 | WriteParam(aMsg, aParam.isPositionValid); |
71 | 0 | WriteParam(aMsg, aParam.isOrientationValid); |
72 | 0 | } |
73 | | |
74 | | static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) |
75 | 0 | { |
76 | 0 | if (!ReadParam(aMsg, aIter, &(aResult->flags)) || |
77 | 0 | !ReadParam(aMsg, aIter, &(aResult->orientation[0])) || |
78 | 0 | !ReadParam(aMsg, aIter, &(aResult->orientation[1])) || |
79 | 0 | !ReadParam(aMsg, aIter, &(aResult->orientation[2])) || |
80 | 0 | !ReadParam(aMsg, aIter, &(aResult->orientation[3])) || |
81 | 0 | !ReadParam(aMsg, aIter, &(aResult->position[0])) || |
82 | 0 | !ReadParam(aMsg, aIter, &(aResult->position[1])) || |
83 | 0 | !ReadParam(aMsg, aIter, &(aResult->position[2])) || |
84 | 0 | !ReadParam(aMsg, aIter, &(aResult->angularVelocity[0])) || |
85 | 0 | !ReadParam(aMsg, aIter, &(aResult->angularVelocity[1])) || |
86 | 0 | !ReadParam(aMsg, aIter, &(aResult->angularVelocity[2])) || |
87 | 0 | !ReadParam(aMsg, aIter, &(aResult->angularAcceleration[0])) || |
88 | 0 | !ReadParam(aMsg, aIter, &(aResult->angularAcceleration[1])) || |
89 | 0 | !ReadParam(aMsg, aIter, &(aResult->angularAcceleration[2])) || |
90 | 0 | !ReadParam(aMsg, aIter, &(aResult->linearVelocity[0])) || |
91 | 0 | !ReadParam(aMsg, aIter, &(aResult->linearVelocity[1])) || |
92 | 0 | !ReadParam(aMsg, aIter, &(aResult->linearVelocity[2])) || |
93 | 0 | !ReadParam(aMsg, aIter, &(aResult->linearAcceleration[0])) || |
94 | 0 | !ReadParam(aMsg, aIter, &(aResult->linearAcceleration[1])) || |
95 | 0 | !ReadParam(aMsg, aIter, &(aResult->linearAcceleration[2])) || |
96 | 0 | !ReadParam(aMsg, aIter, &(aResult->isPositionValid)) || |
97 | 0 | !ReadParam(aMsg, aIter, &(aResult->isOrientationValid))) { |
98 | 0 | return false; |
99 | 0 | } |
100 | 0 | return true; |
101 | 0 | } |
102 | | }; |
103 | | |
104 | | } // namespace IPC |
105 | | |
106 | | #endif // mozilla_dom_gamepad_GamepadMessageUtils_h |