summaryrefslogtreecommitdiff
path: root/tests/kconfigfunctions.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-09-04 20:44:24 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2019-09-04 21:14:12 +0200
commit26e1db651e18fd65fe7374b404a30e20f601969f (patch)
tree3ca8cd4fa01a2f1ab3031c226f2f40783de1e2d3 /tests/kconfigfunctions.py
parente7233c12e91626424c9cfebeb3892c298caca980 (diff)
Allow preprocessor user functions to access the parsing location
Just requires making Kconfig.filename/linenr public. 'lineno' would be a more standard name, but be consistent with MenuNode.linenr.
Diffstat (limited to 'tests/kconfigfunctions.py')
-rw-r--r--tests/kconfigfunctions.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/kconfigfunctions.py b/tests/kconfigfunctions.py
index e760468..8f35511 100644
--- a/tests/kconfigfunctions.py
+++ b/tests/kconfigfunctions.py
@@ -1,14 +1,22 @@
def add(kconf, name, *args):
return str(sum(map(int, args)))
+
def one(kconf, name, s):
return name + 2*s
+
def one_or_more(kconf, name, arg, *args):
return arg + " + " + ",".join(args)
+
+def location(kconf, name):
+ return "{}:{}".format(kconf.filename, kconf.linenr)
+
+
functions = {
"add": (add, 0, None),
"one": (one, 1, 1),
"one-or-more": (one_or_more, 1, None),
+ "location": (location, 0, 0),
}