Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ppapi/generators/test_thunk/simple_thunk.cc

Issue 11417010: Add support for generating thunk source from IDL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed dmichael's comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // From ../test_thunk/simple.idl modified Fri Nov 16 11:26:06 2012.
6
7 #include "ppapi/c/../test_thunk/simple.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppb_instance_api.h"
12 #include "ppapi/thunk/resource_creation_api.h"
13 #include "ppapi/thunk/simple_api.h"
14 #include "ppapi/thunk/thunk.h"
15
16 namespace ppapi {
17 namespace thunk {
18
19 namespace {
20
21 PP_Resource Create(PP_Instance instance) {
22 EnterResourceCreation enter(instance);
23 if (enter.failed())
24 return 0;
25 return enter.functions()->CreateSimple(instance);
26 }
27
28 PP_Bool IsSimple(PP_Resource resource) {
29 EnterResource<PPB_Simple_API> enter(resource, false);
30 return PP_FromBool(enter.succeeded());
31 }
32
33 void PostMessage(PP_Instance instance, PP_Var message) {
34 EnterInstance enter(instance);
35 if (enter.succeeded())
36 enter.functions()->PostMessage(instance, message);
37 }
38
39 uint32_t DoUint32Instance(PP_Instance instance) {
40 EnterInstance enter(instance);
41 if (enter.failed())
42 return 0;
43 return enter.functions()->DoUint32Instance(instance);
44 }
45
46 uint32_t DoUint32Resource(PP_Resource instance) {
47 EnterResource<PPB_Simple_API> enter(instance, true);
48 if (enter.failed())
49 return 0;
50 return enter.object()->DoUint32Resource();
51 }
52
53 uint32_t DoUint32ResourceNoErrors(PP_Resource instance) {
54 EnterResource<PPB_Simple_API> enter(instance, false);
55 if (enter.failed())
56 return 0;
57 return enter.object()->DoUint32ResourceNoErrors();
58 }
59
60 int32_t OnFailure12(PP_Instance instance) {
61 EnterInstance enter(instance);
62 if (enter.failed())
63 return 12;
64 return enter.functions()->OnFailure12(instance);
65 }
66
67 const PPB_Simple_0_5 g_ppb_simple_thunk_0_5 = {
68 &Create,
69 &IsSimple,
70 &PostMessage,
71 &DoUint32Instance,
72 &DoUint32Resource,
73 &DoUint32ResourceNoErrors,
74 };
75
76 const PPB_Simple_1_0 g_ppb_simple_thunk_1_0 = {
77 &Create,
78 &IsSimple,
79 &DoUint32Instance,
80 &DoUint32Resource,
81 &DoUint32ResourceNoErrors,
82 &OnFailure12,
83 };
84
85 } // namespace
86
87 const PPB_Simple_0_5* GetPPB_Simple_0_5_Thunk() {
88 return &g_ppb_simple_thunk_0_5;
89 }
90
91 const PPB_Simple_1_0* GetPPB_Simple_1_0_Thunk() {
92 return &g_ppb_simple_thunk_1_0;
93 }
94
95 } // namespace thunk
96 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698