Aspect Oriented Programming in C++ - Current supported alternatives

前端 未结 2 640
执笔经年
执笔经年 2021-02-10 01:28

I have used AspectJ before for Java, and I recently have thought about checking which possibilities exist for the C++ language.

I heard about AspectC++, but unlike Aspec

相关标签:
2条回答
  • 2021-02-10 01:42

    AspectC++ was a worthy try but university projects don't often continue because the products tend not to be robust, the original academics lose interest and the graduate students that build it move on. That appeared to be case when I wrote this answer in 2010. To my surprise in 2017, AspectC++ still seems to have active development. If you want just aspects for C++, this is probably worth a look.

    Aspect-oriented programming is a just a special kind of program transformation ("find places that match this condition ('pointcut') and do this to the code at that place"). So, if you have a program transformation tool, you can emulate AOP pretty easily. To do transformation on C++ you need a strong C++ front end and as well as ability to transform and regenerate code. OpenC++ was a project to do C++ transformations, where the transformations are coded purely as procedural AST-walks with procedural AST modifications. A particular issue had to do with which dialect of C++ was handled by OpenC++; in particular, I'm not sure OpenC++ handled templates or full common dialects (GCC, MS) of C+; however I have no direct experience with it, just a keen aficionado of such tools.

    Our DMS Software Reengineering Toolkit is a general purpose program transformation parameterized by language definitions. It has robust definitions for GCC and MS dialects of C++. You can implement program transformations procedurally as OpenC++ does, or more conveniently you can write source-to-source pattern-directed transformations (or more usually, mix these to achieve complex effects). DMS has been used to carry out massive restructuring of large scale C++ codes (see Case study: Re-engineering C++ component models via automatic program transformation ). DMS is actively maintained, but it is commercial.

    EDIT March, 2015: Now does C++14 in GCC and MS dialects.

    EDIT July 2017: Now does C++17 in GCC and MS dialects.

    0 讨论(0)
  • 2021-02-10 02:03

    comp.lang.c++ convo I was in a couple years ago lead to something interesting I never actually tried myself: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/c5fd9337577b0bdf/1c639d8b6b3c0985?hl=en&ie=UTF-8&q=comp.lang.c%2B%2B+noah+roberts+aspect+oriented+template#1c639d8b6b3c0985

    0 讨论(0)
提交回复
热议问题