| |
 | Posted by Ben Cooley | Permalink Reply |
|
Ben Cooley 
| 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.
|