summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorHolger Freyther <ich@tamarin.(none)>2009-05-17 12:32:36 +0200
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-10 16:31:48 +0000
commit169e719456e2ab461814e1620e949ef9f6d69e92 (patch)
tree535c250004c25761a5d0073423bcb95600e3267c /bitbake
parent913e78898e65e1d95c6313e86854cdc2ab9e35aa (diff)
downloadpoky-169e719456e2ab461814e1620e949ef9f6d69e92.tar.gz
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.py26
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 c6931650da..0ef9ef69c0 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
56 56
57__parsed_methods__ = methodpool.get_parsed_dict() 57__parsed_methods__ = methodpool.get_parsed_dict()
58 58
59# parsing routines, to be moved into AST classes
60def handleMethod(func_name, body, d):
61 if func_name == "__anonymous":
62 funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____'))))
63 if not funcname in methodpool._parsed_fns:
64 text = "def %s(d):\n" % (funcname) + '\n'.join(body)
65 methodpool.insert_method(funcname, text, fn)
66 anonfuncs = data.getVar('__BBANONFUNCS', d) or []
67 anonfuncs.append(funcname)
68 data.setVar('__BBANONFUNCS', anonfuncs, d)
69 else:
70 data.setVarFlag(func_name, "func", 1, d)
71 data.setVar(func_name, '\n'.join(body), d)
72
59def supports(fn, d): 73def supports(fn, d):
60 return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" 74 return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc"
61 75
@@ -204,17 +218,7 @@ def feeder(lineno, s, fn, root, d):
204 if __infunc__: 218 if __infunc__:
205 if s == '}': 219 if s == '}':
206 __body__.append('') 220 __body__.append('')
207 if __infunc__ == "__anonymous": 221 handleMethod(__infunc__, __body__, d)
208 funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____'))))
209 if not funcname in methodpool._parsed_fns:
210 text = "def %s(d):\n" % (funcname) + '\n'.join(__body__)
211 methodpool.insert_method(funcname, text, fn)
212 anonfuncs = data.getVar('__BBANONFUNCS', d) or []
213 anonfuncs.append(funcname)
214 data.setVar('__BBANONFUNCS', anonfuncs, d)
215 else:
216 data.setVarFlag(__infunc__, "func", 1, d)
217 data.setVar(__infunc__, '\n'.join(__body__), d)
218 __infunc__ = "" 222 __infunc__ = ""
219 __body__ = [] 223 __body__ = []
220 else: 224 else: