Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 09, 2013 [Issue 9285] New: dtoh | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9285 Summary: dtoh Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrei@erdani.com --- Comment #0 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-09 00:10:47 PST --- Generating D files from C or C++ header files is a difficult endeavor. However, the converse process of generating C++ header files from D source files is easier to approach, and very useful. Possible uses include migrating a large C++ codebase to D in small steps without needing to deal with declaration duplication across D code and C++ legacy code. (The dmd compiler itself may use the tool.) Using D as source and translating from D to C++ gives a robust unique point of maintenance. Here are a few requirements: * dtoh takes a D file as input and generates C++ declarations for all pertinent function and class declarations in the D file. * Accepted declarations: data, functions, classes, and interfaces for all types that have a C++ correspondent. * D declarations that cannot be translated into C++ will be ignored. * In order to stay decoupled from the compiler, dtoh should generate C++ code from the JSON output of the D compiler. * For make friendliness, dtoh should overwrite its output if and only if the generated output is different from the existing output. * The generated C++ code should be human readable (nicely indented etc) and use good C++ practices (e.g. include guards etc). * C++11 generation is default, there should be an option to generate C++98. The tool would be in the tools/ repository and distributed alongside with the compiler in source and binary forms. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 Alex Rønne Petersen <alex@lycus.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |alex@lycus.org --- Comment #1 from Alex Rønne Petersen <alex@lycus.org> 2013-01-09 09:14:55 CET --- So how do you see this working overall? Generate a bunch of mangled declarations in the resulting .h and then generate some nice C++-y wrappers around them? > * C++11 generation is default, there should be an option to generate C++98. Virtually every C++ compiler in existence supports C++03, so why not that? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 Iain Buclaw <ibuclaw@ubuntu.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ibuclaw@ubuntu.com --- Comment #2 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-01-09 00:20:53 PST --- (In reply to comment #1) > So how do you see this working overall? Generate a bunch of mangled declarations in the resulting .h and then generate some nice C++-y wrappers around them? > > > * C++11 generation is default, there should be an option to generate C++98. > > Virtually every C++ compiler in existence supports C++03, so why not that? It's true, even GCC's -std=c++98 switch is just an alias for -std=c++03 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 --- Comment #3 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-09 00:22:31 PST --- (In reply to comment #1) > So how do you see this working overall? Generate a bunch of mangled declarations in the resulting .h and then generate some nice C++-y wrappers around them? No, just generate declarations for extern(C++) names. This is a tool for people who want to interface with C++ and know what steps to take. > > * C++11 generation is default, there should be an option to generate C++98. > > Virtually every C++ compiler in existence supports C++03, so why not that? OK -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh utility - convert D files to C++ header files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich@gmail.com --- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-09 08:58:26 PST --- (In reply to comment #0) > * In order to stay decoupled from the compiler, dtoh should generate C++ code from the JSON output of the D compiler. JSON output still needs fixing, see https://github.com/D-Programming-Language/dmd/pull/1179 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh utility - convert D files to C++ header files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 Adam D. Ruppe <destructionator@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |destructionator@gmail.com --- Comment #5 from Adam D. Ruppe <destructionator@gmail.com> 2013-01-09 09:07:41 PST --- I just slapped something together very very quickly. It works for a couple simple things I've tried on linux: simple functions and interfaces. http://arsdnet.net/dcode/dtocpp.zip includes a little test program (test.c, test.cpp, and testcpp.d), a makefile for it, and of course, the main app, dtoh.d. dmd dtoh.d make The makefile will regenerate testcpp.json and run dtoh to build testcpp.h. I just realized, I guess I should add POD structs too, but I have real work to get back to now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh utility - convert D files to C++ header files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 --- Comment #6 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-09 10:14:10 PST --- (In reply to comment #5) > I just slapped something together very very quickly. It works for a couple simple things I've tried on linux: simple functions and interfaces. > > http://arsdnet.net/dcode/dtocpp.zip > > includes a little test program (test.c, test.cpp, and testcpp.d), a makefile for it, and of course, the main app, dtoh.d. > > dmd dtoh.d > make > > The makefile will regenerate testcpp.json and run dtoh to build testcpp.h. > > > I just realized, I guess I should add POD structs too, but I have real work to get back to now. Great. When you'll assess your work is in reviewable form, you may want to submit it as a pull request to github.com/D-Programming-Language/tools. Once we have a good initial codebase others can work on it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh utility - convert D files to C++ header files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 --- Comment #7 from Adam D. Ruppe <destructionator@gmail.com> 2013-01-09 11:16:49 PST --- work is boring so i updated the zip instead. Hit a few problems, we'll really need to improve dmd's json output (I vote for that pull request!) to go much further than this I think. Maybe fix up forward declarations but meh. Turning import into include needs more json from dmd as well, and that's going to be nice to have for real work (though not strictly necessary... the user could always #include everything in the main file). Anyway here it is: http://arsdnet.net/dcode/dtocpp.zip Now structs are outputted too, as plain data skipping any functions (which I'm pretty sure should work anyway), and types are translated a little differently. If you write your declarations in D, whether you implement them in C++ or D doesn't matter, this is kinda cool for going both ways. But yeah I think this is about as good as we're going to get until that dmd pull request for json happens. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2013 [Issue 9285] dtoh utility - convert D files to C++ header files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 --- Comment #8 from Andrei Alexandrescu <andrei@erdani.com> 2013-01-09 11:22:05 PST --- (In reply to comment #7) > Turning import into include needs more json from dmd as well Please submit to bugzilla anything you have, and fill the "depends on" field above to mark the dependency. Thanks! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 15, 2013 [Issue 9285] dtoh utility - convert D files to C++ header files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=9285 --- Comment #9 from Adam D. Ruppe <destructionator@gmail.com> 2013-01-15 10:11:18 PST --- Here's a pull request with what I wrote up last week: https://github.com/D-Programming-Language/tools/pull/39 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation