summaryrefslogtreecommitdiffstats
path: root/ppapi/generators
diff options
context:
space:
mode:
authornoelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 01:21:53 +0000
committernoelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 01:21:53 +0000
commitec5af274afdd374bf2d83f097a18df5f88d1b487 (patch)
tree656910dc88dbc3771997bd0e97149f754226f502 /ppapi/generators
parent09b36763ce6743310f55c73d18f45ebc513d75b7 (diff)
downloadchromium_src-ec5af274afdd374bf2d83f097a18df5f88d1b487.zip
chromium_src-ec5af274afdd374bf2d83f097a18df5f88d1b487.tar.gz
chromium_src-ec5af274afdd374bf2d83f097a18df5f88d1b487.tar.bz2
Update the generator
Fix output file to ignore modified datestamp and copyright year. Minor pychecker fixes (shadowed built-ins) Add 'Type' so we can define builtin types in pp_stdint.h Remove 'skip' of pp_stdint.idl so we now process it. Setup intelligent defaults for generator. BUG= http://code.google.com/p/chromium/issues/detail?id=84272 TEST= python idl_c_header.py & gcl try Generate the new headers, add them to a CL, and try TBR= sehr@google.com Review URL: http://codereview.chromium.org/7396035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generators')
-rw-r--r--ppapi/generators/idl_ast.py16
-rw-r--r--ppapi/generators/idl_c_header.py8
-rw-r--r--ppapi/generators/idl_c_proto.py35
-rw-r--r--ppapi/generators/idl_outfile.py32
-rw-r--r--ppapi/generators/idl_parser.py7
5 files changed, 67 insertions, 31 deletions
diff --git a/ppapi/generators/idl_ast.py b/ppapi/generators/idl_ast.py
index af06de3..57105b7 100644
--- a/ppapi/generators/idl_ast.py
+++ b/ppapi/generators/idl_ast.py
@@ -116,14 +116,14 @@ class IDLAst(IDLNode):
builtin = filenode
break
- if not builtin:
- builtin = IDLFile('pp_stdint.idl', [])
- extranodes = [builtin]
-
- for name in BuiltIn:
- nameattr = IDLAttribute('NAME', name)
- typenode = IDLNode('Type', 'BuiltIn', 1, 0, [nameattr])
- builtin.AddChild(typenode)
+# if not builtin:
+# builtin = IDLFile('pp_stdint.idl', [])
+# extranodes = [builtin]
+
+# for name in BuiltIn:
+# nameattr = IDLAttribute('NAME', name)
+# typenode = IDLNode('Type', 'BuiltIn', 1, 0, [nameattr])
+# builtin.AddChild(typenode)
IDLNode.__init__(self, 'AST', 'BuiltIn', 1, 0, extranodes + children)
self.SetProperty('LABEL', IDLVersionMapDefault())
diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py
index feef088..d95a7c2 100644
--- a/ppapi/generators/idl_c_header.py
+++ b/ppapi/generators/idl_c_header.py
@@ -36,7 +36,7 @@ def IDLToHeader(filenode, relpath=None, prefix=None):
def GenerateHeader(filenode, pref, inline=True):
name = filenode.GetProperty('NAME')
- if name == 'pp_stdint.idl': return
+# if name == 'pp_stdint.idl': return
# If we have an 'out' filter list, then check if we should output this file.
outlist = GetOption('out')
@@ -51,13 +51,13 @@ def GenerateHeader(filenode, pref, inline=True):
gpath = GetOption('guard')
def_guard = IDLToHeader(filenode, relpath=gpath, prefix=pref)
def_guard = def_guard.replace('/','_').replace('.','_').upper() + '_'
- copyright = filenode.GetChildren()[0]
- assert(copyright.IsA('Copyright'))
+ cright_node = filenode.GetChildren()[0]
+ assert(cright_node.IsA('Copyright'))
fileinfo = filenode.GetChildren()[1]
assert(fileinfo.IsA('Comment'))
- out.Write('%s\n' % cgen.Copyright(copyright))
+ out.Write('%s\n' % cgen.Copyright(cright_node))
out.Write('/* From %s modified %s. */\n\n'% (
filenode.GetProperty('NAME'), filenode.GetProperty('DATETIME')))
out.Write('#ifndef %s\n#define %s\n\n' % (def_guard, def_guard))
diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py
index 3809795..f92bf14 100644
--- a/ppapi/generators/idl_c_proto.py
+++ b/ppapi/generators/idl_c_proto.py
@@ -240,8 +240,8 @@ class CGen(object):
def GetTypeByMode(self, node, mode):
self.LogEnter('GetTypeByMode of %s mode=%s' % (node, mode))
name = self.GetTypeName(node)
- type, mode = self.GetRootTypeMode(node, mode)
- out = CGen.TypeMap[type][mode] % name
+ ntype, mode = self.GetRootTypeMode(node, mode)
+ out = CGen.TypeMap[ntype][mode] % name
self.LogExit('GetTypeByMode %s = %s' % (node, out))
return out
@@ -419,6 +419,9 @@ class CGen(object):
self.LogExit('Exit DefineStruct')
return out
+ def DefineType(self, node, prefix='', comment=False):
+ return ''
+
#
# Copyright and Comment
#
@@ -457,33 +460,35 @@ class CGen(object):
# try:
self.LogEnter('Define %s tab=%d prefix="%s"' % (node,tabs,prefix))
- min = node.GetProperty('version')
- max = node.GetProperty('deprecate')
+ node_nim = node.GetProperty('version')
+ node_max = node.GetProperty('deprecate')
- if min is not None:
- min = float(min)
+ if node_nim is not None:
+ node_nim = float(node_nim)
else:
- min = 0.0
+ node_nim = 0.0
- if max is not None:
- max = float(max)
+ if node_max is not None:
+ node_max = float(node_max)
else:
- max = 1.0e100
+ node_max = 1.0e100
label = node.GetLabel()
if label:
lver = label.GetVersion('M14')
# Verify that we are in a valid version.
- if max <= lver: return ''
- if min > lver: return ''
+ if node_max <= lver: return ''
+ if node_nim > lver: return ''
declmap = {
+ 'Describe' : CGen.DefineType,
'Enum' : CGen.DefineEnum,
'Function' : CGen.DefineMember,
'Interface' : CGen.DefineStruct,
'Member' : CGen.DefineMember,
'Struct' : CGen.DefineStruct,
+ 'Type' : CGen.DefineType,
'Typedef' : CGen.DefineTypedef,
}
@@ -520,11 +525,11 @@ class CGen(object):
if len(line) > 80:
left = line.rfind('(') + 1
args = line[left:].split(',')
- max = 0
+ line_max = 0
for arg in args:
- if len(arg) > max: max = len(arg)
+ if len(arg) > line_max: line_max = len(arg)
- if left + max >= 80:
+ if left + line_max >= 80:
space = '%s ' % tab
args = (',\n%s' % space).join([arg.strip() for arg in args])
lines.append('%s\n%s%s' % (line[:left], space, args))
diff --git a/ppapi/generators/idl_outfile.py b/ppapi/generators/idl_outfile.py
index fd00c18..100a49e 100644
--- a/ppapi/generators/idl_outfile.py
+++ b/ppapi/generators/idl_outfile.py
@@ -14,6 +14,36 @@ from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions
from stat import *
+def IsEquivelent(intext, outtext):
+ if not intext: return False
+ inlines = intext.split('\n')
+ outlines = outtext.split('\n')
+
+ # If number of lines don't match, it's a mismatch
+ if len(inlines) != len(outlines): return False
+
+ for index in range(len(inlines)):
+ inline = inlines[index]
+ outline = outlines[index]
+
+ if inline == outline: continue
+
+ # If the line is not an exact match, check for comment deltas
+ inwords = inline.split()
+ outwords = outline.split()
+
+ if inwords[0] != outwords[0] or inwords[0] != '/*': return False
+
+ # Neither the year, nor the modified date need an exact match
+ if inwords[1] == 'Copyright':
+ if inwords[4:] == outwords[4:]: continue
+ elif inwords[1] == 'From':
+ if inwords[0:4] == outwords[0:4]:
+ continue
+ return False
+ return True
+
+
#
# IDLOutFile
#
@@ -51,7 +81,7 @@ class IDLOutFile(object):
else:
intext = None
- if intext == outtext:
+ if IsEquivelent(intext, outtext):
if GetOption('verbose'):
InfoOut.Log('Output %s unchanged.' % self.filename)
return False
diff --git a/ppapi/generators/idl_parser.py b/ppapi/generators/idl_parser.py
index a8a8ef2..77093f6 100644
--- a/ppapi/generators/idl_parser.py
+++ b/ppapi/generators/idl_parser.py
@@ -367,7 +367,7 @@ class IDLParser(IDLLexer):
#
def p_describe_block(self, p):
"""describe_block : modifiers DESCRIBE '{' describe_list '}' ';'"""
- children = ListFromConcat(p[1], p[2])
+ children = ListFromConcat(p[1], p[4])
p[0] = self.BuildProduction('Describe', p, 2, children)
if self.parse_debug: DumpReduction('describe_block', p)
@@ -378,7 +378,7 @@ class IDLParser(IDLLexer):
| modifiers TYPEDEF ';' describe_list
| """
if len(p) > 1:
- Type = self.BuildProduction('Type', p, 2, p[1])
+ Type = self.BuildNamed('Type', p, 2, p[1])
p[0] = ListFromConcat(Type, p[4])
def p_describe_error(self, p):
@@ -1001,7 +1001,8 @@ def ParseFiles(filenames):
srcroot = GetOption('srcroot')
for dir in default_dirs:
srcdir = os.path.join(srcroot, dir, '*.idl')
- filenames += sorted(glob.glob(gendir))
+ srcdir = os.path.normpath(srcdir)
+ filenames += sorted(glob.glob(srcdir))
for filename in filenames:
filenode = parser.ParseFile(filename)