Synopsis - Cross-Reference
File: Synopsis/Processors/ModuleSorter.py1# 2# Copyright (C) 2006 Stefan Seefeld 3# All rights reserved. 4# Licensed to the public under the terms of the GNU LGPL (>= 2), 5# see the file COPYING for details. 6# 7 8from Synopsis.Processor import Processor, Parameter 9from Synopsis import ASG 10 11class ModuleSorter(Processor, ASG.Visitor): 12 """A processor that sorts declarations in a module alphabetically.""" 13 14 def process(self, ir, **kwds): 15 16 self.set_parameters(kwds) 17 self.ir = self.merge_input(ir) 18 19 self.__scopestack = [] 20 self.__currscope = [] 21 22 for decl in self.ir.asg.declarations: 23 decl.accept(self) 24 25 return self.output_and_return_ir() 26 27 28 def visit_meta_module(self, module): 29 """Visits all children of the module, and if there are no declarations 30 after that removes the module""" 31 32 def compare(a, b): return cmp(a.name, b.name) 33 module.declarations.sort(compare) 34
Generated on Tue May 13 02:39:45 2008 by
synopsis (version 0.10)
synopsis (version 0.10)