OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ | 5 #ifndef PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ |
6 #define PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ | 6 #define PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ |
7 | 7 |
8 #include <stddef.h> // For NULL. | 8 #include <stddef.h> // For NULL. |
9 | 9 |
| 10 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 11 |
10 #define FOR_ALL_PPAPI_FUNCTION_APIS(F) \ | 12 #define FOR_ALL_PPAPI_FUNCTION_APIS(F) \ |
11 F(PPB_CharSet_FunctionAPI) \ | 13 F(PPB_CharSet_FunctionAPI) \ |
12 F(PPB_CursorControl_FunctionAPI) \ | 14 F(PPB_CursorControl_FunctionAPI) \ |
13 F(PPB_Find_FunctionAPI) \ | 15 F(PPB_Find_FunctionAPI) \ |
14 F(PPB_Font_FunctionAPI) \ | 16 F(PPB_Font_FunctionAPI) \ |
15 F(PPB_Fullscreen_FunctionAPI) \ | 17 F(PPB_Fullscreen_FunctionAPI) \ |
16 F(PPB_Instance_FunctionAPI) \ | 18 F(PPB_Instance_FunctionAPI) \ |
17 F(ResourceCreationAPI) | 19 F(ResourceCreationAPI) |
18 | 20 |
19 namespace ppapi { | 21 namespace ppapi { |
20 | 22 |
21 // Forward declare all the function APIs. | 23 // Forward declare all the function APIs. |
22 namespace thunk { | 24 namespace thunk { |
23 #define DECLARE_FUNCTION_CLASS(FUNCTIONS) class FUNCTIONS; | 25 #define DECLARE_FUNCTION_CLASS(FUNCTIONS) class FUNCTIONS; |
24 FOR_ALL_PPAPI_FUNCTION_APIS(DECLARE_FUNCTION_CLASS) | 26 FOR_ALL_PPAPI_FUNCTION_APIS(DECLARE_FUNCTION_CLASS) |
25 #undef DECLARE_FUNCTION_CLASS | 27 #undef DECLARE_FUNCTION_CLASS |
26 } // namespace thunk | 28 } // namespace thunk |
27 | 29 |
28 class FunctionGroupBase { | 30 class PPAPI_SHARED_EXPORT FunctionGroupBase { |
29 public: | 31 public: |
30 virtual ~FunctionGroupBase(); | 32 virtual ~FunctionGroupBase(); |
31 | 33 |
32 // Dynamic casting for this object. Returns the pointer to the given type if | 34 // Dynamic casting for this object. Returns the pointer to the given type if |
33 // Inheritance-based dynamic casting for this object. Returns the pointer to | 35 // Inheritance-based dynamic casting for this object. Returns the pointer to |
34 // the given type if it's supported. Derived classes override the functions | 36 // the given type if it's supported. Derived classes override the functions |
35 // they support to return the interface. | 37 // they support to return the interface. |
36 #define DEFINE_TYPE_GETTER(FUNCTIONS) \ | 38 #define DEFINE_TYPE_GETTER(FUNCTIONS) \ |
37 virtual thunk::FUNCTIONS* As##FUNCTIONS(); | 39 virtual thunk::FUNCTIONS* As##FUNCTIONS(); |
38 FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_TYPE_GETTER) | 40 FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_TYPE_GETTER) |
39 #undef DEFINE_TYPE_GETTER | 41 #undef DEFINE_TYPE_GETTER |
40 | 42 |
41 // Template-based dynamic casting. See specializations below. | 43 // Template-based dynamic casting. See specializations below. |
42 template <typename T> T* GetAs() { return NULL; } | 44 template <typename T> T* GetAs() { return NULL; } |
43 }; | 45 }; |
44 | 46 |
45 // Template-based dynamic casting. These specializations forward to the | 47 // Template-based dynamic casting. These specializations forward to the |
46 // AsXXX virtual functions to return whether the given type is supported. | 48 // AsXXX virtual functions to return whether the given type is supported. |
47 #define DEFINE_FUNCTION_CAST(FUNCTIONS) \ | 49 #define DEFINE_FUNCTION_CAST(FUNCTIONS) \ |
48 template<> inline thunk::FUNCTIONS* FunctionGroupBase::GetAs() { \ | 50 template<> inline thunk::FUNCTIONS* FunctionGroupBase::GetAs() { \ |
49 return As##FUNCTIONS(); \ | 51 return As##FUNCTIONS(); \ |
50 } | 52 } |
51 FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_FUNCTION_CAST) | 53 FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_FUNCTION_CAST) |
52 #undef DEFINE_FUNCTION_CAST | 54 #undef DEFINE_FUNCTION_CAST |
53 | 55 |
54 } // namespace ppapi | 56 } // namespace ppapi |
55 | 57 |
56 #endif // PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ | 58 #endif // PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_ |
OLD | NEW |