diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-05 15:41:52 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-05 15:41:52 +0000 |
commit | 25651387cceb1a50869c8c2d1f93d4227e5a6352 (patch) | |
tree | 86d3ecef68f8548cde47a978ecafa1de0ae4e039 /ppapi/examples | |
parent | 4b649887e1241a43c0d2a1cd81a8867d1be46b49 (diff) | |
download | chromium_src-25651387cceb1a50869c8c2d1f93d4227e5a6352.zip chromium_src-25651387cceb1a50869c8c2d1f93d4227e5a6352.tar.gz chromium_src-25651387cceb1a50869c8c2d1f93d4227e5a6352.tar.bz2 |
Update PPAPI IDL generator to define versioned structs, and unversioned typedef.
For interface Foo with versions A and B, structs will be defined for Foo_A and Foo_B, and a typedef generated from Foo_B to Foo. Versioning of IDL structs remains unchanged.
(Follow-up to discussion on CL 8931019)
*** This change breaks compatibility with C code that makes use of unversioned-named interface structs. :( ***
We need to define a versioned-named struct for each interface's current version. We could:
1. Carry on defining the current struct unversioned and typedef a versioned name for it.
The versioned type for the interface would be a typedef for the latest version and a struct for later versions, causing calling C code that uses it to break when a new version is added.
2. Define structs for all versions, and a separate unversioned struct.
This would lose type equivalence between the versioned and unversioned copies of the latest interface specification, and lead to needless duplication, especially for one-version interfaces.
3. Do this CL. We break some C code once, by change the unversioned type from struct to typedef, but we avoid these headaches in future. C++ code shouldn't be affected.
*** Contents of this CL, including notes on to-dos:
This change requires updating thunk-getters to be defined using versioned names, so that the interface structs can be forward declared; the thunk-getters now have versioned names and return values.
Changing the thunk-getter naming requires updating unit-tests to call the versioned names. It also requires some interface headers not generated from IDL to be manually updated to the new scheme (PPB_CharSet_Dev, PPB_Crypto_Dev, PPB_DirectoryReader_Dev, PPB_LayerCompositor_Dev, PPB_Graphics3D, PPB_Flash_Menu, PPB_Instance_Private, PPP_Pdf, PPB_Flash_NetConnector, PPB_GLESChromiumTextureMapping_Dev and PPB_Graphics3D_Trusted).
The proxy GetInfo() calls are updated to use versioned interface macros and thunks. Similarly, most PPBs added in interface_list.cc are now added using versioned interface macros and thunk getters. Ditto PluginModule, and some of PluginInstance. Some implementations (e.g. PPB_CharSet_Dev) needed updating to use versioned thunk getters to fetch interfaces to use.
The VideoDecoder interface size checks are for 32-bit are updated not to expect structs.
It was necessary to replace forward declarations of interface structs with includes, and remove "struct" prefixes where unversioned names were used. In most cases the affected code should really be updated to cope with versions.
PPP_Pdf has become PPP_Pdf_1. Other versionless structs that should be updated for consistenct include PPB_UMA_Private, PPB_GPU_Blacklist_Private, PPB_Proxy_Private, PPP_PDF, PPB_OpenGLES2, PPB_Flash_File_FileRef and PPB_Flash_File_ModuleLocal. Also PPP_Class_Deprecated, PPP_CursorControl_Dev, PPP_Find_Dev, PPP_NetworkState_Dev, PPP_Scrollbar_Dev, PPP_Selection_Dev, PPP_VideoCapture_Dev, PPP_Graphics3D and PPP_Instance_Private.
The Graphics2D and GLES2 examples now use unversioned interface type names without "struct" prefix. It's not clear whether examples should use versioned names, to show best practice, or unversioned.
The typedef hack in PPP_Instance IDL is gone. Yay.
BUG=107398,108379
TEST=All Pepper and NaCl tests should continue to pass on Chromium bots. NaCl SDK examples build correctly.
Review URL: http://codereview.chromium.org/8989006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples')
-rw-r--r-- | ppapi/examples/2d/graphics_2d_example.c | 25 | ||||
-rw-r--r-- | ppapi/examples/gles2/gles2.cc | 14 |
2 files changed, 19 insertions, 20 deletions
diff --git a/ppapi/examples/2d/graphics_2d_example.c b/ppapi/examples/2d/graphics_2d_example.c index 6a3b12d..20b1631 100644 --- a/ppapi/examples/2d/graphics_2d_example.c +++ b/ppapi/examples/2d/graphics_2d_example.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium Authors. All rights reserved. +/* Copyright (c) 2012 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. */ @@ -22,11 +22,11 @@ PPB_GetInterface g_get_browser_interface = NULL; -const struct PPB_Core* g_core_interface; -const struct PPB_Graphics2D* g_graphics_2d_interface; -const struct PPB_ImageData* g_image_data_interface; -const struct PPB_Instance* g_instance_interface; -const struct PPB_View* g_view_interface; +const PPB_Core* g_core_interface; +const PPB_Graphics2D* g_graphics_2d_interface; +const PPB_ImageData* g_image_data_interface; +const PPB_Instance* g_instance_interface; +const PPB_View* g_view_interface; /* PPP_Instance implementation -----------------------------------------------*/ @@ -167,7 +167,7 @@ PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, return PP_FALSE; } -static struct PPP_Instance instance_interface = { +static PPP_Instance instance_interface = { &Instance_DidCreate, &Instance_DidDestroy, &Instance_DidChangeView, @@ -182,15 +182,15 @@ PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, PPB_GetInterface get_browser_interface) { g_get_browser_interface = get_browser_interface; - g_core_interface = (const struct PPB_Core*) + g_core_interface = (const PPB_Core*) get_browser_interface(PPB_CORE_INTERFACE); - g_instance_interface = (const struct PPB_Instance*) + g_instance_interface = (const PPB_Instance*) get_browser_interface(PPB_INSTANCE_INTERFACE); - g_image_data_interface = (const struct PPB_ImageData*) + g_image_data_interface = (const PPB_ImageData*) get_browser_interface(PPB_IMAGEDATA_INTERFACE); - g_graphics_2d_interface = (const struct PPB_Graphics2D*) + g_graphics_2d_interface = (const PPB_Graphics2D*) get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); - g_view_interface = (const struct PPB_View*) + g_view_interface = (const PPB_View*) get_browser_interface(PPB_VIEW_INTERFACE); if (!g_core_interface || !g_instance_interface || !g_image_data_interface || !g_graphics_2d_interface || !g_view_interface) @@ -207,4 +207,3 @@ PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { return &instance_interface; return NULL; } - diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc index 220a6f4..4a1cda1 100644 --- a/ppapi/examples/gles2/gles2.cc +++ b/ppapi/examples/gles2/gles2.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -155,9 +155,9 @@ class GLES2DemoInstance : public pp::Instance, pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_; // Unowned pointers. - const struct PPB_Console_Dev* console_if_; - const struct PPB_Core* core_if_; - const struct PPB_OpenGLES2* gles2_if_; + const PPB_Console_Dev* console_if_; + const PPB_Core* core_if_; + const PPB_OpenGLES2* gles2_if_; // Owned data. pp::Graphics3D* context_; @@ -197,11 +197,11 @@ GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) swap_ticks_(0), callback_factory_(this), context_(NULL) { - assert((console_if_ = static_cast<const struct PPB_Console_Dev*>( + assert((console_if_ = static_cast<const PPB_Console_Dev*>( module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); - assert((core_if_ = static_cast<const struct PPB_Core*>( + assert((core_if_ = static_cast<const PPB_Core*>( module->GetBrowserInterface(PPB_CORE_INTERFACE)))); - assert((gles2_if_ = static_cast<const struct PPB_OpenGLES2*>( + assert((gles2_if_ = static_cast<const PPB_OpenGLES2*>( module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)))); } |