Syniurge / Calypso

LDC fork to experiment direct interfacing with C++
http://wiki.dlang.org/LDC
Other
135 stars 10 forks source link

FastFlow test case #12

Open wilsonk opened 9 years ago

wilsonk commented 9 years ago

Hello Elie,

There is an issue with trying to instantiate an abstract class from the FastFlow C++ library in a D test program. If I use this simple test program:

modmap (C++) "ff/farm.hpp"; import (C++) ff.ff_node; class Worker : ff_node { //alias svc = cpp.ff.ff_node.ff_node.svc; public: override void* svc(void * task) { return task; } } void main() {}

I get this error:

test.d(10): Error: function test.Worker.svc does not override any function, did you mean to override 'cpp.ff.ff_node.ff_node.svc'?

You can see I tried to use an alias to get the override to work (and I tried a few other things to no avail). I tried making a cpp file and overriding in a simple class and then using that class also, bit it didn't work either.

Thanks, Kelly

wilsonk commented 8 years ago

You still out there Elie? Just thought I would check in and see how you are doing since I haven't seen any commits or anything lately. :)

Syniurge commented 8 years ago

Hi Kelly, thanks for checking I'm fine except that I've had little free time and I come home tired in the evenings, not sure why but my colleagues too, maybe it's because of the dry season which is the hottest time of the year for French Guiana.

I also got myself stuck in another undertaking aiming at saving the template and implicit member instantiations back in a new PCH. Strangely Clang wasn't designed to do this when a PCH is already loaded for the current AST, it always assumes that I want to generate the next chained PCH. And it's not just a tweak that is required to make this work but a whole lot of tweaks that I'm currently making in a Clang fork, now a submodule of Calypso.

One benefit from this is that Calypso doesn't depend on a Clang 3.6 installation anymore. It now uses the Clang libraries instead of the executable to generate the PCH, and ships with the Clang builtin headers.

Still need to get this and the previous mess I created sorted out but free time is sparse.. can't wait for my 10 days of vacation in two weeks to truly push this through.

wilsonk commented 8 years ago

Thanks for the update Elie.

I assumed you didn't have too much free time and that there were some complex issues with Calypso to work out.

And also...I typed this into this comment box 4 days ago and forgot to push 'comment' ... cripes :)

wilsonk commented 7 years ago

Hello Elie,

Unfortunately, this example above doesn't work again as of Oct 2016. If you want to just download fastflow via:

svn checkout svn://svn.code.sf.net/p/mc-fastflow/code/ mc-fastflow-code

and compile it. Then copy and paste the example above into a quicksort.d file and build with:

ldc2 -wi -release -cpp-args -std=c++11 -L-lstdc++ -cpp-args -O3 -cpp-args -finline-functions 
-cpp -args -I/path/to/mc-fastflow-code quicksort.d

Then you should get an error like this:

ldc2: /home/wilsonk/Downloads/Calypso/dmd2/cpp/cpptypes.cpp:432: Type*
cpp::TypeMapper::FromType::fromTypeBuiltin(const clang::BuiltinType*): Assertion `t &&
 "missing built-in type correspondance"' failed.
Syniurge commented 7 years ago

Hey Kelly,

It should be fixed by ee44f7f0fb7b6c333904a206af5c0d94e47d0c77, and your code compiles and seems to run fine by adding a few extern (C++) to the methods overriding C++ virtual methods and uncommenting the print_array call.

wilsonk commented 7 years ago

Yep, that seems to have fixed the example. The example runs about 4% slower than the fastflow example with optimizations turned on for D and C++, so not too bad. Still have to turn off the GC for large arrays, though.

Unfortunately, the example above isn't quite correct when reading in the command line args and I can't seem to get std.getopt to work. It expects main to be of type 'main(string[] args)' but Calypso dies whenever there is the keyword 'string' being used (and 'main(char[][])' won't work with getopt!!!).

Also, using to!string to try to convert the char[][] args doesn't work because of the 'string' again. Tried to alias it or something and I still get a conflict with C++ basic_string when using Calypso. Any ideas?