Merge "Keep the kernel header scrubber's data structures in sync."
This commit is contained in:
commit
8979cfe14b
@ -7,7 +7,7 @@ from utils import *
|
|||||||
|
|
||||||
noUpdate = 1
|
noUpdate = 1
|
||||||
|
|
||||||
def cleanupFile( path, original_path):
|
def cleanupFile(path, original_path):
|
||||||
"""reads an original header and perform the cleanup operation on it
|
"""reads an original header and perform the cleanup operation on it
|
||||||
this functions returns the destination path and the clean header
|
this functions returns the destination path and the clean header
|
||||||
as a single string"""
|
as a single string"""
|
||||||
|
@ -685,9 +685,9 @@ class CppExpr:
|
|||||||
# we have the defined keyword, check the rest
|
# we have the defined keyword, check the rest
|
||||||
self.i += 1
|
self.i += 1
|
||||||
self.skip_spaces()
|
self.skip_spaces()
|
||||||
use_parens = 0
|
used_parens = 0
|
||||||
if self.i < self.n and self.tok[self.i].id == tokLPAREN:
|
if self.i < self.n and self.tok[self.i].id == tokLPAREN:
|
||||||
use_parens = 1
|
used_parens = 1
|
||||||
self.i += 1
|
self.i += 1
|
||||||
self.skip_spaces()
|
self.skip_spaces()
|
||||||
|
|
||||||
@ -699,7 +699,7 @@ class CppExpr:
|
|||||||
self.throw(CppConstantExpected,i,"### 'defined' must be followed by macro name")
|
self.throw(CppConstantExpected,i,"### 'defined' must be followed by macro name")
|
||||||
|
|
||||||
self.i += 1
|
self.i += 1
|
||||||
if use_parens:
|
if used_parens:
|
||||||
self.expectId(tokRPAREN)
|
self.expectId(tokRPAREN)
|
||||||
|
|
||||||
return ("defined", t.value)
|
return ("defined", t.value)
|
||||||
@ -1162,7 +1162,7 @@ class Block:
|
|||||||
return self.directive in ["if","ifdef","ifndef","elif"]
|
return self.directive in ["if","ifdef","ifndef","elif"]
|
||||||
|
|
||||||
def isInclude(self):
|
def isInclude(self):
|
||||||
"""checks wether this is a #include directive. if true, then returns the
|
"""checks whether this is a #include directive. if true, then returns the
|
||||||
corresponding file name (with brackets or double-qoutes). None otherwise"""
|
corresponding file name (with brackets or double-qoutes). None otherwise"""
|
||||||
if self.directive != "include":
|
if self.directive != "include":
|
||||||
return None
|
return None
|
||||||
@ -1517,15 +1517,20 @@ class BlockList:
|
|||||||
tokens = tokens[:-1] # remove trailing tokLN
|
tokens = tokens[:-1] # remove trailing tokLN
|
||||||
self.blocks = [ Block(tokens) ] + self.blocks
|
self.blocks = [ Block(tokens) ] + self.blocks
|
||||||
|
|
||||||
def replaceTokens(self,replacements=dict()):
|
def replaceTokens(self,replacements):
|
||||||
"""replace tokens according to the given dict
|
"""replace tokens according to the given dict"""
|
||||||
"""
|
|
||||||
for b in self.blocks:
|
for b in self.blocks:
|
||||||
if (not b.isDirective()) or b.isDefine():
|
made_change = False
|
||||||
|
if b.isInclude() == None:
|
||||||
for tok in b.tokens:
|
for tok in b.tokens:
|
||||||
if tok.id == tokIDENT:
|
if tok.id == tokIDENT:
|
||||||
if tok.value in replacements:
|
if tok.value in replacements:
|
||||||
tok.value = replacements[tok.value]
|
tok.value = replacements[tok.value]
|
||||||
|
made_change = True
|
||||||
|
|
||||||
|
if made_change and b.isIf():
|
||||||
|
# Keep 'expr' in sync with 'tokens'.
|
||||||
|
b.expr = CppExpr(b.tokens)
|
||||||
|
|
||||||
class BlockParser:
|
class BlockParser:
|
||||||
"""a class used to convert an input source file into a BlockList object"""
|
"""a class used to convert an input source file into a BlockList object"""
|
||||||
@ -1798,6 +1803,10 @@ def test_optimizeAll():
|
|||||||
#define X
|
#define X
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SIGRTMAX
|
||||||
|
#define SIGRTMAX 123
|
||||||
|
#endif /* SIGRTMAX */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#if 1
|
#if 1
|
||||||
#define BAD_6
|
#define BAD_6
|
||||||
@ -1817,12 +1826,17 @@ def test_optimizeAll():
|
|||||||
#define X
|
#define X
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SIGRTMAX
|
||||||
|
#define __SIGRTMAX 123
|
||||||
|
#endif
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
out = StringOutput()
|
out = StringOutput()
|
||||||
lines = string.split(text, '\n')
|
lines = string.split(text, '\n')
|
||||||
list = BlockParser().parse( CppLinesTokenizer(lines) )
|
list = BlockParser().parse( CppLinesTokenizer(lines) )
|
||||||
#D_setlevel(2)
|
#D_setlevel(2)
|
||||||
|
list.replaceTokens( kernel_token_replacements )
|
||||||
list.optimizeAll( {"__KERNEL__":kCppUndefinedMacro} )
|
list.optimizeAll( {"__KERNEL__":kCppUndefinedMacro} )
|
||||||
list.write(out)
|
list.write(out)
|
||||||
if out.get() != expected:
|
if out.get() != expected:
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
#define SIGUNUSED 31
|
#define SIGUNUSED 31
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
#define __SIGRTMIN 32
|
#define __SIGRTMIN 32
|
||||||
#ifndef SIGRTMAX
|
#ifndef __SIGRTMAX
|
||||||
#define __SIGRTMAX _KERNEL__NSIG
|
#define __SIGRTMAX _KERNEL__NSIG
|
||||||
#endif
|
#endif
|
||||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user