OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright 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 #ifndef PPAPI_SIMPLE_PS_MAIN_H_ | 5 #ifndef PPAPI_SIMPLE_PS_MAIN_H_ |
6 #define PPAPI_SIMPLE_PS_MAIN_H_ | 6 #define PPAPI_SIMPLE_PS_MAIN_H_ |
7 | 7 |
8 #include "ppapi_simple/ps.h" | 8 #include "ppapi_simple/ps.h" |
9 #include "ppapi_simple/ps_event.h" | 9 #include "ppapi_simple/ps_event.h" |
10 | 10 |
11 EXTERN_C_BEGIN | 11 EXTERN_C_BEGIN |
12 | 12 |
13 typedef int (*PSMainFunc_t)(int argc, char *argv[]); | 13 typedef int (*PSMainFunc_t)(int argc, char *argv[]); |
14 | 14 |
15 /** | 15 /** |
16 * PSMainCreate | |
17 * | |
18 * Constructs an instance SimpleInstance and configures it to call into | |
19 * the provided "main" function. | |
20 */ | |
21 void* PSMainCreate(PP_Instance inst, PSMainFunc_t entry_point); | |
22 | |
23 /** | |
24 * PSUserMainGet | 16 * PSUserMainGet |
25 * | 17 * |
26 * Prototype for the user provided function which retrieves the user's main | 18 * Prototype for the user provided function which retrieves the user's main |
27 * function. | 19 * function. |
28 * This is normally defined using the PPAPI_SIMPLE_REGISTER_MAIN macro. | 20 * This is normally defined using the PPAPI_SIMPLE_REGISTER_MAIN macro. |
29 */ | 21 */ |
30 PSMainFunc_t PSUserMainGet(); | 22 PSMainFunc_t PSUserMainGet(); |
31 | 23 |
32 /** | 24 /** |
33 * PPAPI_SIMPLE_REGISTER_MAIN | 25 * PPAPI_SIMPLE_REGISTER_MAIN |
34 * | 26 * |
35 * Constructs a PSInstance object and configures it to use call the provided | 27 * Constructs a PSInstance object and configures it to use call the provided |
36 * 'main' function on its own thread once initialization is complete. | 28 * 'main' function on its own thread once initialization is complete. |
| 29 * |
| 30 * The ps_entrypoint_*.o and ps_main.o objects will not be linked by default, |
| 31 * so we force them to be linked here. |
37 */ | 32 */ |
38 #define PPAPI_SIMPLE_REGISTER_MAIN(main_func) \ | 33 #define PPAPI_SIMPLE_REGISTER_MAIN(main_func) \ |
39 PSMainFunc_t PSUserMainGet() { \ | 34 EXTERN_C_BEGIN \ |
40 return main_func; \ | 35 FORCE_LINK_THAT(ps_entry) \ |
41 } \ | 36 FORCE_LINK_THAT(ps_main) \ |
42 void* PSUserCreateInstance(PP_Instance inst) { \ | 37 EXTERN_C_END \ |
43 return PSMainCreate(inst, main_func); \ | 38 PSMainFunc_t PSUserMainGet() { return main_func; } |
44 } | |
45 | 39 |
46 EXTERN_C_END | 40 EXTERN_C_END |
47 | 41 |
48 #endif /* PPAPI_SIMPLE_PS_MAIN_H_ */ | 42 #endif /* PPAPI_SIMPLE_PS_MAIN_H_ */ |
OLD | NEW |