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 */ | |
dmichael (off chromium)
2012/11/16 18:24:44
How hard would it be to do a C++ style copyright h
teravest
2012/11/16 18:52:36
Done. I changed the "From...modified..." to be C++
| |
4 | 5 |
5 #include "ppapi/thunk/thunk.h" | 6 /* From dev/ppb_widget_dev.idl modified Thu Nov 15 11:21:48 2012. */ |
7 | |
8 #include "ppapi/c/dev/ppb_widget_dev.h" | |
9 #include "ppapi/c/pp_errors.h" | |
10 #include "ppapi/shared_impl/tracked_callback.h" | |
6 #include "ppapi/thunk/enter.h" | 11 #include "ppapi/thunk/enter.h" |
12 #include "ppapi/thunk/ppb_instance_api.h" | |
7 #include "ppapi/thunk/ppb_widget_api.h" | 13 #include "ppapi/thunk/ppb_widget_api.h" |
8 #include "ppapi/thunk/resource_creation_api.h" | 14 #include "ppapi/thunk/resource_creation_api.h" |
15 #include "ppapi/thunk/thunk.h" | |
9 | 16 |
10 namespace ppapi { | 17 namespace ppapi { |
11 namespace thunk { | 18 namespace thunk { |
12 | 19 |
13 namespace { | 20 namespace { |
14 | 21 |
15 PP_Bool IsWidget(PP_Resource resource) { | 22 PP_Bool IsWidget(PP_Resource resource) { |
16 EnterResource<PPB_Widget_API> enter(resource, false); | 23 EnterResource<PPB_Widget_API> enter(resource, false); |
17 return PP_FromBool(enter.succeeded()); | 24 return PP_FromBool(enter.succeeded()); |
18 } | 25 } |
19 | 26 |
20 PP_Bool Paint(PP_Resource widget, const PP_Rect* rect, PP_Resource image_id) { | 27 PP_Bool Paint(PP_Resource widget, |
28 const struct PP_Rect* rect, | |
dmichael (off chromium)
2012/11/16 18:24:44
since this is C++, the struct is superfluous. If t
teravest
2012/11/16 18:52:36
This is easiest because it's what IDL gives me for
| |
29 PP_Resource image) { | |
21 EnterResource<PPB_Widget_API> enter(widget, false); | 30 EnterResource<PPB_Widget_API> enter(widget, false); |
22 if (enter.failed()) | 31 if (enter.failed()) |
23 return PP_FALSE; | 32 return PP_FALSE; |
24 return enter.object()->Paint(rect, image_id); | 33 return enter.object()->Paint(rect, image); |
25 } | 34 } |
26 | 35 |
27 PP_Bool HandleEvent(PP_Resource widget, PP_Resource pp_input_event) { | 36 PP_Bool HandleEvent(PP_Resource widget, PP_Resource input_event) { |
28 EnterResource<PPB_Widget_API> enter(widget, false); | 37 EnterResource<PPB_Widget_API> enter(widget, false); |
29 if (enter.failed()) | 38 if (enter.failed()) |
30 return PP_FALSE; | 39 return PP_FALSE; |
31 return enter.object()->HandleEvent(pp_input_event); | 40 return enter.object()->HandleEvent(input_event); |
32 } | 41 } |
33 | 42 |
34 PP_Bool GetLocation(PP_Resource widget, PP_Rect* location) { | 43 PP_Bool GetLocation(PP_Resource widget, struct PP_Rect* location) { |
35 EnterResource<PPB_Widget_API> enter(widget, false); | 44 EnterResource<PPB_Widget_API> enter(widget, false); |
36 if (enter.failed()) | 45 if (enter.failed()) |
37 return PP_FALSE; | 46 return PP_FALSE; |
38 return enter.object()->GetLocation(location); | 47 return enter.object()->GetLocation(location); |
39 } | 48 } |
40 | 49 |
41 void SetLocation(PP_Resource widget, const PP_Rect* location) { | 50 void SetLocation(PP_Resource widget, const struct PP_Rect* location) { |
42 EnterResource<PPB_Widget_API> enter(widget, false); | 51 EnterResource<PPB_Widget_API> enter(widget, false); |
43 if (enter.succeeded()) | 52 if (enter.succeeded()) |
44 enter.object()->SetLocation(location); | 53 enter.object()->SetLocation(location); |
45 } | 54 } |
46 | 55 |
47 void SetScale(PP_Resource widget, float scale) { | 56 void SetScale(PP_Resource widget, float scale) { |
48 EnterResource<PPB_Widget_API> enter(widget, false); | 57 EnterResource<PPB_Widget_API> enter(widget, false); |
49 if (enter.succeeded()) | 58 if (enter.succeeded()) |
50 enter.object()->SetScale(scale); | 59 enter.object()->SetScale(scale); |
51 } | 60 } |
52 | 61 |
53 const PPB_Widget_Dev_0_3 g_ppb_widget_thunk_0_3 = { | 62 const PPB_Widget_Dev_0_3 g_ppb_widget_dev_thunk_0_3 = { |
54 &IsWidget, | 63 &IsWidget, |
55 &Paint, | 64 &Paint, |
56 &HandleEvent, | 65 &HandleEvent, |
57 &GetLocation, | 66 &GetLocation, |
58 &SetLocation, | 67 &SetLocation, |
59 }; | 68 }; |
60 | 69 |
61 const PPB_Widget_Dev_0_4 g_ppb_widget_thunk_0_4 = { | 70 const PPB_Widget_Dev_0_4 g_ppb_widget_dev_thunk_0_4 = { |
62 &IsWidget, | 71 &IsWidget, |
63 &Paint, | 72 &Paint, |
64 &HandleEvent, | 73 &HandleEvent, |
65 &GetLocation, | 74 &GetLocation, |
66 &SetLocation, | 75 &SetLocation, |
67 &SetScale | 76 &SetScale, |
68 }; | 77 }; |
69 | 78 |
70 } // namespace | 79 } // namespace |
71 | 80 |
72 const PPB_Widget_Dev_0_3* GetPPB_Widget_Dev_0_3_Thunk() { | 81 const PPB_Widget_Dev_0_3* GetPPB_Widget_Dev_0_3_Thunk() { |
73 return &g_ppb_widget_thunk_0_3; | 82 return &g_ppb_widget_dev_thunk_0_3; |
74 } | 83 } |
75 | 84 |
76 const PPB_Widget_Dev_0_4* GetPPB_Widget_Dev_0_4_Thunk() { | 85 const PPB_Widget_Dev_0_4* GetPPB_Widget_Dev_0_4_Thunk() { |
77 return &g_ppb_widget_thunk_0_4; | 86 return &g_ppb_widget_dev_thunk_0_4; |
78 } | 87 } |
79 | 88 |
80 } // namespace thunk | 89 } // namespace thunk |
81 } // namespace ppapi | 90 } // namespace ppapi |
OLD | NEW |