diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
| -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 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 | ||
| 60 | def 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 | |||
| 59 | def supports(fn, d): | 73 | def 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: |
