diff options
author | Holger Freyther <ich@tamarin.(none)> | 2009-05-17 12:32:36 +0200 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-02-10 16:31:48 +0000 |
commit | 169e719456e2ab461814e1620e949ef9f6d69e92 (patch) | |
tree | 535c250004c25761a5d0073423bcb95600e3267c /bitbake | |
parent | 913e78898e65e1d95c6313e86854cdc2ab9e35aa (diff) | |
download | openembedded-core-169e719456e2ab461814e1620e949ef9f6d69e92.tar.gz openembedded-core-169e719456e2ab461814e1620e949ef9f6d69e92.tar.bz2 openembedded-core-169e719456e2ab461814e1620e949ef9f6d69e92.tar.xz openembedded-core-169e719456e2ab461814e1620e949ef9f6d69e92.zip |
bitbake: [parser] Move the handling of a method to a function
We want to convert this into a proper AST. So move all
such operations to methods... Later change them to generate
a node... and create that node from here.
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index c6931650d..0ef9ef69c 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py @@ -56,6 +56,20 @@ IN_PYTHON_EOF = -9999999999999 __parsed_methods__ = methodpool.get_parsed_dict() +# parsing routines, to be moved into AST classes +def handleMethod(func_name, body, d): + if func_name == "__anonymous": + funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____')))) + if not funcname in methodpool._parsed_fns: + text = "def %s(d):\n" % (funcname) + '\n'.join(body) + methodpool.insert_method(funcname, text, fn) + anonfuncs = data.getVar('__BBANONFUNCS', d) or [] + anonfuncs.append(funcname) + data.setVar('__BBANONFUNCS', anonfuncs, d) + else: + data.setVarFlag(func_name, "func", 1, d) + data.setVar(func_name, '\n'.join(body), d) + def supports(fn, d): return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" @@ -204,17 +218,7 @@ def feeder(lineno, s, fn, root, d): if __infunc__: if s == '}': __body__.append('') - if __infunc__ == "__anonymous": - funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____')))) - if not funcname in methodpool._parsed_fns: - text = "def %s(d):\n" % (funcname) + '\n'.join(__body__) - methodpool.insert_method(funcname, text, fn) - anonfuncs = data.getVar('__BBANONFUNCS', d) or [] - anonfuncs.append(funcname) - data.setVar('__BBANONFUNCS', anonfuncs, d) - else: - data.setVarFlag(__infunc__, "func", 1, d) - data.setVar(__infunc__, '\n'.join(__body__), d) + handleMethod(__infunc__, __body__, d) __infunc__ = "" __body__ = [] else: |