Commit 6b963515 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Minor polish.

In other news: I've gotten much better at writing python.
parent 66860cd0
...@@ -842,7 +842,7 @@ class AliasStanza(Stanza): ...@@ -842,7 +842,7 @@ class AliasStanza(Stanza):
def find_symbol(self, tbl, name): def find_symbol(self, tbl, name):
for sym in tbl: for sym in tbl:
if sym.proto is None: if sym.proto is None:
continue; continue
if sym.proto.name == name: if sym.proto.name == name:
return sym return sym
err("Symbol '%s' not found\n" % name, warn=False) err("Symbol '%s' not found\n" % name, warn=False)
...@@ -1049,7 +1049,7 @@ class vcc(object): ...@@ -1049,7 +1049,7 @@ class vcc(object):
fo.write("#endif\n") fo.write("#endif\n")
fo.write("\n") fo.write("\n")
self.mkdefs(fo); self.mkdefs(fo)
for j in sorted(self.enums): for j in sorted(self.enums):
fo.write("extern VCL_ENUM VENUM(%s);\n" % j) fo.write("extern VCL_ENUM VENUM(%s);\n" % j)
...@@ -1084,22 +1084,31 @@ class vcc(object): ...@@ -1084,22 +1084,31 @@ class vcc(object):
fmt_cstruct(fo, '.enum_%s =' % j, '&VENUM(%s),' % j) fmt_cstruct(fo, '.enum_%s =' % j, '&VENUM(%s),' % j)
fo.write("};\n") fo.write("};\n")
def json(self, fo): def vmod_proto(self, fo, fnx):
fo.write("\nstatic const char Vmod_Proto[] =\n")
for i in open(fnx):
fo.write('\t"%s\\n"\n' % i.rstrip())
fo.write('\t"static struct %s %s;";\n' % (self.csn, self.csn))
def iter_json(self):
jl = [["$VMOD", "1.0"]] jl = [["$VMOD", "1.0"]]
for j in self.contents: for j in self.contents:
j.json(jl) j.json(jl)
for i in json.dumps(jl, indent=2, separators=(",", ": ")).splitlines():
yield i + " "
def json(self, fo):
fo.write("\nstatic const char Vmod_Json[] = {\n") fo.write("\nstatic const char Vmod_Json[] = {\n")
t = '\t"'
for i in json.dumps(jl, indent=2, separators=(",", ": ")): for i in self.iter_json(fnx):
if i == '\n': fo.write('\t"')
fo.write(t + ' "\n') for j in i:
t = '\t"' if j in '"\\':
else: fo.write('\\')
if i in '"\\': fo.write(j)
t += '\\' fo.write('"\n')
t += i fo.write('\t\"\\n\"\n};\n')
fo.write(t + '\\n"\n};\n')
def vmod_data(self, fo): def vmod_data(self, fo):
vmd = "Vmod_%s_Data" % self.modname vmd = "Vmod_%s_Data" % self.modname
...@@ -1133,7 +1142,7 @@ class vcc(object): ...@@ -1133,7 +1142,7 @@ class vcc(object):
write_c_file_warning(fo, self.inputfile) write_c_file_warning(fo, self.inputfile)
self.mkdefs(fx); self.mkdefs(fx)
fo.write('#include "config.h"\n') fo.write('#include "config.h"\n')
for i in ["vdef", "vrt", self.pfx, "vmod_abi"]: for i in ["vdef", "vrt", self.pfx, "vmod_abi"]:
...@@ -1167,17 +1176,14 @@ class vcc(object): ...@@ -1167,17 +1176,14 @@ class vcc(object):
fx.close() fx.close()
fo.write("\nstatic const char Vmod_Proto[] =\n") self.vmod_proto(fo, fnx)
for i in open(fnx):
fo.write('\t"%s\\n"\n' % i.rstrip())
fo.write('\t"static struct %s %s;";\n' % (self.csn, self.csn))
os.remove(fnx)
self.json(fo) self.json(fo)
self.vmod_data(fo) self.vmod_data(fo)
os.remove(fnx)
fo.close() fo.close()
####################################################################### #######################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment