From stefan at synopsis.fresco.org Tue Dec 2 05:40:12 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper In directory frida:/tmp/cvs-serv30582/Processors/Grouper Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Grouper added to the repository From stefan at synopsis.fresco.org Tue Dec 2 05:40:12 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous In directory frida:/tmp/cvs-serv30582/Processors/Previous Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Previous added to the repository From stefan at synopsis.fresco.org Tue Dec 2 05:40:34 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper/input - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper/input In directory frida:/tmp/cvs-serv30601/Processors/Grouper/input Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Grouper/input added to the repository From stefan at synopsis.fresco.org Tue Dec 2 05:40:34 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper/expected - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper/expected In directory frida:/tmp/cvs-serv30601/Processors/Grouper/expected Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Grouper/expected added to the repository From stefan at synopsis.fresco.org Tue Dec 2 05:40:34 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous/input - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous/input In directory frida:/tmp/cvs-serv30601/Processors/Previous/input Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Previous/input added to the repository From stefan at synopsis.fresco.org Tue Dec 2 05:40:34 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous/expected - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous/expected In directory frida:/tmp/cvs-serv30601/Processors/Previous/expected Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Previous/expected added to the repository From stefan at synopsis.fresco.org Tue Dec 2 05:41:50 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper/input groups.cc,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper/input In directory frida:/tmp/cvs-serv30640/Processors/Grouper/input Added Files: groups.cc Log Message: more tests --- NEW FILE: groups.cc --- // group documentation // @group first group { // some comment // extending over multiple lines // another comment struct foo { }; int test1; int test2; // } int bar; // another group // @group tests { int test3; int test4; // } // @group outer { // @group inner { int f; // @group xxx { not a group int test5; // } and not a group end // } // and not a group either int test6; // } // } From stefan at synopsis.fresco.org Tue Dec 2 05:41:50 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous synopsis.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous In directory frida:/tmp/cvs-serv30640/Processors/Previous Added Files: synopsis.py Log Message: more tests --- NEW FILE: synopsis.py --- from Synopsis.process import process from Synopsis.Processor import Composite from Synopsis.Parsers import Cxx from Synopsis.Processors.Comments import SSComments, Previous from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), SSComments(), Previous(), Dump.Formatter(show_ids = False))) From stefan at synopsis.fresco.org Tue Dec 2 05:41:50 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous/input previous.cc,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous/input In directory frida:/tmp/cvs-serv30640/Processors/Previous/input Added Files: previous.cc Log Message: more tests --- NEW FILE: previous.cc --- struct Foo { int first; //< first comment int second; //< second comment int third; //< third comment }; enum Enum { ONE, //< ONE comment TWO, //< TWO comment THREE //< THREE comment }; From stefan at synopsis.fresco.org Tue Dec 2 05:41:50 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper synopsis.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper In directory frida:/tmp/cvs-serv30640/Processors/Grouper Added Files: synopsis.py Log Message: more tests --- NEW FILE: synopsis.py --- from Synopsis.process import process from Synopsis.Processor import Composite from Synopsis.Parsers import Cxx from Synopsis.Processors.Comments import SSComments, Grouper1 from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), SSComments(), Grouper1(), Dump.Formatter(show_ids = False))) From stefan at synopsis.fresco.org Tue Dec 2 05:42:42 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors config.py,1.1,NONE Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors In directory frida:/tmp/cvs-serv30679/Processors Removed Files: config.py Log Message: removed obsolete config --- config.py DELETED --- From stefan at synopsis.fresco.org Tue Dec 2 05:44:10 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis AST.py,1.29,1.30 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis In directory frida:/tmp/cvs-serv30701/Synopsis Modified Files: AST.py Log Message: add new Builtin type Index: AST.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/AST.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -p -d -r1.29 -r1.30 --- AST.py 11 Nov 2003 06:05:03 -0000 1.29 +++ AST.py 2 Dec 2003 05:44:07 -0000 1.30 @@ -299,6 +299,16 @@ class Declaration: """Change the accessibility""" self.__accessibility = axs +class Builtin (Declaration): + """An ast node for internal use only.""" + + def __init__(self, file, line, language, type, name): + """Constructor""" + + Declaration.__init__(self, file, line, language, type, name) + + def accept(self, visitor): visitor.visitBuiltin(self) + class Macro (Declaration): """A preprocessor macro. Note that macros are not strictly part of the AST, and as such are always in the global scope. A macro is "temporary" if @@ -669,6 +679,7 @@ class Visitor : def visitAST(self, node): for declaration in node.declarations(): declaration.accept(self) def visitDeclaration(self, node): return + def visitBuiltin(self, node): return def visitMacro(self, node): self.visitDeclaration(node) def visitForward(self, node): self.visitDeclaration(node) def visitGroup(self, node): From stefan at synopsis.fresco.org Tue Dec 2 05:45:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters Dump.py,1.7,1.8 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatters In directory frida:/tmp/cvs-serv30802/Synopsis/Formatters Modified Files: Dump.py Log Message: cleanup Index: Dump.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatters/Dump.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -p -d -r1.7 -r1.8 --- Dump.py 30 Nov 2003 01:28:57 -0000 1.7 +++ Dump.py 2 Dec 2003 05:45:03 -0000 1.8 @@ -127,6 +127,7 @@ class Formatter(Processor): self.pop() def visit_instance(self, obj): + if isinstance(obj, AST.SourceFile): # just write down the filename self.add_text(obj.filename()) return From stefan at synopsis.fresco.org Tue Dec 2 05:45:54 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:11 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parsers/Cxx/syn ast.cc,1.19,1.20 ast.hh,1.23,1.24 builder.cc,1.44,1.45 builder.hh,1.32,1.33 dumper.cc,1.23,1.24 dumper.hh,1.15,1.16 synopsis.cc,1.49,1.50 synopsis.hh,1.32,1.33 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn In directory frida:/tmp/cvs-serv30814/Synopsis/Parsers/Cxx/syn Modified Files: ast.cc ast.hh builder.cc builder.hh dumper.cc dumper.hh synopsis.cc synopsis.hh Log Message: generate Builtin 'end of scope' instead of Declaration 'dummy' Index: ast.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/ast.cc,v retrieving revision 1.19 retrieving revision 1.20 diff -u -p -d -r1.19 -r1.20 --- ast.cc 27 Jan 2003 06:53:36 -0000 1.19 +++ ast.cc 2 Dec 2003 05:45:51 -0000 1.20 @@ -22,6 +22,9 @@ // 02111-1307, USA. // $Log$ +// Revision 1.20 2003/12/02 05:45:51 stefan +// generate Builtin 'end of scope' instead of Declaration 'dummy' +// // Revision 1.19 2003/01/27 06:53:36 chalky // Added macro support for C++. // @@ -100,6 +103,23 @@ Declaration::declared() } // +// AST::Builtin +// + +Builtin::Builtin(SourceFile* file, int line, const std::string &type, const ScopedName& name) + : Declaration(file, line, type, name) +{ } + +Builtin::~Builtin() +{ } + +void +Builtin::accept(Visitor* visitor) +{ + visitor->visit_builtin(this); +} + +// // AST::Macro // @@ -357,6 +377,10 @@ Visitor::~Visitor() {} void Visitor::visit_declaration(Declaration*) {} + +void Visitor::visit_builtin(Builtin*) +{} + void Visitor::visit_macro(Macro* d) { visit_declaration(d); Index: ast.hh =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/ast.hh,v retrieving revision 1.23 retrieving revision 1.24 diff -u -p -d -r1.23 -r1.24 --- ast.hh 11 Nov 2003 06:01:45 -0000 1.23 +++ ast.hh 2 Dec 2003 05:45:51 -0000 1.24 @@ -399,6 +399,20 @@ private: Include::vector m_includes; }; +//. A Builtin is a node to be used internally. +//. Right now it's being used to capture comments +//. at the end of a scope. +class Builtin : public Declaration +{ +public: + Builtin(SourceFile* file, int line, const std::string &type, const ScopedName& name); + + //. Destructor + virtual ~Builtin(); + + //. Accepts the given visitor + virtual void accept(Visitor*); +}; //. Encapsulates a preprocessor macro. Macros are stored in the AST, but since //. they are not regular C++ syntax they are treated specially: They will be @@ -987,6 +1001,7 @@ public: // Abstract destructor makes the class abstract virtual ~Visitor() = 0; virtual void visit_declaration(Declaration*); + virtual void visit_builtin(Builtin*); virtual void visit_macro(Macro*); virtual void visit_scope(Scope*); virtual void visit_namespace(Namespace*); Index: builder.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/builder.cc,v retrieving revision 1.44 retrieving revision 1.45 diff -u -p -d -r1.44 -r1.45 --- builder.cc 27 Jan 2003 06:53:37 -0000 1.44 +++ builder.cc 2 Dec 2003 05:45:51 -0000 1.45 @@ -22,6 +22,9 @@ // 02111-1307, USA. // $Log$ +// Revision 1.45 2003/12/02 05:45:51 stefan +// generate Builtin 'end of scope' instead of Declaration 'dummy' +// // Revision 1.44 2003/01/27 06:53:37 chalky // Added macro support for C++. // @@ -658,13 +661,13 @@ AST::Enum* Builder::add_enum(int line, c } //. Add tail comment -AST::Declaration* Builder::add_tail_comment(int line) +AST::Builtin *Builder::add_tail_comment(int line) { ScopedName name; - name.push_back("dummy"); - AST::Declaration* decl = new AST::Declaration(m_file, line, "dummy", name); - add(decl); - return decl; + name.push_back("EOS"); + AST::Builtin *builtin = new AST::Builtin(m_file, line, "EOS", name); + add(builtin); + return builtin; } // A functor that adds only inheritances which are class objects to a given Index: builder.hh =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/builder.hh,v retrieving revision 1.32 retrieving revision 1.33 diff -u -p -d -r1.32 -r1.33 --- builder.hh 27 Jan 2003 06:53:37 -0000 1.32 +++ builder.hh 2 Dec 2003 05:45:51 -0000 1.33 @@ -199,9 +199,8 @@ public: //. Add an enum AST::Enum* add_enum(int, const std::string& name, const AST::Enumerator::vector &); - //. Add a tail comment. This will be a dummy declaration with an empty name - //. and type "dummy" - AST::Declaration* add_tail_comment(int line); + //. Add a tail comment. This will be a builtin with name 'EOS' + AST::Builtin *add_tail_comment(int line); // // Using methods Index: dumper.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/dumper.cc,v retrieving revision 1.23 retrieving revision 1.24 diff -u -p -d -r1.23 -r1.24 --- dumper.cc 27 Jan 2003 06:53:37 -0000 1.23 +++ dumper.cc 2 Dec 2003 05:45:51 -0000 1.24 @@ -22,6 +22,9 @@ // 02111-1307, USA. // $Log$ +// Revision 1.24 2003/12/02 05:45:51 stefan +// generate Builtin 'end of scope' instead of Declaration 'dummy' +// // Revision 1.23 2003/01/27 06:53:37 chalky // Added macro support for C++. // @@ -293,9 +296,13 @@ std::string Dumper::formatParam(AST::Par void Dumper::visit_declaration(AST::Declaration* decl) { visit(decl->comments()); - if (decl->type() == "dummy") - return; std::cout << m_indent_string << "DECL " << decl->name() << std::endl; +} + +void Dumper::visit_builtin(AST::Builtin *builtin) +{ + visit(builtin->comments()); + std::cout << m_indent_string << "BUILTIN " << builtin->name() << std::endl; } void Dumper::visit_macro(AST::Macro* macro) Index: dumper.hh =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/dumper.hh,v retrieving revision 1.15 retrieving revision 1.16 diff -u -p -d -r1.15 -r1.16 --- dumper.hh 27 Jan 2003 06:53:37 -0000 1.15 +++ dumper.hh 2 Dec 2003 05:45:51 -0000 1.16 @@ -87,6 +87,7 @@ public: void visit(const std::vector&); virtual void visit_macro(AST::Macro*); virtual void visit_declaration(AST::Declaration*); + virtual void visit_builtin(AST::Builtin*); virtual void visit_scope(AST::Scope*); virtual void visit_namespace(AST::Namespace*); virtual void visit_forward(AST::Forward*); Index: synopsis.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/synopsis.cc,v retrieving revision 1.49 retrieving revision 1.50 diff -u -p -d -r1.49 -r1.50 --- synopsis.cc 11 Nov 2003 06:01:45 -0000 1.49 +++ synopsis.cc 2 Dec 2003 05:45:51 -0000 1.50 @@ -23,6 +23,9 @@ // 02111-1307, USA. // $Log$ +// Revision 1.50 2003/12/02 05:45:51 stefan +// generate Builtin 'end of scope' instead of Declaration 'dummy' +// // Revision 1.49 2003/11/11 06:01:45 stefan // adjust to directory/package layout changes // @@ -663,6 +666,21 @@ PyObject *Synopsis::Declaration(AST::Dec return pydecl; } +PyObject *Synopsis::Builtin(AST::Builtin* decl) +{ + Trace trace("Synopsis::Builtin"); + PyObject *pybuiltin, *file, *type, *name; + pybuiltin = PyObject_CallMethod(m_ast, "Builtin", "OiOOO", + file = m->py(decl->file()), decl->line(), m->cxx(), + type = m->py(decl->type()), name = m->Tuple(decl->name())); + assertObject(pybuiltin); + addComments(pybuiltin, decl); + Py_DECREF(file); + Py_DECREF(type); + Py_DECREF(name); + return pybuiltin; +} + PyObject *Synopsis::Macro(AST::Macro* decl) { Trace trace("Synopsis::Macro"); @@ -976,6 +994,11 @@ void Synopsis::visit_declaration(AST::De // Assume this is a dummy declaration if (m_filter->should_store(decl)) m->add(decl, Declaration(decl)); +} +void Synopsis::visit_builtin(AST::Builtin* decl) +{ + if (m_filter->should_store(decl)) + m->add(decl, Builtin(decl)); } void Synopsis::visit_macro(AST::Macro* decl) { Index: synopsis.hh =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/syn/synopsis.hh,v retrieving revision 1.32 retrieving revision 1.33 diff -u -p -d -r1.32 -r1.33 --- synopsis.hh 27 Jan 2003 06:53:37 -0000 1.32 +++ synopsis.hh 2 Dec 2003 05:45:51 -0000 1.33 @@ -105,6 +105,7 @@ public: PyObject* SourceFile(AST::SourceFile*); PyObject* Include(AST::Include*); PyObject* Declaration(AST::Declaration*); + PyObject* Builtin(AST::Builtin*); PyObject* Macro(AST::Macro*); PyObject* Forward(AST::Forward*); PyObject* Scope(AST::Scope*); @@ -125,6 +126,7 @@ public: // AST::Visitor methods // void visit_declaration(AST::Declaration*); + void visit_builtin(AST::Builtin*); void visit_macro(AST::Macro*); void visit_scope(AST::Scope*); void visit_namespace(AST::Namespace*); From stefan at synopsis.fresco.org Tue Dec 2 05:46:58 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Processors/Comments Comments.py,1.26,1.27 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Processors/Comments In directory frida:/tmp/cvs-serv30838/Synopsis/Processors/Comments Modified Files: Comments.py Log Message: got rid of Dummies and other cleanup Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/Comments/Comments.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -p -d -r1.26 -r1.27 --- Comments.py 11 Nov 2003 06:03:59 -0000 1.26 +++ Comments.py 2 Dec 2003 05:46:56 -0000 1.27 @@ -8,9 +8,9 @@ # from Synopsis.Processor import Processor, Parameter -from Synopsis import AST, Util +from Synopsis import AST -import sys, string, re, types +import string, re class CommentProcessor(Processor, AST.Visitor): """Base class for comment processors. @@ -41,6 +41,10 @@ class CommentProcessor(Processor, AST.Vi def visitDeclaration(self, decl): self.visit_comments(decl) + def visitBuiltin(self, decl): + if decl.type() == 'EOS': # treat it if it is an 'end of scope' marker + self.visit_comments(decl) + class SSDComments(CommentProcessor): """A class that selects only //. comments.""" @@ -231,44 +235,7 @@ class Transformer (CommentProcessor): return self.__currscope -class Dummies (Transformer): - """A class that deals with dummy declarations and their comments. This - class just removes them.""" - - def visitDeclaration(self, decl): - """Checks for dummy declarations""" - - if decl.type() == "dummy": return - self.add(decl) - - def visitScope(self, scope): - """Visits all children of the scope in a new scope. The value of - currscope() at the end of the list is used to replace scope's list of - declarations - hence you can remove (or insert) declarations from the - list. Such as dummy declarations :)""" - - self.push() - for decl in scope.declarations(): decl.accept(self) - scope.declarations()[:] = self.currscope() - self.pop(scope) - - def visitEnum(self, enum): - """Does the same as visitScope, but for the enum's list of - enumerators""" - - self.push() - for enumor in enum.enumerators(): enumor.accept(self) - enum.enumerators()[:] = self.currscope() - self.pop(enum) - - def visitEnumerator(self, enumor): - """Removes dummy enumerators""" - - if enumor.type() == "dummy": return #This wont work since Core.AST.Enumerator forces type to "enumerator" - if not len(enumor.name()): return # workaround. - self.add(enumor) - -class Previous(Dummies): +class Previous(CommentProcessor): """A class that maps comments that begin with '<' to the previous declaration""" @@ -283,35 +250,30 @@ class Previous(Dummies): for decl in ast.declarations(): decl.accept(self) self.last = decl - ast.declarations()[:] = self.currscope() return self.output_and_return_ast() def push(self): """decorates push() to also push 'last' onto 'laststack'""" - Dummies.push(self) self.__laststack.append(self.last) self.last = None - def pop(self, decl): + def pop(self): """decorates pop() to also pop 'last' from 'laststack'""" - Dummies.pop(self, decl) self.last = self.__laststack.pop() def visitScope(self, scope): """overrides visitScope() to set 'last' after each declaration""" - self.removeSuspect(scope) self.push() for decl in scope.declarations(): decl.accept(self) self.last = decl - scope.declarations()[:] = self.currscope() - self.pop(scope) + self.pop() - def checkPrevious(self, decl): + def visit_comments(self, decl): """Checks a decl to see if the comment should be moved. If the comment begins with a less-than sign, then it is moved to the 'last' declaration""" @@ -319,43 +281,26 @@ class Previous(Dummies): if len(decl.comments()) and self.last: first = decl.comments()[0] if len(first.text()) and first.text()[0] == "<" and self.last: + if self.debug: + print 'found comment for previous in', decl.name() first.set_suspect(0) # Remove suspect flag first.set_text(first.text()[1:]) # Remove '<' self.last.comments().append(first) del decl.comments()[0] - def removeSuspect(self, decl): - """Removes any suspect comments from the declaration""" - - non_suspect = lambda decl: not decl.is_suspect() - comments = decl.comments() - comments[:] = filter(non_suspect, comments) - - def visitDeclaration(self, decl): - """Calls checkPrevious on the declaration and removes dummies""" - - self.checkPrevious(decl) - self.removeSuspect(decl) - if decl.type() != "dummy": - self.add(decl) - def visitEnum(self, enum): """Does the same as visitScope but for enum and enumerators""" - self.removeSuspect(enum) self.push() for enumor in enum.enumerators(): enumor.accept(self) self.last = enumor - enum.enumerators()[:] = self.currscope() - self.pop(enum) + self.pop() def visitEnumerator(self, enumor): """Checks previous comment and removes dummies""" - self.removeSuspect(enumor) - self.checkPrevious(enumor) - if len(enumor.name()): self.add(enumor) + self.visit_comments(enumor) class Grouper (Transformer): """A class that detects grouping tags and moves the enclosed nodes @@ -382,7 +327,7 @@ class Grouper (Transformer): """replace the AST with the newly created one""" self.strip_dangling_groups() - super(Transformer, self).finalize() + super(Grouper, self).finalize() def push(self): """starts a new group stack to be able to validate group scopes""" @@ -435,7 +380,7 @@ class Grouper (Transformer): """Visits all children of the scope in a new scope. The value of currscope() at the end of the list is used to replace scope's list of declarations - hence you can remove (or insert) declarations from the - list. Such as dummy declarations :)""" + list.""" self.visit_comments(scope) self.push() @@ -484,6 +429,10 @@ class Grouper1(Grouper): comments.append(c) continue elif tag.group('open'): + + if self.debug: + print 'found group open tag in', decl.name() + # Open group. Name is remainder of line label = tag.group('name') or 'unnamed' # The comment before the open marker becomes the group comment @@ -494,8 +443,14 @@ class Grouper1(Grouper): group.comments()[:] = comments comments = [] self.push_group(group) + elif tag.group('close'): + + if self.debug: + print 'found group close tag in', decl.name() + self.pop_group(decl) + decl.comments()[:] = comments class Grouper2(Grouper): @@ -523,6 +478,10 @@ class Grouper2(Grouper): comments.append(c) continue elif tag.group('open'): + + if self.debug: + print 'found group open tag in', decl.name() + # Open group. Name is remainder of line label = tag.group('name') or 'unnamed' # The comment before the open marker becomes the group comment @@ -537,7 +496,12 @@ class Grouper2(Grouper): decl.comments().insert(0, AST.Comment(tag.group('remainder'), c.file(), c.line())) self.push_group(group) elif tag.group('close'): + + if self.debug: + print 'found group close tag in', decl.name() + self.pop_group(decl) + # The comment before the close marker is ignored...? maybe post-comment? # The comment after the close marker becomes the next comment to process remainder = string.join([tag.group('remainder'), c.text()[tag.end():]], '') @@ -626,7 +590,6 @@ processors = { 'ss' : SSComments, 'java': JavaComments, 'qt': QtComments, - 'dummy': Dummies, 'prev': Previous, 'group': Grouper1, 'group2': Grouper2, @@ -634,31 +597,3 @@ processors = { 'summary' : Summarizer, 'javatags' : JavaTags, } - -#class Comments(Operation): - -# def __init__(self): -# """Constructor, parses the config object""" - -# self.processor_list = [] - -# if hasattr(config, 'comment_processors'): -# for proc in config.comment_processors: -# if type(proc) == types.StringType: -# if processors.has_key(proc): -# self.processor_list.append(processors[proc]()) -# else: -# raise ImportError, 'No such processor: %s'%(proc,) -# elif type(proc) == types.TupleType: -# mod = Util._import(proc[0]) -# clas = getattr(mod, proc[1]) -# self.processor_list.append(clas()) - -# def execute(self, ast): - -# declarations = ast.declarations() -# for processor in self.processor_list: -# processor.process(ast, **kwds) - -#linkerOperation = Comments - From stefan at synopsis.fresco.org Tue Dec 2 05:51:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/Boost synopsis.py,1.4,1.5 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/Boost In directory frida:/tmp/cvs-serv30940/demo/C++/Boost Modified Files: synopsis.py Log Message: get rid of 'Dummies' processor Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/Boost/synopsis.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -p -d -r1.4 -r1.5 --- synopsis.py 23 Nov 2003 17:27:32 -0000 1.4 +++ synopsis.py 2 Dec 2003 05:51:03 -0000 1.5 @@ -35,8 +35,7 @@ linker = Linker(Stripper(), # st SSComments(), # filter out any non-'//' comments Grouper2(), # group declarations according to '@group' tags CommentStripper(), # strip any 'suspicious' comments - Previous(), # attach '//<-' comments - Dummies(), # drop 'dummy' declarations + Previous(), # attach '//<' comments EmptyNS(), # skip empty namespaces AccessRestrictor()) # filter out unwanted ('private', say) declarations From stefan at synopsis.fresco.org Tue Dec 2 05:51:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial Tutorial.xml,1.3,1.4 html.xsl,1.4,1.5 Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial In directory frida:/tmp/cvs-serv30940/doc/Tutorial Modified Files: Tutorial.xml html.xsl Log Message: get rid of 'Dummies' processor Index: Tutorial.xml =================================================================== RCS file: /cvs/synopsis/Synopsis/doc/Tutorial/Tutorial.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -p -d -r1.3 -r1.4 --- Tutorial.xml 29 Nov 2003 23:43:22 -0000 1.3 +++ Tutorial.xml 2 Dec 2003 05:51:03 -0000 1.4 @@ -1,7 +1,7 @@ - + Synopsis Tutorial @@ -56,6 +56,21 @@ + +
+ Parsing source code + + +
+ +
+ Using comments for documentation + + + + + +
@@ -195,4 +210,4 @@ formatter.process(linker.process(parser. -
\ No newline at end of file +
Index: html.xsl =================================================================== RCS file: /cvs/synopsis/Synopsis/doc/Tutorial/html.xsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -p -d -r1.4 -r1.5 --- html.xsl 27 Nov 2003 06:00:36 -0000 1.4 +++ html.xsl 2 Dec 2003 05:51:03 -0000 1.5 @@ -7,6 +7,7 @@ + From stefan at synopsis.fresco.org Tue Dec 2 05:51:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Manual synopsis.py,1.5,1.6 Message-ID: Update of /cvs/synopsis/Synopsis/doc/Manual In directory frida:/tmp/cvs-serv30940/doc/Manual Modified Files: synopsis.py Log Message: get rid of 'Dummies' processor Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/doc/Manual/synopsis.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- synopsis.py 25 Nov 2003 22:13:16 -0000 1.5 +++ synopsis.py 2 Dec 2003 05:51:03 -0000 1.6 @@ -29,7 +29,6 @@ cxx = Cxx.Parser(base_path = topdir, xref_prefix='xref') cxx_processor = Linker(EmptyNS(), - Dummies(), SSDComments(), JavaTags(), Summarizer(), From stefan at synopsis.fresco.org Tue Dec 2 05:51:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/GapBuffer synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/GapBuffer In directory frida:/tmp/cvs-serv30940/demo/C++/GapBuffer Modified Files: synopsis.py Log Message: get rid of 'Dummies' processor Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/GapBuffer/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 22 Nov 2003 21:49:28 -0000 1.2 +++ synopsis.py 2 Dec 2003 05:51:03 -0000 1.3 @@ -17,8 +17,7 @@ linker = Linker(Stripper(), # st SSDComments(), # filter out any non-'//.' comments Grouper1(), # group declarations according to '@group' tags CommentStripper(), # strip any 'suspicious' comments - Previous(), # attach '//<-' comments - Dummies(), # drop 'dummy' declarations + Previous(), # attach '//<' comments EmptyNS(), # skip empty namespaces AccessRestrictor()) # filter out unwanted ('private', say) declarations From stefan at synopsis.fresco.org Tue Dec 2 06:22:44 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial/examples - New directory Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial/examples In directory frida:/tmp/cvs-serv31592/examples Log Message: Directory /cvs/synopsis/Synopsis/doc/Tutorial/examples added to the repository From stefan at synopsis.fresco.org Tue Dec 2 06:23:23 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial/examples/example1 - New directory Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial/examples/example1 In directory frida:/tmp/cvs-serv31605/examples/example1 Log Message: Directory /cvs/synopsis/Synopsis/doc/Tutorial/examples/example1 added to the repository From stefan at synopsis.fresco.org Tue Dec 2 06:23:23 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial/examples/example3 - New directory Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial/examples/example3 In directory frida:/tmp/cvs-serv31605/examples/example3 Log Message: Directory /cvs/synopsis/Synopsis/doc/Tutorial/examples/example3 added to the repository From stefan at synopsis.fresco.org Tue Dec 2 06:23:23 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial/examples/example2 - New directory Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial/examples/example2 In directory frida:/tmp/cvs-serv31605/examples/example2 Log Message: Directory /cvs/synopsis/Synopsis/doc/Tutorial/examples/example2 added to the repository From stefan at synopsis.fresco.org Tue Dec 2 06:23:23 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial/examples/example4 - New directory Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial/examples/example4 In directory frida:/tmp/cvs-serv31605/examples/example4 Log Message: Directory /cvs/synopsis/Synopsis/doc/Tutorial/examples/example4 added to the repository From stefan at synopsis.fresco.org Tue Dec 2 14:35:58 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Processors EmptyNS.py,1.5,1.6 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Processors In directory frida:/tmp/cvs-serv8125/Synopsis/Processors Modified Files: EmptyNS.py Log Message: rename 'EmptyNS' -> 'EmptyModuleRemover' Index: EmptyNS.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/EmptyNS.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- EmptyNS.py 25 Nov 2003 20:19:50 -0000 1.5 +++ EmptyNS.py 2 Dec 2003 14:35:53 -0000 1.6 @@ -8,12 +8,10 @@ # from Synopsis.Processor import Processor, Parameter -from Synopsis import AST, Type, Util - -import string +from Synopsis import AST, Type -class EmptyNS (Processor, AST.Visitor): - """A class that removes empty namespaces""" +class EmptyModuleRemover (Processor, AST.Visitor): + """A processor that removes empty modules""" def process(self, ast, **kwds): From stefan at synopsis.fresco.org Tue Dec 2 16:19:43 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Processors Linker.py,1.11,1.12 __init__.py,1.6,1.7 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Processors In directory frida:/tmp/cvs-serv9887/Synopsis/Processors Modified Files: Linker.py __init__.py Log Message: mv 'EmptyNS' -> 'EmptyModuleRemover' and integrate it into Linker Index: Linker.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/Linker.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -p -d -r1.11 -r1.12 --- Linker.py 25 Nov 2003 20:19:00 -0000 1.11 +++ Linker.py 2 Dec 2003 16:19:41 -0000 1.12 @@ -10,11 +10,13 @@ import string from Synopsis.Processor import Composite, Parameter -from Synopsis import AST, Type, Util +from Synopsis import AST, Type class Linker(Composite, AST.Visitor, Type.Visitor): """Visitor that removes duplicate declarations""" + remove_empty_modules = Parameter(True, 'Remove empty modules.') + def process(self, ast, **kwds): self.set_parameters(kwds) @@ -35,8 +37,12 @@ class Linker(Composite, AST.Visitor, Typ for file in self.ast.files().values(): self.visitSourceFile(file) + if self.remove_empty_modules: + import EmptyModuleRemover + self.ast = EmptyModuleRemover.EmptyModuleRemover().process(self.ast) + # now deal with the sub-processors, if any - self.ast = Composite.process(self, self.ast, input=[]) + self.ast = Composite.process(self, self.ast, input=[], output='') return self.output_and_return_ast() Index: __init__.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/__init__.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- __init__.py 22 Nov 2003 21:48:05 -0000 1.6 +++ __init__.py 2 Dec 2003 16:19:41 -0000 1.7 @@ -10,7 +10,7 @@ from Stripper import * from NameMapper import * from Comments import * from XRefCompiler import * -from EmptyNS import * +from EmptyModuleRemover import * from AccessRestrictor import * from TypeMapper import * from LanguageMapper import * From stefan at synopsis.fresco.org Tue Dec 2 16:20:31 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Manual synopsis.py,1.6,1.7 Message-ID: Update of /cvs/synopsis/Synopsis/doc/Manual In directory frida:/tmp/cvs-serv9984/doc/Manual Modified Files: synopsis.py Log Message: eliminate EmptyNS Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/doc/Manual/synopsis.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- synopsis.py 2 Dec 2003 05:51:03 -0000 1.6 +++ synopsis.py 2 Dec 2003 16:20:29 -0000 1.7 @@ -28,8 +28,7 @@ cxx = Cxx.Parser(base_path = topdir, syntax_prefix='links', xref_prefix='xref') -cxx_processor = Linker(EmptyNS(), - SSDComments(), +cxx_processor = Linker(SSDComments(), JavaTags(), Summarizer(), NamePrefixer(prefix = ['Synopsis', 'Parsers', 'Cxx', 'Parser'], From stefan at synopsis.fresco.org Tue Dec 2 16:20:31 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/GapBuffer synopsis.py,1.3,1.4 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/GapBuffer In directory frida:/tmp/cvs-serv9984/demo/C++/GapBuffer Modified Files: synopsis.py Log Message: eliminate EmptyNS Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/GapBuffer/synopsis.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -p -d -r1.3 -r1.4 --- synopsis.py 2 Dec 2003 05:51:03 -0000 1.3 +++ synopsis.py 2 Dec 2003 16:20:29 -0000 1.4 @@ -18,7 +18,6 @@ linker = Linker(Stripper(), # st Grouper1(), # group declarations according to '@group' tags CommentStripper(), # strip any 'suspicious' comments Previous(), # attach '//<' comments - EmptyNS(), # skip empty namespaces AccessRestrictor()) # filter out unwanted ('private', say) declarations xref = XRefCompiler(prefix = 'xref') From stefan at synopsis.fresco.org Tue Dec 2 16:20:31 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/Employee synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/Employee In directory frida:/tmp/cvs-serv9984/demo/C++/Employee Modified Files: synopsis.py Log Message: eliminate EmptyNS Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/Employee/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 22 Nov 2003 21:49:27 -0000 1.2 +++ synopsis.py 2 Dec 2003 16:20:29 -0000 1.3 @@ -11,7 +11,6 @@ linker = Linker(Stripper(), # st JavaComments(), # only keep javadoc-like comments JavaTags(), # process javadoc-like tags Summarizer(), - EmptyNS(), # skip empty namespaces AccessRestrictor()) # filter out unwanted ('private', say) declarations process(parse = Cxx.Parser(), From stefan at synopsis.fresco.org Tue Dec 2 16:20:31 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/Perceps synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/demo/Perceps In directory frida:/tmp/cvs-serv9984/demo/Perceps Modified Files: synopsis.py Log Message: eliminate EmptyNS Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/Perceps/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 22 Nov 2003 21:49:28 -0000 1.2 +++ synopsis.py 2 Dec 2003 16:20:29 -0000 1.3 @@ -120,7 +120,6 @@ linker = Linker(Stripper(), NameMapper(), PercepsCommProcessor(), PercepsCommSplitter(), - EmptyNS(), AccessRestrictor()) html = HTML.Formatter(stylesheet_file = '../html.css', From stefan at synopsis.fresco.org Tue Dec 2 16:20:31 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/Mixed synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/demo/Mixed In directory frida:/tmp/cvs-serv9984/demo/Mixed Modified Files: synopsis.py Log Message: eliminate EmptyNS Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/Mixed/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 22 Nov 2003 21:49:28 -0000 1.2 +++ synopsis.py 2 Dec 2003 16:20:29 -0000 1.3 @@ -33,7 +33,6 @@ class Cxx2IDL(TypeMapper): idl = Composite(IDL.Parser(), Linker(), # remove duplicate and forward declarations - EmptyNS(), # skip empty namespaces SSDComments(), # filter out any non-'//.' comments CommentStripper()) # strip any 'suspicious' comments @@ -41,7 +40,6 @@ cxx = Composite(Cxx.Parser(preprocessor cppflags = ['-I.', '-D__x86__']), Cxx2IDL(), # map to interface to hide the skeletons Linker(), # remove duplicate and forward declarations - EmptyNS(), # skip empty namespaces SSDComments(), # filter out any non-'//.' comments CommentStripper()) # strip any 'suspicious' comments From stefan at synopsis.fresco.org Tue Dec 2 16:20:31 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/Boost synopsis.py,1.5,1.6 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/Boost In directory frida:/tmp/cvs-serv9984/demo/C++/Boost Modified Files: synopsis.py Log Message: eliminate EmptyNS Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/Boost/synopsis.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- synopsis.py 2 Dec 2003 05:51:03 -0000 1.5 +++ synopsis.py 2 Dec 2003 16:20:29 -0000 1.6 @@ -36,12 +36,12 @@ linker = Linker(Stripper(), # st Grouper2(), # group declarations according to '@group' tags CommentStripper(), # strip any 'suspicious' comments Previous(), # attach '//<' comments - EmptyNS(), # skip empty namespaces AccessRestrictor()) # filter out unwanted ('private', say) declarations formatter = HTML.Formatter(stylesheet_file = '../../html.css') -process(parse = Composite(parser, linker), +process(parse2 = parser, + parse = Composite(parser, linker), xref = xref, link = linker, format = formatter) From stefan at synopsis.fresco.org Tue Dec 2 16:31:46 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker In directory frida:/tmp/cvs-serv10215/tests/Processors/Linker Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Linker added to the repository From stefan at synopsis.fresco.org Tue Dec 2 16:32:04 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:12 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/second - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/second In directory frida:/tmp/cvs-serv10226/tests/Processors/Linker/second Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Linker/second added to the repository From stefan at synopsis.fresco.org Tue Dec 2 16:32:04 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/first - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/first In directory frida:/tmp/cvs-serv10226/tests/Processors/Linker/first Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Linker/first added to the repository From stefan at synopsis.fresco.org Tue Dec 2 16:32:43 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/first/input - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/first/input In directory frida:/tmp/cvs-serv10243/tests/Processors/Linker/first/input Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Linker/first/input added to the repository From stefan at synopsis.fresco.org Tue Dec 2 16:32:43 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/second/input - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/second/input In directory frida:/tmp/cvs-serv10243/tests/Processors/Linker/second/input Log Message: Directory /cvs/synopsis/Synopsis/tests/Processors/Linker/second/input added to the repository From stefan at synopsis.fresco.org Tue Dec 2 16:34:32 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/first/input definition.h,NONE,1.1 forward.h,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/first/input In directory frida:/tmp/cvs-serv10271/tests/Processors/Linker/first/input Added Files: definition.h forward.h Log Message: new linker tests --- NEW FILE: definition.h --- class Foo {}; --- NEW FILE: forward.h --- #include class Foo; From stefan at synopsis.fresco.org Tue Dec 2 16:34:32 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/first synopsis.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/first In directory frida:/tmp/cvs-serv10271/tests/Processors/Linker/first Added Files: synopsis.py Log Message: new linker tests --- NEW FILE: synopsis.py --- from Synopsis.process import process from Synopsis.Processor import Composite from Synopsis.Parsers import Cxx from Synopsis.Processors import Linker from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), Linker(remove_empty_modules=False), Dump.Formatter(show_ids = False))) From stefan at synopsis.fresco.org Tue Dec 2 16:34:32 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/qmtest/classes synopsis_database.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/tests/qmtest/classes In directory frida:/tmp/cvs-serv10271/tests/qmtest/classes Modified Files: synopsis_database.py Log Message: new linker tests Index: synopsis_database.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/qmtest/classes/synopsis_database.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis_database.py 30 Nov 2003 00:43:58 -0000 1.2 +++ synopsis_database.py 2 Dec 2003 16:34:30 -0000 1.3 @@ -30,21 +30,32 @@ class Database(database.Database): and os.path.isdir(path)): raise NoSuchSuiteError, id - test_ids = [] - suite_ids = filter(lambda x: os.path.isdir(os.path.join(path, x)), - dircache.listdir(path)) - if 'input' in suite_ids: - test_ids = map(lambda x: os.path.splitext(x)[0], - dircache.listdir(os.path.join(path, 'input'))) - if 'CVS' in test_ids: test_ids.remove('CVS') - suite_ids.remove('input') - if 'expected' in suite_ids: suite_ids.remove('expected') - if 'CVS' in suite_ids: suite_ids.remove('CVS') + if id.startswith('Processors.Linker'): + # tests in the Linker suite are treated differently because + # input files in 'input' are processed together in a single test + child_ids = filter(lambda x: os.path.isdir(os.path.join(path, x)), + dircache.listdir(path)) + # if there is a subdir 'input', we consider this a test + # else it's a suite + test_ids = filter(lambda x: os.path.isdir(os.path.join(path, x, 'input')), + dircache.listdir(path)) + suite_ids = [] + + else: + test_ids = [] + suite_ids = filter(lambda x: os.path.isdir(os.path.join(path, x)), + dircache.listdir(path)) + if 'input' in suite_ids: + test_ids = map(lambda x: os.path.splitext(x)[0], + dircache.listdir(os.path.join(path, 'input'))) + if 'CVS' in test_ids: test_ids.remove('CVS') + suite_ids.remove('input') + if 'expected' in suite_ids: suite_ids.remove('expected') + if 'CVS' in suite_ids: suite_ids.remove('CVS') if id: test_ids = map(lambda x: string.join([id, x], '.'), test_ids) suite_ids = map(lambda x: string.join([id, x], '.'), suite_ids) - return Suite(self, id, 0, test_ids, suite_ids) def GetTest(self, id): @@ -53,20 +64,55 @@ class Database(database.Database): if not id: raise NoSuchTestError, id + if id.startswith('Processors.Linker'): + return self.make_linker_test(id) + else: + return self.make_test(id) + + def make_test(self, id): + components = id.split('.') dirname = os.path.join(*components[:-1]) - input = os.path.join(dirname, 'input', components[-1]) - if components[:-1] == ['Parsers', 'IDL']: input += '.idl' - elif components[:-1] == ['Parsers', 'Cxx']: input += '.cc' - elif components[:-1] == ['Parsers', 'Python']: input += '.py' - if not os.path.isfile(input): + + input = [os.path.join(dirname, 'input', components[-1])] + + if components[:-1] == ['Parsers', 'IDL']: + input = map(lambda x: x + '.idl', input) + elif components[:-1] == ['Parsers', 'Python']: + input = map(lambda x: x + '.py', input) + else: # all other tests use C++ input + input = map(lambda x: x + '.cc', input) + if reduce(lambda x, y: x + y, # sum all non-files + filter(lambda x: not os.path.isfile(x), input), 0): raise NoSuchTestError, id + output = os.path.join(dirname, 'output', components[-1] + '.xml') + expected = os.path.join(dirname, 'expected', components[-1] + '.xml') + synopsis = os.path.join(dirname, 'synopsis.py') + parameters = {} parameters['srcdir'] = '.' - parameters['input'] = [input] - parameters['output'] = os.path.join(dirname, 'output', components[-1] + '.xml') - parameters['expected'] = os.path.join(dirname, 'expected', components[-1] + '.xml') + parameters['input'] = input + parameters['output'] = output + parameters['expected'] = expected parameters['synopsis'] = os.path.join(dirname, 'synopsis.py') + return TestDescriptor(self, id, 'synopsis_test.ProcessorTest', parameters) + def make_linker_test(self, id): + + if not os.path.isdir(id.replace('.', os.sep)): + raise NoSuchTestError, id + + components = id.split('.') + dirname = os.path.join(*components + ['input']) + + parameters = {} + parameters['srcdir'] = '.' + parameters['input'] = map(lambda x: os.path.join(dirname, x), + dircache.listdir(dirname)) + parameters['output'] = os.path.join(*components + ['output.xml']) + parameters['expected'] = os.path.join(*components + ['expected.xml']) + parameters['synopsis'] = os.path.join(*components + ['synopsis.py']) + + return TestDescriptor(self, id, 'synopsis_test.ProcessorTest', parameters) From stefan at synopsis.fresco.org Tue Dec 2 16:34:32 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/second synopsis.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/second In directory frida:/tmp/cvs-serv10271/tests/Processors/Linker/second Added Files: synopsis.py Log Message: new linker tests --- NEW FILE: synopsis.py --- from Synopsis.process import process from Synopsis.Processor import Composite from Synopsis.Parsers import Cxx from Synopsis.Processors import Linker from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), Linker(), Dump.Formatter(show_ids = False))) From stefan at synopsis.fresco.org Tue Dec 2 16:34:32 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/second/input definition.h,NONE,1.1 forward.h,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/second/input In directory frida:/tmp/cvs-serv10271/tests/Processors/Linker/second/input Added Files: definition.h forward.h Log Message: new linker tests --- NEW FILE: definition.h --- class Foo {}; --- NEW FILE: forward.h --- #include class Foo; From stefan at synopsis.fresco.org Wed Dec 3 00:37:50 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Processors Linker.py,1.12,1.13 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Processors In directory frida:/tmp/cvs-serv18739/Synopsis/Processors Modified Files: Linker.py Log Message: backup and restore the 'output' parameter while the super class overrides it Index: Linker.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/Linker.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -p -d -r1.12 -r1.13 --- Linker.py 2 Dec 2003 16:19:41 -0000 1.12 +++ Linker.py 3 Dec 2003 00:37:47 -0000 1.13 @@ -42,8 +42,10 @@ class Linker(Composite, AST.Visitor, Typ self.ast = EmptyModuleRemover.EmptyModuleRemover().process(self.ast) # now deal with the sub-processors, if any + output = self.output self.ast = Composite.process(self, self.ast, input=[], output='') - + self.output = output + return self.output_and_return_ast() def lookup(self, name): From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/first synopsis.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/first In directory frida:/tmp/cvs-serv22070/Processors/Linker/first Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Processors/Linker/first/synopsis.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- synopsis.py 2 Dec 2003 16:34:30 -0000 1.1 +++ synopsis.py 3 Dec 2003 03:41:38 -0000 1.2 @@ -6,4 +6,5 @@ from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), Linker(remove_empty_modules=False), - Dump.Formatter(show_ids = False))) + Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper synopsis.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper In directory frida:/tmp/cvs-serv22070/Processors/Grouper Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Processors/Grouper/synopsis.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- synopsis.py 2 Dec 2003 05:41:47 -0000 1.1 +++ synopsis.py 3 Dec 2003 03:41:38 -0000 1.2 @@ -7,4 +7,5 @@ from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), SSComments(), Grouper1(), - Dump.Formatter(show_ids = False))) + Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/second synopsis.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/second In directory frida:/tmp/cvs-serv22070/Processors/Linker/second Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Processors/Linker/second/synopsis.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- synopsis.py 2 Dec 2003 16:34:30 -0000 1.1 +++ synopsis.py 3 Dec 2003 03:41:38 -0000 1.2 @@ -6,4 +6,5 @@ from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), Linker(), - Dump.Formatter(show_ids = False))) + Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parsers/Python synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parsers/Python In directory frida:/tmp/cvs-serv22070/Parsers/Python Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parsers/Python/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 30 Nov 2003 01:28:31 -0000 1.2 +++ synopsis.py 3 Dec 2003 03:41:37 -0000 1.3 @@ -3,5 +3,6 @@ from Synopsis.Processor import Composite from Synopsis.Parsers import Python from Synopsis.Formatters import Dump -process(parse = Composite(Python.Parser(), Dump.Formatter(show_ids = False))) +process(parse = Composite(Python.Parser(), Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parsers/IDL/expected CosNaming.xml,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parsers/IDL/expected In directory frida:/tmp/cvs-serv22070/Parsers/IDL/expected Modified Files: CosNaming.xml Log Message: suppress stylesheet Index: CosNaming.xml =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parsers/IDL/expected/CosNaming.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- CosNaming.xml 30 Nov 2003 01:28:31 -0000 1.1 +++ CosNaming.xml 3 Dec 2003 03:41:37 -0000 1.2 @@ -1,5 +1,4 @@ - From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parsers/Cxx synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parsers/Cxx In directory frida:/tmp/cvs-serv22070/Parsers/Cxx Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parsers/Cxx/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 30 Nov 2003 01:28:30 -0000 1.2 +++ synopsis.py 3 Dec 2003 03:41:37 -0000 1.3 @@ -3,5 +3,6 @@ from Synopsis.Processor import Composite from Synopsis.Parsers import Cxx from Synopsis.Formatters import Dump -process(parse = Composite(Cxx.Parser(), Dump.Formatter(show_ids = False))) +process(parse = Composite(Cxx.Parser(), Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parsers/Python/expected class.xml,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parsers/Python/expected In directory frida:/tmp/cvs-serv22070/Parsers/Python/expected Modified Files: class.xml Log Message: suppress stylesheet Index: class.xml =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parsers/Python/expected/class.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- class.xml 30 Nov 2003 01:28:31 -0000 1.1 +++ class.xml 3 Dec 2003 03:41:37 -0000 1.2 @@ -1,5 +1,4 @@ - From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parsers/IDL synopsis.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parsers/IDL In directory frida:/tmp/cvs-serv22070/Parsers/IDL Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parsers/IDL/synopsis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- synopsis.py 30 Nov 2003 01:28:31 -0000 1.2 +++ synopsis.py 3 Dec 2003 03:41:37 -0000 1.3 @@ -3,5 +3,6 @@ from Synopsis.Processor import Composite from Synopsis.Parsers import IDL from Synopsis.Formatters import Dump -process(parse = Composite(IDL.Parser(), Dump.Formatter(show_ids = False))) +process(parse = Composite(IDL.Parser(), Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:41:40 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous synopsis.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous In directory frida:/tmp/cvs-serv22070/Processors/Previous Modified Files: synopsis.py Log Message: suppress stylesheet Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Processors/Previous/synopsis.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- synopsis.py 2 Dec 2003 05:41:48 -0000 1.1 +++ synopsis.py 3 Dec 2003 03:41:38 -0000 1.2 @@ -7,4 +7,5 @@ from Synopsis.Formatters import Dump process(parse = Composite(Cxx.Parser(), SSComments(), Previous(), - Dump.Formatter(show_ids = False))) + Dump.Formatter(show_ids = False, + stylesheet = None))) From stefan at synopsis.fresco.org Wed Dec 3 03:43:29 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:13 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parsers/Cxx Parser.py,1.5,1.6 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx In directory frida:/tmp/cvs-serv22178/Synopsis/Parsers/Cxx Modified Files: Parser.py Log Message: suppress obsolete extract_tails parameter Index: Parser.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/Parser.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- Parser.py 18 Nov 2003 07:25:58 -0000 1.5 +++ Parser.py 3 Dec 2003 03:43:26 -0000 1.6 @@ -24,7 +24,6 @@ class Parser(Processor): cppflags = Parameter([], 'list of preprocessor flags such as -I or -D') main_file_only = Parameter(True, 'should only main file be processed') base_path = Parameter('', 'path prefix to strip off of the file names') - extract_tails = Parameter(True, 'consider comments at the end of declarations') syntax_prefix = Parameter(None, 'path prefix (directory) to contain syntax info') xref_prefix = Parameter(None, 'path prefix (directory) to contain xref info') @@ -43,7 +42,6 @@ class Parser(Processor): self.base_path, self.preprocessor, self.cppflags, - self.extract_tails, self.syntax_prefix, self.xref_prefix, self.emulate_compiler) From stefan at synopsis.fresco.org Wed Dec 3 05:37:58 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial Makefile,1.10,1.11 Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial In directory frida:/tmp/cvs-serv24303/doc/Tutorial Modified Files: Makefile Log Message: use fop for pdf generation Index: Makefile =================================================================== RCS file: /cvs/synopsis/Synopsis/doc/Tutorial/Makefile,v retrieving revision 1.10 retrieving revision 1.11 diff -u -p -d -r1.10 -r1.11 --- Makefile 27 Nov 2003 12:39:09 -0000 1.10 +++ Makefile 3 Dec 2003 05:37:56 -0000 1.11 @@ -7,16 +7,20 @@ all: html pdf html: Tutorial.xml mkdir -p $@ cp $(srcdir)/synopsis.css $@ - xsltproc --novalid -o $@/ $(srcdir)/html.xsl $^ + xsltproc --novalid --xinclude -o $@/ $(srcdir)/html.xsl $^ mkdir -p $@/images cp $(srcdir)/images/*.png $@/images pdf: Tutorial.pdf -Tutorial.pdf: Tutorial.xml - docbook2pdf $^ +Tutorial.pdf: Tutorial.fo + fop $^ $@ + +Tutorial.fo: Tutorial.xml + xsltproc --novalid --xinclude -o $@ $(srcdir)/fo.xsl $^ clean: + rm Tutorial.fo distclean: clean rm -rf html Tutorial.pdf From stefan at synopsis.fresco.org Wed Dec 3 05:43:58 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/qmtest/classes synopsis_test.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/qmtest/classes In directory frida:/tmp/cvs-serv24402/qmtest/classes Modified Files: synopsis_test.py Log Message: check return value of executed command Index: synopsis_test.py =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/qmtest/classes/synopsis_test.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- synopsis_test.py 29 Nov 2003 22:57:06 -0000 1.1 +++ synopsis_test.py 3 Dec 2003 05:43:55 -0000 1.2 @@ -37,12 +37,14 @@ class ProcessorTest(Test): string.join(self.input, ' ')) script = RedirectedExecutable(60) # 1 minute ought to be enough... status = script.Run(string.split(command)) - return self.output + if status != 0: + result.Fail("unable to run '%s'"%command) + return status == 0 def Run(self, context, result): - self.run_processor(context, result) - expected = open(self.expected).readlines() - output = open(self.output).readlines() - if expected != output: - result.Fail("output mismatch") + if self.run_processor(context, result): + expected = open(self.expected).readlines() + output = open(self.output).readlines() + if expected != output: + result.Fail("output mismatch") From stefan at synopsis.fresco.org Wed Dec 3 06:56:38 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/doc/Tutorial fo.xsl,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/doc/Tutorial In directory frida:/tmp/cvs-serv25924/doc/Tutorial Added Files: fo.xsl Log Message: stylesheet for xml->fo->pdf --- NEW FILE: fo.xsl --- From stefan at synopsis.fresco.org Wed Dec 3 16:21:15 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Grouper/expected groups.xml,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Grouper/expected In directory frida:/tmp/cvs-serv3636/Processors/Grouper/expected Added Files: groups.xml Log Message: more tests --- NEW FILE: groups.xml --- Processors/Grouper/input/groups.cc group documentation Processors/Grouper/input/groups.cc some comment extending over multiple lines Processors/Grouper/input/groups.cc another comment Processors/Grouper/input/groups.cc another group Processors/Grouper/input/groups.cc @group xxx { not a group Processors/Grouper/input/groups.cc } and not a group end } and not a group either Processors/Grouper/input/groups.cc From stefan at synopsis.fresco.org Wed Dec 3 16:21:58 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Previous/expected previous.xml,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Previous/expected In directory frida:/tmp/cvs-serv3652/Processors/Previous/expected Added Files: previous.xml Log Message: more tests --- NEW FILE: previous.xml --- Processors/Previous/input/previous.cc first comment Processors/Previous/input/previous.cc second comment Processors/Previous/input/previous.cc third comment Processors/Previous/input/previous.cc ONE comment Processors/Previous/input/previous.cc TWO comment Processors/Previous/input/previous.cc THREE comment Processors/Previous/input/previous.cc From stefan at synopsis.fresco.org Thu Dec 4 01:08:39 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Processors Linker.py,1.13,1.14 EmptyModuleRemover.py,1.6,1.7 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Processors In directory frida:/tmp/cvs-serv12741 Modified Files: Linker.py EmptyModuleRemover.py Log Message: recover lost Builtins Index: Linker.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/Linker.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -p -d -r1.13 -r1.14 --- Linker.py 3 Dec 2003 00:37:47 -0000 1.13 +++ Linker.py 4 Dec 2003 01:08:36 -0000 1.14 @@ -54,9 +54,6 @@ class Linker(Composite, AST.Visitor, Typ if self.__dicts[-1].has_key(name): return self.__dicts[-1][name] - #for decl in self.__scopes[-1].declarations(): - # if hasattr(decl, 'name') and decl.name() == name: - # return decl return None def append(self, declaration): @@ -234,11 +231,11 @@ class Linker(Composite, AST.Visitor, Typ If there is already a Forward declaration, then this replaces it unless this is also a Forward. """ - + name = decl.name() dict = self.__dicts[-1] decls = self.top().declarations() - if dict.has_key(name) and name != ('dummy',): + if dict.has_key(name): prev = dict[name] if not isinstance(prev, AST.Forward): return @@ -249,6 +246,12 @@ class Linker(Composite, AST.Visitor, Typ return decls.append(decl) dict[name] = decl + + def visitBuiltin(self, builtin): + """preserve builtins unconditionally""" + + decls = self.top().declarations() + decls.append(builtin) def visitNamed(self, decl): Index: EmptyModuleRemover.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Processors/EmptyModuleRemover.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- EmptyModuleRemover.py 2 Dec 2003 14:35:53 -0000 1.6 +++ EmptyModuleRemover.py 4 Dec 2003 01:08:36 -0000 1.7 @@ -55,15 +55,9 @@ class EmptyModuleRemover (Processor, AST self.add(decl) - def visitGroup(self, group): - """Overrides recursive behaviour to just add the group""" - - self.add(group) - - def visitEnum(self, enum): - """Overrides recursive behaviour to just add the enum""" - - self.add(enum) + visitBuiltin = visitDeclaration + visitGroup = visitDeclaration + visitEnum = visitDeclaration def visitModule(self, module): """Visits all children of the module, and if there are no declarations From stefan at synopsis.fresco.org Thu Dec 4 01:13:49 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parsers/Cxx Parser.py,1.6,1.7 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx In directory frida:/tmp/cvs-serv12849/Synopsis/Parsers/Cxx Modified Files: Parser.py Log Message: accept input from the constructor Index: Parser.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parsers/Cxx/Parser.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- Parser.py 3 Dec 2003 03:43:26 -0000 1.6 +++ Parser.py 4 Dec 2003 01:13:46 -0000 1.7 @@ -31,10 +31,9 @@ class Parser(Processor): def process(self, ast, **kwds): - input = kwds.get('input') self.set_parameters(kwds) self.ast = ast - for file in input: + for file in self.input: self.ast = occ.parse(self.ast, file, self.extra_files, self.verbose, From stefan at synopsis.fresco.org Thu Dec 4 01:14:37 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/Boost synopsis.py,1.6,1.7 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/Boost In directory frida:/tmp/cvs-serv12866/demo/C++/Boost Modified Files: synopsis.py Log Message: cleanup Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/Boost/synopsis.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- synopsis.py 2 Dec 2003 16:20:29 -0000 1.6 +++ synopsis.py 4 Dec 2003 01:14:35 -0000 1.7 @@ -22,7 +22,6 @@ parser = Cxx.Parser(cppflags = ['-DPYTHO main_file_only = True, syntax_prefix = 'links/', xref_prefix = 'xref/', - extract_tails = True, emulate_compiler = 'g++', # 'extra_files' will go away shortly extra_files = extra_input) @@ -30,18 +29,15 @@ parser = Cxx.Parser(cppflags = ['-DPYTHO xref = XRefCompiler(prefix='xref/') # compile xref dictionary -linker = Linker(Stripper(), # strip prefix (see Linker.Stripper.Stripper docs) - NameMapper(), # apply name mapping if any (prefix adding, etc.) - SSComments(), # filter out any non-'//' comments +linker = Linker(SSComments(), # filter out any non-'//' comments Grouper2(), # group declarations according to '@group' tags - CommentStripper(), # strip any 'suspicious' comments Previous(), # attach '//<' comments + CommentStripper(), # strip any 'suspicious' comments AccessRestrictor()) # filter out unwanted ('private', say) declarations formatter = HTML.Formatter(stylesheet_file = '../../html.css') -process(parse2 = parser, - parse = Composite(parser, linker), +process(parse = Composite(parser, linker), xref = xref, link = linker, format = formatter) From stefan at synopsis.fresco.org Thu Dec 4 01:22:02 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Processors/Linker/second expected.xml,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Processors/Linker/second In directory frida:/tmp/cvs-serv13073/tests/Processors/Linker/second Added Files: expected.xml Log Message: more tests --- NEW FILE: expected.xml --- __gnu_cxx std /usr/include/c++/3.2/bits/stl_iterator.h /usr/include/c++/3.2/bits/stl_algobase.h /usr/lib/gcc-lib/i386-redhat-linux/3.2/include/limits.h /usr/include/libio.h /usr/lib/gcc-lib/i386-redhat-linux/3.2/include/stdarg.h /usr/include/bits/local_lim.h /usr/include/sys/sysmacros.h /usr/include/_G_config.h /usr/include/signal.h Processors/Linker/second/input/forward.h /usr/include/c++/3.2/memory /usr/include/bits/posix2_lim.h /usr/include/stdlib.h /usr/include/xlocale.h /usr/include/gnu/stubs.h /usr/include/c++/3.2/bits/concept_check.h /usr/lib/gcc-lib/i386-redhat-linux/3.2/include/syslimits.h /usr/include/gconv.h /usr/include/c++/3.2/bits/stl_tempbuf.h /usr/include/c++/3.2/bits/stl_iterator_base_types.h /usr/include/c++/3.2/string /usr/include/c++/3.2/bits/stl_alloc.h /usr/include/c++/3.2/bits/stl_iterator_base_funcs.h /usr/include/bits/sigthread.h /usr/include/sys/cdefs.h /usr/include/bits/sys_errlist.h /usr/include/bits/pthreadtypes.h /usr/include/bits/select.h /usr/include/alloca.h /usr/include/string.h /usr/include/c++/3.2/bits/stl_construct.h /usr/include/bits/stdio_lim.h /usr/include/c++/3.2/iosfwd /usr/include/c++/3.2/bits/stl_algo.h /usr/include/c++/3.2/bits/stl_uninitialized.h /usr/include/c++/3.2/exception_defines.h /usr/include/assert.h /usr/include/c++/3.2/bits/stl_heap.h /usr/include/c++/3.2/i386-redhat-linux/bits/atomicity.h /usr/include/c++/3.2/algorithm /usr/include/c++/3.2/cstdlib /usr/include/sys/types.h /usr/include/c++/3.2/i386-redhat-linux/bits/gthr.h /usr/include/bits/posix1_lim.h /usr/include/c++/3.2/bits/basic_string.tcc /usr/include/c++/3.2/bits/fpos.h /usr/include/c++/3.2/bits/char_traits.h /usr/include/stdio.h /usr/include/c++/3.2/ctime /usr/include/c++/3.2/climits Processors/Linker/second/input/definition.h /usr/include/bits/sigset.h /usr/include/bits/xopen_lim.h /usr/include/c++/3.2/cassert /usr/include/c++/3.2/bits/stl_function.h /usr/include/sched.h /usr/include/c++/3.2/bits/stl_pair.h Processors/Linker/second/input/CVS /usr/include/c++/3.2/bits/basic_string.h /usr/include/c++/3.2/i386-redhat-linux/bits/os_defines.h /usr/include/wchar.h /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h /usr/lib/gcc-lib/i386-redhat-linux/3.2/include/stddef.h /usr/include/bits/endian.h /usr/include/limits.h /usr/include/c++/3.2/bits/stl_raw_storage_iter.h /usr/include/c++/3.2/bits/type_traits.h /usr/include/bits/sched.h /usr/include/pthread.h /usr/include/c++/3.2/cstddef /usr/include/bits/wchar.h /usr/include/features.h /usr/include/c++/3.2/i386-redhat-linux/bits/c++config.h /usr/include/linux/limits.h /usr/include/c++/3.2/bits/stl_threads.h /usr/include/sys/select.h /usr/include/c++/3.2/cstdio /usr/include/bits/types.h /usr/include/bits/initspin.h /usr/include/bits/time.h /usr/include/c++/3.2/cwchar /usr/include/time.h /usr/include/c++/3.2/new /usr/include/c++/3.2/exception /usr/include/c++/3.2/i386-redhat-linux/bits/c++io.h /usr/include/c++/3.2/cstring /usr/include/endian.h /usr/include/c++/3.2/i386-redhat-linux/bits/gthr-default.h /usr/include/c++/3.2/bits/stringfwd.h /usr/include/c++/3.2/bits/functexcept.h /usr/include/bits/wordsize.h From stefan at synopsis.fresco.org Thu Dec 4 01:34:51 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/demo/C++/Boost synopsis.py,1.7,1.8 Message-ID: Update of /cvs/synopsis/Synopsis/demo/C++/Boost In directory frida:/tmp/cvs-serv13288 Modified Files: synopsis.py Log Message: reenable xref, source listing Index: synopsis.py =================================================================== RCS file: /cvs/synopsis/Synopsis/demo/C++/Boost/synopsis.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -p -d -r1.7 -r1.8 --- synopsis.py 4 Dec 2003 01:14:35 -0000 1.7 +++ synopsis.py 4 Dec 2003 01:34:49 -0000 1.8 @@ -6,6 +6,7 @@ from Synopsis.Parsers import Cxx from Synopsis.Processors import * from Synopsis.Formatters import Dump from Synopsis.Formatters import HTML +from Synopsis.Formatters.HTML.Pages import * # this is actually only here as a hack for backward compatibility. import glob @@ -35,7 +36,19 @@ linker = Linker(SSComments(), # fi CommentStripper(), # strip any 'suspicious' comments AccessRestrictor()) # filter out unwanted ('private', say) declarations -formatter = HTML.Formatter(stylesheet_file = '../../html.css') +formatter = HTML.Formatter(stylesheet_file = '../../html.css', + pages = [FramesIndex(), + Scope(), + ModuleListing(), + ModuleIndexer(), + FileListing(), + FileIndexer(), + FileDetails(), + InheritanceTree(), + InheritanceGraph(), + FileSource(prefix = 'links'), + NameIndex(), + XRef(xref_file = 'bpl.xref')]) process(parse = Composite(parser, linker), xref = xref, From stefan at synopsis.fresco.org Thu Dec 4 20:01:50 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML CommentFormatter.py,1.22,1.23 FormatStrategy.py,1.35,1.36 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML In directory frida:/tmp/cvs-serv656/Synopsis/Formatters/HTML Modified Files: CommentFormatter.py FormatStrategy.py Log Message: fix little typos Index: CommentFormatter.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML/CommentFormatter.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -p -d -r1.22 -r1.23 --- CommentFormatter.py 14 Nov 2003 14:51:09 -0000 1.22 +++ CommentFormatter.py 4 Dec 2003 20:01:44 -0000 1.23 @@ -44,7 +44,7 @@ class CommentFormatter: # Let each strategy format the text in turn for method in self.__format_methods: text = method(page, decl, text) - return text + return text def format_summary(self, page, decl): """Formats the summary of the first comment of the given @@ -79,9 +79,9 @@ class CommentFormatterStrategy(Parametri @param text the comment text to format """ - pass + return text - def format_summary(self, page, decl, summary): + def format_summary(self, page, decl, text): """Format the given comment summary @param page the Page to use for references and determining the correct relative filename. @@ -89,7 +89,7 @@ class CommentFormatterStrategy(Parametri @param summary the comment summary to format """ - pass + return text class QuoteHTML(CommentFormatterStrategy): """A formatter that quotes HTML characters like the angle brackets and the Index: FormatStrategy.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML/FormatStrategy.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -p -d -r1.35 -r1.36 --- FormatStrategy.py 19 Nov 2003 17:15:06 -0000 1.35 +++ FormatStrategy.py 4 Dec 2003 20:01:44 -0000 1.36 @@ -461,10 +461,11 @@ class DetailAST(BaseAST): class DetailCommenter(Default): """Adds summary comments to all declarations""" + def format_declaration(self, decl): + text = self.processor.comments.format(self.page, decl) - if text: - return desc(text) + if text: return desc(text) return '' class ClassHierarchySimple(Strategy): @@ -534,13 +535,16 @@ class ClassHierarchyGraph(ClassHierarchy class Inheritance(Default): """Prints just the name of each declaration, with a link to its doc""" + def format_declaration(self, decl, label=None): + if not label: label = decl.name()[-1] fullname = Util.ccolonName(decl.name(), self.formatter.scope()) title = decl.type() + " " + anglebrackets(fullname) return self.reference(decl.name(), label=label, title=title) + ' ' def format_function(self, decl): + return self.format_declaration(decl, label=decl.realname()[-1]) def format_operation(self, decl): return self.format_function(decl) From stefan at synopsis.fresco.org Thu Dec 4 21:04:30 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:14 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML Formatter.py,1.13,1.14 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML In directory frida:/tmp/cvs-serv1738 Modified Files: Formatter.py Log Message: put comment formatters into their own package Index: Formatter.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML/Formatter.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -p -d -r1.13 -r1.14 --- Formatter.py 22 Nov 2003 21:45:59 -0000 1.13 +++ Formatter.py 4 Dec 2003 21:04:27 -0000 1.14 @@ -15,9 +15,9 @@ from Synopsis.Formatters.ClassTree impor from Synopsis.Formatters.XRef import CrossReferencer from FileLayout import * from TreeFormatter import * -from CommentFormatter import * from DeclarationStyle import * from Pages import * +import Comments import Tags class Struct: @@ -25,6 +25,55 @@ class Struct: def __init__(self, **keys): for name, value in keys.items(): setattr(self, name, value) +class CommentFormatter: + """A class that takes a Declaration and formats its comments into a string.""" + + def __init__(self, formatters): + + # Cache the bound methods + self.__format_methods = map(lambda f:f.format, formatters) + self.__format_summary_methods = map(lambda f:f.format_summary, formatters) + # Weed out the unneccessary calls to the empty base methods + base = Comments.Formatter.format.im_func + self.__format_methods = filter( + lambda m, base=base: m.im_func is not base, self.__format_methods) + base = Comments.Formatter.format_summary.im_func + self.__format_summary_methods = filter( + lambda m, base=base: m.im_func is not base, self.__format_summary_methods) + + def format(self, page, decl): + """Formats the first comment of the given AST.Declaration. + Note that the Linker.Comments.Summarizer CommentProcessor is supposed + to have combined all comments first in the Linker stage. + @return the formatted text + """ + + comments = decl.comments() + if len(comments) == 0: return '' + text = comments[0].text() + if not text: return '' + # Let each strategy format the text in turn + for method in self.__format_methods: + text = method(page, decl, text) + return text + + def format_summary(self, page, decl): + """Formats the summary of the first comment of the given + AST.Declaration. + Note that the Linker.Comments.Summarizer CommentProcessor is supposed + to have combined all comments first in the Linker stage. + @return the formatted summary text + """ + + comments = decl.comments() + if len(comments) == 0: return '' + text = comments[0].summary() + if not text: return '' + # Let each strategy format the text in turn + for method in self.__format_summary_methods: + text = method(page, decl, text) + return text + class Formatter(Processor): stylesheet = Parameter('style.css', '') @@ -46,8 +95,8 @@ class Formatter(Processor): NameIndex()], '') - comment_formatters = Parameter([QuoteHTML(), - SectionFormatter()], + comment_formatters = Parameter([Comments.QuoteHTML(), + Comments.Section()], '') tree_formatter = Parameter(TreeFormatter(), 'define how to lay out tree views') @@ -64,7 +113,7 @@ class Formatter(Processor): self.decl_style = Style() for f in self.comment_formatters: f.init(self) - self.comments = CommentFormatter(self) + self.comments = CommentFormatter(self.comment_formatters) # Create the Class Tree (TODO: only if needed...) self.class_tree = ClassTree() # Create the File Tree (TODO: only if needed...) From stefan at synopsis.fresco.org Thu Dec 4 21:04:30 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:07:15 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatters/HTML/Comments Javadoc.py,NONE,1.1 Qtdoc.py,NONE,1.1 QuoteHTML.py,NONE,1.1 Section.py,NONE,1.1 __init__.py,NONE,1.1 Formatter.py,1.23,1.24 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML/Comments In directory frida:/tmp/cvs-serv1738/Comments Modified Files: Formatter.py Added Files: Javadoc.py Qtdoc.py QuoteHTML.py Section.py __init__.py Log Message: put comment formatters into their own package --- NEW FILE: Javadoc.py --- # $Id: Javadoc.py,v 1.1 2003/12/04 21:04:28 stefan Exp $ # # Copyright (C) 2000 Stephen Davies # Copyright (C) 2000 Stefan Seefeld # All rights reserved. # Licensed to the public under the terms of the GNU LGPL (>= 2), # see the file COPYING for details. # from Formatter import Formatter import re class Javadoc(Formatter): """A formatter that formats comments similar to Javadoc @tags""" # @see IDL/Foo.Bar _re_see = '@see (([A-Za-z+]+)/)?(([A-Za-z_]+\.?)+)' _re_see_line = '^[ \t]*@see[ \t]+(([A-Za-z+]+)/)?(([A-Za-z_]+\.?)+)(\([^)]*\))?([ \t]+(.*))?$' _re_param = '^[ \t]*@param[ \t]+(?P(A-Za-z+]+)([ \t]+(?P.*))?$' def __init__(self): """Create regex objects for regexps""" self.re_see = re.compile(self._re_see) self.re_see_line = re.compile(self._re_see_line,re.M) def extract(self, regexp, str): """Extracts all matches of the regexp from the text. The MatchObjects are returned in a list""" mo = regexp.search(str) ret = [] while mo: ret.append(mo) start, end = mo.start(), mo.end() str = str[:start] + str[end:] mo = regexp.search(str, start) return str, ret def format(self, page, decl, text): """Format any @tags in the text, and any @tags stored by the JavaTags CommentProcessor in the Linker stage.""" if text is None: return text see_tags, attr_tags, param_tags, return_tag = [], [], [], None tags = decl.comments()[0].tags() # Parse each of the tags for tag in tags: name, rest = tag.name(), tag.text() if name == '@see': see_tags.append(string.split(rest,' ',1)) elif name == '@param': param_tags.append(string.split(rest,' ',1)) elif name == '@return': return_tag = rest elif name == '@attr': attr_tags.append(string.split(rest,' ',1)) else: # unknown tag pass return "%s%s%s%s%s"%(self.format_inline_see(page, decl, text), self.format_params(param_tags), self.format_attrs(attr_tags), self.format_return(return_tag), self.format_see(page, see_tags, decl)) def format_inline_see(self, page, decl, text): """Formats inline @see tags in the text""" #TODO change to link or whatever javadoc uses mo = self.re_see.search(text) while mo: groups, start, end = mo.groups(), mo.start(), mo.end() lang = groups[1] or '' link = self.find_link(page, groups[2], decl) text = text[:start] + link + text[end:] end = start + len(link) mo = self.re_see.search(text, end) return text def format_params(self, param_tags): """Formats a list of (param, description) tags""" if not len(param_tags): return '' return div('tag-heading',"Parameters:") + \ div('tag-section', string.join( map(lambda p:"%s - %s"%(p[0],p[1]), param_tags), '
')) def format_attrs(self, attr_tags): """Formats a list of (attr, description) tags""" if not len(attr_tags): return '' table = '%s
' row = '%s%s' return div('tag-heading',"Attributes:") + \ table%string.join(map(lambda p,row=row:row%(p[0],p[1]), attr_tags)) def format_return(self, return_tag): """Formats a since description string""" if not return_tag: return '' return div('tag-heading',"Return:")+div('tag-section',return_tag) def format_see(self, page, see_tags, decl): """Formats a list of (ref,description) tags""" if not len(see_tags): return '' seestr = div('tag-heading', "See Also:") seelist = [] for see in see_tags: ref,desc = see[0], len(see)>1 and see[1] or '' link = self.find_link(page, ref, decl) seelist.append(link + desc) return seestr + div('tag-section', string.join(seelist,'\n
\n')) def find_link(self, page, ref, decl): """Given a "reference" and a declaration, returns a HTML link. Various methods are tried to resolve the reference. First the parameters are taken off, then we try to split the ref using '.' or '::'. The params are added back, and then we try to match this scoped name against the current scope. If that fails, then we recursively try enclosing scopes. """ # Remove params index, label = string.find(ref,'('), ref if index >= 0: params = ref[index:] ref = ref[:index] else: params = '' # Split ref ref = string.split(ref, '.') if len(ref) == 1: ref = string.split(ref[0], '::') # Add params back ref = ref[:-1] + [ref[-1]+params] # Find in all scopes scope = list(decl.name()) while 1: entry = self._find_link_at(ref, scope) if entry: url = rel(page.filename(), entry.link) return href(url, label) if len(scope) == 0: break del scope[-1] # Not found return label+" " def _find_link_at(self, ref, scope): # Try scope + ref[0] entry = self.processor.toc.lookup(scope+ref[:1]) if entry: # Found. if len(ref) > 1: # Find sub-refs entry = self._find_link_at(ref[1:], scope+ref[:1]) if entry: # Recursive sub-ref was okay! return entry else: # This was the last scope in ref. Done! return entry # Try a method name match: if len(ref) == 1: entry = self._find_method_entry(ref[0], scope) if entry: return entry # Not found at this scope return None def _find_method_entry(self, name, scope): """Tries to find a TOC entry for a method adjacent to decl. The enclosing scope is found using the types dictionary, and the realname()'s of all the functions compared to ref.""" try: scope = self.processor.ast.types()[scope] except KeyError: #print "No parent scope:",decl.name()[:-1] return None if not scope: return None if not isinstance(scope, Type.Declared): return None scope = scope.declaration() if not isinstance(scope, AST.Scope): return None for decl in scope.declarations(): if isinstance(decl, AST.Function): if decl.realname()[-1] == name: return self.processor.toc.lookup(decl.name()) # Failed return None --- NEW FILE: Qtdoc.py --- # $Id: Qtdoc.py,v 1.1 2003/12/04 21:04:28 stefan Exp $ # # Copyright (C) 2000 Stephen Davies # Copyright (C) 2000 Stefan Seefeld # All rights reserved. # Licensed to the public under the terms of the GNU LGPL (>= 2), # see the file COPYING for details. # from Javadoc import Javadoc class Qtdoc(Javadoc): """A formatter that uses Qt-style doc tags.""" _re_see = '@see (([A-Za-z+]+)/)?(([A-Za-z_]+\.?)+)' _re_tags = r'((?P.*?)\n)?[ \t]*(?P\\[a-zA-Z]+[ \t]+.*)' _re_seealso = '[ \t]*(,|and|,[ \t]*and)[ \t]*' def __init__(self): Javadoc.__init__(self) self.re_seealso = re.compile(self._re_seealso) def parse_text(self, str, decl): if str is None: return str #str, see = self.extract(self.re_see_line, str) see_tags, param_tags, return_tag = [], [], None joiner = lambda x,y: len(y) and y[0]=='\\' and x+[y] or x[:-1]+[x[-1]+y] str, tags = self.parse_tags(str, joiner) # Parse each of the tags for line in tags: tag, rest = string.split(line,' ',1) if tag == '\\sa': see_tags.extend(map(lambda x: [x,''], self.re_seealso.split(rest))) elif tag == '\\param': param_tags.append(string.split(rest,' ',1)) elif tag == '\\return': return_tag = rest else: # Warning: unknown tag pass return "%s%s%s%s"%(self.parse_see(str, decl), self.format_params(param_tags), self.format_return(return_tag), self.format_see(see_tags, decl)) def format_see(self, see_tags, decl): """Formats a list of (ref,description) tags""" if not len(see_tags): return '' seestr = div('tag-see-header', "See Also:") seelist = [] for see in see_tags: ref,desc = see[0], len(see)>1 and see[1] or '' tag = self.re_seealso.match(ref) and ' %s '%ref or self.find_link(ref, decl) seelist.append(span('tag-see', tag+desc)) return seestr + string.join(seelist,'') --- NEW FILE: QuoteHTML.py --- # $Id: QuoteHTML.py,v 1.1 2003/12/04 21:04:28 stefan Exp $ # # Copyright (C) 2000 Stephen Davies # Copyright (C) 2000 Stefan Seefeld # All rights reserved. # Licensed to the public under the terms of the GNU LGPL (>= 2), # see the file COPYING for details. # from Formatter import Formatter class QuoteHTML(Formatter): """A formatter that quotes HTML characters like angle brackets and ampersand. Formats both text and summary.""" def format(self, page, decl, text): """Replace angle brackets with HTML codes""" text = text.replace('&', '&') text = text.replace('<', '<') text = text.replace('>', '>') return text def format_summary(self, page, decl, text): """Replace angle brackets with HTML codes""" text = text.replace('&', '&') text = text.replace('<', '<') text = text.replace('>', '>') return text --- NEW FILE: Section.py --- # $Id: Section.py,v 1.1 2003/12/04 21:04:28 stefan Exp $ # # Copyright (C) 2000 Stephen Davies # Copyright (C) 2000 Stefan Seefeld # All rights reserved. # Licensed to the public under the terms of the GNU LGPL (>= 2), # see the file COPYING for details. # from Formatter import Formatter import re class Section(Formatter): """A test formatter""" __re_break = '\n[ \t]*\n' def __init__(self): self.re_break = re.compile(Section.__re_break) def format(self, page, decl, text): if text is None: return text para = '

\n

' mo = self.re_break.search(text) while mo: start, end = mo.start(), mo.end() text = text[:start] + para + text[end:] end = start + len(para) mo = self.re_break.search(text, end) return '

%s

'%text --- NEW FILE: __init__.py --- from Formatter import Formatter from Javadoc import Javadoc from Qtdoc import Qtdoc from QuoteHTML import QuoteHTML from Section import Section Index: Formatter.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatters/HTML/Comments/Formatter.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -p -d -r1.23 -r1.24 --- Formatter.py 4 Dec 2003 20:01:44 -0000 1.23 +++ Formatter.py 4 Dec 2003 21:04:27 -0000 1.24 @@ -7,63 +7,10 @@ # see the file COPYING for details. # -"""CommentParser, CommentFormatter and derivatives.""" - from Synopsis.Processor import Parametrized, Parameter from Synopsis import AST, Type, Util -from Tags import * - -import re, string - -class CommentFormatter: - """A class that takes a Declaration and formats its comments into a string.""" - def __init__(self, processor): - self.__formatters = processor.comment_formatters - # Cache the bound methods - self.__format_methods = map(lambda f:f.format, self.__formatters) - self.__format_summary_methods = map(lambda f:f.format_summary, self.__formatters) - # Weed out the unneccessary calls to the empty base methods - base = CommentFormatterStrategy.format.im_func - self.__format_methods = filter( - lambda m, base=base: m.im_func is not base, self.__format_methods) - base = CommentFormatterStrategy.format_summary.im_func - self.__format_summary_methods = filter( - lambda m, base=base: m.im_func is not base, self.__format_summary_methods) - - def format(self, page, decl): - """Formats the first comment of the given AST.Declaration. - Note that the Linker.Comments.Summarizer CommentProcessor is supposed - to have combined all comments first in the Linker stage. - @return the formatted text - """ - - comments = decl.comments() - if len(comments) == 0: return '' - text = comments[0].text() - if not text: return '' - # Let each strategy format the text in turn - for method in self.__format_methods: - text = method(page, decl, text) - return text - - def format_summary(self, page, decl): - """Formats the summary of the first comment of the given - AST.Declaration. - Note that the Linker.Comments.Summarizer CommentProcessor is supposed - to have combined all comments first in the Linker stage. - @return the formatted summary text - """ - - comments = decl.comments() - if len(comments) == 0: return '' - text = comments[0].summary() - if not text: return '' - # Let each strategy format the text in turn - for method in self.__format_summary_methods: - text = method(page, decl, text) - return text -class CommentFormatterStrategy(Parametrized): +class Formatter(Parametrized): """Interface class that takes a comment and formats its summary and/or detail strings.""" @@ -90,283 +37,3 @@ class CommentFormatterStrategy(Parametri """ return text - -class QuoteHTML(CommentFormatterStrategy): - """A formatter that quotes HTML characters like the angle brackets and the - ampersand. Formats both text and summary.""" - - def format(self, page, decl, text): - """Replace angle brackets with HTML codes""" - - text = text.replace('&', '&') - text = text.replace('<', '<') - text = text.replace('>', '>') - return text - - def format_summary(self, page, decl, text): - """Replace angle brackets with HTML codes""" - - text = text.replace('&', '&') - text = text.replace('<', '<') - text = text.replace('>', '>') - return text - -class JavadocFormatter(CommentFormatterStrategy): - """A formatter that formats comments similar to Javadoc @tags""" - - # @see IDL/Foo.Bar - _re_see = '@see (([A-Za-z+]+)/)?(([A-Za-z_]+\.?)+)' - _re_see_line = '^[ \t]*@see[ \t]+(([A-Za-z+]+)/)?(([A-Za-z_]+\.?)+)(\([^)]*\))?([ \t]+(.*))?$' - _re_param = '^[ \t]*@param[ \t]+(?P(A-Za-z+]+)([ \t]+(?P.*))?$' - - def __init__(self): - """Create regex objects for regexps""" - - self.re_see = re.compile(self._re_see) - self.re_see_line = re.compile(self._re_see_line,re.M) - - def extract(self, regexp, str): - """Extracts all matches of the regexp from the text. The MatchObjects - are returned in a list""" - - mo = regexp.search(str) - ret = [] - while mo: - ret.append(mo) - start, end = mo.start(), mo.end() - str = str[:start] + str[end:] - mo = regexp.search(str, start) - return str, ret - - def format(self, page, decl, text): - """Format any @tags in the text, and any @tags stored by the JavaTags - CommentProcessor in the Linker stage.""" - - if text is None: return text - see_tags, attr_tags, param_tags, return_tag = [], [], [], None - tags = decl.comments()[0].tags() - # Parse each of the tags - for tag in tags: - name, rest = tag.name(), tag.text() - if name == '@see': - see_tags.append(string.split(rest,' ',1)) - elif name == '@param': - param_tags.append(string.split(rest,' ',1)) - elif name == '@return': - return_tag = rest - elif name == '@attr': - attr_tags.append(string.split(rest,' ',1)) - else: - # unknown tag - pass - return "%s%s%s%s%s"%(self.format_inline_see(page, decl, text), - self.format_params(param_tags), - self.format_attrs(attr_tags), - self.format_return(return_tag), - self.format_see(page, see_tags, decl)) - - def format_inline_see(self, page, decl, text): - """Formats inline @see tags in the text""" - - #TODO change to link or whatever javadoc uses - mo = self.re_see.search(text) - while mo: - groups, start, end = mo.groups(), mo.start(), mo.end() - lang = groups[1] or '' - link = self.find_link(page, groups[2], decl) - text = text[:start] + link + text[end:] - end = start + len(link) - mo = self.re_see.search(text, end) - return text - - def format_params(self, param_tags): - """Formats a list of (param, description) tags""" - - if not len(param_tags): return '' - return div('tag-heading',"Parameters:") + \ - div('tag-section', string.join( - map(lambda p:"%s - %s"%(p[0],p[1]), param_tags), - '
')) - - def format_attrs(self, attr_tags): - """Formats a list of (attr, description) tags""" - - if not len(attr_tags): return '' - table = '%s
' - row = '%s%s' - return div('tag-heading',"Attributes:") + \ - table%string.join(map(lambda p,row=row:row%(p[0],p[1]), attr_tags)) - - def format_return(self, return_tag): - """Formats a since description string""" - - if not return_tag: return '' - return div('tag-heading',"Return:")+div('tag-section',return_tag) - - def format_see(self, page, see_tags, decl): - """Formats a list of (ref,description) tags""" - - if not len(see_tags): return '' - seestr = div('tag-heading', "See Also:") - seelist = [] - for see in see_tags: - ref,desc = see[0], len(see)>1 and see[1] or '' - link = self.find_link(page, ref, decl) - seelist.append(link + desc) - return seestr + div('tag-section', string.join(seelist,'\n
\n')) - - def find_link(self, page, ref, decl): - """Given a "reference" and a declaration, returns a HTML link. - Various methods are tried to resolve the reference. First the - parameters are taken off, then we try to split the ref using '.' or - '::'. The params are added back, and then we try to match this scoped - name against the current scope. If that fails, then we recursively try - enclosing scopes. - """ - - # Remove params - index, label = string.find(ref,'('), ref - if index >= 0: - params = ref[index:] - ref = ref[:index] - else: - params = '' - # Split ref - ref = string.split(ref, '.') - if len(ref) == 1: - ref = string.split(ref[0], '::') - # Add params back - ref = ref[:-1] + [ref[-1]+params] - # Find in all scopes - scope = list(decl.name()) - while 1: - entry = self._find_link_at(ref, scope) - if entry: - url = rel(page.filename(), entry.link) - return href(url, label) - if len(scope) == 0: break - del scope[-1] - # N