Jump to page: 1 24  
Page
Thread overview
htod - convert C .h files to D import files
May 21, 2006
Walter Bright
May 22, 2006
Dave
May 22, 2006
Tom
May 22, 2006
Derek Parnell
May 22, 2006
Walter Bright
May 22, 2006
Lionello Lunesu
May 22, 2006
Walter Bright
May 22, 2006
Walter Bright
May 22, 2006
Lionello Lunesu
May 22, 2006
Lionello Lunesu
May 23, 2006
Lionello Lunesu
May 23, 2006
Walter Bright
May 23, 2006
Lionello Lunesu
May 23, 2006
Walter Bright
May 23, 2006
Lionello Lunesu
May 24, 2006
Stewart Gordon
May 24, 2006
Lionello Lunesu
May 24, 2006
Daniel Keep
May 23, 2006
Sean Kelly
May 23, 2006
Don Clugston
May 23, 2006
Walter Bright
May 23, 2006
BCS
May 24, 2006
Walter Bright
May 24, 2006
BCS
May 24, 2006
Tom S
May 25, 2006
BCS
May 25, 2006
Lionello Lunesu
May 25, 2006
Derek Parnell
May 25, 2006
BCS
May 27, 2006
Rémy Mouëza
May 27, 2006
Lars Ivar Igesund
May 28, 2006
Rémy Mouëza
May 21, 2006
I'm not sure how useful this will be.

Here it is: http://www.digitalmars.com/d/htod.html
May 22, 2006
Walter Bright wrote:
> I'm not sure how useful this will be.
> 
> Here it is: http://www.digitalmars.com/d/htod.html

Thanks!
May 22, 2006
Walter Bright escribió:
> I'm not sure how useful this will be.
> 
> Here it is: http://www.digitalmars.com/d/htod.html

Wow, that was quick. Seems like a great work!
May 22, 2006
On Sun, 21 May 2006 16:17:38 -0700, Walter Bright wrote:

> I'm not sure how useful this will be.

Very useful.  Thanks for this Walter.

> Here it is: http://www.digitalmars.com/d/htod.html

I just used it on windows.h. It found a 'bug' in winscard.h ;-) After I added

  #include <BaseTsd.h>
  #include <Guiddef.h>

to winscard.h and ran it again, it generated a very useful windows.d file.

The command I used was ...

htod windows.h -Iy:\dm\include -hs -DUNICODE

and I got a 177823 lines in windows.d (mostly comments of course.).

With the -hc switch this went down to 85572 lines of useful code.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
22/05/2006 12:05:43 PM
May 22, 2006
Walter Bright wrote:

> I'm not sure how useful this will be.
> 
> Here it is: http://www.digitalmars.com/d/htod.html

Q: Will there be source code later, for porting to GDC ?

"Bugs: 2. No Linux version" (no Mac OS X version either)

--anders
May 22, 2006
Walter Bright wrote:
> I'm not sure how useful this will be.
> 
> Here it is: http://www.digitalmars.com/d/htod.html

Cool tool! Seems to work fine with some small headers I've tested.

But shouldn't the tool create a .di file, like dmd -H does?

L.
May 22, 2006
Anders F Björklund wrote:
> Walter Bright wrote:
> 
>> I'm not sure how useful this will be.
>>
>> Here it is: http://www.digitalmars.com/d/htod.html
> 
> Q: Will there be source code later, for porting to GDC ?

Sorry, but it's totally based on the C compiler. But that also means it could be done to gcc.


> "Bugs: 2. No Linux version" (no Mac OS X version either)

True.
May 22, 2006
Walter Bright wrote:
> Anders F Björklund wrote:
>> Walter Bright wrote:
>>
>>> I'm not sure how useful this will be.
>>>
>>> Here it is: http://www.digitalmars.com/d/htod.html
>>
>> Q: Will there be source code later, for porting to GDC ?
> 
> Sorry, but it's totally based on the C compiler. But that also means it could be done to gcc.

I've been playing around with libcpp (the c preprocessor) from gcc and was wondering if that was indeed enough to make a tool like htod.

I mean, do you need to parse the C code further, or is a preprocessor (passing you the tokens) enough to do what htod does?

(You'd have to detect the 3 tokens "unsigned long long" yourself and replace it with "ulong", but that's find&replace, hardly parsing)

L.
May 22, 2006
Lionello Lunesu wrote:
> I've been playing around with libcpp (the c preprocessor) from gcc and was wondering if that was indeed enough to make a tool like htod.
> 
> I mean, do you need to parse the C code further, or is a preprocessor (passing you the tokens) enough to do what htod does?
> 
> (You'd have to detect the 3 tokens "unsigned long long" yourself and replace it with "ulong", but that's find&replace, hardly parsing)

htod does a real parse of the C code, and generates the D output from the internal symbol table. Parsing it all the way means that the corner cases work. Also, it means it'll work with C++ header files that have extern "C" declarations in them.

"unsigned long long" can be:

unsigned long long
long unsigned long
long long unsigned
int unsigned long long
unsigned long const int long

etc.
May 22, 2006
Walter Bright wrote:

>> Q: Will there be source code later, for porting to GDC ?
> 
> Sorry, but it's totally based on the C compiler. But that also means it could be done to gcc.

It doesn't have to be complete... As long as it's something like
"insert C/C++ front end here", it could then be adapted to GCC ?

Anyway, we can probably do a re-implementation from the documentation
but the more info you are able to provide the more similar they'll get.

If we can do a larger implementation test, like Dstress for the compiler, then we can run that on the two "htod" to compare them...

Will do a spike / hack in a scripting language. "ghtod", I suppose. ?
Time will tell if that'll do, or if we need a "real" C or D program.

--anders
« First   ‹ Prev
1 2 3 4