OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "ppapi/c/dev/ppb_text_input_dev.h" | 6 #include "ppapi/c/dev/ppb_text_input_dev.h" |
7 #include "ppapi/c/ppb_text_input_controller.h" | 7 #include "ppapi/c/ppb_text_input_controller.h" |
8 #include "ppapi/shared_impl/var.h" | 8 #include "ppapi/shared_impl/var.h" |
9 #include "ppapi/thunk/enter.h" | 9 #include "ppapi/thunk/enter.h" |
10 #include "ppapi/thunk/ppb_instance_api.h" | 10 #include "ppapi/thunk/ppb_instance_api.h" |
11 #include "ppapi/thunk/thunk.h" | 11 #include "ppapi/thunk/thunk.h" |
12 | 12 |
13 namespace ppapi { | 13 namespace ppapi { |
14 namespace thunk { | 14 namespace thunk { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_NONE) == int(PP_TEXTINPUT_TYPE_NONE), | 18 #define STATIC_ASSERT_ENUM(a, b) \ |
19 mismatching_enums); | 19 static_assert(int(a) == int(b), "mismatching enum values: " #a) |
20 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT), | 20 |
21 mismatching_enums); | 21 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_NONE, PP_TEXTINPUT_TYPE_NONE); |
22 COMPILE_ASSERT( | 22 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_TEXT, PP_TEXTINPUT_TYPE_TEXT); |
23 int(PP_TEXTINPUT_TYPE_DEV_PASSWORD) == int(PP_TEXTINPUT_TYPE_PASSWORD), | 23 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_PASSWORD, PP_TEXTINPUT_TYPE_PASSWORD); |
24 mismatching_enums); | 24 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_SEARCH, PP_TEXTINPUT_TYPE_SEARCH); |
25 COMPILE_ASSERT( | 25 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_EMAIL, PP_TEXTINPUT_TYPE_EMAIL); |
26 int(PP_TEXTINPUT_TYPE_DEV_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH), | 26 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_NUMBER, PP_TEXTINPUT_TYPE_NUMBER); |
27 mismatching_enums); | 27 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_TELEPHONE, |
28 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_EMAIL) == int(PP_TEXTINPUT_TYPE_EMAIL), | 28 PP_TEXTINPUT_TYPE_TELEPHONE); |
29 mismatching_enums); | 29 STATIC_ASSERT_ENUM(PP_TEXTINPUT_TYPE_DEV_URL, PP_TEXTINPUT_TYPE_URL); |
30 COMPILE_ASSERT( | |
31 int(PP_TEXTINPUT_TYPE_DEV_NUMBER) == int(PP_TEXTINPUT_TYPE_NUMBER), | |
32 mismatching_enums); | |
33 COMPILE_ASSERT( | |
34 int(PP_TEXTINPUT_TYPE_DEV_TELEPHONE) == int(PP_TEXTINPUT_TYPE_TELEPHONE), | |
35 mismatching_enums); | |
36 COMPILE_ASSERT(int(PP_TEXTINPUT_TYPE_DEV_URL) == int(PP_TEXTINPUT_TYPE_URL), | |
37 mismatching_enums); | |
38 | 30 |
39 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { | 31 void SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { |
40 EnterInstance enter(instance); | 32 EnterInstance enter(instance); |
41 if (enter.succeeded()) | 33 if (enter.succeeded()) |
42 enter.functions()->SetTextInputType(instance, type); | 34 enter.functions()->SetTextInputType(instance, type); |
43 } | 35 } |
44 | 36 |
45 void SetTextInputType_0_2(PP_Instance instance, PP_TextInput_Type_Dev type) { | 37 void SetTextInputType_0_2(PP_Instance instance, PP_TextInput_Type_Dev type) { |
46 EnterInstance enter(instance); | 38 EnterInstance enter(instance); |
47 if (enter.succeeded()) | 39 if (enter.succeeded()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() { | 116 const PPB_TextInput_Dev_0_2* GetPPB_TextInput_Dev_0_2_Thunk() { |
125 return &g_ppb_textinput_0_2_thunk; | 117 return &g_ppb_textinput_0_2_thunk; |
126 } | 118 } |
127 | 119 |
128 const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() { | 120 const PPB_TextInputController_1_0* GetPPB_TextInputController_1_0_Thunk() { |
129 return &g_ppb_textinputcontroller_1_0_thunk; | 121 return &g_ppb_textinputcontroller_1_0_thunk; |
130 } | 122 } |
131 | 123 |
132 } // namespace thunk | 124 } // namespace thunk |
133 } // namespace ppapi | 125 } // namespace ppapi |
OLD | NEW |