Template population now functional

This commit is contained in:
Hilton Bristow
2013-03-18 12:37:42 +10:00
committed by hbristow
parent 827b4f93e4
commit 66c40bee6f
29 changed files with 96 additions and 3319 deletions

View File

@@ -2,8 +2,8 @@ from string import join
from textwrap import fill
class ParseTree(object):
def __init__(self, namespaces=[]):
self.namespaces = namespaces
def __init__(self, namespaces=None):
self.namespaces = namespaces if namespaces else []
def __str__(self):
return join((ns.__str__() for ns in self.namespaces), '\n\n\n')
@@ -24,7 +24,7 @@ class ParseTree(object):
constants.append(obj)
else:
raise TypeError('Unexpected object type: '+str(type(obj)))
self.namespaces.append(Namespace(name, class_tree.values(), functions, constants))
self.namespaces.append(Namespace(name, constants, class_tree.values(), functions))
def insertIntoClassTree(self, obj, class_tree):
cname = obj.name if type(obj) is Class else obj.clss
@@ -106,8 +106,8 @@ class Namespace(object):
def __str__(self):
return 'namespace '+self.name+' {\n\n'+\
(join((f.__str__() for f in self.functions), '\n')+'\n\n' if self.functions else '')+\
(join((c.__str__() for c in self.constants), '\n')+'\n\n' if self.constants else '')+\
(join((f.__str__() for f in self.functions), '\n')+'\n\n' if self.functions else '')+\
(join((o.__str__() for o in self.classes), '\n\n') if self.classes else '')+'\n};'
class Class(object):