Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: ppapi/generators/idl_c_header.py

Issue 13973011: Pepper IDL: Check for structs in callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/generators/idl_c_header.py
diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py
index 2c3cf2cb3a2755a3d14e78ad4c7033449255de79..f97ebfe23adc75a171cdc6bde28156417a6b0867 100755
--- a/ppapi/generators/idl_c_header.py
+++ b/ppapi/generators/idl_c_header.py
@@ -139,11 +139,43 @@ 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.
+ """
+ typedefs = {}
+ cgen = CGen()
Mark Seaborn 2013/04/22 23:48:41 cgen seems to be unused.
+ node_whitelist = ('PPB_Flash_BrowserOperations_GetSettingsCallback',
Mark Seaborn 2013/04/22 23:48:41 Why does this interface fail the check? From c/pr
+ 'PP_Ext_Alarms_OnAlarm_Func_Dev_0_1')
noelallen1 2013/04/22 21:48:26 I think this is the current problem file for NaCl.
Mark Seaborn 2013/04/22 23:48:41 We'll have to change that interface if it's going
+ for node in filenode.GetListOf('Typedef'):
+ if node.GetName() in node_whitelist:
+ continue
+ build_list = node.GetUniqueReleases(releases)
+ callnode = node.GetOneOf('Callspec')
+ if not callnode:
+ typedefs[node.GetName()] = node.GetType(build_list[0])
+ else:
+ for param in callnode.GetListOf('Param'):
+ t = param.GetType(build_list[0])
+ if t.IsA('Struct'):
+ raise Exception('%s is a struct in callback %s. '
noelallen1 2013/04/22 21:48:26 Isn't this only an issue of the param is [in]? Sh
Mark Seaborn 2013/04/22 23:48:41 Yes, I think so, on both counts.
+ 'See http://crbug.com/233439' %
+ (t.GetName(), node.GetName()))
+ elif t.IsA('Typedef'):
+ if t.GetName() in typedefs:
+ # We can't handle typedefs that are defined in another file.
+ if typedefs[t.GetName()].IsA('Struct'):
noelallen1 2013/04/22 21:48:26 I would expect GetType of the typedef to return th
+ 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]:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698