From stefan at synopsis.fresco.org Fri Oct 3 14:27:35 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter DUMP.py,1.14,1.15 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter In directory frida:/tmp/cvs-serv19545 Modified Files: DUMP.py Log Message: turn off reference identification and pretty printing by default such that the DUMP can be used more easily with 'diff' Index: DUMP.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatter/DUMP.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -p -d -r1.14 -r1.15 --- DUMP.py 12 Dec 2002 17:25:32 -0000 1.14 +++ DUMP.py 3 Oct 2003 14:27:33 -0000 1.15 @@ -19,6 +19,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.15 2003/10/03 14:27:33 stefan +# turn off reference identification and pretty printing by default such that the DUMP can be used more easily with 'diff' +# # Revision 1.14 2002/12/12 17:25:32 chalky # Implemented Include support for C++ parser. A few other minor fixes. # @@ -62,7 +65,7 @@ from Synopsis.Core import Type, AST verbose = 0 class Dumper: - def __init__(self): + def __init__(self, identify, pretty): self.handlers = { types.NoneType : self.visitNone, types.TypeType : self.visitType, @@ -75,6 +78,8 @@ class Dumper: types.DictType : self.visitDict, types.InstanceType : self.visitInstance, } + self.identify = identify + self.pretty = pretty self.clear() def clear(self): self.indent_level = 0 @@ -105,11 +110,12 @@ class Dumper: if self.visited.has_key(i): if t == types.InstanceType: t = obj.__class__.__name__+" instance" if hasattr(obj, 'name'): - self.write(""%(t,i,string.join(obj.name(),"::"))) + ident = self.identify and '( %d ) '%i or '' + self.write(""%(t,ident,string.join(obj.name(),"::"))) elif hasattr(obj, 'filename'): - self.write(""%(t,i,obj.filename())) + self.write(""%(t,ident,obj.filename())) else: - self.write(""%(t,i)) + self.write(""%(t,ident)) return if self.handlers.has_key(t): self.handlers[t](obj) @@ -220,10 +226,8 @@ class Dumper: obj.is_next(), obj.target().filename())) return self.visited[id(obj)] = None - self.write("%s.%s = "%( - obj.__class__.__module__, - obj.__class__.__name__ - )) + template = self.pretty and "%s.%s = " or "%s.%s = " + self.write(template%(obj.__class__.__module__,obj.__class__.__name__)) self.visitDict(obj.__dict__, self._instAttr) def usage(): @@ -234,32 +238,38 @@ def usage(): -d Show declarations -t Show types -f Show forwards also + -i identify referenced objects + -p enable pretty printing (If none of -d, -t or -f specified, will default to -d, -t) """ def __parseArgs(args): global output, verbose, show_decls, show_types, show_forwards, show_files + global identify, pretty # Set defaults output = sys.stdout show_decls = 0 show_types = 0 show_forwards = 0 show_files = 1 + identify = 0 + pretty = 0 try: - opts,remainder = getopt.getopt(args, "o:vdtf") + opts,remainder = getopt.getopt(args, "o:vdtfip") except getopt.error, e: sys.stderr.write("Error in arguments: " + str(e) + "\n") sys.exit(1) for opt in opts: o,a = opt - if o == "-o": output = open(a, "w") elif o == "-v": verbose = 1 elif o == "-d": show_decls = 1 elif o == "-t": show_types = 1 elif o == "-f": show_forwards = 1 + elif o == "-i": identify = 1 + elif o == "-p": pretty = 1 # Consolidate - if no show_ selected, show decls and types if not (show_decls or show_types or show_forwards): @@ -272,7 +282,7 @@ def format(args, ast, config_obj): #formatter = ASCIIFormatter(output) #for type in dictionary: # type.output(formatter) - dumper = Dumper() + dumper = Dumper(identify, pretty) show_sourcefiles = 0 if show_decls: print "*** Declarations:" From stefan at synopsis.fresco.org Fri Oct 3 14:47:56 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter DUMP.py,1.15,1.16 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter In directory frida:/tmp/cvs-serv20023/Synopsis/Formatter Modified Files: DUMP.py Log Message: let DUMP finally respect the '-o' option Index: DUMP.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatter/DUMP.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -p -d -r1.15 -r1.16 --- DUMP.py 3 Oct 2003 14:27:33 -0000 1.15 +++ DUMP.py 3 Oct 2003 14:47:54 -0000 1.16 @@ -19,6 +19,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.16 2003/10/03 14:47:54 stefan +# let DUMP finally respect the '-o' option +# # Revision 1.15 2003/10/03 14:27:33 stefan # turn off reference identification and pretty printing by default such that the DUMP can be used more easily with 'diff' # @@ -65,7 +68,7 @@ from Synopsis.Core import Type, AST verbose = 0 class Dumper: - def __init__(self, identify, pretty): + def __init__(self, output, identify, pretty): self.handlers = { types.NoneType : self.visitNone, types.TypeType : self.visitType, @@ -78,6 +81,7 @@ class Dumper: types.DictType : self.visitDict, types.InstanceType : self.visitInstance, } + self.output = output self.identify = identify self.pretty = pretty self.clear() @@ -94,10 +98,10 @@ class Dumper: self.write(text) def write(self, text): if self.newline: - sys.stdout.write("\n") - sys.stdout.write(self.indent_string) + self.output.write("\n") + self.output.write(self.indent_string) self.newline = 0 - sys.stdout.write(str(text)) + self.output.write(str(text)) def indent(self, str=" "): self.indent_level = self.indent_level + 1 self.indent_string = self.indent_string+str @@ -282,17 +286,17 @@ def format(args, ast, config_obj): #formatter = ASCIIFormatter(output) #for type in dictionary: # type.output(formatter) - dumper = Dumper(identify, pretty) + dumper = Dumper(output, identify, pretty) show_sourcefiles = 0 if show_decls: - print "*** Declarations:" + output.write("*** Declarations:\n") dumper.visit(ast.declarations()) if show_types: - if show_decls: print "\n\n\n" - print "*** Types:" + if show_decls: output.write("\n\n\n") + output.write("*** Types:\n") dumper.visit(ast.types()) if show_files: show_sourcefiles = 1 - print "\n\n\n" - print "*** Files:" + output.write("\n\n\n") + output.write("*** Files:\n") dumper.visit(ast.files()) From stefan at synopsis.fresco.org Fri Oct 3 14:56:14 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests In directory frida:/tmp/cvs-serv20271/tests Log Message: Directory /cvs/synopsis/Synopsis/tests added to the repository From stefan at synopsis.fresco.org Fri Oct 3 14:56:28 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser In directory frida:/tmp/cvs-serv20291/tests/Parser Log Message: Directory /cvs/synopsis/Synopsis/tests/Parser added to the repository From stefan at synopsis.fresco.org Fri Oct 3 14:56:41 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++ - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++ In directory frida:/tmp/cvs-serv20305/tests/Parser/C++ Log Message: Directory /cvs/synopsis/Synopsis/tests/Parser/C++ added to the repository From stefan at synopsis.fresco.org Fri Oct 3 14:56:53 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/src - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/src In directory frida:/tmp/cvs-serv20318/tests/Parser/C++/src Log Message: Directory /cvs/synopsis/Synopsis/tests/Parser/C++/src added to the repository From stefan at synopsis.fresco.org Fri Oct 3 14:57:18 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:36 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/expected - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/expected In directory frida:/tmp/cvs-serv20336/tests/Parser/C++/expected Log Message: Directory /cvs/synopsis/Synopsis/tests/Parser/C++/expected added to the repository From stefan at synopsis.fresco.org Fri Oct 3 14:58:13 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:37 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/src cast.cc,NONE,1.1 comment_proximity.cc,NONE,1.1 comments.cc,NONE,1.1 concat.cc,NONE,1.1 condition.cc,NONE,1.1 for.cc,NONE,1.1 forward_class.cc,NONE,1.1 func.cc,NONE,1.1 func_ptr.cc,NONE,1.1 func_template.cc,NONE,1.1 func_template_arg.cc,NONE,1.1 if.cc,NONE,1.1 koenig.cc,NONE,1.1 macro.cc,NONE,1.1 operator.cc,NONE,1.1 static_cast.cc,NONE,1.1 std.cc,NONE,1.1 template.cc,NONE,1.1 template_spec.cc,NONE,1.1 template_spec2.cc,NONE,1.1 try.cc,NONE,1.1 typename.cc,NONE,1.1 using.cc,NONE,1.1 using2.cc,NONE,1.1 using3.cc,NONE,1.1 using4.cc,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/src In directory frida:/tmp/cvs-serv20349/tests/Parser/C++/src Added Files: cast.cc comment_proximity.cc comments.cc concat.cc condition.cc for.cc forward_class.cc func.cc func_ptr.cc func_template.cc func_template_arg.cc if.cc koenig.cc macro.cc operator.cc static_cast.cc std.cc template.cc template_spec.cc template_spec2.cc try.cc typename.cc using.cc using2.cc using3.cc using4.cc Log Message: reorganize unit tests for C++ parser --- NEW FILE: cast.cc --- typedef int Foo; void func() { (Foo)1; (Foo*)1; (const Foo&)1; } --- NEW FILE: comment_proximity.cc --- // Comment at start int test1; // Test2: This should have a comment, unlike test1 // It should also have two lines int test2; /* A comment by itself * Over multiple lines. */ int test3; /* This comment should be ignored. */ /* Test4: Should have a comment * */ int test4; /* Test5: This should have a comment, unlike test 3 * Which had a gap. */ int test5; //< This should still be tail-appended! --- NEW FILE: comments.cc --- // 1. Comments Test: One line cpp test // 2. Two line cpp test // Second line of test /* 3. One line c test */ /* 4. Another c test */ /* 5. Two on one */ /* 6. line */ /* 7. Multi * line */ --- NEW FILE: concat.cc --- // According to spec, the ## operator must produce a valid PP token. // Unfortunately, no compilers known to man enforce this rule except UCPP, so // this test is to make sure it is 'fixed' to ignore the error. #define CAT(a,b) a ## b class Foo {}; void CAT(operator,+) (const Foo&, const Foo&) {} void operator CAT(+,=) (const Foo&, const Foo&) {} --- NEW FILE: condition.cc --- // Tests the ability to use a declaration in the condition of an if or switch struct X { operator bool() const {return true;} struct Y { operator bool() const {return true;} }; }; void foo() { int _i; X _x; X::Y _y; if (int i = 3) {} if (const int i = 3) {} if (const int* i = &_i) {} if (int* const i = &_i) {} if (X foo = _x) {} if (const X foo = _x) {} if (const X* foo = &_x) {} if (X* const foo = &_x) {} if (X::Y foo = _y) {} if (const X::Y foo = _y) {} if (const X::Y* foo = &_y) {} if (X::Y* const foo = &_y) {} switch (int i = 3) {} switch (const int i = 3) {} } --- NEW FILE: for.cc --- void func() { int x; for (int x = 3, y = 10; x < y; ++x) { cout << x; } } --- NEW FILE: forward_class.cc --- class X { public: void f(int); int a; }; class Y; int X::* pmi = &X::a; void (X::* pmf)(int) = &X::f; double X::* pmd; char Y::* pmc; X obj; X* pobj; void foo() { obj.*pmi = 7; // assign 7 to an integer // member of obj (obj.*pmf)(7); // call a function member of obj // with the argument 7 pobj->*pmi = 7; // assign 7 to an integer (pobj->*pmf)(7); // call a function member of obj } --- NEW FILE: func.cc --- void func(char); void func(int); void func(double); void func(const char*); void test() { func('c'); func(123); func(1.2); func("s"); } --- NEW FILE: func_ptr.cc --- // Tests function pointers typedef void PyObject; // A function which takes a func ptr as a parameter void insert(void* (*convert)(PyObject*), bool yesno); // A function which takes a func ptr as a parameter void insert(void* (*convert)(PyObject*, int), bool yesno); // A function which returns a func ptr void* (*insert2(int))(PyObject*); int main() { (void)insert2(1); } --- NEW FILE: func_template.cc --- // Test function templates // Test template arg template int func1(A a) { return 0; }; // Test template return template A func2(int i) { return 0; }; // Test template arg and return template A func2(A a) { return 0; }; // Test template arg and return w/ different types template B func2(A a) { return 0; }; // Test template arg and return w/ different types. Function declaration template B func2(A a); --- NEW FILE: func_template_arg.cc --- // Test function pointers as template arguments template struct function { }; // Test template class with function argument // (not really a template function) template struct function { }; // Test return type fptr template struct function { }; // Test return type fptr template struct function { }; --- NEW FILE: if.cc --- // If test void func() { int x = 0; if (x) cout << "Hi"; // test x = "`func()::x" if (x == 2) cout << "hi"; // test x = "`func()::x" if (!x) cout << "foo"; // test x = "`func()::x" if (x) cout << "one"; else cout << "two"; if (x) {cout << "one"; cout << "two"; } else { cout<<"three"; } } --- NEW FILE: koenig.cc --- namespace NS { struct A {}; int operator +(A, A); }; void func(int); void func(NS::A) { NS::A x, y; func(x + y); // should call func(int) } --- NEW FILE: macro.cc --- int x; #define LONGER 12345678 #define SHORTER 1234 #define LINKINSIDE x #define ARGS(a, b, c) x int A = LONGER, A2 = x; int B = SHORTER, B2 = x; int C = LINKINSIDE, C2 = x; int D = ARGS(1, 2, 3), D2 = x; --- NEW FILE: operator.cc --- struct A {}; struct B {}; A operator +(const B&, const B&); int operator +(const A&, const A&); void func(A); void func(B); void func(int); void main() { B x, y; func( (x + y) + (x + y) ); // should call func(int), test func = "func(int)" } --- NEW FILE: static_cast.cc --- #define CAT(a, b) CAT_D(a, b) #define CAT_D(a, b) a ## b #define AB(x, y) CAT(x, y) // There should be a variable XY here int CAT(A, B)(X, Y) ; --- NEW FILE: std.cc --- #include namespace Foo { void func(std::vector array); } --- NEW FILE: template.cc --- struct Object { float f; double func(); Object(); Object(const Object&); Object& operator = (const Object&); }; template class list { T* m_array; int m_size; public: list(); list(T*); T& operator [] (int index) { return m_array[index]; } int size() { return m_size; } void replace(int index, const T& with) { m_array[index] = with; } }; void main() { list a_list; a_list.replace(1, Object()); Object b(a_list[1]); a_list[2].func(); b = a_list[3]; } --- NEW FILE: template_spec.cc --- // Test template specializations template class list { public: list(T*, int size); }; template <> class list { public: list(void*, int size) {} }; template <> class list { public: list(int*, int size) {} }; --- NEW FILE: template_spec2.cc --- // Test template specializations #2 template class list { public: list(T*, int size); int size() { return I; } }; template class list { public: list(void*, int size) {} int size() { return 0; } }; template class list { public: list(int*, int size) {} int size() { return I; } }; --- NEW FILE: try.cc --- void func() { try { cout << bar; } catch (string foo) { cout << "Error: " << foo << endl; } catch (...) { cout << "Catchall"; } } --- NEW FILE: typename.cc --- template ::fast TruncPoly> class crc_optimal { // Implementation type typedef detail::mask_uint_t masking_type; public: // Type typedef typename masking_type::fast value_type; // Constants for the template parameters static const std::size_t bit_count = Bits; }; --- NEW FILE: using.cc --- namespace Foo { int x; } void func() { using namespace Foo; x; } void func2() { using namespace Foo = Bar; Bar::x; } void func3() { Foo::x; } void func4() { using Foo::x; x; } --- NEW FILE: using2.cc --- // From C++WD'96 7.4.3.2 Example namespace A { int i; namespace B { namespace C { int i; } using namespace A::B::C; void f1() { i = 5; // C::i hides A::i } } namespace D { using namespace B; using namespace C; void f2() { i = 5; // ambiguous, B::C::i or A::i } } void f3() { i = 5; // uses A::i } } void f4() { i = 5; // ill-formed, neither i visible } --- NEW FILE: using3.cc --- // From C++WD'96 7.4.3.3 Example 2 namespace A { int i; } namespace B { int i; int j; namespace C { namespace D { using namespace A; int j; int k; int a = i; // B::i hides A::i } using namespace D; int k = 89; // no problem yet int l = k; // ambiguous: C::k or D::k int m = i; // B::i hides A::i int n = j; // D::j hides B::j } } --- NEW FILE: using4.cc --- // From C++WD'96 7.4.3.6 Example namespace D { int d1; void f(char); } using namespace D; int d1; // ok, no conflict with D::d1 namespace E { int e; void f(int); } namespace D // namespace extension { int d2; using namespace E; void f(int); } void f() { d1++; // error: ambiguous: ::d1 or D::d1 ::d1++; // ok D::d1++; // ok d2++; // ok D::d2 e++; // ok E::e f(1); // error: ambiguous: D::f(int) or E::f(int) f('a'); // ok: D::f(char) } From stefan at synopsis.fresco.org Fri Oct 3 15:00:34 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:37 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter DUMP.py,1.16,1.17 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter In directory frida:/tmp/cvs-serv20475/Synopsis/Formatter Modified Files: DUMP.py Log Message: bug fix Index: DUMP.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatter/DUMP.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -p -d -r1.16 -r1.17 --- DUMP.py 3 Oct 2003 14:47:54 -0000 1.16 +++ DUMP.py 3 Oct 2003 15:00:32 -0000 1.17 @@ -19,6 +19,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.17 2003/10/03 15:00:32 stefan +# bug fix +# # Revision 1.16 2003/10/03 14:47:54 stefan # let DUMP finally respect the '-o' option # @@ -113,13 +116,13 @@ class Dumper: i,t = id(obj), type(obj) if self.visited.has_key(i): if t == types.InstanceType: t = obj.__class__.__name__+" instance" + i = self.identify and '( %d ) '%i or '' if hasattr(obj, 'name'): - ident = self.identify and '( %d ) '%i or '' - self.write(""%(t,ident,string.join(obj.name(),"::"))) + self.write(""%(t,i,string.join(obj.name(),"::"))) elif hasattr(obj, 'filename'): - self.write(""%(t,ident,obj.filename())) + self.write(""%(t,i,obj.filename())) else: - self.write(""%(t,ident)) + self.write(""%(t,i)) return if self.handlers.has_key(t): self.handlers[t](obj) From stefan at synopsis.fresco.org Fri Oct 3 15:03:24 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:37 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Linker - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Linker In directory frida:/tmp/cvs-serv20497/tests/Linker Log Message: Directory /cvs/synopsis/Synopsis/tests/Linker added to the repository From stefan at synopsis.fresco.org Fri Oct 3 15:03:34 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:37 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Linker/Comments - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Linker/Comments In directory frida:/tmp/cvs-serv20517/tests/Linker/Comments Log Message: Directory /cvs/synopsis/Synopsis/tests/Linker/Comments added to the repository From stefan at synopsis.fresco.org Fri Oct 3 18:11:17 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:37 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/IDL - New directory Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/IDL In directory frida:/tmp/cvs-serv25581/IDL Log Message: Directory /cvs/synopsis/Synopsis/tests/Parser/IDL added to the repository From stefan at synopsis.fresco.org Fri Oct 3 18:12:02 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:38 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/IDL CosNaming.idl,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/IDL In directory frida:/tmp/cvs-serv25606/IDL Added Files: CosNaming.idl Log Message: more on unit testing --- NEW FILE: CosNaming.idl --- #ifndef _CosNaming_IDL_ #define _CosNaming_IDL_ #pragma prefix "omg.org" //. a CosNaming module module CosNaming { //. an Istring typedef typedef string Istring; //. a NameComponent struct. //. with a multi-line comment. struct NameComponent { //. an id member Istring id; //. a kind member Istring kind; }; //. a Name type. //. This is a sequence of NameComponents //. so it forms a scoped name of sorts typedef sequence Name; //. a BindingType enum enum BindingType { nobject, ncontext }; //. a Binding struct struct Binding { //. a binding_name member Name binding_name; //. a binding_type member BindingType binding_type; }; //. a BindingList type typedef sequence BindingList; interface BindingIterator; //. a NamingContext interface interface NamingContext { //. a NotFoundReason enum enum NotFoundReason { missing_node, not_context, not_object }; //. an exception exception NotFound { NotFoundReason why; Name rest_of_name; }; exception CannotProceed { NamingContext ctx; Name rest_of_name; }; exception InvalidName{}; exception AlreadyBound{}; exception NotEmpty{}; //. and the bind method... void bind(in Name n, in Object obj) raises(NotFound, CannotProceed, InvalidName, AlreadyBound); void rebind(in Name n, in Object obj) raises(NotFound, CannotProceed, InvalidName); void bind_context(in Name n, in NamingContext nc) raises(NotFound, CannotProceed, InvalidName, AlreadyBound); void rebind_context(in Name n, in NamingContext nc) raises(NotFound, CannotProceed, InvalidName); Object resolve(in Name n) raises(NotFound, CannotProceed, InvalidName); void unbind(in Name n) raises(NotFound, CannotProceed, InvalidName); NamingContext new_context(); NamingContext bind_new_context(in Name n) raises(NotFound, AlreadyBound, CannotProceed, InvalidName); void destroy() raises(NotEmpty); void list(in unsigned long how_many, out BindingList bl, out BindingIterator bi); }; interface BindingIterator { boolean next_one(out Binding b); boolean next_n(in unsigned long how_many, out BindingList bl); void destroy(); }; }; #endif /* !_CosNaming_IDL_ */ From stefan at synopsis.fresco.org Mon Oct 6 02:57:02 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:38 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Linker config.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Linker In directory frida:/tmp/cvs-serv20453/tests/Linker Added Files: config.py Log Message: more unit testing work --- NEW FILE: config.py --- from Synopsis.Config import Base class Config(Base): class Linker(Base.Linker): class SS(Base.Linker.Linker): comment_processors = ['ss'] class Group(Base.Linker.Linker): comment_processors = ['group'] class Dummy(Base.Linker.Linker): comment_processors = ['dummy'] class Prev(Base.Linker.Linker): comment_processors = ['prev'] modules = {'SS': SS, 'Group': Group, 'Dummy': Dummy, 'Prev': Prev} From stefan at synopsis.fresco.org Mon Oct 6 02:57:02 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:38 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/src groups.cc,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/src In directory frida:/tmp/cvs-serv20453/tests/Parser/C++/src Added Files: groups.cc Log Message: more unit testing work --- NEW FILE: groups.cc --- // { Group1 struct foo { }; int test1; int test2; // } // { Group2 int test3; int test4; // } From stefan at synopsis.fresco.org Tue Oct 7 02:54:41 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:38 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Unduplicator.py,1.5,1.6 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv26893/Synopsis/Linker Modified Files: Unduplicator.py Log Message: don't remove duplicate 'dummy' declarations Index: Unduplicator.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Unduplicator.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- Unduplicator.py 10 Dec 2002 07:28:49 -0000 1.5 +++ Unduplicator.py 7 Oct 2003 02:54:38 -0000 1.6 @@ -20,6 +20,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.6 2003/10/07 02:54:38 stefan +# don't remove duplicate 'dummy' declarations +# # Revision 1.5 2002/12/10 07:28:49 chalky # Unduplicate the list of declarations for each file # @@ -222,7 +225,7 @@ class Unduplicator(AST.Visitor, Type.Vis name = decl.name() dict = self.__dicts[-1] decls = self.top().declarations() - if dict.has_key(name): + if dict.has_key(name) and name != ('dummy',): prev = dict[name] if not isinstance(prev, AST.Forward): return From stefan at synopsis.fresco.org Tue Oct 7 02:55:43 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:39 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Comments.py,1.18,1.19 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv27031/Synopsis/Linker Modified Files: Comments.py Log Message: make group handling more fault tolerant Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Comments.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -p -d -r1.18 -r1.19 --- Comments.py 20 Jan 2003 06:43:02 -0000 1.18 +++ Comments.py 7 Oct 2003 02:55:40 -0000 1.19 @@ -20,6 +20,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.19 2003/10/07 02:55:40 stefan +# make group handling more fault tolerant +# # Revision 1.18 2003/01/20 06:43:02 chalky # Refactored comment processing. Added AST.CommentTag. Linker now determines # comment summary and extracts tags. Increased AST version number. @@ -96,12 +99,17 @@ class CommentProcessor (AST.Visitor): method. """ def processAll(self, declarations): - for decl in declarations: - decl.accept(self) + for decl in declarations: + decl.accept(self) + self.finalize(declarations) def process(self, decl): - """Process comments for the given declaration""" + """Process comments for the given declaration""" + pass + def finalize(self, declarations): + """Do any finalization steps that may be necessary.""" + pass def visitDeclaration(self, decl): - self.process(decl) + self.process(decl) class SSDComments (CommentProcessor): """A class that selects only //. comments.""" @@ -226,9 +234,8 @@ class Transformer (CommentProcessor): """Constructor""" self.__scopestack = [] self.__currscope = [] - def processAll(self, declarations): - """Overrides the default processAll() to setup the stack""" - for decl in declarations: decl.accept(self) + def finalize(self, declarations): + """replace the AST with the newly created one""" declarations[:] = self.__currscope def push(self): """Pushes the current scope onto the stack and starts a new one""" @@ -343,14 +350,61 @@ class Previous (Dummies): class Grouper (Transformer): """A class that detects grouping tags and moves the enclosed nodes into a subnode (a 'Group')""" - __re_open = r'^[ \t]*{ ?(.*)$' - __re_close = r'^[ \t]*} ?(.*)$' + __re_group = r'^[ \t]*((?P{)[ \t]*(?P[a-zA-Z_]\w*)*|(?P})) ?(.*)$' def __init__(self): Transformer.__init__(self) - self.re_open = re.compile(Grouper.__re_open, re.M) - self.re_close = re.compile(Grouper.__re_close, re.M) - self.__groups = [] - def visitDeclaration(self, decl): + self.re_group = re.compile(Grouper.__re_group, re.M) + self.__group_stack = [[]] + + def strip_dangling_groups(self): + """As groups must not overlap with 'real' scopes, + make sure all groups created in the current scope are closed + when leaving the scope.""" + if self.__group_stack[-1]: + print 'Warning: group stack is non-empty !' + while (self.__group_stack[-1]): + group = self.__group_stack[-1][-1] + print 'forcing closing of group %s (opened near %s:%d)'%(group.name(), group.file().filename(), group.line()) + self.pop_group() + + def finalize(self, declarations): + """replace the AST with the newly created one""" + self.strip_dangling_groups() + Transformer.finalize(self, declarations) + + def push(self): + """starts a new group stack to be able to validate group scopes""" + Transformer.push(self) + self.__group_stack.append([]) + + def pop(self, decl): + """Make sure the current group stack is empty.""" + self.strip_dangling_groups() + self.__group_stack.pop() + Transformer.pop(self, decl) + + def push_group(self, group): + """Push new group scope to the stack.""" + self.__group_stack[-1].append(group) + Transformer.push(self) + + def pop_group(self, decl=None): + """Pop a group scope from the stack. + + decl -- an optional declaration from which to extract the context, + used for the error message if needed. + """ + if self.__group_stack[-1]: + group = self.__group_stack[-1].pop() + group.declarations()[:] = self.currscope() + Transformer.pop(self, group) + else: + if decl: + print "Warning: no group open in current scope (near %s:%d), ignoring."%(decl.file().filename(), decl.line()) + else: + print "Warning: no group open in current scope, ignoring." + + def process(self, decl): """Checks for grouping tags. If an opening tag is found in the middle of a comment, a new Group is generated, the preceeding comments are associated with it, and is pushed onto the scope stack as well as the groups stack. @@ -359,55 +413,57 @@ class Grouper (Transformer): process_comments = decl.comments() while len(process_comments): c = process_comments.pop(0) - open_mo = self.re_open.search(c.text()) - if open_mo: + tag = self.re_group.search(c.text()) + if not tag: + comments.append(c) + elif tag.group('open'): # Open group. Name is remainder of line - label = open_mo.group(1) + label = tag.group('name') or 'unnamed' # The comment before the { becomes the group comment - if open_mo.start() > 0: - text = c.text()[:open_mo.start()] + if tag.start() > 0: + text = c.text()[:tag.start()] comments.append(AST.Comment(text, c.file(), c.line())) group = AST.Group(decl.file(), decl.line(), decl.language(), "group", [label]) group.comments()[:] = comments comments = [] # The comment after the { becomes the next comment to process - if open_mo.end() < len(c.text()): - text = c.text()[open_mo.end()+1:] + if tag.end() < len(c.text()): + text = c.text()[tag.end()+1:] process_comments.insert(0, AST.Comment(text, c.file(), c.line())) - self.push() - self.__groups.append(group) - continue - close_mo = self.re_close.search(c.text()) - if close_mo: - # Fixme: the close group doesn't handle things as well as open - # does! - group = self.__groups.pop() - group.declarations()[:] = self.currscope() - self.pop(group) + self.push_group(group) + elif tag.group('close'): + self.pop_group(decl) # The comment before the } is ignored...? maybe post-comment? # The comment after the } becomes the next comment to process - if close_mo.end() < len(c.text()): - text = c.text()[close_mo.end()+1:] + if tag.end() < len(c.text()): + text = c.text()[tag.end()+1:] process_comments.insert(0, AST.Comment(text, c.file(), c.line())) - else: comments.append(c) decl.comments()[:] = comments + + def visitDeclaration(self, decl): + self.process(decl) 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.process(scope) 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.process(enum) 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" @@ -511,3 +567,4 @@ class Comments(Operation): processor.processAll(declarations) linkerOperation = Comments + From stefan at synopsis.fresco.org Tue Oct 7 03:52:24 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:39 2005 Subject: [Synopsis-changes] Synopsis/Synopsis setup.py,1.6,1.7 Message-ID: Update of /cvs/synopsis/Synopsis In directory frida:/tmp/cvs-serv28605 Modified Files: setup.py Log Message: add more metadata to the packages Index: setup.py =================================================================== RCS file: /cvs/synopsis/Synopsis/setup.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -d -r1.6 -r1.7 --- setup.py 29 Sep 2003 20:03:14 -0000 1.6 +++ setup.py 7 Oct 2003 03:52:22 -0000 1.7 @@ -17,6 +17,12 @@ from Synopsis.dist.command.build_doc imp from Synopsis.dist.command.build import build from Synopsis.dist.command.build_ext import build_ext +# patch distutils if it can't cope with the "classifiers" keyword +from distutils.dist import DistributionMetadata +if not hasattr(DistributionMetadata, 'classifiers'): + DistributionMetadata.classifiers = None + DistributionMetadata.download_url = None + module_ext = sysconfig.get_config_var('SO') def prefix(list, pref): return map(lambda x, p=pref: p + x, list) @@ -49,9 +55,19 @@ setup(cmdclass={'config':config, name="synopsis", version=__version__, author="Stefan Seefeld & Stephen Davies", - author_email="synopsis-devel@lists.sf.net", + author_email="stefan@fresco.org", description="source code inspection tool", url="http://synopsis.fresco.org", + download_url = 'http://synopsis.fresco.org/download', + classifiers = ['Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Operating System :: POSIX', + 'Programming Language :: Python', + 'Programming Language :: C++', + 'Topic :: Software Development :: Documentation'], packages=py_packages, ext_modules=ext_modules, scripts=prefix(scripts, "bin/"), From stefan at synopsis.fresco.org Tue Oct 7 14:06:18 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:39 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter/HTML ScopePages.py,1.18,1.19 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter/HTML In directory frida:/tmp/cvs-serv12899/Synopsis/Formatter/HTML Modified Files: ScopePages.py Log Message: refer to the new site Index: ScopePages.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatter/HTML/ScopePages.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -p -d -r1.18 -r1.19 --- ScopePages.py 1 Nov 2002 07:21:15 -0000 1.18 +++ ScopePages.py 7 Oct 2003 14:06:16 -0000 1.19 @@ -20,6 +20,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.19 2003/10/07 14:06:16 stefan +# refer to the new site +# # Revision 1.18 2002/11/01 07:21:15 chalky # More HTML formatting fixes eg: ampersands and stuff # @@ -196,7 +199,7 @@ class ScopePages (Page.Page): """Overrides end_file to provide synopsis logo""" self.write('
\n') now = time.strftime(r'%c', time.localtime(time.time())) - logo = href('http://synopsis.sourceforge.net', 'synopsis') + logo = href('http://synopsis.fresco.org', 'synopsis') self.write(div('logo', 'Generated on ' + now + ' by \n
\n' + logo)) Page.Page.end_file(self) From stefan at synopsis.fresco.org Tue Oct 7 21:14:38 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:39 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/src groups.cc,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/src In directory frida:/tmp/cvs-serv24764/Parser/C++/src Modified Files: groups.cc Log Message: adjust to new default grouping syntax Index: groups.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parser/C++/src/groups.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- groups.cc 6 Oct 2003 02:57:00 -0000 1.1 +++ groups.cc 7 Oct 2003 21:14:35 -0000 1.2 @@ -1,11 +1,16 @@ -// { Group1 +// group documentation +// @group first group { some comment +// extending over multiple lines struct foo { }; int test1; int test2; -// } -// { Group2 +// @group } +// an unnamed group +// @group { +// test3 documentation int test3; int test4; -// } +// @group } + From stefan at synopsis.fresco.org Tue Oct 7 21:15:02 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:39 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Comments.py,1.19,1.20 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv24785 Modified Files: Comments.py Log Message: adjust to new default grouping syntax Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Comments.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -p -d -r1.19 -r1.20 --- Comments.py 7 Oct 2003 02:55:40 -0000 1.19 +++ Comments.py 7 Oct 2003 21:15:00 -0000 1.20 @@ -20,6 +20,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.20 2003/10/07 21:15:00 stefan +# adjust to new default grouping syntax +# # Revision 1.19 2003/10/07 02:55:40 stefan # make group handling more fault tolerant # @@ -350,7 +353,8 @@ class Previous (Dummies): class Grouper (Transformer): """A class that detects grouping tags and moves the enclosed nodes into a subnode (a 'Group')""" - __re_group = r'^[ \t]*((?P{)[ \t]*(?P[a-zA-Z_]\w*)*|(?P})) ?(.*)$' + __re_group = r'^[ \t]*((?P@group[ \t]*(?P.*){)|(?P@group[ \t]*}))(?P.*)$' + #__re_group = r'^[ \t]*((?P{)[ \t]*(?P[a-zA-Z_]\w*)*|(?P})) ?(.*)$' def __init__(self): Transformer.__init__(self) self.re_group = re.compile(Grouper.__re_group, re.M) @@ -405,39 +409,39 @@ class Grouper (Transformer): print "Warning: no group open in current scope, ignoring." def process(self, decl): - """Checks for grouping tags. + """Checks for grouping tags. If an opening tag is found in the middle of a comment, a new Group is generated, the preceeding comments are associated with it, and is pushed onto the scope stack as well as the groups stack. """ comments = [] - process_comments = decl.comments() - while len(process_comments): - c = process_comments.pop(0) + process_comments = decl.comments() + while len(process_comments): + c = process_comments.pop(0) tag = self.re_group.search(c.text()) if not tag: comments.append(c) + continue elif tag.group('open'): - # Open group. Name is remainder of line + # Open group. Name is remainder of line label = tag.group('name') or 'unnamed' - # The comment before the { becomes the group comment - if tag.start() > 0: - text = c.text()[:tag.start()] - comments.append(AST.Comment(text, c.file(), c.line())) + # The comment before the open marker becomes the group comment + if tag.start('open') > 0: + text = c.text()[:tag.start('open')] + comments.append(AST.Comment(text, c.file(), c.line())) group = AST.Group(decl.file(), decl.line(), decl.language(), "group", [label]) group.comments()[:] = comments comments = [] - # The comment after the { becomes the next comment to process - if tag.end() < len(c.text()): - text = c.text()[tag.end()+1:] - process_comments.insert(0, AST.Comment(text, c.file(), c.line())) + # The comment after the open marker becomes the next comment to process + if tag.group('remainder'): + process_comments.insert(0, AST.Comment(tag.group('remainder'), c.file(), c.line())) self.push_group(group) elif tag.group('close'): self.pop_group(decl) - # The comment before the } is ignored...? maybe post-comment? - # The comment after the } becomes the next comment to process - if tag.end() < len(c.text()): - text = c.text()[tag.end()+1:] - process_comments.insert(0, AST.Comment(text, c.file(), c.line())) + # 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():]], '') + if remainder: + process_comments.insert(0, AST.Comment(remainder, c.file(), c.line())) decl.comments()[:] = comments def visitDeclaration(self, decl): From stefan at synopsis.fresco.org Thu Oct 9 05:02:42 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:39 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis Config.py,1.22,1.23 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis In directory frida:/tmp/cvs-serv12078/Synopsis Modified Files: Config.py Log Message: a new Dump formatter using xml for easy validation Index: Config.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Config.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -p -d -r1.22 -r1.23 --- Config.py 21 Sep 2003 19:37:49 -0000 1.22 +++ Config.py 9 Oct 2003 05:02:39 -0000 1.23 @@ -572,6 +572,10 @@ class Base: name = 'DUMP' def __init__(self, argv): pass + class Dump: + name = 'Dump' + def __init__(self, argv): pass + class Dia: name = 'Dia' def __init__(self, argv): pass @@ -579,7 +583,7 @@ class Base: modules = { 'HTML': HTML, 'DocBook':DocBook, 'TexInfo':TexInfo, 'Dot':Dot, 'HTML_Simple':HTML_Simple, 'ASCII':ASCII, - 'DUMP':DUMP, 'Dia':Dia, + 'DUMP':DUMP, 'Dump':Dump, 'Dia':Dia, 'HTML_Doxygen':HTML_Doxygen, 'BoostBook':BoostBook } From stefan at synopsis.fresco.org Thu Oct 9 05:02:42 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:40 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter Dump.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter In directory frida:/tmp/cvs-serv12078/Synopsis/Formatter Added Files: Dump.py Log Message: a new Dump formatter using xml for easy validation --- NEW FILE: Dump.py --- # $Id: Dump.py,v 1.1 2003/10/09 05:02:39 stefan Exp $ # # This file is a part of Synopsis. # Copyright (C) 2003 Stefan Seefeld # # Synopsis is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # # $Log: Dump.py,v $ # Revision 1.1 2003/10/09 05:02:39 stefan # a new Dump formatter using xml for easy validation # # """ Verbose attribute-oriented xml dump of AST, useful for validation, introspection, and debugging. """ # THIS-IS-A-FORMATTER import sys, getopt, os, os.path, string, types import xml from xml.dom.minidom import getDOMImplementation dom = getDOMImplementation().createDocument(None, "dump", None) from Synopsis.Core import Type, AST verbose = 0 __dom_implementation = xml.dom.minidom.getDOMImplementation() class Writer: def __init__(self): self.handlers = {types.NoneType : self.visit_none, types.TypeType : self.visit_type, types.IntType : self.visit_string, types.LongType : self.visit_string, types.FloatType : self.visit_string, types.StringType : self.visit_string, types.TupleType : self.visit_tuple, types.ListType : self.visit_list, types.DictType : self.visit_dict, types.InstanceType : self.visit_instance} self.visited = {} def push(self, name): element = dom.createElement(name) self.node.appendChild(element) self.node = element def pop(self): self.node = self.node.parentNode def add_text(self, text): node = dom.createTextNode(text) self.node.appendChild(node) def visit(self, obj): i,t = id(obj), type(obj) if self.visited.has_key(i): self.node.setAttribute('xref', str(i)) return if self.handlers.has_key(t): self.handlers[t](obj) else: print "Unknown type %s for object: '%s'"%(t,obj) def visit_none(self, obj): pass def visit_string(self, obj): self.add_text(str(obj)) def visit_type(self, obj): self.write(obj) # where is that used ?? def visit_tuple(self, obj): if len(obj) == 0: return for i in obj: self.push('item') self.visit(i) self.pop() def visit_list(self, obj): if len(obj) == 0: return for i in obj: self.push('item') self.visit(i) self.pop() def visit_dict(self, dict): items = dict.items() if len(items) == 0: return items.sort() for i in items: self.push("key") self.visit(i[0]) self.pop() self.push("value") self.visit(i[1]) self.pop() def visit_instance(self, obj): if isinstance(obj, AST.SourceFile): # just write down the filename self.add_text(obj.filename()) return if isinstance(obj, AST.Include): self.write("Include: (macro:%d, next:%d) '%s'"%(obj.is_macro(), obj.is_next(), obj.target().filename())) return self.visited[id(obj)] = None self.push("%s.%s"%(obj.__class__.__module__,obj.__class__.__name__)) self.node.setAttribute('id', str(id(obj))) attrs = obj.__dict__.items() attrs.sort() for name, value in attrs: # ignore None values if (value == None or value == [] or value == ()): continue # special case for some known attributes... if name == '_Named__name': self.node.setAttribute('name', string.join(value, '.')) continue if name == '_Declaration__name': self.node.setAttribute('name', string.join(value, '.')) continue if name == '_Declaration__file': if value: self.node.setAttribute('file', value.filename()) continue if name[0] == '_': index = string.find(name, '__') if index >= 0: #name = "%s.%s"%(name[1:index],name[index+2:]) name = name[index+2:] if (self.handlers[type(value)] == self.visit_string and not (obj.__class__.__name__ == 'Comment' and (name == 'summary' or name == 'text'))): self.node.setAttribute(name, str(value)) else: self.push(name) self.visit(value) self.pop() self.pop() def write_declarations(self, declarations): self.node = dom.createElement("declarations") for d in declarations: self.visit(d) self.node.writexml(output, indent=" ", addindent=" ", newl="\n") self.node.unlink() del self.node def write_types(self, types): self.node = dom.createElement("types") for t in types.values(): self.visit(t) self.node.writexml(output, indent=" ", addindent=" ", newl="\n") self.node.unlink() del self.node def write_files(self, files): self.node = dom.createElement("files") for f in files: self.visit(f) self.node.writexml(output, indent=" ", addindent=" ", newl="\n") self.node.unlink() del self.node def usage(): """Print usage to stdout""" print \ """ -o Output file -d Show declarations -t Show types -f Show files (If none of -d, -t or -f specified, will default to -d, -t) """ def __parseArgs(args): global output, verbose, show_decls, show_types, show_files # Set defaults output = sys.stdout show_decls = 0 show_types = 0 show_files = 0 try: opts,remainder = getopt.getopt(args, "o:vdtfip") except getopt.error, e: sys.stderr.write("Error in arguments: " + str(e) + "\n") sys.exit(1) for opt in opts: o,a = opt if o == "-o": output = open(a, "w") elif o == "-v": verbose = 1 elif o == "-d": show_decls = 1 elif o == "-t": show_types = 1 elif o == "-f": show_files = 1 # Consolidate - if no show_ selected, show decls and types if not (show_decls or show_types or show_files): show_decls = 1 show_types = 1 show_files = 1 def format(args, ast, config_obj): global output, show_files __parseArgs(args) # Write out the prologue. output.write("\n") output.write("\n") writer = Writer() if show_decls: writer.write_declarations(ast.declarations()) if show_types: writer.write_types(ast.types()) if show_files: writer.write_files(ast.files()) output.write("\n") From stefan at synopsis.fresco.org Thu Oct 9 05:09:08 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:40 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter Dump.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter In directory frida:/tmp/cvs-serv12227/Synopsis/Formatter Modified Files: Dump.py Log Message: fix option parsing Index: Dump.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatter/Dump.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- Dump.py 9 Oct 2003 05:02:39 -0000 1.1 +++ Dump.py 9 Oct 2003 05:09:06 -0000 1.2 @@ -19,6 +19,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.2 2003/10/09 05:09:06 stefan +# fix option parsing +# # Revision 1.1 2003/10/09 05:02:39 stefan # a new Dump formatter using xml for easy validation # @@ -178,7 +181,7 @@ def usage(): -d Show declarations -t Show types -f Show files - (If none of -d, -t or -f specified, will default to -d, -t) + (If none of -d, -t or -f specified, will default to -d, -t, -f) """ def __parseArgs(args): @@ -190,7 +193,7 @@ def __parseArgs(args): show_files = 0 try: - opts,remainder = getopt.getopt(args, "o:vdtfip") + opts,remainder = getopt.getopt(args, "o:vdtf") except getopt.error, e: sys.stderr.write("Error in arguments: " + str(e) + "\n") sys.exit(1) From stefan at synopsis.fresco.org Thu Oct 9 05:50:11 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:40 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/docs/Manual index.html,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/docs/Manual In directory frida:/tmp/cvs-serv13581/docs/Manual Modified Files: index.html Log Message: fix manual pages Index: index.html =================================================================== RCS file: /cvs/synopsis/Synopsis/docs/Manual/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- index.html 16 Mar 2003 04:23:42 -0000 1.1 +++ index.html 9 Oct 2003 05:50:09 -0000 1.2 @@ -1,10 +1,51 @@ - + + + + + Synopsis Home + + + -

User Manual

-

By running make in the docs/Manual directory you can generate a User Manual - in HTML and PDF formats. The Manual is written in XML DocBook.

-

You can view the manual here in the following formats:

-

Synopsis User Manual (HTML)

-

Synopsis User Manual (PDF)

+

Synopsis - User Manual

+ + + + + +
+

+ By running make in the docs/Manual directory you can generate a + User Manual in HTML and PDF formats. The Manual is written in + XML DocBook. +

+

You can view the manual here in the following formats:

+

Synopsis User Manual (HTML)

+

Synopsis User Manual (PDF)

+
+
+
+
+
+
+
+ Last modified: 2003-09-22
+ by Stefan Seefeld +
From stefan at synopsis.fresco.org Thu Oct 9 05:50:11 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:40 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/docs/RefManual index.html,1.4,1.5 Message-ID: Update of /cvs/synopsis/Synopsis/docs/RefManual In directory frida:/tmp/cvs-serv13581/docs/RefManual Modified Files: index.html Log Message: fix manual pages Index: index.html =================================================================== RCS file: /cvs/synopsis/Synopsis/docs/RefManual/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -p -d -r1.4 -r1.5 --- index.html 11 Jul 2001 06:40:12 -0000 1.4 +++ index.html 9 Oct 2003 05:50:09 -0000 1.5 @@ -1,29 +1,59 @@ - - + + + + Synopsis Developer Reference Manual - - - -

Synopsis Developer Reference Manual

- -

By running make in the docs/RefManual directory you can generate - documentation for Synopsis. Both Python and C++ sections of the code are - incorporated into the one manual, as you will notice from the modules - section which starts with "Python" and "C++". By browsing the [Source] - links from the pages for the C++ parser, you may also see the - cross-referenced source code.

- -

- Synopsis Reference Manual (HTML) -

- -

- Synopsis Reference Manual (PDF) -

- -

- Synopsis Reference Manual (info tarball) -

- - + + + +

Synopsis - Developer Reference Manual

+ + + + + +
+

+ By running make in the docs/RefManual directory you can generate + documentation for Synopsis. Both Python and C++ sections of the code are + incorporated into the one manual, as you will notice from the modules + section which starts with "Python" and "C++". By browsing the [Source] + links from the pages for the C++ parser, you may also see the + cross-referenced source code. +

+

+ Synopsis Reference Manual (HTML) +

+

+ Synopsis Reference Manual (PDF) +

+

+ Synopsis Reference Manual (info tarball) +

+
+
+
+
+
+
+
+ Last modified: 2003-10-09
+ by Stefan Seefeld +
+ From stefan at synopsis.fresco.org Thu Oct 9 05:50:53 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:40 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/dist/command build_doc.py,1.1,1.2 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/dist/command In directory frida:/tmp/cvs-serv13611/Synopsis/dist/command Modified Files: build_doc.py Log Message: more work on build_doc command Index: build_doc.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/dist/command/build_doc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -d -r1.1 -r1.2 --- build_doc.py 18 Sep 2003 02:54:14 -0000 1.1 +++ build_doc.py 9 Oct 2003 05:50:51 -0000 1.2 @@ -1,16 +1,151 @@ -import os, sys, string +import os, sys, string, re, stat +from stat import * +import os.path +from shutil import * +import glob from distutils.command import build -from distutils.dir_util import mkpath from distutils.spawn import spawn, find_executable -from shutil import * +from distutils.dep_util import newer, newer_group +from distutils.dir_util import copy_tree, remove_tree +from distutils.file_util import copy_file + + +class Target: + def __init__(self, cmd, rule, dependencies, **kw): + + self.cmd = cmd + self.rule = rule + self.dependencies = dependencies + self.dict = kw + self.mtime = 0 + # assume output is a single file + if kw.has_key('output') and os.path.exists(kw['output']): + self.mtime = os.stat(kw['output'])[ST_MTIME] + + def announce(self, msg): + self.cmd.announce(msg) + + def needs_update(self): + """Return true if any of the dependencies was modified after self""" + latest = 0 + for d in self.dependencies: + if isinstance(d, Target): + if d.mtime > latest: latest = d.mtime + else: # assume a filename + mtime = os.stat(d)[ST_MTIME] + if mtime > latest: latest = mtime + # always consider input as an implicit dependency + if self.dict.has_key('input'): + for i in self.dict['input']: + mtime = os.stat(i)[ST_MTIME] + if mtime > latest: latest = mtime + return latest > self.mtime + + def process(self): + for d in self.dependencies: + d.process() + if self.rule and self.needs_update(): + dict = self.dict.copy() + # if input is given, it is a list, so convert it to a string here + if self.dict.has_key('input'): + dict['input'] = string.join(self.dict['input']) + command = self.rule%dict + self.announce(command) + spawn(string.split(command)) class build_doc(build.build): + """Defines the specific procedure to build synopsis' documentation.""" description = "build documentation" def run(self): + """Run this command, i.e. do the actual document generation.""" + self.manual() + + def manual(self): + + synopsis = "synopsis -c config.py" + py_sources = [] + hh_sources = [] + cc_sources = [] + py = re.compile(r'.*\.py$') + hh = re.compile(r'.*\.hh$') + cc = re.compile(r'.*\.cc$') + def add_py(arg, dirname, names): + #exclude the dist stuff for now + if dirname == 'Synopsis/dist/command': + return + arg.extend(map(lambda f, d=dirname: os.path.join(d, f), + filter(lambda f, re=py: re.match(f), names))) + def add_hh(arg, dirname, names): + arg.extend(map(lambda f, d=dirname: os.path.join(d, f), + filter(lambda f, re=hh: re.match(f), names))) + def add_cc(arg, dirname, names): + arg.extend(map(lambda f, d=dirname: os.path.join(d, f), + filter(lambda f, re=cc: re.match(f), names))) + + os.path.walk('Synopsis', add_py, py_sources) + + cwd = os.getcwd() + os.chdir(os.path.normpath('docs/RefManual')) + py_syns = map(lambda f,s=self:Target(s, synopsis + " -Wc,parser=Py,linker=Py -o %(output)s %(input)s", + [], + output=re.sub('\.py$', '.syn', f), + input=[os.path.join('..','..',f)]), + py_sources) + py_syn = Target(self, synopsis + " -o %(output)s %(input)s", py_syns, + output='py.syn', input=map(lambda f:re.sub('\.py$', '.syn', f), + py_sources)) + core_ast_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::AST' -o %(output)s %(input)%", + [py_syn], output="core-ast.syn", input=['py.syn']) + core_type_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::Type' -o %(output)s %(input)%", + [py_syn], output="core-type.syn", input=['py.syn']) + core_util_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::Util' -o %(output)s %(input)%", + [py_syn], output="core-util.syn", input=['py.syn']) + parser_cxx_py_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Parser::C++' -o %(output)s %(input)%", + [py_syn], output="parser-c++-py.syn", input=['py.syn']) + parser_cxx_cpp_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)%", + [py_syn], output="parser-c++-cpp.syn", input=['py.syn']) + parser_cxx_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)%", + [parser_cxx_py_syn, parser_cxx_cpp_syn], output="parser-c++.syn", input=['py.syn']) + parser_idl_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Parser::IDL' -o %(output)s %(input)%", + [py_syn], output="parser-idl.syn", input=['py.syn']) + parser_py_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Parser::Python' -o %(output)s %(input)%", + [py_syn], output="parser-py.syn", input=['py.syn']) + linker_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Linker' -o %(output)s %(input)%", + [py_syn], output="linker.syn", input=['py.syn']) + formatter_ascii_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::ASCII' -o %(output)s %(input)%", + [py_syn], output="formatter-ascii.syn", input=['py.syn']) + formatter_html_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::HTML' -o %(output)s %(input)%", + [py_syn], output="formatter-html.syn", input=['py.syn']) + formatter_dump_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::DUMP' -o %(output)s %(input)%", + [py_syn], output="formatter-dump.syn", input=['py.syn']) + formatter_dia_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::Dia' -o %(output)s %(input)%", + [py_syn], output="formatter-dia.syn", input=['py.syn']) + formatter_docbook_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::Docbook' -o %(output)s %(input)%", + [py_syn], output="formatter-docbook.syn", input=['py.syn']) + formatter_dot_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::Dot' -o %(output)s %(input)%", + [py_syn], output="formatter-dot.syn", input=['py.syn']) + formatter_html_simple_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::HTML_Simple' -o %(output)s %(input)%", + [py_syn], output="formatter-html-simple.syn", input=['py.syn']) + formatter_texi_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Formatter::TexInfo' -o %(output)s %(input)%", + [py_syn], output="formatter-texi.syn", input=['py.syn']) + + all_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)s", + [py_syn], output="all.syn", input=['py.syn']) + + html = Target(self, synopsis + " -Wc,formatter=HTML %(input)s", + [all_syn], output="html", input=['all.syn']) + + html.process() + #for t in py_syn: + # t.process() + os.chdir(cwd) + + + def tutorial(self): xmlto = find_executable('xmlto') if not xmlto: self.announce("cannot build html docs without 'xmlto'") From stefan at synopsis.fresco.org Thu Oct 9 20:30:13 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/dist/command build_doc.py,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/dist/command In directory frida:/tmp/cvs-serv5079/Synopsis/dist/command Modified Files: build_doc.py Log Message: include C++ code into the reference manual Index: build_doc.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/dist/command/build_doc.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- build_doc.py 9 Oct 2003 05:50:51 -0000 1.2 +++ build_doc.py 9 Oct 2003 20:30:08 -0000 1.3 @@ -9,7 +9,7 @@ from distutils.spawn import spawn, find_ from distutils.dep_util import newer, newer_group from distutils.dir_util import copy_tree, remove_tree from distutils.file_util import copy_file - +from distutils import sysconfig class Target: def __init__(self, cmd, rule, dependencies, **kw): @@ -68,17 +68,24 @@ class build_doc(build.build): synopsis = "synopsis -c config.py" py_sources = [] - hh_sources = [] - cc_sources = [] + cxx_sources = [] py = re.compile(r'.*\.py$') - hh = re.compile(r'.*\.hh$') - cc = re.compile(r'.*\.cc$') + # only parse C++ code for now + #cxx = re.compile(r'((.*)\.(hh|h|cc)$)') + cxx = re.compile(r'((.*)\.(hh|cc)$)') def add_py(arg, dirname, names): - #exclude the dist stuff for now + # exclude the dist stuff for now, + # or else a synopsis bug will be triggered if dirname == 'Synopsis/dist/command': return arg.extend(map(lambda f, d=dirname: os.path.join(d, f), filter(lambda f, re=py: re.match(f), names))) + def add_cxx(arg, dirname, names): + # only parse the C++ parser for now + if dirname[:19] != 'Synopsis/Parser/C++': + return + arg.extend(map(lambda f, d=dirname: os.path.join(d, f), + filter(lambda f, re=cxx: re.match(f), names))) def add_hh(arg, dirname, names): arg.extend(map(lambda f, d=dirname: os.path.join(d, f), filter(lambda f, re=hh: re.match(f), names))) @@ -87,17 +94,29 @@ class build_doc(build.build): filter(lambda f, re=cc: re.match(f), names))) os.path.walk('Synopsis', add_py, py_sources) + os.path.walk('Synopsis', add_cxx, cxx_sources) cwd = os.getcwd() os.chdir(os.path.normpath('docs/RefManual')) - py_syns = map(lambda f,s=self:Target(s, synopsis + " -Wc,parser=Py,linker=Py -o %(output)s %(input)s", - [], + command = synopsis + " -Wc,parser=Py,linker=Py -o %(output)s %(input)s" + py_syns = map(lambda f,s=self:Target(s, command, [], output=re.sub('\.py$', '.syn', f), input=[os.path.join('..','..',f)]), py_sources) py_syn = Target(self, synopsis + " -o %(output)s %(input)s", py_syns, output='py.syn', input=map(lambda f:re.sub('\.py$', '.syn', f), py_sources)) + command = synopsis + " -I ../../Synopsis/Parser/C++ -I ../../Synopsis/Parser/C++/gc/include -I " + sysconfig.get_python_inc() + command += " -Wc,parser=C++,linker=C++ -Wp,-s,syn/%s-links,%s" + cxx_syns = map(lambda f,s=self:Target(s, command%(f[0], f[1]) + " -o %(output)s %(input)s", [], + output=f[0] + ".syn", + input=[os.path.join('..','..',f[0])]), + # this maps to (, , ) + map(lambda f:cxx.match(f).groups(), cxx_sources)) + cxx_syn = Target(self, synopsis + " -Wc,linker=C++Final -o %(output)s %(input)s", cxx_syns, + output='c++.syn', + input=map(lambda f:f + ".syn", cxx_sources)) + core_ast_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::AST' -o %(output)s %(input)%", [py_syn], output="core-ast.syn", input=['py.syn']) core_type_syn = Target(self, synopsis + " -Wc,linker=All -Wl,-s,'Synopsis::Core::Type' -o %(output)s %(input)%", @@ -134,7 +153,7 @@ class build_doc(build.build): [py_syn], output="formatter-texi.syn", input=['py.syn']) all_syn = Target(self, synopsis + " -Wc,linker=All -o %(output)s %(input)s", - [py_syn], output="all.syn", input=['py.syn']) + [py_syn, cxx_syn], output="all.syn", input=['py.syn', 'c++.syn']) html = Target(self, synopsis + " -Wc,formatter=HTML %(input)s", [all_syn], output="html", input=['all.syn']) From stefan at synopsis.fresco.org Mon Oct 13 01:15:11 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parser/C++/syn swalker.cc,1.74,1.75 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn In directory frida:/tmp/cvs-serv8534/Synopsis/Parser/C++/syn Modified Files: swalker.cc Log Message: Translate one node at a time, not the concatenated list. Index: swalker.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn/swalker.cc,v retrieving revision 1.74 retrieving revision 1.75 diff -u -p -d -r1.74 -r1.75 --- swalker.cc 23 Dec 2002 13:47:36 -0000 1.74 +++ swalker.cc 13 Oct 2003 01:15:09 -0000 1.75 @@ -25,6 +25,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.75 2003/10/13 01:15:09 stefan +// Translate one node at a time, not the concatenated list. +// // Revision 1.74 2002/12/23 13:47:36 chalky // Reset namespace filenames for each namespace declaration. // @@ -1225,7 +1228,7 @@ SWalker::TranslateFunctionDeclarator(Ptr Ptree* p = Ptree::First(m_declaration); while (p) { - premod.push_back(p->ToString()); + premod.push_back(p->Car()->ToString()); p = Ptree::Rest(p); } From stefan at synopsis.fresco.org Mon Oct 13 18:50:22 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/src groups.cc,1.2,1.3 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/src In directory frida:/tmp/cvs-serv914/tests/Parser/C++/src Modified Files: groups.cc Log Message: * provide a clearer definition of 'Comment', i.e. a single comment as opposed to a list of comments * simplify grouping tags with the above clarifications Index: groups.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/tests/Parser/C++/src/groups.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -d -r1.2 -r1.3 --- groups.cc 7 Oct 2003 21:14:35 -0000 1.2 +++ groups.cc 13 Oct 2003 18:50:20 -0000 1.3 @@ -1,16 +1,33 @@ // group documentation -// @group first group { some comment +// @group first group { + +// some comment // extending over multiple lines + +// another comment struct foo { }; int test1; int test2; -// @group } -// an unnamed group -// @group { -// test3 documentation +// } +int bar; +// another group +// @group tests { int test3; int test4; -// @group } +// } + +// @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 Mon Oct 13 18:50:22 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Comments.py,1.20,1.21 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv914/Synopsis/Linker Modified Files: Comments.py Log Message: * provide a clearer definition of 'Comment', i.e. a single comment as opposed to a list of comments * simplify grouping tags with the above clarifications Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Comments.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -p -d -r1.20 -r1.21 --- Comments.py 7 Oct 2003 21:15:00 -0000 1.20 +++ Comments.py 13 Oct 2003 18:50:19 -0000 1.21 @@ -20,6 +20,11 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.21 2003/10/13 18:50:19 stefan +# * provide a clearer definition of 'Comment', i.e. +# a single comment as opposed to a list of comments +# * simplify grouping tags with the above clarifications +# # Revision 1.20 2003/10/07 21:15:00 stefan # adjust to new default grouping syntax # @@ -353,8 +358,7 @@ class Previous (Dummies): class Grouper (Transformer): """A class that detects grouping tags and moves the enclosed nodes into a subnode (a 'Group')""" - __re_group = r'^[ \t]*((?P@group[ \t]*(?P.*){)|(?P@group[ \t]*}))(?P.*)$' - #__re_group = r'^[ \t]*((?P{)[ \t]*(?P[a-zA-Z_]\w*)*|(?P})) ?(.*)$' + __re_group = r'^[ \t]*((?P@group[ \t]*(?P.*){)|(?P[ \t]*}))[ \t]*\Z' def __init__(self): Transformer.__init__(self) self.re_group = re.compile(Grouper.__re_group, re.M) @@ -431,17 +435,9 @@ class Grouper (Transformer): group = AST.Group(decl.file(), decl.line(), decl.language(), "group", [label]) group.comments()[:] = comments comments = [] - # The comment after the open marker becomes the next comment to process - if tag.group('remainder'): - process_comments.insert(0, AST.Comment(tag.group('remainder'), c.file(), c.line())) self.push_group(group) elif tag.group('close'): 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():]], '') - if remainder: - process_comments.insert(0, AST.Comment(remainder, c.file(), c.line())) decl.comments()[:] = comments def visitDeclaration(self, decl): @@ -480,20 +476,14 @@ class Summarizer (CommentProcessor): def __init__(self): self.re_summary = re.compile(Summarizer.re_summary, re.S) def process(self, decl): - """Combine and summarize the comments of this declaration.""" - # First combine + """Summarize the comment of this declaration.""" comments = decl.comments() if not len(comments): return - comment = comments[0] + # Only use last comment + comment = comments[-1] tags = comment.tags() - if len(comments) > 1: - # Should be rare to have >1 comment - for extra in comments[1:]: - tags.extend(extra.tags()) - comment.set_text(comment.text() + extra.text()) - del comments[1:] - # Now decide how much of the comment is the summary + # Decide how much of the comment is the summary text = comment.text() mo = self.re_summary.match(text) if mo: From stefan at synopsis.fresco.org Mon Oct 13 18:50:22 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parser/C++/syn swalker.cc,1.75,1.76 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn In directory frida:/tmp/cvs-serv914/Synopsis/Parser/C++/syn Modified Files: swalker.cc Log Message: * provide a clearer definition of 'Comment', i.e. a single comment as opposed to a list of comments * simplify grouping tags with the above clarifications Index: swalker.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn/swalker.cc,v retrieving revision 1.75 retrieving revision 1.76 diff -u -p -d -r1.75 -r1.76 --- swalker.cc 13 Oct 2003 01:15:09 -0000 1.75 +++ swalker.cc 13 Oct 2003 18:50:20 -0000 1.76 @@ -25,6 +25,11 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.76 2003/10/13 18:50:20 stefan +// * provide a clearer definition of 'Comment', i.e. +// a single comment as opposed to a list of comments +// * simplify grouping tags with the above clarifications +// // Revision 1.75 2003/10/13 01:15:09 stefan // Translate one node at a time, not the concatenated list. // @@ -241,114 +246,80 @@ Leaf* make_Leaf(char* pos, int len) void SWalker::add_comments(AST::Declaration* decl, Ptree* node) { - if (node == NULL) - return; + if (!node) return; - AST::Comment::vector comments_to_add; + AST::Comment::vector comments; - // First, make sure that node is a list of comments - if (node->What() == ntDeclaration) - node = static_cast(node)->GetComments(); + // First, make sure that node is a list of comments + if (node->What() == ntDeclaration) + node = static_cast(node)->GetComments(); - // Loop over all comments in the list - for (Ptree* next = node->Rest(); node && !node->IsLeaf(); next = node->Rest()) + // Loop over all comments in the list + for (Ptree* next = node->Rest(); node && !node->IsLeaf(); next = node->Rest()) + { + Ptree* first = node->First(); + if (!first || !first->IsLeaf()) { - Ptree* first = node->First(); - if (!first || !first->IsLeaf()) - { - node = next; - continue; - } - - update_line_number(node); - // Make sure comment is in same file! - if (decl && (m_file != decl->file())) - { - node = next; - // Empty list of comments to add: an #include in the middle is not - // allowed! - comments_to_add.clear(); - continue; - } - - // Check if comment is continued, eg: consecutive C++ comments - while (next && next->First() && next->First()->IsLeaf()) - { - if (strncmp(next->First()->GetPosition(), "//", 2)) - break; - char* next_pos = next->First()->GetPosition(); - char* start_pos = node->First()->GetPosition(); - char* curr_pos = start_pos + node->First()->GetLength(); - // Must only be whitespace between current comment and next - // and only one newline - int newlines = 0; - while (curr_pos < next_pos && strchr(" \t\r\n", *curr_pos)) - if (*curr_pos == '\n' && newlines > 0) - break; - else if (*curr_pos++ == '\n') - ++newlines; - if (curr_pos < next_pos) - break; - // Current comment stretches to end of next - int len = int(next_pos - start_pos + next->First()->GetLength()); - //node->SetCar(first = new Leaf(start_pos, len)); - node->SetCar(first = make_Leaf(start_pos, len)); - // Skip the combined comment - next = next->Rest(); - } - - // Ensure that there is no more than one newline between the comment and - // the declaration. We assume that the declaration is the next - // non-comment thing (which could be a bad assumption..) - // If extract_tails is set, then comments separated by a space are still - // included, but are marked as suspect for the Linker to deal with - bool suspect = false; - char* pos = first->GetPosition() + first->GetLength(); - while (*pos && strchr(" \t\r", *pos)) - ++pos; - if (*pos == '\n') - { - ++pos; - // Found only allowed \n - while (*pos && strchr(" \t\r", *pos)) - ++pos; - if (*pos == '\n' || !strncmp(pos, "/*", 2)) - { - // 1. More than one newline.. skip entire comment and move onto next. - // 2. This comment is followed by a /*, so ignore this one - // If extract_tails is set, we keep it anyway but mark as suspect - if (!m_extract_tails) - { - node = next; - continue; - } - else - suspect = true; - } - } + node = next; + continue; + } + update_line_number(node); + // Make sure comment is in same file! + if (decl && (m_file != decl->file())) + { + node = next; + // Empty list of comments to add: an #include in the middle is not + // allowed! + comments.clear(); + continue; + } - if (decl) - { - //AST::Comment* comment = new AST::Comment("", 0, first->ToString(), suspect); - AST::Comment* comment = make_Comment(m_file, 0, first, suspect); - //decl->comments().push_back(comment); - comments_to_add.push_back(comment); - } - if (m_links) - m_links->long_span(first, "file-comment"); - // Set first to nil so we dont accidentally do them twice (eg: - // when parsing expressions) - node->SetCar(nil); - node = next; + // Check if comment is continued, eg: consecutive C++ comments + while (next && next->First() && next->First()->IsLeaf()) + { + if (!strncmp(first->GetPosition() + first->GetLength() - 2, "*/", 2)) + break; + if (strncmp(next->First()->GetPosition(), "//", 2)) + break; + char* next_pos = next->First()->GetPosition(); + char* start_pos = node->First()->GetPosition(); + char* curr_pos = start_pos + node->First()->GetLength(); + // Must only be whitespace between current comment and next + // and only one newline + int newlines = 0; + while (curr_pos < next_pos && strchr(" \t\r\n", *curr_pos)) + if (*curr_pos == '\n' && newlines > 0) + break; + else if (*curr_pos++ == '\n') + ++newlines; + if (curr_pos < next_pos) + break; + // Current comment stretches to end of next + int len = int(next_pos - start_pos + next->First()->GetLength()); + //node->SetCar(first = new Leaf(start_pos, len)); + node->SetCar(first = make_Leaf(start_pos, len)); + // Skip the combined comment + next = next->Rest(); } - // Now add the comments, if applicable - if (decl && comments_to_add.size()) + if (decl) { - AST::Comment::vector::iterator i_comment = comments_to_add.begin(); - while (i_comment != comments_to_add.end()) - decl->comments().push_back(*i_comment++); + AST::Comment* comment = make_Comment(m_file, 0, first); + comments.push_back(comment); } + if (m_links) m_links->long_span(first, "file-comment"); + // Set first to nil so we dont accidentally do them twice (eg: + // when parsing expressions) + node->SetCar(nil); + node = next; + } + + // Now add the comments, if applicable + if (decl) + for (AST::Comment::vector::iterator i = comments.begin(); + i != comments.end(); + ++i) + decl->comments().push_back(*i); } // -- These methods implement add_comments for various node types that store From stefan at synopsis.fresco.org Tue Oct 14 00:28:56 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Comments.py,1.21,1.22 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv8926/Synopsis/Linker Modified Files: Comments.py Log Message: * separate the 'Grouper' class into base and derived such that the derived class provides the 'process' method that is specific to the actual tags used for opening and closing the group * add a 'Stripper' class that removes all but the last comments from all declarations Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Comments.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -p -d -r1.21 -r1.22 --- Comments.py 13 Oct 2003 18:50:19 -0000 1.21 +++ Comments.py 14 Oct 2003 00:28:54 -0000 1.22 @@ -20,6 +20,13 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.22 2003/10/14 00:28:54 stefan +# * separate the 'Grouper' class into base and derived +# such that the derived class provides the 'process' method +# that is specific to the actual tags used for opening and closing the group +# * add a 'Stripper' class that removes all but the last comments from +# all declarations +# # Revision 1.21 2003/10/13 18:50:19 stefan # * provide a clearer definition of 'Comment', i.e. # a single comment as opposed to a list of comments @@ -358,10 +365,8 @@ class Previous (Dummies): class Grouper (Transformer): """A class that detects grouping tags and moves the enclosed nodes into a subnode (a 'Group')""" - __re_group = r'^[ \t]*((?P@group[ \t]*(?P.*){)|(?P[ \t]*}))[ \t]*\Z' def __init__(self): Transformer.__init__(self) - self.re_group = re.compile(Grouper.__re_group, re.M) self.__group_stack = [[]] def strip_dangling_groups(self): @@ -417,28 +422,7 @@ class Grouper (Transformer): If an opening tag is found in the middle of a comment, a new Group is generated, the preceeding comments are associated with it, and is pushed onto the scope stack as well as the groups stack. """ - comments = [] - process_comments = decl.comments() - while len(process_comments): - c = process_comments.pop(0) - tag = self.re_group.search(c.text()) - if not tag: - comments.append(c) - continue - elif tag.group('open'): - # Open group. Name is remainder of line - label = tag.group('name') or 'unnamed' - # The comment before the open marker becomes the group comment - if tag.start('open') > 0: - text = c.text()[:tag.start('open')] - comments.append(AST.Comment(text, c.file(), c.line())) - group = AST.Group(decl.file(), decl.line(), decl.language(), "group", [label]) - group.comments()[:] = comments - comments = [] - self.push_group(group) - elif tag.group('close'): - self.pop_group(decl) - decl.comments()[:] = comments + pass def visitDeclaration(self, decl): self.process(decl) @@ -470,6 +454,49 @@ class Grouper (Transformer): if not len(enumor.name()): return # workaround. self.add(enumor) +class Grouper1(Grouper): + """Grouper that detects ' @group {' and '}' group markup""" + __re_group = r'^[ \t]*((?P@group[ \t]*(?P.*){)|(?P[ \t]*}))[ \t]*\Z' + def __init__(self): + Grouper.__init__(self) + self.re_group = re.compile(Grouper1.__re_group, re.M) + + def process(self, decl): + """Checks for grouping tags. + If an opening tag is found in the middle of a comment, a new Group is generated, the preceeding + comments are associated with it, and is pushed onto the scope stack as well as the groups stack. + """ + comments = [] + process_comments = decl.comments() + while len(process_comments): + c = process_comments.pop(0) + tag = self.re_group.search(c.text()) + if not tag: + comments.append(c) + continue + elif tag.group('open'): + # Open group. Name is remainder of line + label = tag.group('name') or 'unnamed' + # The comment before the open marker becomes the group comment + if tag.start('open') > 0: + text = c.text()[:tag.start('open')] + comments.append(AST.Comment(text, c.file(), c.line())) + group = AST.Group(decl.file(), decl.line(), decl.language(), "group", [label]) + group.comments()[:] = comments + comments = [] + self.push_group(group) + elif tag.group('close'): + self.pop_group(decl) + decl.comments()[:] = comments + +class Stripper(CommentProcessor): + """Strip off all but the last comment.""" + def process(self, decl): + """Summarize the comment of this declaration.""" + if not len(decl.comments()): + return + decl.comments()[:] = [decl.comments()[-1]] + class Summarizer (CommentProcessor): """Splits comments into summary/detail parts.""" re_summary = r"[ \t\n]*(.*?\.)([ \t\n]|$)" @@ -533,7 +560,8 @@ processors = { 'qt': QtComments, 'dummy': Dummies, 'prev': Previous, - 'group': Grouper, + 'group': Grouper1, + 'stripper': Stripper, 'summary' : Summarizer, 'javatags' : JavaTags, } From stefan at synopsis.fresco.org Wed Oct 15 03:44:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:41 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/tests/Parser/C++/src groups2.cc,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/tests/Parser/C++/src In directory frida:/tmp/cvs-serv14961/tests/Parser/C++/src Added Files: groups2.cc Log Message: add new Grouper 'group2' to match '@group {' and '@group }' --- NEW FILE: groups2.cc --- // group documentation // @group first group { some comment // continued and // extending over multiple lines // another comment struct foo { private: // helper functions // blabla // // @group make_fn { // bla. // blabla int make_fn() {} // bla. // blabla int make_fn(int) {} // } // @group } is this lost ? }; int test1; int test2; // @group } int bar; // another group // @group tests { int test3; int test4; // @group } // @group outer { // @group inner { int f; // @group xxx { not a group int test5; // @group } this is accepted // @group } // and this too int test6; // @group } From stefan at synopsis.fresco.org Wed Oct 15 03:44:05 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:42 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Comments.py,1.22,1.23 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv14961/Synopsis/Linker Modified Files: Comments.py Log Message: add new Grouper 'group2' to match '@group {' and '@group }' Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Comments.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -p -d -r1.22 -r1.23 --- Comments.py 14 Oct 2003 00:28:54 -0000 1.22 +++ Comments.py 15 Oct 2003 03:44:01 -0000 1.23 @@ -20,6 +20,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.23 2003/10/15 03:44:01 stefan +# add new Grouper 'group2' to match '@group {' and '@group }' +# # Revision 1.22 2003/10/14 00:28:54 stefan # * separate the 'Grouper' class into base and derived # such that the derived class provides the 'process' method @@ -489,6 +492,49 @@ class Grouper1(Grouper): self.pop_group(decl) decl.comments()[:] = comments +class Grouper2(Grouper): + """Grouper that detects ' @group {' and ' @group }' group markup""" + __re_group = r'^[ \t]*((?P@group[ \t]*(?P.*){)|(?P@group[ \t]*}))(?P.*)$' + def __init__(self): + Grouper.__init__(self) + self.re_group = re.compile(Grouper2.__re_group, re.M) + + def process(self, decl): + """Checks for grouping tags. + If an opening tag is found in the middle of a comment, a new Group is generated, the preceeding + comments are associated with it, and is pushed onto the scope stack as well as the groups stack. + """ + comments = [] + process_comments = decl.comments() + while len(process_comments): + c = process_comments.pop(0) + tag = self.re_group.search(c.text()) + if not tag: + comments.append(c) + continue + elif tag.group('open'): + # Open group. Name is remainder of line + label = tag.group('name') or 'unnamed' + # The comment before the open marker becomes the group comment + if tag.start('open') > 0: + text = c.text()[:tag.start('open')] + comments.append(AST.Comment(text, c.file(), c.line())) + group = AST.Group(decl.file(), decl.line(), decl.language(), "group", [label]) + group.comments()[:] = comments + comments = [] + # The comment after the open marker becomes the next comment to process + if tag.group('remainder'): + process_comments.insert(0, AST.Comment(tag.group('remainder'), c.file(), c.line())) + self.push_group(group) + elif tag.group('close'): + 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():]], '') + if remainder: + process_comments.insert(0, AST.Comment(remainder, c.file(), c.line())) + decl.comments()[:] = comments + class Stripper(CommentProcessor): """Strip off all but the last comment.""" def process(self, decl): @@ -561,6 +607,7 @@ processors = { 'dummy': Dummies, 'prev': Previous, 'group': Grouper1, + 'group2': Grouper2, 'stripper': Stripper, 'summary' : Summarizer, 'javatags' : JavaTags, From stefan at synopsis.fresco.org Wed Oct 15 04:29:01 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:42 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Linker Comments.py,1.23,1.24 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Linker In directory frida:/tmp/cvs-serv16077/Synopsis/Linker Modified Files: Comments.py Log Message: * only keep last comment if it is not suspect * provide an alternative Grouper Index: Comments.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Linker/Comments.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -p -d -r1.23 -r1.24 --- Comments.py 15 Oct 2003 03:44:01 -0000 1.23 +++ Comments.py 15 Oct 2003 04:28:59 -0000 1.24 @@ -20,6 +20,10 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.24 2003/10/15 04:28:59 stefan +# * only keep last comment if it is not suspect +# * provide an alternative Grouper +# # Revision 1.23 2003/10/15 03:44:01 stefan # add new Grouper 'group2' to match '@group {' and '@group }' # @@ -541,7 +545,10 @@ class Stripper(CommentProcessor): """Summarize the comment of this declaration.""" if not len(decl.comments()): return - decl.comments()[:] = [decl.comments()[-1]] + if decl.comments()[-1].is_suspect(): + decl.comments()[:] = [] + else: + decl.comments()[:] = [decl.comments()[-1]] class Summarizer (CommentProcessor): """Splits comments into summary/detail parts.""" From stefan at synopsis.fresco.org Wed Oct 15 04:29:01 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:42 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parser/C++/syn swalker.cc,1.76,1.77 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn In directory frida:/tmp/cvs-serv16077/Synopsis/Parser/C++/syn Modified Files: swalker.cc Log Message: * only keep last comment if it is not suspect * provide an alternative Grouper Index: swalker.cc =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parser/C++/syn/swalker.cc,v retrieving revision 1.76 retrieving revision 1.77 diff -u -p -d -r1.76 -r1.77 --- swalker.cc 13 Oct 2003 18:50:20 -0000 1.76 +++ swalker.cc 15 Oct 2003 04:28:58 -0000 1.77 @@ -25,6 +25,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.77 2003/10/15 04:28:58 stefan +// * only keep last comment if it is not suspect +// * provide an alternative Grouper +// // Revision 1.76 2003/10/13 18:50:20 stefan // * provide a clearer definition of 'Comment', i.e. // a single comment as opposed to a list of comments @@ -302,9 +306,23 @@ SWalker::add_comments(AST::Declaration* next = next->Rest(); } + // all comments that are not immediately (i.e. separated + // by a single new line) followed by a declaration are + // marked as 'suspect' + bool suspect = false; + char* pos = first->GetPosition() + first->GetLength(); + while (*pos && strchr(" \t\r", *pos)) ++pos; + if (*pos == '\n') + { + ++pos; + // Found only allowed \n + while (*pos && strchr(" \t\r", *pos)) ++pos; + if (*pos == '\n' || !strncmp(pos, "/*", 2)) suspect = true; + } + if (decl) { - AST::Comment* comment = make_Comment(m_file, 0, first); + AST::Comment* comment = make_Comment(m_file, 0, first, suspect); comments.push_back(comment); } if (m_links) m_links->long_span(first, "file-comment"); From stefan at synopsis.fresco.org Tue Oct 21 20:53:32 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:42 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Formatter/HTML Page.py,1.16,1.17 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Formatter/HTML In directory frida:/tmp/cvs-serv15298 Modified Files: Page.py Log Message: reenable logging of page instance to aid debugging Index: Page.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Formatter/HTML/Page.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -p -d -r1.16 -r1.17 --- Page.py 16 Jan 2003 12:46:46 -0000 1.16 +++ Page.py 21 Oct 2003 20:53:30 -0000 1.17 @@ -20,6 +20,9 @@ # 02111-1307, USA. # # $Log$ +# Revision 1.17 2003/10/21 20:53:30 stefan +# reenable logging of page instance to aid debugging +# # Revision 1.16 2003/01/16 12:46:46 chalky # Renamed FilePages to FileSource, FileTree to FileListing. Added FileIndexer # (used to be part of FileTree) and FileDetails. @@ -111,7 +114,7 @@ class PageFormat: as appropraite.""" return self.__prefix - def page_header(self, os, title, body, headextra): + def page_header(self, os, title, body, headextra, page): """Called to output the page header to the given output stream. @param os a file-like object (use os.write()) @param title the title of this page @@ -122,6 +125,8 @@ class PageFormat: """ os.write('') os.write("\n\n") + os.write('\n') + os.write('\n') os.write(entity('title','Synopsis - '+ title) + '\n') ss = self.stylesheet() if ss: os.write(solotag('link', type='text/css', rel='stylesheet', href=ss) + '\n') @@ -206,7 +211,7 @@ class TemplatePageFormat (PageFormat): sections = string.split(text, '@PREFIX@') os.write(string.join(sections, self.prefix())) - def page_header(self, os, title, body, headextra): + def page_header(self, os, title, body, headextra, page): """Formats the header using the template file""" if not body: return PageFormat.page_header(self, os, title, body, headextra) header = self.__header @@ -320,7 +325,7 @@ class Page: self.__os = self.open_file() prefix = rel(self.filename(), '') self.__format.set_prefix(prefix) - self.__format.page_header(self.__os, self.title(), body, headextra) + self.__format.page_header(self.__os, self.title(), body, headextra, self) def end_file(self, body=''): """Close the file using given close body tag. The default is From stefan at synopsis.fresco.org Thu Oct 30 05:54:38 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:42 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Parser/Python Parser.py,NONE,1.1 __init__.py,1.5,1.6 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Parser/Python In directory frida:/tmp/cvs-serv8010/Synopsis/Parser/Python Modified Files: __init__.py Added Files: Parser.py Log Message: add Processor base class --- NEW FILE: Parser.py --- # $Id: Parser.py,v 1.1 2003/10/30 05:54:36 stefan Exp $ # # Copyright (C) 2003 Stefan Seefeld # All rights reserved. # Licensed to the public under the terms of the GNU GPL (>= 2), # see the file COPYING for details. # from Synopsis.Core.Processor import Processor from python import parse class Parser(Processor): basename='' def process(self, **kwds): for file in kwds['input']: print file parse(file, 0, {}, None) # # $Log: Parser.py,v $ # Revision 1.1 2003/10/30 05:54:36 stefan # add Processor base class # Index: __init__.py =================================================================== RCS file: /cvs/synopsis/Synopsis/Synopsis/Parser/Python/__init__.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -p -d -r1.5 -r1.6 --- __init__.py 13 Feb 2001 06:55:23 -0000 1.5 +++ __init__.py 30 Oct 2003 05:54:36 -0000 1.6 @@ -1,7 +1,20 @@ +# $Id$ +# +# Copyright (C) 2003 Stefan Seefeld +# All rights reserved. +# Licensed to the public under the terms of the GNU GPL (>= 2), +# see the file COPYING for details. +# + """Parser for Python based around Python's docstring extraction example""" # Python parser from python import parse, usage, get_synopsis - +from Parser import Parser # THIS-IS-A-PARSER +# +# $Log$ +# Revision 1.6 2003/10/30 05:54:36 stefan +# add Processor base class +# From stefan at synopsis.fresco.org Thu Oct 30 05:54:38 2003 From: stefan at synopsis.fresco.org (Stefan Seefeld) Date: Wed Mar 2 21:06:42 2005 Subject: [Synopsis-changes] Synopsis/Synopsis/Synopsis/Core Processor.py,NONE,1.1 Message-ID: Update of /cvs/synopsis/Synopsis/Synopsis/Core In directory frida:/tmp/cvs-serv8010/Synopsis/Core Added Files: Processor.py Log Message: add Processor base class --- NEW FILE: Processor.py --- # $Id: Processor.py,v 1.1 2003/10/30 05:54:36 stefan Exp $ # # Copyright (C) 2003 Stefan Seefeld # All rights reserved. # Licensed to the public under the terms of the GNU GPL (>= 2), # see the file COPYING for details. # import sys class Processor(object): """Processor overrides the __new__ operator for automatic attribute instantiation. All class attributes of type Processor (or lists or tuples thereof) found in any base class of the given type are instantiated and assigned to instance attributes of the same name for the newly created instance, thus overriding the old value. This, together with the __init__ function that sets instance attributes directly, unifies the different ways to configure processors. Either an option is overridden as a class attribute set in a customized sub-class, or it is passed as a named value to the constructor.""" def __new__(cls, *args, **kwds): """Initialize the instance attribute dictionary such that attributes of type 'Processor' are replaced by Processor objects.""" dictionary = {} # iterate over all base classes, starting on the root hier = list(cls.__mro__[:]) hier.reverse() for c in hier: for name, value in c.__dict__.items(): # skip privates if name.startswith("_"): continue # if this is a processor, instantiate it if (type(value) == type and issubclass(value, Processor)): dictionary[name] = value() # if this is a list or tuple containing # at least one processor, instantiate the whole list elif ((type(value) == list or type(value) == tuple) and filter(lambda item:(type(item) == type and issubclass(item, Processor)), value)): # generate a new list, replacing all Processor types # by their respective instances... new_list = map(lambda item:(type(item) == type and issubclass(item, Processor) and item() or item), value) dictionary[name] = new_list # if there already is an entry from a base class # override it, no matter the type elif name in dictionary: dictionary[name] = value instance = object.__new__(cls) instance.__dict__.update(dictionary) return instance verbose=False def __init__(self, **kwds): """Use named values to override default attributes.""" self.__dict__.update(kwds); def process(self, **kwds): """provide the processor specific code here""" self.__dict__.update(kwds); def error(msg): """Write an error message and exit.""" sys.stderr.write(msg) sys.stderr.write('\n') sys.exit(-1) def process(**kwds): """Define the entry point to synopsis. Call this at the end of the frontend script, passing named processors that can be called by name such as: python synopsis.py parse arg1=value1 """ if len(sys.argv) < 2: print 'usage : %s [args]'%sys.argv[0] sys.exit(-1) command = sys.argv[1] props = {} args = sys.argv[2:] while args and args[0].find('=') != -1: l = args[0].split('=') if len(l) < 2: raise Error, 'argument "%s" not propname=value'%args[0] key, value = l[0], '='.join(l[1:]) if value: try: props[key] = eval(value) except: error("""an error occured trying to evaluate \'%s\' to pass this as a string, please use %s="'%s'" """%(value, key, value)) else: props[key] = None args = args[1:] # remaining arguments are mapped to the 'input' value, # if that is not yet defined if args and 'input' not in props: props['input'] = args if command in kwds: try: kwds[command].process(**props) except KeyError, e: error('missing argument "%s"'%e) else: error('no command "%s"'%command) # # $Log: Processor.py,v $ # Revision 1.1 2003/10/30 05:54:36 stefan # add Processor base class #