assert(condition[, message]) patch
"Rémy J. A. Mouëza"
ray.jay.ay.moueza at do.not.spam.gmail.com
Wed Aug 2 01:30:03 PDT 2006
I've done something close to what you discribe using Python ( C++
wrapping using the output of gccxml ). You can have a look at it on
http://remy.moueza.free.fr. Gregor Richards has done better with BCD,
available on dsource, only using D and gccxml. Swig also output xml,
thus it is also possible to use it as an alternative to gccxml. I didn't
know doxygen could output an xml view of its analysis.
Good luck.
> I don't think PyD will apply to my project. Let me get incredibly off
> topic and explain a little more. I am trying to make a program that
> generates wrappers for C++ programs so you can use them in D. My
> current plan is to process the XML output from Doxygen with Python and
> the ElementTree library. I will then generate a C++ file with a C
> interface to the class and D wrapper file for each class. Something
> similar to below:
>
> // C++ Code
> class MyClass {
> int m_num;
> public:
> MyClass(int num) {
> m_num = num;
> }
>
> int getNum() {
> return m_num;
> }
> };
>
> // C Wrapper Code
> extern "C"
> {
> void* MyClass_new(int num) {
> return (void*)(new myClass(num));
> }
>
> int MyClass_getNum(void* obj) {
> return ((myClass*)obj)->getNum();
> }
>
> void MyClass_delete(void* obj) {
> delete (myClass*)obj;
> }
> }
>
> // D wrapper class
> extern (C)
> {
> void* MyClass_new(int num);
> int MyClass_getNum(void* obj);
> void MyClass_delete(void* obj);
> }
>
> class MyClass {
> private void* cppObj;
>
> this(int num) {
> cppObj = MyClass_new(num);
> }
>
> ~this() {
> MyClass_delete(cppObj);
> }
>
> int getNum() {
> return MyClass_getNum(cppObj);
> }
> }
>
> That is a very basic example and doesn't handle exception being thrown
> from the C++ code. I haven't start work on the generator yet. I am
> currently testing my ideas on the following issues:
>
> -properly handling the passing of D wrapped C++ classes to and from
> the C++ code.
> -using directors at the bottom of the inheritance tree to properly
> pass virtual function calls of to inherited D class
> -Throwing C++ and D exceptions through the interface that has C
> linkage.
> -Mapping of types from C++ to C to D.
>
> If this ever gets off the ground I am thinking of calling it WrapeD, the
> lack of two p's is intentional. I hope to have simpler interface file
> system than swig. Something looks more like SCons build files.
>
> -Joseph
More information about the Digitalmars-d
mailing list