www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - A modest proposal...

reply Ben Cooley <Ben_member pathlink.com> writes:
Okay.. how about this...

From within D, it is possible to parse a Cpp header file to obtain the function,
macro, enum, global, and class declarations.  For inline code, all inlines may
be ignored, or certain simple inlines could optionally be understood
(accessors).  The level of inline usage would be implementation dependent.
Basically this is no more than what GCC-XML and elsa can already do.

From this information, you can use D compiler intrinsic cpp calls to call a cpp
method, create or delete a cpp class, or access a cpp field.  The D compiler
then will then generate a .cpp file which includes the Cpp headers used
declaring C functions to force a real Cpp compiler to instantiate inlines not
comprehended by the D Cpp inteface.  The Cpp interface intrinsics in the D code
then reduce down to constants, member accesses of classes or structures,
indirect Cpp style vtable calls, or calls to the C functions instantiated in the
generated .cpp file to call complex inlines.

The header parsing is "swig" like, meaning that is somewhat forgiving of parsing
errors, ignoring constructs it doesn't know about, warnings about the inability
to comprehend certain constructs or keywords and recovering where possible.

And yes, it in my opinion this should be a part of the language standard, FWIW.
May 15 2006
next sibling parent Gregor Richards <Richards codu.org> writes:
It's not exactly wise to title your suggestion in a way that draws 
connections to eating children.

  - Gregor Richards
May 15 2006
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Ben Cooley" <Ben_member pathlink.com> wrote in message 
news:e4bk43$v8j$1 digitaldaemon.com...
 Okay.. how about this...

 From within D, it is possible to parse a Cpp header file to obtain the 
 function,
 macro, enum, global, and class declarations.

The government enforcing the eating of babies would be more likely than this ever coming to be. Sorry.
May 16 2006
parent Ben Cooley <Ben_member pathlink.com> writes:
In article <e4d827$16os$1 digitaldaemon.com>, Jarrett Billingsley says...
"Ben Cooley" <Ben_member pathlink.com> wrote in message 
news:e4bk43$v8j$1 digitaldaemon.com...
 Okay.. how about this...

 From within D, it is possible to parse a Cpp header file to obtain the 
 function,
 macro, enum, global, and class declarations.

The government enforcing the eating of babies would be more likely than this ever coming to be. Sorry.

Heh.
May 16 2006