| Index: ppapi/shared_impl/function_group_base.h
|
| ===================================================================
|
| --- ppapi/shared_impl/function_group_base.h (revision 87436)
|
| +++ ppapi/shared_impl/function_group_base.h (working copy)
|
| @@ -5,49 +5,53 @@
|
| #ifndef PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_
|
| #define PPAPI_SHARED_IMPL_FUNCTION_GROUP_BASE_H_
|
|
|
| -#include <stddef.h> // For NULL.
|
| -
|
| -#define FOR_ALL_PPAPI_FUNCTION_APIS(F) \
|
| - F(PPB_CharSet_FunctionAPI) \
|
| - F(PPB_CursorControl_FunctionAPI) \
|
| - F(PPB_Find_FunctionAPI) \
|
| - F(PPB_Font_FunctionAPI) \
|
| - F(ResourceCreationAPI)
|
| -
|
| namespace ppapi {
|
|
|
| -// Forward declare all the function APIs.
|
| namespace thunk {
|
| -#define DECLARE_FUNCTION_CLASS(FUNCTIONS) class FUNCTIONS;
|
| -FOR_ALL_PPAPI_FUNCTION_APIS(DECLARE_FUNCTION_CLASS)
|
| -#undef DECLARE_FUNCTION_CLASS
|
| -} // namespace thunk
|
| +class PPB_CharSet_FunctionAPI;
|
| +class PPB_CursorControl_FunctionAPI;
|
| +class PPB_Font_FunctionAPI;
|
| +class ResourceCreationAPI;
|
| +}
|
|
|
| class FunctionGroupBase {
|
| public:
|
| - virtual ~FunctionGroupBase();
|
| + virtual ~FunctionGroupBase() {}
|
|
|
| // Dynamic casting for this object. Returns the pointer to the given type if
|
| - // Inheritance-based dynamic casting for this object. Returns the pointer to
|
| - // the given type if it's supported. Derived classes override the functions
|
| - // they support to return the interface.
|
| - #define DEFINE_TYPE_GETTER(FUNCTIONS) \
|
| - virtual thunk::FUNCTIONS* As##FUNCTIONS();
|
| - FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_TYPE_GETTER)
|
| - #undef DEFINE_TYPE_GETTER
|
| + // it's supported.
|
| + virtual thunk::PPB_CharSet_FunctionAPI* AsCharSet_FunctionAPI() {
|
| + return NULL;
|
| + }
|
| + virtual thunk::PPB_CursorControl_FunctionAPI* AsCursorControl_FunctionAPI() {
|
| + return NULL;
|
| + }
|
| + virtual thunk::PPB_Font_FunctionAPI* AsFont_FunctionAPI() {
|
| + return NULL;
|
| + }
|
| + virtual thunk::ResourceCreationAPI* AsResourceCreation() {
|
| + return NULL;
|
| + }
|
|
|
| - // Template-based dynamic casting. See specializations below.
|
| template <typename T> T* GetAs() { return NULL; }
|
| };
|
|
|
| -// Template-based dynamic casting. These specializations forward to the
|
| -// AsXXX virtual functions to return whether the given type is supported.
|
| -#define DEFINE_FUNCTION_CAST(FUNCTIONS) \
|
| - template<> inline thunk::FUNCTIONS* FunctionGroupBase::GetAs() { \
|
| - return As##FUNCTIONS(); \
|
| - }
|
| -FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_FUNCTION_CAST)
|
| -#undef DEFINE_FUNCTION_CAST
|
| +template<>
|
| +inline thunk::PPB_CharSet_FunctionAPI* FunctionGroupBase::GetAs() {
|
| + return AsCharSet_FunctionAPI();
|
| +}
|
| +template<>
|
| +inline thunk::PPB_CursorControl_FunctionAPI* FunctionGroupBase::GetAs() {
|
| + return AsCursorControl_FunctionAPI();
|
| +}
|
| +template<>
|
| +inline thunk::PPB_Font_FunctionAPI* FunctionGroupBase::GetAs() {
|
| + return AsFont_FunctionAPI();
|
| +}
|
| +template<>
|
| +inline ppapi::thunk::ResourceCreationAPI* FunctionGroupBase::GetAs() {
|
| + return AsResourceCreation();
|
| +}
|
|
|
| } // namespace ppapi
|
|
|
|
|