January 22, 2015
> Currently making D classes derive from C++ classes with a virtual table only works with MinGW because only the Itanium ABI is supported. I'm going to add the Microsoft ABI ASAP (it's just a few lines of code) but it'll be untested.

Could you explain can I call function from C++ dll directly? I am
need only basic C++ support -- just ability to call very basic
functions.

Am I right understand that with Calypso I do not need to create
bindings?

If it's correct - could you provide any example of calling C++
function from dll?
January 22, 2015
"First you need a LLVM + Clang 3.5 source tree, built libraries and the Clang binaries. Installing binary packages from your distribution isn't enough since the include/ files aren't exposing many symbols, so the source packages are needed as well"

Do I need to compile from source just Clang or both?
January 22, 2015
I can't build clang. I am getting strange error:
D:\llvm\cfe-3.5.0.src\cfe-3.5.0.src>make
Error on line 23: expecting target : dependencies
January 22, 2015
On Thursday, 22 January 2015 at 07:27:03 UTC, Suliman wrote:
> "First you need a LLVM + Clang 3.5 source tree, built libraries and the Clang binaries. Installing binary packages from your distribution isn't enough since the include/ files aren't exposing many symbols, so the source packages are needed as well"
>
> Do I need to compile from source just Clang or both?

Usually Clang is built with LLVM, i.e running make inside the LLVM build directory will build both LLVM and Clang.

On Thursday, 22 January 2015 at 07:07:42 UTC, Suliman wrote:
>> Currently making D classes derive from C++ classes with a virtual table only works with MinGW because only the Itanium ABI is supported. I'm going to add the Microsoft ABI ASAP (it's just a few lines of code) but it'll be untested.
>
> Could you explain can I call function from C++ dll directly? I am
> need only basic C++ support -- just ability to call very basic
> functions.
>
> Am I right understand that with Calypso I do not need to create
> bindings?
>
> If it's correct - could you provide any example of calling C++
> function from dll?

On Windows the Clang executable has to be in one of the %PATH% folders and then in your D code:

  modmap (C++) "headerofyourdll.h"; // will make Clang generate a precompiled header

  import (C++) Namespace1.Namespace2._; // If your functions are global functions inside Namespace1.Namespace2, _ is a special module (for now) that contains all the global funcs, vars and typedefs
  import (C++) Namespace1.Struct1; // If they are inside a struct named Struct1

The imports expose symbols that you can use like you'd use D structs and functions.

Finally you need to tell LDC to link to your library:

  ldc -L="yourDLL.lib" (...)
January 23, 2015
On Thursday, 22 January 2015 at 00:08:13 UTC, Walter Bright wrote:
> Just making STL work would be an achievement!
>
> Is the output of Calypso a file that can be imported?

The only outputs specific to Calypso are ligthweight object files per C++ module that contain symbols created by LDC for aggregates (InitZ...) and template specializations by Clang if they're not defined in the PCH.

What Calypso basically does is tell Clang to generate a big PCH for all the headers in modmap directives, and to map "on demand" C++ declarations from the PCH to D symbols in a separate tree of modules (hence the (C++) in imports, they're not physical modules). Those symbols can be used like D's, although they have different implementations to handle the C++ specificities, and all the non-trivial semantic work is done by Clang libraries and queried back by Calypso (aggregate layout, partial template argument deduction, ...).

There are still some very "feels hackish" areas like the fact that DMD considers C++ classes to derive from Object too (fortunately Object is only a handful of virtual functions), I haven't solved yet how class values should be treated, etc.

Also the PCH is a temporary solution because at the time I began working on Calypso Clang's support for modules was broken. But they would be great to break the global namespace in smaller pieces, so now that they seem ready to use the plan is to replace the PCH by them, or by a slightly different flavor of them (because there's currently one limitation that reduces its usefulness, it's that one header can't be split across several modules).
January 23, 2015
Just in case you don't follow digitalmars.D:

http://forum.dlang.org/thread/m9s4cd$2s1v$1@digitalmars.com#post-m9s4cd:242s1v:241:40digitalmars.com
January 23, 2015
On 2014-12-23 00:14, Elie Morisse wrote:
> Hi everyone,
>
> I have the pleasure to announce to you all the existence of a modified
> LDC able to interface directly to C++ libraries, wiping out the need to
> write bindings:
>
>   https://github.com/Syniurge/Calypso

Could this work for Objective-C as well. I'm working on adding support for Objective-C to DMD [1].

[1] https://github.com/D-Programming-Language/dmd/pull/4321

-- 
/Jacob Carlborg
January 23, 2015
Hello Elie,

This project looks great, thanks for the hard work. I downloaded Calypso and ldc2 about 6 hours ago to try your project out.

I can get Calypso to compile with a couple small changes to assistbuilder.cpp (just adding a namespace qualifier for two class instantiations of CodeGen). That is with clang-3.5 from todays svn. Maybe a recent clang commit has changed things?

Once I had a working Calypso ldc2 build, I unfortunately couldn't get the showcase example to build. I just use the build line from your git page to try to build, but I get an 'undefined identifier size_t' error. The pch file is produced properly but then this error comes up...it seems like while compiling druntime from the '-v' output?? Maybe something changed in the druntime submodule in the last few days...but I didn't really look into it yet.

I hacked a couple things to just get around this error and then things fail because libshowcase.a isn't available. I assume that is a remnant from an earlier compilation technique, because it appears everything is self contained in the .o files being produced and then linked on the command line...so I just thought I would let you know this part doesn't work.

If you could give me a hint on the 'undefined identifier size_t' error, I can look into it a bit further here...I am just getting tired and probably not seeing what is going on there. If you are on #ldc I will be on there later today. Not sure what your username is in #ldc. At least one other person has been by asking if you were there also :)


Thanks,
Kelly (wilsonk-laptop)


January 23, 2015
On Friday, 23 January 2015 at 12:29:56 UTC, Kelly wrote:
> Hello Elie,
>
> This project looks great, thanks for the hard work. I downloaded Calypso and ldc2 about 6 hours ago to try your project out.
>
> I can get Calypso to compile with a couple small changes to assistbuilder.cpp (just adding a namespace qualifier for two class instantiations of CodeGen). That is with clang-3.5 from todays svn. Maybe a recent clang commit has changed things?
>
> Once I had a working Calypso ldc2 build, I unfortunately couldn't get the showcase example to build. I just use the build line from your git page to try to build, but I get an 'undefined identifier size_t' error. The pch file is produced properly but then this error comes up...it seems like while compiling druntime from the '-v' output?? Maybe something changed in the druntime submodule in the last few days...but I didn't really look into it yet.
>
> I hacked a couple things to just get around this error and then things fail because libshowcase.a isn't available. I assume that is a remnant from an earlier compilation technique, because it appears everything is self contained in the .o files being produced and then linked on the command line...so I just thought I would let you know this part doesn't work.
>
> If you could give me a hint on the 'undefined identifier size_t' error, I can look into it a bit further here...I am just getting tired and probably not seeing what is going on there. If you are on #ldc I will be on there later today. Not sure what your username is in #ldc. At least one other person has been by asking if you were there also :)
>
>
> Thanks,
> Kelly (wilsonk-laptop)

Thanks for the feedback Kelly, you're probably the first person to give it a serious try, sorry for the bumpy ride :)

Since I was focused on getting Ogre working and neither rebuilt druntime/phobos nor tested the showcase example against the latest commits they might have broken something.
Also the README forgets to say how libshowcase.a should be built:

  clang++ -std=c++11 -c showcase.cpp -o showcase.cpp.o
  ar rcs libshowcase.a showcase.cpp.o

  ldc2 -cpp-args -std=c++11 -Llibshowcase.a -L-lstdc++ showcase.d

Adding this now.

I'm going to fix the rest this afternoon (finally some free time), and also figure out why assistbuilder.cpp failed to compile against the latest Clang 3.5.

Also going to setup a testing script to ensure not everything gets broken again by a commit.
January 23, 2015
On Friday, 23 January 2015 at 10:02:55 UTC, Jacob Carlborg wrote:
> Could this work for Objective-C as well. I'm working on adding support for Objective-C to DMD [1].
>
> [1] https://github.com/D-Programming-Language/dmd/pull/4321

It's planned to add Objective-C to Calypso, although I never used it and know little about it. Would you be interested in implementing support for its different flavors in Calypso, Jacob? You'd be welcome to the team :-)