Re: H1 2015 - C++ integration

2015-07-05 Thread Guillaume Chatelet via Digitalmars-d
On Friday, 13 February 2015 at 12:23:58 UTC, Guillaume Chatelet wrote: I'm working on integration of D with the C++ STL (at least the linux gnu one). [...] I finally took some time to put up a first draft https://github.com/D-Programming-Language/druntime/pull/1316 There's a bunch of

Re: H1 2015 - C++ integration

2015-02-17 Thread Paolo Invernizzi via Digitalmars-d
On Tuesday, 17 February 2015 at 11:39:06 UTC, Guillaume Chatelet wrote: We'll also have to provide a new pragma to allow correct mangling of types on Windows. Maybe something like : extern(C++, std) { pragma(mangleAs, class) struct basic_string() { ... } } +1 please! --- Paolo

Re: H1 2015 - C++ integration

2015-02-17 Thread Andrei Alexandrescu via Digitalmars-d
On 2/17/15 3:39 AM, Guillaume Chatelet wrote: We'll also have to provide a new pragma to allow correct mangling of types on Windows. Maybe something like : extern(C++, std) { pragma(mangleAs, class) struct basic_string() { ... } } Yah, I don't think we can get away without that. -- Andrei

Re: H1 2015 - C++ integration

2015-02-17 Thread Andrei Alexandrescu via Digitalmars-d
On 2/17/15 3:34 AM, Guillaume Chatelet wrote: On Sunday, 15 February 2015 at 19:49:28 UTC, Andrei Alexandrescu wrote: Please file bugs for any constructor/destructor issues you find (I notice you filed one already). Walter is up to the task and of course I'm counting on others, too. ctor/dtor

Re: H1 2015 - C++ integration

2015-02-17 Thread Guillaume Chatelet via Digitalmars-d
On Sunday, 15 February 2015 at 19:49:28 UTC, Andrei Alexandrescu wrote: Please file bugs for any constructor/destructor issues you find (I notice you filed one already). Walter is up to the task and of course I'm counting on others, too. ctor/dtor C++ naming :

Re: H1 2015 - C++ integration

2015-02-17 Thread Guillaume Chatelet via Digitalmars-d
We'll also have to provide a new pragma to allow correct mangling of types on Windows. Maybe something like : extern(C++, std) { pragma(mangleAs, class) struct basic_string() { ... } }

Re: H1 2015 - C++ integration

2015-02-17 Thread Benjamin Thaut via Digitalmars-d
On Tuesday, 17 February 2015 at 11:39:06 UTC, Guillaume Chatelet wrote: We'll also have to provide a new pragma to allow correct mangling of types on Windows. Maybe something like : extern(C++, std) { pragma(mangleAs, class) struct basic_string() { ... } } Yes please. I'm running into the

Re: H1 2015 - C++ integration

2015-02-17 Thread Guillaume Chatelet via Digitalmars-d
On Tuesday, 17 February 2015 at 12:09:11 UTC, Benjamin Thaut wrote: On Tuesday, 17 February 2015 at 11:39:06 UTC, Guillaume Chatelet wrote: We'll also have to provide a new pragma to allow correct mangling of types on Windows. Maybe something like : extern(C++, std) { pragma(mangleAs, class)

Re: H1 2015 - C++ integration

2015-02-15 Thread Paolo Invernizzi via Digitalmars-d
On Sunday, 15 February 2015 at 14:42:46 UTC, Guillaume Chatelet wrote: I updated https://github.com/gchatelet/dlang_cpp_std to provide a struct and class implementation of string. Also added a README to weigh the pros and cons of each, list bugs I encountered and other things we need to think

Re: H1 2015 - C++ integration

2015-02-15 Thread Guillaume Chatelet via Digitalmars-d
I updated https://github.com/gchatelet/dlang_cpp_std to provide a struct and class implementation of string. Also added a README to weigh the pros and cons of each, list bugs I encountered and other things we need to think about.

Re: H1 2015 - C++ integration

2015-02-15 Thread Andrei Alexandrescu via Digitalmars-d
On 2/15/15 6:42 AM, Guillaume Chatelet wrote: I updated https://github.com/gchatelet/dlang_cpp_std to provide a struct and class implementation of string. Also added a README to weigh the pros and cons of each, list bugs I encountered and other things we need to think about. Awesome work,

Re: H1 2015 - C++ integration

2015-02-15 Thread Paolo Invernizzi via Digitalmars-d
On Sunday, 15 February 2015 at 19:44:39 UTC, Guillaume Chatelet wrote: On Sunday, 15 February 2015 at 15:37:33 UTC, Paolo Invernizzi wrote: That's a great work. Thx :) Guillaume, I'll try to ask this question again. I'm wrapping the C++ API of OpenCV [1], and it works great. I'm using a D

Re: H1 2015 - C++ integration

2015-02-15 Thread Guillaume Chatelet via Digitalmars-d
On Sunday, 15 February 2015 at 15:37:33 UTC, Paolo Invernizzi wrote: That's a great work. Thx :) Guillaume, I'll try to ask this question again. I'm wrapping the C++ API of OpenCV [1], and it works great. I'm using a D struct for std::string instead of D class, because I agree with your

Re: H1 2015 - C++ integration

2015-02-14 Thread Guillaume Chatelet via Digitalmars-d
On Friday, 13 February 2015 at 18:47:53 UTC, Daniel Murphy wrote: Guillaume Chatelet wrote in message news:gvnxmwplwkyfrydwr...@forum.dlang.org... I'm not sure I get your point. In C++ classes without vtables are exactly like structs. Also I don't see any difference between a struct or a

Re: H1 2015 - C++ integration

2015-02-14 Thread Guillaume Chatelet via Digitalmars-d
On Saturday, 14 February 2015 at 18:04:50 UTC, Andrei Alexandrescu wrote: On 2/13/15 4:23 AM, Guillaume Chatelet wrote: * In the video Walter posted recently (3), he states that one should use a class to represent a std::string or std::vector in D because most of the time we want to have

Re: H1 2015 - C++ integration

2015-02-14 Thread Guillaume Chatelet via Digitalmars-d
I did a few tests. Using a class doesn't work because of the added vptr. The data would be managed at the same time on the D and the C++ side. Structs work however because we can add something like this : struct std_string { void[8] _ = void; // to match sizeof(std::string) and pad the

Re: H1 2015 - C++ integration

2015-02-14 Thread Paolo Invernizzi via Digitalmars-d
On Saturday, 14 February 2015 at 17:24:51 UTC, Guillaume Chatelet wrote: I did a few tests. Using a class doesn't work because of the added vptr. The data would be managed at the same time on the D and the C++ side. Structs work however because we can add something like this : struct

Re: H1 2015 - C++ integration

2015-02-14 Thread Andrei Alexandrescu via Digitalmars-d
On 2/13/15 4:23 AM, Guillaume Chatelet wrote: * In the video Walter posted recently (3), he states that one should use a class to represent a std::string or std::vector in D because most of the time we want to have reference semantic. I find this a bit counter intuitive for people coming from

Re: H1 2015 - C++ integration

2015-02-14 Thread Daniel Murphy via Digitalmars-d
Guillaume Chatelet wrote in message news:fzxoskcrswitmsdsz...@forum.dlang.org... I did a few tests. Using a class doesn't work because of the added vptr. This is a bug, D currently adds a vptr even if there are no members. It's just one that doesn't happen to affect ddmd so I never got

Re: H1 2015 - C++ integration

2015-02-14 Thread Guillaume Chatelet via Digitalmars-d
On Saturday, 14 February 2015 at 19:54:53 UTC, Daniel Murphy wrote: - name mangling on linux (bug reported in my first message) Is this in bugzilla? I just created it https://issues.dlang.org/show_bug.cgi?id=14178

Re: H1 2015 - C++ integration

2015-02-13 Thread Guillaume Chatelet via Digitalmars-d
On Friday, 13 February 2015 at 13:03:18 UTC, Kagamin wrote: It's not like you're free to choose, because struct and class can use different mangling. I'm not sure I get your point. In C++ classes without vtables are exactly like structs. Also I don't see any difference between a struct or a

Re: H1 2015 - C++ integration

2015-02-13 Thread Kagamin via Digitalmars-d
On Friday, 13 February 2015 at 14:07:44 UTC, Guillaume Chatelet wrote: I'm not sure I get your point. In C++ classes without vtables are exactly like structs. Also I don't see any difference between a struct or a class name mangling on Gnu Linux. Do you want it to be compatible with Gnu Linux

Re: H1 2015 - C++ integration

2015-02-13 Thread Kagamin via Digitalmars-d
It's not like you're free to choose, because struct and class can use different mangling.

Re: H1 2015 - C++ integration

2015-02-13 Thread Guillaume Chatelet via Digitalmars-d
On Friday, 13 February 2015 at 14:15:10 UTC, Kagamin wrote: On Friday, 13 February 2015 at 14:07:44 UTC, Guillaume Chatelet wrote: I'm not sure I get your point. In C++ classes without vtables are exactly like structs. Also I don't see any difference between a struct or a class name mangling

Re: H1 2015 - C++ integration

2015-02-13 Thread Daniel Murphy via Digitalmars-d
Guillaume Chatelet wrote in message news:gvnxmwplwkyfrydwr...@forum.dlang.org... I'm not sure I get your point. In C++ classes without vtables are exactly like structs. Also I don't see any difference between a struct or a class name mangling on Gnu Linux. class/struct S{}; S foo(); foo

H1 2015 - C++ integration

2015-02-13 Thread Guillaume Chatelet via Digitalmars-d
I'm working on integration of D with the C++ STL (at least the linux gnu one). * You can have a look at a current draft implementation (1). * There is a name mangling issue in dmd related to the compression of usual stl types when the type is const eg. dmd will mangle 'std::vectorint::size()