summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-01-05 23:31:51 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-01-05 23:37:28 +0100
commitcb5214f2e9b2caf1c3cc998fc29a95429812f947 (patch)
tree3caeda75b7f9d6faced8875794beffef198ba6d8
parentd331e92f806eb0e3f4a86523a847bfac5501084f (diff)
Iterate over defined_syms in write_autoconf()
Simpler. I realized there's actually no need to follow the node pointers, since menus and comments never generate output.
-rw-r--r--kconfiglib.py48
1 files changed, 13 insertions, 35 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index afc57cb..413738f 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -853,60 +853,38 @@ class Kconfig(object):
for sym in self.defined_syms:
sym._written = False
- node = self.top_node.list
- if not node:
- # Empty configuration
- return
-
- while 1:
- item = node.item
- if isinstance(item, Symbol) and not item._written:
+ for sym in self.defined_syms:
+ if not sym._written:
# Note: _write_to_conf is determined when the value is
# calculated. This is a hidden function call due to
# property magic.
- val = item.str_value
- if item._write_to_conf:
- if item.orig_type in (BOOL, TRISTATE):
+ val = sym.str_value
+ if sym._write_to_conf:
+ if sym.orig_type in (BOOL, TRISTATE):
if val != "n":
write("#define {}{}{} 1\n"
- .format(self.config_prefix, item.name,
+ .format(self.config_prefix, sym.name,
"_MODULE" if val == "m" else ""))
- elif item.orig_type == STRING:
+ elif sym.orig_type == STRING:
write('#define {}{} "{}"\n'
- .format(self.config_prefix, item.name,
+ .format(self.config_prefix, sym.name,
escape(val)))
- elif item.orig_type in (INT, HEX):
- if item.orig_type == HEX and \
+ elif sym.orig_type in (INT, HEX):
+ if sym.orig_type == HEX and \
not val.startswith(("0x", "0X")):
val = "0x" + val
write("#define {}{} {}\n"
- .format(self.config_prefix, item.name,
- val))
+ .format(self.config_prefix, sym.name, val))
else:
_internal_error("Internal error while creating C "
'header: unknown type "{}".'
- .format(item.orig_type))
-
- item._written = True
+ .format(sym.orig_type))
- # Iterative tree walk using parent pointers
-
- if node.list:
- node = node.list
- elif node.next:
- node = node.next
- else:
- while node.parent:
- node = node.parent
- if node.next:
- node = node.next
- break
- else:
- return
+ sym._written = True
def write_config(self, filename,
header="# Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)\n"):