Kaydet (Commit) 2f7f8c4a authored tarafından Jack Jansen's avatar Jack Jansen

Don't be over-enthusiastic with the ascii() calls: we don't need it if

the result passes through backticks.
üst 8b777670
...@@ -317,7 +317,7 @@ def compileaete(aete, resinfo, fname): ...@@ -317,7 +317,7 @@ def compileaete(aete, resinfo, fname):
fp.write("_classdeclarations = {\n") fp.write("_classdeclarations = {\n")
for codenamemapper in allprecompinfo: for codenamemapper in allprecompinfo:
for k, v in codenamemapper.getall('class'): for k, v in codenamemapper.getall('class'):
fp.write("\t%s : %s,\n" % (`ascii(k)`, v)) fp.write("\t%s : %s,\n" % (`k`, v))
fp.write("}\n") fp.write("}\n")
if suitelist: if suitelist:
...@@ -325,7 +325,7 @@ def compileaete(aete, resinfo, fname): ...@@ -325,7 +325,7 @@ def compileaete(aete, resinfo, fname):
for code, modname in suitelist[1:]: for code, modname in suitelist[1:]:
fp.write(",\n\t\t%s_Events"%modname) fp.write(",\n\t\t%s_Events"%modname)
fp.write(",\n\t\taetools.TalkTo):\n") fp.write(",\n\t\taetools.TalkTo):\n")
fp.write("\t_signature = %s\n\n"%`ascii(creatorsignature)`) fp.write("\t_signature = %s\n\n"%`creatorsignature`)
fp.write("\t_moduleName = '%s'\n\n"%packagename) fp.write("\t_moduleName = '%s'\n\n"%packagename)
fp.close() fp.close()
...@@ -393,7 +393,7 @@ def compilesuite((suite, fss, modname), major, minor, language, script, fname, b ...@@ -393,7 +393,7 @@ def compilesuite((suite, fss, modname), major, minor, language, script, fname, b
fp.write('import aetools\n') fp.write('import aetools\n')
fp.write('import MacOS\n\n') fp.write('import MacOS\n\n')
fp.write("_code = %s\n\n"% `ascii(code)`) fp.write("_code = %s\n\n"% `code`)
if basepackage and basepackage._code_to_module.has_key(code): if basepackage and basepackage._code_to_module.has_key(code):
# We are an extension of a baseclass (usually an application extending # We are an extension of a baseclass (usually an application extending
# Standard_Suite or so). Import everything from our base module # Standard_Suite or so). Import everything from our base module
...@@ -452,7 +452,7 @@ def compileevent(fp, event, enumsneeded): ...@@ -452,7 +452,7 @@ def compileevent(fp, event, enumsneeded):
if arguments: if arguments:
fp.write("\t_argmap_%s = {\n"%funcname) fp.write("\t_argmap_%s = {\n"%funcname)
for a in arguments: for a in arguments:
fp.write("\t\t%s : %s,\n"%(`identify(a[0])`, `ascii(a[1])`)) fp.write("\t\t%s : %s,\n"%(`identify(a[0])`, `a[1]`))
fp.write("\t}\n\n") fp.write("\t}\n\n")
# #
...@@ -474,7 +474,7 @@ def compileevent(fp, event, enumsneeded): ...@@ -474,7 +474,7 @@ def compileevent(fp, event, enumsneeded):
# Generate doc string (important, since it may be the only # Generate doc string (important, since it may be the only
# available documentation, due to our name-remaping) # available documentation, due to our name-remaping)
# #
fp.write('\t\t"""%s: %s\n'%(ascii(name), ascii(desc))) fp.write('\t\t"""%s: %s\n'%(name, desc))
if has_arg: if has_arg:
fp.write("\t\tRequired argument: %s\n"%getdatadoc(accepts)) fp.write("\t\tRequired argument: %s\n"%getdatadoc(accepts))
elif opt_arg: elif opt_arg:
...@@ -489,8 +489,8 @@ def compileevent(fp, event, enumsneeded): ...@@ -489,8 +489,8 @@ def compileevent(fp, event, enumsneeded):
# #
# Fiddle the args so everything ends up in 'arguments' dictionary # Fiddle the args so everything ends up in 'arguments' dictionary
# #
fp.write("\t\t_code = %s\n"% `ascii(code)`) fp.write("\t\t_code = %s\n"% `code`)
fp.write("\t\t_subcode = %s\n\n"% `ascii(subcode)`) fp.write("\t\t_subcode = %s\n\n"% `subcode`)
# #
# Do keyword name substitution # Do keyword name substitution
# #
...@@ -518,7 +518,7 @@ def compileevent(fp, event, enumsneeded): ...@@ -518,7 +518,7 @@ def compileevent(fp, event, enumsneeded):
ename = a[2][0] ename = a[2][0]
if ename <> '****': if ename <> '****':
fp.write("\t\taetools.enumsubst(_arguments, %s, _Enum_%s)\n" % fp.write("\t\taetools.enumsubst(_arguments, %s, _Enum_%s)\n" %
(`ascii(kname)`, identify(ename))) (`kname`, identify(ename)))
enumsneeded[ename] = 1 enumsneeded[ename] = 1
fp.write("\n") fp.write("\n")
# #
...@@ -721,14 +721,14 @@ class ObjectCompiler: ...@@ -721,14 +721,14 @@ class ObjectCompiler:
if self.fp: if self.fp:
self.fp.write("class %s(aetools.NProperty):\n" % pname) self.fp.write("class %s(aetools.NProperty):\n" % pname)
self.fp.write('\t"""%s - %s """\n' % (ascii(name), ascii(what[1]))) self.fp.write('\t"""%s - %s """\n' % (ascii(name), ascii(what[1])))
self.fp.write("\twhich = %s\n" % `ascii(code)`) self.fp.write("\twhich = %s\n" % `code`)
self.fp.write("\twant = %s\n" % `ascii(what[0])`) self.fp.write("\twant = %s\n" % `what[0]`)
self.namemappers[0].addnamecode('property', pname, code) self.namemappers[0].addnamecode('property', pname, code)
def compileelement(self, elem): def compileelement(self, elem):
[code, keyform] = elem [code, keyform] = elem
if self.fp: if self.fp:
self.fp.write("# element %s as %s\n" % (`ascii(code)`, ascii(keyform))) self.fp.write("# element %s as %s\n" % (`code`, keyform))
def fillclasspropsandelems(self, cls): def fillclasspropsandelems(self, cls):
[name, code, desc, properties, elements] = cls [name, code, desc, properties, elements] = cls
...@@ -765,7 +765,7 @@ class ObjectCompiler: ...@@ -765,7 +765,7 @@ class ObjectCompiler:
name, ename, module = self.findcodename('class', ecode) name, ename, module = self.findcodename('class', ecode)
if not name: if not name:
if self.fp: if self.fp:
self.fp.write("# XXXX %s element %s not found!!\n"%(cname, `ascii(ecode)`)) self.fp.write("# XXXX %s element %s not found!!\n"%(cname, `ecode`))
else: else:
elist.append((name, ename)) elist.append((name, ename))
...@@ -800,7 +800,7 @@ class ObjectCompiler: ...@@ -800,7 +800,7 @@ class ObjectCompiler:
def compileenumerator(self, item): def compileenumerator(self, item):
[name, code, desc] = item [name, code, desc] = item
self.fp.write("\t%s : %s,\t# %s\n" % (`identify(name)`, `ascii(code)`, desc)) self.fp.write("\t%s : %s,\t# %s\n" % (`identify(name)`, `code`, desc))
def checkforenum(self, enum): def checkforenum(self, enum):
"""This enum code is used by an event. Make sure it's available""" """This enum code is used by an event. Make sure it's available"""
...@@ -819,19 +819,19 @@ class ObjectCompiler: ...@@ -819,19 +819,19 @@ class ObjectCompiler:
self.fp.write("\n#\n# Indices of types declared in this module\n#\n") self.fp.write("\n#\n# Indices of types declared in this module\n#\n")
self.fp.write("_classdeclarations = {\n") self.fp.write("_classdeclarations = {\n")
for k, v in self.namemappers[0].getall('class'): for k, v in self.namemappers[0].getall('class'):
self.fp.write("\t%s : %s,\n" % (`ascii(k)`, v)) self.fp.write("\t%s : %s,\n" % (`k`, v))
self.fp.write("}\n") self.fp.write("}\n")
self.fp.write("\n_propdeclarations = {\n") self.fp.write("\n_propdeclarations = {\n")
for k, v in self.namemappers[0].getall('property'): for k, v in self.namemappers[0].getall('property'):
self.fp.write("\t%s : %s,\n" % (`ascii(k)`, v)) self.fp.write("\t%s : %s,\n" % (`k`, v))
self.fp.write("}\n") self.fp.write("}\n")
self.fp.write("\n_compdeclarations = {\n") self.fp.write("\n_compdeclarations = {\n")
for k, v in self.namemappers[0].getall('comparison'): for k, v in self.namemappers[0].getall('comparison'):
self.fp.write("\t%s : %s,\n" % (`ascii(k)`, v)) self.fp.write("\t%s : %s,\n" % (`k`, v))
self.fp.write("}\n") self.fp.write("}\n")
self.fp.write("\n_enumdeclarations = {\n") self.fp.write("\n_enumdeclarations = {\n")
for k, v in self.namemappers[0].getall('enum'): for k, v in self.namemappers[0].getall('enum'):
self.fp.write("\t%s : %s,\n" % (`ascii(k)`, v)) self.fp.write("\t%s : %s,\n" % (`k`, v))
self.fp.write("}\n") self.fp.write("}\n")
def compiledata(data): def compiledata(data):
...@@ -855,7 +855,7 @@ def getdatadoc(data): ...@@ -855,7 +855,7 @@ def getdatadoc(data):
return 'anything' return 'anything'
if type == 'obj ': if type == 'obj ':
return 'an AE object reference' return 'an AE object reference'
return "undocumented, typecode %s"%`ascii(type)` return "undocumented, typecode %s"%`type`
dataflagdict = {15: "optional", 14: "list", 13: "enum", 12: "mutable"} dataflagdict = {15: "optional", 14: "list", 13: "enum", 12: "mutable"}
def compiledataflags(flags): def compiledataflags(flags):
...@@ -877,7 +877,7 @@ def ascii(str): ...@@ -877,7 +877,7 @@ def ascii(str):
if c in ('\t', '\n', '\r') or ' ' <= c < chr(0x7f): if c in ('\t', '\n', '\r') or ' ' <= c < chr(0x7f):
rv = rv + c rv = rv + c
else: else:
rv = rv + '\\x%02.2x' % ord(c) rv = rv + '\\' + 'x%02.2x' % ord(c)
return rv return rv
def identify(str): def identify(str):
......
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