View previous topic :: View next topic |
Author |
Message |
BenHinkle
Joined: 27 Mar 2004 Posts: 76
|
Posted: Tue Jun 29, 2004 1:37 pm Post subject: running h2d on /usr/include |
|
|
I just ran across this project and it looks very cool! I haven't tried it yet but I have a bunch of C headers to test it out on.
Imagine running this at DMD install time to grok all the local C headers in /usr/include and make D wrappers! That way we could get rid of std/c/linux/ and std/c/windows/ and replace it with "the real thing". Is there any hope of doing this or would that be too ambitious?
-Ben |
|
Back to top |
|
|
Cabal
Joined: 28 Apr 2004 Posts: 18 Location: UK
|
Posted: Tue Jun 29, 2004 3:21 pm Post subject: |
|
|
Lo Ben,
Hows that for providence? The first time I get time to look at this in 3 weeks and its the day someone else posts here.
My original intention was for h2d to be used on selected strategic headers which could be viewed as D modules. eg. pthread.h or al.h from the openal project. These high level files would be C pre-processed before h2d'ing to produce complete D wrappers around a logical piece of functionality.
But.... of the two people that have expressed an interest, 100? have assumed that individual C headers would be processed independently. So, not having any real objections to going down that route (I have a feeling something will bite me whichever way I jump) its time to have a little rethink.
Using h2d wholesale on /usr/include will require a few major changes, the first of which that spring to mind will be exchanging #includes for imports. The second thing will be to excise any included header definitions from the C pre-processed file - I still favour running the headers thru the C pre-processor prior to h2d'ing as I *really* don't want to be having to sort out all the #ifdef's myself. err... thats all for now - its getting late.
Anyone with any ideas for things I will need to take into account is most welcome to post them here. Looking at the traffic on the forum, that means you Ben
Cabal _________________ In all large corporations, there is a pervasive fear that someone, somewhere is having fun with a computer on company time. Networks help alleviate that fear.
John C. Dvorak |
|
Back to top |
|
|
BenHinkle
Joined: 27 Mar 2004 Posts: 76
|
Posted: Wed Jun 30, 2004 9:12 pm Post subject: |
|
|
I agree with the approach of pre-processing the header first. I guess when I said "all of /usr/include" I meant "all the important stuff in /usr/include" like the pthread.h you mention. All the hierarchy of foo.h importing bits/foo.h and so on is probably not worth worrying about.
Of course, if the h2d transformation is 100? correct (cough cough) maybe we could convince Walter that a special import flag could be added to the language so that the D compiler runs the transformation automatically. Basically what I have in mind is that if a D file has
import pthread.h
then the compiler will run the transformer on pthread.h (I guess it would need to start worrying about C include paths...) and import that. The biggest drawback is that modules can't be called "h" then and the transformer would have to be very very good. |
|
Back to top |
|
|
Cabal
Joined: 28 Apr 2004 Posts: 18 Location: UK
|
Posted: Thu Jul 01, 2004 1:38 am Post subject: |
|
|
h2d is not meant to be 100?. It is most definitely and intentionally a 95? solution - I have no intention of spending the sort of time which would be required to complete the last 5?. As I've said before (not in this thread) h2d is not the correct way to go about this. The correct way would be to hijack an existing C frontend and modify it so that it produces legal D. A gcc hacker or Walter (as he produces the Mars C compiler) would be much more suited to that task - and quite frankly given Walters skillset and the amount of 'wasted' effort which appears to be going into converting C headers I am gobsmacked that he hasn't already done the job. Anyway, I can't foresee the point where h2d would be suitable for the sort of integration into D that you would like to see. Feel free to prove me wrong
As of now I intend taking h2d forward with a couple more scripts to auto-generate a D module directory tree from a list of supported headers. You would download h2d, compile it up (maybe) and run the script. It will parse a file listing headers which I know are converted correctly (possibly with the help of patches) and output D modules in an equivalent tree.
If you haven't tried h2d yet, give it go. The binary is reasonably compent at the 95? of the work that's required of it and the patch facility does the rest. Give the README a view to get your bearings.
Cabal _________________ In all large corporations, there is a pervasive fear that someone, somewhere is having fun with a computer on company time. Networks help alleviate that fear.
John C. Dvorak |
|
Back to top |
|
|
|