diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-01 05:51:27 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-01 05:51:27 +0000 |
commit | 4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5 (patch) | |
tree | 4b27e9a2b6f932059c57c20aed2f4841f5a15d0a /ppapi/shared_impl | |
parent | 2f89b6045896d8e8efc3984da72c3bf4c63d6e0f (diff) | |
download | chromium_src-4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5.zip chromium_src-4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5.tar.gz chromium_src-4697f72f5bdb2ead8aa9051b47fb0fade5acd1f5.tar.bz2 |
Revert 87415 - Convert more interfaces to the new thunk system. This goes up to and including
the ones starting with "F".
Since this adds a lot more interfaces, I added the macro stuff we used for the
old system to generate the various template specializations. This involded a
lot of renaming since the As* needs to match the name (I was previously leaving
off the "PPB_" part). I did other misc cleanup to the infrastructure.
Review URL: http://codereview.chromium.org/7082036
TBR=brettw@chromium.org
Review URL: http://codereview.chromium.org/7006022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl')
-rw-r--r-- | ppapi/shared_impl/audio_impl.cc | 2 | ||||
-rw-r--r-- | ppapi/shared_impl/audio_impl.h | 2 | ||||
-rw-r--r-- | ppapi/shared_impl/function_group_base.cc | 17 | ||||
-rw-r--r-- | ppapi/shared_impl/function_group_base.h | 68 | ||||
-rw-r--r-- | ppapi/shared_impl/resource_object_base.cc | 18 | ||||
-rw-r--r-- | ppapi/shared_impl/resource_object_base.h | 94 | ||||
-rw-r--r-- | ppapi/shared_impl/tracker_base.h | 4 |
7 files changed, 89 insertions, 116 deletions
diff --git a/ppapi/shared_impl/audio_impl.cc b/ppapi/shared_impl/audio_impl.cc index 09d4589..0173d6e 100644 --- a/ppapi/shared_impl/audio_impl.cc +++ b/ppapi/shared_impl/audio_impl.cc @@ -25,7 +25,7 @@ AudioImpl::~AudioImpl() { } } -::ppapi::thunk::PPB_Audio_API* AudioImpl::AsPPB_Audio_API() { +::ppapi::thunk::PPB_Audio_API* AudioImpl::AsAudio_API() { return this; } diff --git a/ppapi/shared_impl/audio_impl.h b/ppapi/shared_impl/audio_impl.h index 4916cd6..ba7c780 100644 --- a/ppapi/shared_impl/audio_impl.h +++ b/ppapi/shared_impl/audio_impl.h @@ -26,7 +26,7 @@ class AudioImpl : public ResourceObjectBase, virtual ~AudioImpl(); // ResourceObjectBase implementation. - virtual ::ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API() OVERRIDE; + virtual ::ppapi::thunk::PPB_Audio_API* AsAudio_API() OVERRIDE; bool playing() const { return playing_; } diff --git a/ppapi/shared_impl/function_group_base.cc b/ppapi/shared_impl/function_group_base.cc deleted file mode 100644 index 8fb7ad5..0000000 --- a/ppapi/shared_impl/function_group_base.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/shared_impl/function_group_base.h" - -namespace ppapi { - -FunctionGroupBase::~FunctionGroupBase() { -} - -#define DEFINE_TYPE_GETTER(FUNCTIONS) \ - thunk::FUNCTIONS* FunctionGroupBase::As##FUNCTIONS() { return NULL; } -FOR_ALL_PPAPI_FUNCTION_APIS(DEFINE_TYPE_GETTER) -#undef DEFINE_TYPE_GETTER - -} // namespace ppapi diff --git a/ppapi/shared_impl/function_group_base.h b/ppapi/shared_impl/function_group_base.h index 6f828ae..4f98396 100644 --- a/ppapi/shared_impl/function_group_base.h +++ b/ppapi/shared_impl/function_group_base.h @@ -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 - - // Template-based dynamic casting. See specializations below. + // 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 <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 diff --git a/ppapi/shared_impl/resource_object_base.cc b/ppapi/shared_impl/resource_object_base.cc deleted file mode 100644 index 4c0a9af..0000000 --- a/ppapi/shared_impl/resource_object_base.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/shared_impl/resource_object_base.h" - -namespace ppapi { - -ResourceObjectBase::~ResourceObjectBase() { -} - -#define DEFINE_TYPE_GETTER(RESOURCE) \ - thunk::RESOURCE* ResourceObjectBase::As##RESOURCE() { return NULL; } -FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) -#undef DEFINE_TYPE_GETTER - -} // namespace ppapi - diff --git a/ppapi/shared_impl/resource_object_base.h b/ppapi/shared_impl/resource_object_base.h index 00ac498..c8d88c1 100644 --- a/ppapi/shared_impl/resource_object_base.h +++ b/ppapi/shared_impl/resource_object_base.h @@ -5,58 +5,66 @@ #ifndef PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ #define PPAPI_SHARED_IMPL_RESOURCE_OBJECT_BASE_H_ -#include <stddef.h> // For NULL. - -#define FOR_ALL_PPAPI_RESOURCE_APIS(F) \ - F(PPB_Audio_API) \ - F(PPB_AudioConfig_API) \ - F(PPB_AudioTrusted_API) \ - F(PPB_Broker_API) \ - F(PPB_Buffer_API) \ - F(PPB_DirectoryReader_API) \ - F(PPB_FileChooser_API) \ - F(PPB_FileIO_API) \ - F(PPB_FileRef_API) \ - F(PPB_FileSystem_API) \ - F(PPB_Find_API) \ - F(PPB_Font_API) \ - F(PPB_Graphics2D_API) \ - F(PPB_ImageData_API) - namespace ppapi { -// Forward declare all the resource APIs. namespace thunk { -#define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; -FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS) -#undef DECLARE_RESOURCE_CLASS -} // namespace thunk +class PPB_Audio_API; +class PPB_AudioConfig_API; +class PPB_AudioTrusted_API; +class PPB_Broker_API; +class PPB_Buffer_API; +class PPB_Font_API; +class PPB_Graphics2D_API; +class PPB_ImageData_API; +} class ResourceObjectBase { public: - virtual ~ResourceObjectBase(); - - // 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(RESOURCE) \ - virtual thunk::RESOURCE* As##RESOURCE(); - FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) - #undef DEFINE_TYPE_GETTER - - // Template-based dynamic casting. See specializations below. + + virtual thunk::PPB_Audio_API* AsAudio_API() { return NULL; } + virtual thunk::PPB_AudioConfig_API* AsAudioConfig_API() { return NULL; } + virtual thunk::PPB_AudioTrusted_API* AsAudioTrusted_API() { return NULL; } + virtual thunk::PPB_Buffer_API* AsBuffer_API() { return NULL; } + virtual thunk::PPB_Broker_API* AsBroker_API() { return NULL; } + virtual thunk::PPB_Font_API* AsFont_API() { return NULL; } + virtual thunk::PPB_Graphics2D_API* AsGraphics2D_API() { return NULL; } + virtual thunk::PPB_ImageData_API* AsImageData_API() { return NULL; } + 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_RESOURCE_CAST(RESOURCE) \ - template<> inline thunk::RESOURCE* ResourceObjectBase::GetAs() { \ - return As##RESOURCE(); \ - } -FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) -#undef DEFINE_RESOURCE_CAST +template<> +inline thunk::PPB_Audio_API* ResourceObjectBase::GetAs() { + return AsAudio_API(); +} +template<> +inline thunk::PPB_AudioConfig_API* ResourceObjectBase::GetAs() { + return AsAudioConfig_API(); +} +template<> +inline thunk::PPB_AudioTrusted_API* ResourceObjectBase::GetAs() { + return AsAudioTrusted_API(); +} +template<> +inline thunk::PPB_Broker_API* ResourceObjectBase::GetAs() { + return AsBroker_API(); +} +template<> +inline thunk::PPB_Buffer_API* ResourceObjectBase::GetAs() { + return AsBuffer_API(); +} +template<> +inline thunk::PPB_Font_API* ResourceObjectBase::GetAs() { + return AsFont_API(); +} +template<> +inline thunk::PPB_Graphics2D_API* ResourceObjectBase::GetAs() { + return AsGraphics2D_API(); +} +template<> +inline thunk::PPB_ImageData_API* ResourceObjectBase::GetAs() { + return AsImageData_API(); +} } // namespace ppapi diff --git a/ppapi/shared_impl/tracker_base.h b/ppapi/shared_impl/tracker_base.h index 28cd442..4b7e447 100644 --- a/ppapi/shared_impl/tracker_base.h +++ b/ppapi/shared_impl/tracker_base.h @@ -40,10 +40,6 @@ class TrackerBase { // there isn't one. virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, pp::proxy::InterfaceID id) = 0; - - // Returns the instance corresponding to the given resource, or 0 if the - // resource is invalid. - virtual PP_Instance GetInstanceForResource(PP_Resource resource) = 0; }; } // namespace ppapi |