From: Grzegorz J. <ja...@he...> - 2004-05-11 00:42:52
|
On Mon, 10 May 2004, Aitor Garay-Romero wrote: > Hi there!, > > Lately I have been thinking on how it could be possible to implement an > iContract like tool for C++. iContract is a Design by Contract tool for > Java. The basic idea is to parse the C++ source code looking for special > comment blocks that specify the precondition/postcondition/invariants of the > class. Then the input source code is extended with code that check the > contracts at runtime. > There are a few options for implementing such a DbC tool for C++. I have > come to OpenC++ and believe that is the most promising way to implement it > "easily". Other alternatives I'm considering are implementing a standalone > application that uses some freely available grammar or may be extending the > AspectC compiler. > I have no experience at all with OpenC++ and I have a few doubts. > > - do OpenC++ meta-programs have access to the source code comments? Only at the class level, see Class::Comments(). However lexer recognizes comments, you would need to tweak parser to put the comments in the parse tree. > - are the meta-programs able to transverse the inheritance hierarchy of a > given class? Yes. > - how well does OpenC++ handle macros? OpenC++ does not see any macros, OpenC++ works on preprocessed sources. AFAIU this is what you need. Some applications, however, need to understand code with macros unexpanded (e.g. if you want to regenerate human-readable source code). Asen Kovachev, Stefan Seelfeld and myself are thinking of this functionality, but it is definitely still in "thinking" phase. > And namespaces? OpenC++ understand namespaces and qualified names except namespace aliases. Thanks to Stefan namespace alias declarations can be parsed now, but still they are not considered in lookup :-( > - is it possible to introduce new methods in the generated classes? Yes. > Is it > possible to do arbitrary transformations like nesting the body of a method > inside some try/catch blocks? Yes. > > Sorry for the long list of questions, it would be very helpful if I can get > a rough idea of OpenC++ possibilities before getting deep into it. Has > someone hear about some similar effort of implementing DbC for C++? Any > ideas? (1) Browse archives of this list to get more insight of what can be done. (2) There are two major modes of using OpenC++: * Deriving classes from "Class" in order to customize the source-to-source translation. * Taking OpenC++ source code as a code base to build your own application of top of it (it usually means deriving from "Abstract...Walker" and/or making modifications to existing code). (3) The most up-to-date version of OpenC++ is in sandbox_jakacki_frontend1, Stefan and myself are working now on merging it to MAIN and releasing it soon. BR Grzegorz > > Thanks!, > > /AITOR > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Sleepycat Software > Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver > higher performing products faster, at low TCO. > http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 > _______________________________________________ > Opencxx-users mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/opencxx-users > > ################################################################## # Grzegorz Jakacki Huada Electronic Design # # Senior Engineer, CAD Dept. 1 Gaojiayuan, Chaoyang # # tel. +86-10-64365577 x2074 Beijing 100015, China # # Copyright (C) 2004 Grzegorz Jakacki, HED. All Rights Reserved. # ################################################################## |