逆向工程 C++使用“企业架构师”编写代码

发布于 2024-10-08 15:10:34 字数 779 浏览 7 评论 0原文

这又是一个“如何正确地做”的问题。抱歉,如果有人生气了。

我必须理解大约 150 个 C/C++ 混合物的 TLOC。我已经在 UML 工具“Enterprise Architect”中导入了代码,并得到了一个凌乱的图表。由于这种类似 C 的构造,许多结构和枚举都具有匿名名称:typedef struct/enum {...} MyType;

在第二次运行中,我将其转换为 C++ 形式:struct/ enum MyType{...}; 但得到了一堆不相关的结构。不幸的是,Enterprise Architect 无法解析 typedef。例如,A、B 和 C 之间没有关系被识别:

struct A;
struct B;
typedef A *PtrA;
typedef List<B> BList;
struct C{ PtrA pA; BList lB; };

由于整个命名约定,我能够用原始类型替换所有 typedef,如下所示:

struct C{ A pA; B lB; };

现在在“企业架构师”中导入源代码给出了包含所有关系的漂亮图表。 当然,代码无法编译,并且不一样。代码中的所有更改都需要进行烦人的转换,以使 EA 再次可以理解此“伪”代码。因此我的问题是:

  1. 是否有可能教授 EA 识别原始类型?
  2. 其他 UML 工具是否识别这些类型 (并在它们之间建立关系) 更稳健?

非常感谢您的任何建议! 瓦伦丁·海尼茨

It is again a sort of "how to do it properly" question. Sorry if someone is annoyed.

I've got to understand ca 150 TLOCs of C/C++ mixture. I've imported the code in UML-Tool "Enterprise Architect" and got a messy chart. Many Structs and Enums had anonymous names because of this C-ish constructs: typedef struct/enum {...} MyType;

In second run I've converted it to C++ form: struct/enum MyType{...}; but got a bunch of unrelated structs. Unfortunately, Enterprise Architect doesn't resolve typedefs. e.g. no relations between A, B and C were recognized:

struct A;
struct B;
typedef A *PtrA;
typedef List<B> BList;
struct C{ PtrA pA; BList lB; };

Thanks to throughout naming convention, I was able to replace all typedefs by original type like this:

struct C{ A pA; B lB; };

Now importing source-code in "Enterprise Architect" gave a nice diagram with all relations.
Of cause, the code doesn't compile, and is not the same. All changes in code require an annoying conversion for making this "pseudo" code understandable by EA again. Therefore my questions:

  1. Is there any possibility to teach EA
    recognizing the original types?
  2. Do other UML-Tools recognize the types
    (and create relations between them)
    more robust?

Thank you very much for any advice!
Valentin Heinitz

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

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

发布评论

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

评论(1

独留℉清风醉 2024-10-15 15:10:35

我有 Enterprise Architect,并且几乎总是为了在大型代码体上执行您尝试的操作,我使用 doxygen 代替。它生成类图和调用图。将其与 GraphViz 和“UML 样式”类图一起使用,您将获得相当好的代码导航和理解工具,具有灵活的配置,可以根据需要添加或排除细节。

I have Enterprise Architect, and almost invariably for doing what you are attempting on a large code body I use doxygen instead. It generates both class and call graphs. Use it with GraphViz and "UML-style" class diagrams, and you have a reasonably good code navigation and comprehension tool, with flexible configuration to add or exclude detail as necessary.

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