sunsetquest / cppheadertocsharpconverter Goto Github PK
View Code? Open in Web Editor NEWA compile-time tool for converting C/C++ header constants, enums, and structures to C#.
A compile-time tool for converting C/C++ header constants, enums, and structures to C#.
Running on a source file with the following text:
`
typedef enum
{
MI_INVALID_0 = 0, // do not modify
MI_OOB, // do not modify
MI_ErrorMessage, // do not modify
MI_MessageCode, // do not modify
// NOTE: try to put messages that are likely to be used by *any* system in the first group, this may be fixed for these, sometime
MI_REG_START, // used for looping
MI_Fans = MI_REG_START, // fan data
MI_Currents, // current data from water probe etc.
MI_State1, // a regular dump of all data 1 (includes event data, allows synchronisation without restart)
MI_State2, // a regular dump of all data 2 (ditto)
MI_State3,
MI_REG_END = MI_State3, // used for looping
MI_INVALID_MAX = 0xFF // do not modify
} MsgIds_t;
`
And receive the following output
[Flags] public enum MsgIds_t { MI_INVALID_0 = 0, MI_OOB, MI_ErrorMessage, MI_MessageCode, group, these, MI_REG_START, MI_Fans = MI_REG_START, MI_Currents, MI_State1, data, MI_State2, MI_State3, MI_REG_END = MI_State3, MI_INVALID_MAX = 0xFF // do not modify, };
I applied a minor patch to strip any comments out from the rows, diff below.
I'm using your tool in a multi-header use though, so I may send a few more fixes through, at the moment I have 20 files all with a constant class :). Apart from that, I'm hoping this will save me a bit of effort on keeping a embedded projects header files in step with the C# backend that is receiving messages from it.
Thanks for the work!
`
cppHeaderParse/Program.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/cppHeaderParse/Program.cs b/cppHeaderParse/Program.cs
index abccfff..bed3d4c 100644
--- a/cppHeaderParse/Program.cs
+++ b/cppHeaderParse/Program.cs
@@ -290,6 +290,7 @@ namespace cppHeaderParse
string rows = match.Groups["enum_rows"].ToString() + ",";
sb.AppendLine(" public enum " + name);
sb.AppendLine(" {");
rows = Regex.Replace(rows, @"//.*", string.Empty);
MatchCollection items = Regex.Matches(rows,
@"\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*(?:\s*=\s*([^\,(?:\r?\n)\{\}\;]*?))?\s*,");
foreach (Match r in items)
`
Can you tell me if this tool has any support for:
All of these would be common requirements on the kind of project I work on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.