Open mw66 opened 1 year ago
cpp.dpp
has C++ code in it. That's not going to work.
Sorry about that, after I move cpp.dpp
to cpp.h
, and create new cpp.dpp
:
$ cat cpp.dpp
#include "cpp.h"
the output is:
class PriceBarI
{
private:
public:
pragma(mangle, "_ZN9PriceBarI5open_Ev") abstract double open_() @nogc nothrow;
pragma(mangle, "_ZN9PriceBarI5high_Ev") abstract double high_() @nogc nothrow;
pragma(mangle, "_ZN9PriceBarI4low_Ev") abstract double low_() @nogc nothrow;
pragma(mangle, "_ZN9PriceBarI6close_Ev") abstract double close_() @nogc nothrow;
pragma(mangle, "_ZN9PriceBarI7volume_Ev") abstract double volume_() @nogc nothrow;
pragma(mangle, "_ZN9PriceBarI7millis_Ev") abstract c_long millis_() @nogc nothrow;
}
This is largely correct.
However, it would be nice if a class only contains C++ pure virtual function:
1) translate to D interface
2) can we add option to make @nogc nothrow
optional? the reason is that these attribute are transitive, sometimes the method implementation need to call 3rd party library function which is not marked as nogc nothrow
, while the developers has no control to change.
Those would be nice additions. PRs welcome.
Looks like the C++ pure virtual function is not recognized.
It will be nice to parse C++ pure virtual function, and if a class only contains C++ pure virtual function: 1) translate to D
interface
2) translate C++ pure virtual functions to Dabstract
methods.Then it will be easier to interface D and C++:
https://dlang.org/spec/cpp_interface.html#using_d_classes_from_cpp
so the expected output are:
This example can be used as unittest case.