February 09, 2015
On Sunday, 8 February 2015 at 22:45:14 UTC, Elie Morisse wrote:
> On Sunday, 8 February 2015 at 20:56:31 UTC, Syro wrote:
>> That is really cool.
>
> Thanks, just got that tangled mess of templates that is std::string working too:
>
> https://github.com/Syniurge/Calypso/blob/master/tests/calypso/libstdc%2B%2B/string.d

Congrats! This is definitely an exciting news!!
February 09, 2015
On Sunday, 8 February 2015 at 22:45:14 UTC, Elie Morisse wrote:
> On Sunday, 8 February 2015 at 20:56:31 UTC, Syro wrote:
>> That is really cool.
>
> Thanks, just got that tangled mess of templates that is std::string working too:
On Sunday, 8 February 2015 at 22:45:14 UTC, Elie Morisse wrote:
> On Sunday, 8 February 2015 at 20:56:31 UTC, Syro wrote:
>> That is really cool.
>
> Thanks, just got that tangled mess of templates that is std::string working too:

Hey Elie, this is great stuff, as usual. I have written a test file for bitset here also (including a couple failures I am sure you are aware of, but others might want to see what works and what doesn't).


/**
 * std::bitset example.
 *
 * Build with:
 *   $ ldc2 -L-lstdc++ bitset.d
 */

modmap (C++) "bitset";

import std.stdio;
import (C++) std.bitset;

void main()
{
    enum : ulong { A=0, B, C, D, E, F, G, H, numColors };
    auto usedColors = new bitset!(numColors);

    usedColors.set(A, true);
    usedColors.set(C, true);

    writeln("usedColors.len=\t", numColors);   // '8' as it should be
    write("usedColors = \t");
    if (usedColors.any())                      // any() works
    {
        for(int i=0; i<usedColors.size; i++)   // size seems to work
            if (usedColors.test(i))            // works
                write('1');
            else
                write('0');
        write('\n');           // prints 10100000 for usedColors
    }                          // seems backwards also see 'b' below
                               // is this right?

    writeln("C bit = \t", usedColors.test(C));      // true as it should be
    writeln("count = \t", usedColors.count());      // seems like count is
                                                    // working...returns 2
    writeln("as ulong = \t", usedColors.to_ulong);  // '5' is correct

    writeln("all = \t\t", usedColors.all);
    writeln("none = \t\t", usedColors.none);        // these work
    writeln("any = \t\t", usedColors.any);

    usedColors.flip(C);
    writeln("C flipped = \t", usedColors.test(C));  // false as appropriate

    write("b = \t\t");
    auto a = new bitset!(4u)(0b0110);
    auto b = new bitset!(4u)(0b1101);
    for(int i=0; i<b.size; i++)        // size seems to work
    {
        if (b.test(i))
            write('1'); // prints out 1011 for 'b'
        else
            write('0');
    }
    write('\n');
    writeln("b as ulong = \t", b.to_ulong); // '13' is correct

// FAILURE in phobos format.d
//    writeln(b);

// FAILURE because the [] operator isn't recognised
//    writeln(usedColors[C]);

// FAILURE on operators again
//    auto d = a&b;

}

Thanks,
Kelly
February 09, 2015
Ugh, this forum needs a preview button!!

Sorry about the poor formatting,
Kelly
February 09, 2015
If somebody have working Windows build, could you please share it?
February 09, 2015
On Monday, 9 February 2015 at 04:33:04 UTC, Kelly wrote:
> Ugh, this forum needs a preview button!!
>
> Sorry about the poor formatting,
> Kelly

http://pastebin.com/
February 09, 2015
On 2/8/15 2:45 PM, Elie Morisse wrote:
> On Sunday, 8 February 2015 at 20:56:31 UTC, Syro wrote:
>> That is really cool.
>
> Thanks, just got that tangled mess of templates that is std::string
> working too:
>
> https://github.com/Syniurge/Calypso/blob/master/tests/calypso/libstdc%2B%2B/string.d

You may want to put this on reddit too (unless you're the one who did): http://www.reddit.com/r/programming/comments/2vc0eg/calypso_dc_interface_using_stdvector_and/

Andrei


February 09, 2015
On Monday, 9 February 2015 at 04:27:06 UTC, Kelly wrote:
>> Thanks, just got that tangled mess of templates that is std::string working too:
>
> Hey Elie, this is great stuff, as usual. I have written a test file for bitset here also (including a couple failures I am sure you are aware of, but others might want to see what works and what doesn't).
>


Hi Kelly,

Good to see bitset instantiating and basically working too! Can I add your code to the tests?

So yes to clear things up a bit, operators are still missing and so are many other features. Off the top of my head:

 - Function templates => the groundwork is here, they're already mapped and it
shouldn't be too difficult to get them instantiating from D
 - Operators => probably easy to add although there might be differences between C++ and D operators
 - Functions with class values parameters aren't even mapped yet, since I haven't made my mind on how to handle class values. Despite the "POD or not" issue it still feels more consistent to treat C++ classes like D classes, while adding C++ class value types to DMD's types like C++ reference types were with TypeReference (which makes C++ variables with reference types usable but which can't be assigned as the types of D variables)
 - C++ reference types are supported by DMD but not by LDC yet, they only work for function parameters and return types since Calypso replace them by "ref"
February 09, 2015
On Monday, 9 February 2015 at 07:10:56 UTC, Suliman wrote:
> If somebody have working Windows build, could you please share it?

It would be nice to know if someone even managed to build Calypso on Windows yet :)

On Monday, 9 February 2015 at 20:17:33 UTC, Andrei Alexandrescu wrote:
> You may want to put this on reddit too (unless you're the one who did): http://www.reddit.com/r/programming/comments/2vc0eg/calypso_dc_interface_using_stdvector_and/
>
> Andrei

Nice, I'll dust my antique barely used account if questions pop up.
February 10, 2015
On Monday, 9 February 2015 at 22:24:49 UTC, Elie Morisse wrote:
>
>
> Hi Kelly,
>
> Good to see bitset instantiating and basically working too! Can I add your code to the tests?
>
> So yes to clear things up a bit, operators are still missing and so are many other features. Off the top of my head:
>
>  - Function templates => the groundwork is here, they're already mapped and it
> shouldn't be too difficult to get them instantiating from D
>  - Operators => probably easy to add although there might be differences between C++ and D operators
>  - Functions with class values parameters aren't even mapped yet, since I haven't made my mind on how to handle class values. Despite the "POD or not" issue it still feels more consistent to treat C++ classes like D classes, while adding C++ class value types to DMD's types like C++ reference types were with TypeReference (which makes C++ variables with reference types usable but which can't be assigned as the types of D variables)
>  - C++ reference types are supported by DMD but not by LDC yet, they only work for function parameters and return types since Calypso replace them by "ref"


Hello Elie,

Yes, you can use the code above for bitsets (modify as you see fit, it is public domain as far as I am concerned), thanks for asking.

I have set up test files for most other STL headers...some seem quite close to working. Hopefully soon :)

Thanks,
Kelly
February 11, 2015
On Monday, 9 February 2015 at 22:38:51 UTC, Elie Morisse wrote:
> On Monday, 9 February 2015 at 07:10:56 UTC, Suliman wrote:
>> If somebody have working Windows build, could you please share it?
>
> It would be nice to know if someone even managed to build Calypso on Windows yet :)
>

Hello Elie,

I did manage to build Calypso on Win7, and the resulting binary works to produce an obj file, but linking of a full executable fails :(

I am getting "file contains invalid .pdata contributions" when trying to link. Trass3r over on ldc's github page was getting this error at one point also, but I don't know what the solution was. It seems like this was back in Aug 2014 so I would have thought any changes needed were picked up by Calypso when you forked in Oct.

I would post an issue with ldc but Calypso isn't up to date, so it might not be really fair as the fix may be in the newest ldc. I can't see anything standing out in the commits for an issue like this, but I might just be missing it.

Thanks,
Kelly



P.S. There is a small patch needed to compile on windows with VS2013. Things should still build fine on Linux with the patch. Here it is:

diff --git a/dmd2/cpp/cppimport.cpp b/dmd2/cpp/cppimport.cpp
index 709f324..2dec2ae 100644
--- a/dmd2/cpp/cppimport.cpp
+++ b/dmd2/cpp/cppimport.cpp
@@ -6,7 +6,10 @@
 #include "cpp/calypso.h"
 #include "expression.h"

+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>

diff --git a/dmd2/cpp/cppmodule.cpp b/dmd2/cpp/cppmodule.cpp
index 114f3f0..385cb79 100644
--- a/dmd2/cpp/cppmodule.cpp
+++ b/dmd2/cpp/cppmodule.cpp
@@ -21,7 +21,10 @@
 #include "cppexpression.h"
 #include "cpptemplate.h"

+#ifndef _MSC_VER
 #include <unistd.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>

diff --git a/dmd2/mars.h b/dmd2/mars.h
index b22dc5b..fc8f798 100644
--- a/dmd2/mars.h
+++ b/dmd2/mars.h
@@ -270,8 +270,8 @@ struct Compiler
     const char *vendor;     // Compiler backend name
 };

-struct LangPlugin;
-typedef Array<struct LangPlugin *> LangPlugins;
+class LangPlugin;
+typedef Array<class LangPlugin *> LangPlugins;

 typedef unsigned structalign_t;
 #define STRUCTALIGN_DEFAULT ((structalign_t) ~0)