diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-24 16:52:27 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-24 16:52:27 +0000 |
commit | 590a06e3cea751a20a2c88a9c964f7b661d54b58 (patch) | |
tree | faf381741e224f0b91ffec98b135aba252d71b8a /ppapi | |
parent | 4d4f9b2843e706c4378fb23854907156b6dfe07b (diff) | |
download | chromium_src-590a06e3cea751a20a2c88a9c964f7b661d54b58.zip chromium_src-590a06e3cea751a20a2c88a9c964f7b661d54b58.tar.gz chromium_src-590a06e3cea751a20a2c88a9c964f7b661d54b58.tar.bz2 |
Pepper IDL: Check for structs in callbacks.
It's problematic for PNaCl when callbacks take structs that are passed by
value; there's not enough type information for matching GCC's calling
conventions on the target architecture.
This change scans for typedefs that define functions, and scans the arguments
to see if any are a struct (or a typedef of a struct).
This change whitelists one existing problematic callback.
Tested:
Verified that exceptions are raised for the one type in the whitelist when
the whitelist was empty. Verified that no exceptions are raised with this
change as-is.
BUG=233439
Review URL: https://chromiumcodereview.appspot.com/13973011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rwxr-xr-x | ppapi/generators/idl_c_header.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py index 2c3cf2c..4ad27ba 100755 --- a/ppapi/generators/idl_c_header.py +++ b/ppapi/generators/idl_c_header.py @@ -139,11 +139,40 @@ def GenerateHeader(out, filenode, releases): out.Write(CommentLines(['*',' @}', '']) + '\n') +def CheckTypedefs(filenode, releases): + """Checks that typedefs don't specify callbacks that take some structs. + + See http://crbug.com/233439 for details. + """ + cgen = CGen() + # TODO(teravest): Fix the following callback to pass PP_Var by pointer + # instead of by value. + node_whitelist = ['PP_Ext_Alarms_OnAlarm_Func_Dev_0_1'] + for node in filenode.GetListOf('Typedef'): + if node.GetName() in node_whitelist: + continue + build_list = node.GetUniqueReleases(releases) + callnode = node.GetOneOf('Callspec') + if callnode: + for param in callnode.GetListOf('Param'): + if param.GetListOf('Array'): + continue + if cgen.GetParamMode(param) != 'in': + continue + t = param.GetType(build_list[0]) + while t.IsA('Typedef'): + t = t.GetType(build_list[0]) + if t.IsA('Struct'): + raise Exception('%s is a struct in callback %s. ' + 'See http://crbug.com/233439' % + (t.GetName(), node.GetName())) + class HGen(GeneratorByFile): def __init__(self): Generator.__init__(self, 'C Header', 'cgen', 'Generate the C headers.') def GenerateFile(self, filenode, releases, options): + CheckTypedefs(filenode, releases) savename = GetHeaderFromNode(filenode, GetOption('dstroot')) my_min, my_max = filenode.GetMinMax(releases) if my_min > releases[-1] or my_max < releases[0]: |