C++ Equivalents
-
I decided to make my life much harder than it is and convert some C++ code I have to C# (and possibly Java some day). Please - no "Why do that you dummy" responses, that serves no purpose. Also, with NO EXCEPTIONS there isno single tool to take a C++ code set, reverse it to a complete UML model and re-engineer it into C# (there are numerous tools that kinda do parts, but still leave too much work. I figured out that a combination of 6(six) yes 6 tools will provide that process at a total cost to myself of too much (money and effort). Lastly, C++ has too much complexity and I refuse to pander to it anymore than I must - AND I DO NOT WANT TO WRITE MY OWN PARSER for all the crap that's snuck into it. Actually I'm answering some personal questions I have about development and processes in general and this seemed like a good test. Also I have a large body of "real" C++ code I'd like to rebuild in C# and I'm working on a methodology and VS tools to do it. I selected this specific code for specific reasons and is quite large and complex (its the source code to a windows based RTS game from a few years back), and I think I have a handle on most issues. However .... I would like suggestions as to how to gracefully handle the following situations: (what I'm currently doing in parens) - TYPEDEF's (So far I've punted and done a global Search and Replace) - Macros (Utility functions) - Unions (distinct structs, remodelled use) - const (removed and ignored) Any physiologically possible solutions gratefully received and considered. If you have any additional problems in this (such as struct inheritance) please let me know. If I get the time I'll post an article on this subject (with attributions) - I can't be the only person wishing for a NET/C# alternative to some of the s****y C++ code out there. Nor the only person who wants tools to make it more efficient.
Nothing is impossible, we just don't know the way of it yet.
-
I decided to make my life much harder than it is and convert some C++ code I have to C# (and possibly Java some day). Please - no "Why do that you dummy" responses, that serves no purpose. Also, with NO EXCEPTIONS there isno single tool to take a C++ code set, reverse it to a complete UML model and re-engineer it into C# (there are numerous tools that kinda do parts, but still leave too much work. I figured out that a combination of 6(six) yes 6 tools will provide that process at a total cost to myself of too much (money and effort). Lastly, C++ has too much complexity and I refuse to pander to it anymore than I must - AND I DO NOT WANT TO WRITE MY OWN PARSER for all the crap that's snuck into it. Actually I'm answering some personal questions I have about development and processes in general and this seemed like a good test. Also I have a large body of "real" C++ code I'd like to rebuild in C# and I'm working on a methodology and VS tools to do it. I selected this specific code for specific reasons and is quite large and complex (its the source code to a windows based RTS game from a few years back), and I think I have a handle on most issues. However .... I would like suggestions as to how to gracefully handle the following situations: (what I'm currently doing in parens) - TYPEDEF's (So far I've punted and done a global Search and Replace) - Macros (Utility functions) - Unions (distinct structs, remodelled use) - const (removed and ignored) Any physiologically possible solutions gratefully received and considered. If you have any additional problems in this (such as struct inheritance) please let me know. If I get the time I'll post an article on this subject (with attributions) - I can't be the only person wishing for a NET/C# alternative to some of the s****y C++ code out there. Nor the only person who wants tools to make it more efficient.
Nothing is impossible, we just don't know the way of it yet.
"- TYPEDEF's (So far I've punted and done a global Search and Replace)" - I think this is the only practical way to handle typedef. You can replace certain simple cases with the C# alias syntax "using Foo = x.y.z". "- Macros (Utility functions)" - We handle it with search/replace combined with replacement with the simple C# flag type #define (the flag #define allows the converted #ifdef FOO directives to continue to be useful). One problem is that macros are type-less, so it's problematic to refactor these to static methods. "- const (removed and ignored)" - Yes, they must be removed, but they provide information for a C++ to C# conversions (especially for parameters). C++ to C# (or to any other language) is indeed no picnic (we've recently released 'C++ to C# Converter', which eases the task somewhat, but there's just too much complexity in the C++ language to allow a high conversion rate).
David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter C++ to C# Converter: converts C++ to C# C++ to VB Converter: converts C++ to VB Instant C++: converts C# to C++/CLI and VB to C++/CLI Instant Python: converts C# to IronPython and VB to IronPython
-
"- TYPEDEF's (So far I've punted and done a global Search and Replace)" - I think this is the only practical way to handle typedef. You can replace certain simple cases with the C# alias syntax "using Foo = x.y.z". "- Macros (Utility functions)" - We handle it with search/replace combined with replacement with the simple C# flag type #define (the flag #define allows the converted #ifdef FOO directives to continue to be useful). One problem is that macros are type-less, so it's problematic to refactor these to static methods. "- const (removed and ignored)" - Yes, they must be removed, but they provide information for a C++ to C# conversions (especially for parameters). C++ to C# (or to any other language) is indeed no picnic (we've recently released 'C++ to C# Converter', which eases the task somewhat, but there's just too much complexity in the C++ language to allow a high conversion rate).
David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter C++ to C# Converter: converts C++ to C# C++ to VB Converter: converts C++ to VB Instant C++: converts C# to C++/CLI and VB to C++/CLI Instant Python: converts C# to IronPython and VB to IronPython
Valid point regarding the const - the information IS important to C++ but can be dealt with at the C# model level (remove the need). I looked at the demo - fairly nice tool but addresses pure conversion only. A very real secondary need (almost at the same level as pure translation) is the ability to place the C++ code into a UML model - not just the class diagrams, but sequence etc diagrams too. Then I can "Fix" some issues of the basic model, perform package management, remodel the design, etc, and regenerate/test. I would suggest you look at CodeVizualizer (http://www.codedrawer.com/ - $50) which is a great tool for learning individual code segments but doesn't have the ability to generate all documentation I require/need for analysis, nor does it provide the big picture. I would highly recommend it for a utility tool for a C++ maintenance/enhancement project, but it falls short of being a "corporate" architect tool.
Nothing is impossible, we just don't know the way of it yet.