C++ 中的面向方面编程- 当前支持的替代方案

发布于 2024-10-03 01:10:05 字数 353 浏览 3 评论 0原文

我之前在 Java 中使用过 AspectJ,最近我考虑检查 C++ 语言存在哪些可能性。

我听说过 AspectC++,但与 AspectJ 不同,AspectC++ 似乎已被放弃,因为最新版本的发布日期为 21.12 .2005年,根据他们的网站。

我想知道目前是否有任何更新的替代方案正在使用或开发,并且仍然受到支持并不断更新和发展,并且这些替代方案中是否有某种集成插件可以更轻松地在 Eclipse IDE 中使用。

如果没有,在考虑使用 AspectC++ 之前我是否应该注意一些最有问题的限制?

提前致谢。

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 AspectJ, AspectC++ seems to be abandoned in the sense that the latest release dates from 21.12.2005, according to their website.

I wonder if there are any more recent alternatives currently being used or developed nowadays, and which are still supported and having continuous updates and evolution, and also if any of such alternatives happen to have some sort of integration plugin for easier use within the Eclipse IDE.

In the event that there aren't, are there some most problematic limitations from AspectC++ that I should be aware of before considering to use it?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

看透却不说透 2024-10-10 01:10:05

AspectC++ 是一次值得尝试的尝试,但大学项目通常不会继续下去,因为产品往往不够稳健,最初的学者失去了兴趣,而构建它的研究生则继续前进。当我在 2010 年写下这个答案时,情况似乎就是这样。令我惊讶的是,在 2017 年,AspectC++ 似乎仍然在积极开发。如果您想要仅仅 C++ 的方面,这可能值得一看。

面向方面的编程只是一种特殊的程序转换(“查找与此条件(‘切入点’)匹配的位置,并对该位置的代码执行此操作”)。所以,如果你有一个程序转换工具,你就可以很容易地模拟 AOP。要在 C++ 上进行转换,您需要强大的 C++ 前端以及转换和重新生成代码的能力。 OpenC++ 是一个进行 C++ 转换的项目,其中转换纯粹编码为带有过程 AST 修改的过程 AST 行走。一个特殊的问题与 OpenC++ 处理 C++ 的哪种方言有关。特别是,我不确定 OpenC++ 是否处理了 C+ 的模板或完整的常见方言(GCC、MS);然而我没有直接的经验,只是这些工具的狂热爱好者。

我们的 DMS 软件再工程工具包是一个通过语言定义参数化的通用程序转换。它具有针对 C++ 的 GCC 和 MS 方言的可靠定义。您可以像 OpenC++ 一样按程序实现程序转换,或者更方便地,您可以编写源到源模式定向转换(或者更常见的是,混合这些以实现复杂的效果)。 DMS 已用于对大规模 C++ 代码进行大规模重组
(参见案例研究:通过自动程序转换重新设计 C++ 组件模型)。 DMS 得到积极维护,但它是商业性的。

2015 年 3 月编辑:现在 GCC 和 MS 方言中包含 C++14。

2017 年 7 月编辑:现在在 GCC 和 MS 方言中使用 C++17。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文