Codegen indent fixes

This commit is contained in:
Bruno de Oliveira Abinader 2014-12-30 11:31:43 -04:00
parent c950e3d61e
commit 0721c624d9

View file

@ -103,7 +103,7 @@ class CastableObjectUnwrapper():
def __init__(self, descriptor, source, codeOnFailure): def __init__(self, descriptor, source, codeOnFailure):
self.substitution = { self.substitution = {
"source": source, "source": source,
"codeOnFailure": CGIndenter(CGGeneric(codeOnFailure), 4).define(), "codeOnFailure": CGIndenter(CGGeneric(codeOnFailure), 8).define(),
} }
def __str__(self): def __str__(self):
@ -1317,7 +1317,7 @@ class CGIndenter(CGThing):
A class that takes another CGThing and generates code that indents that A class that takes another CGThing and generates code that indents that
CGThing by some number of spaces. The default indent is two spaces. CGThing by some number of spaces. The default indent is two spaces.
""" """
def __init__(self, child, indentLevel=2): def __init__(self, child, indentLevel=4):
CGThing.__init__(self) CGThing.__init__(self)
self.child = child self.child = child
self.indent = " " * indentLevel self.indent = " " * indentLevel
@ -1778,7 +1778,7 @@ class CGAbstractMethod(CGThing):
def define(self): def define(self):
body = self.definition_body() body = self.definition_body()
if self.unsafe: if self.unsafe:
body = CGWrapper(body, pre="unsafe {\n", post="\n}") body = CGWrapper(CGIndenter(body), pre="unsafe {\n", post="\n}")
return CGWrapper(CGIndenter(body), return CGWrapper(CGIndenter(body),
pre=self.definition_prologue(), pre=self.definition_prologue(),
@ -4350,8 +4350,8 @@ class CGDictionary(CGThing):
" }\n" " }\n"
"}").substitute({ "}").substitute({
"selfName": self.makeClassName(d), "selfName": self.makeClassName(d),
"initParent": CGIndenter(CGGeneric(initParent), indentLevel=6).define(), "initParent": CGIndenter(CGGeneric(initParent), indentLevel=12).define(),
"initMembers": CGIndenter(memberInits, indentLevel=6).define(), "initMembers": CGIndenter(memberInits, indentLevel=12).define(),
}) })
@staticmethod @staticmethod