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/generators | |
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/generators')
-rw-r--r-- | ppapi/generators/idl_c_proto.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py index 861f86f..fa34b94 100644 --- a/ppapi/generators/idl_c_proto.py +++ b/ppapi/generators/idl_c_proto.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# 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. @@ -498,9 +498,20 @@ class CGen(object): out = '' build_list = node.GetUniqueReleases(releases) - # Build the most recent one with comments - out = self.DefineStructInternals(node, build_list[-1], - include_version=False, comment=True) + if node.IsA('Interface'): + # Build the most recent one versioned, with comments + out = self.DefineStructInternals(node, build_list[-1], + include_version=True, comment=True) + + # Define an unversioned typedef for the most recent version + out += '\ntypedef struct %s %s;\n' % ( + self.GetStructName(node, build_list[-1], include_version=True), + self.GetStructName(node, build_list[-1], include_version=False)) + else: + # Build the most recent one versioned, with comments + out = self.DefineStructInternals(node, build_list[-1], + include_version=False, comment=True) + # Build the rest without comments and with the version number appended for rel in build_list[0:-1]: |