Conversation
|
Thanks for your pull request and interest in making D better, @edi33416! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2348" |
| enum classInstanceAlignment(T) = size_t.alignof >= T.alignof ? size_t.alignof : T.alignof; | ||
|
|
||
| T emplace(T, Args...)(T chunk, auto ref Args args) | ||
| if (is(T == class)) |
There was a problem hiding this comment.
Needs to handle non D classes.
There was a problem hiding this comment.
Got it. What non D classes are supported? C++ ones?
There was a problem hiding this comment.
In addition to C++ classes: Objective-C classes and interfaces and COM interfaces.
There was a problem hiding this comment.
@jacob-carlborg that was copied from the phobos implementation (later to be moved), can you explain what needs to be done here? Thanks! Also: would rather add that as an additional PR after this.
There was a problem hiding this comment.
TypeInfo is somewhat broken for non D classes. But emplace might not be affected. Test it and see what happens and make sure to add tests for it.
There was a problem hiding this comment.
What do you guys think about moving emplace to core.internal.traits ?
There was a problem hiding this comment.
It's not really a trait is it?
There was a problem hiding this comment.
You are right. My bad, sorry :).
The question remains: should we move it into a core.internal.conv ?
I think emplace is especially usefull when you want to construct an immutable object into a predefined memory area.
There was a problem hiding this comment.
Let's make it private for now and postpone that decision. Fight one fight at a time.
| } | ||
|
|
||
| void dispose(A, T)(auto ref A alloc, auto ref T p) | ||
| if (is(T == class) || is(T == interface)) |
There was a problem hiding this comment.
Needs to handle non D classes and interfaces.
There was a problem hiding this comment.
Same question: can you please provide me with an example?
There was a problem hiding this comment.
Replied to the other comment.
| a.front.x = 20; | ||
| } | ||
| assert(c.x == 20); | ||
| } |
There was a problem hiding this comment.
Should have tests with non D classes as well.
|
|
This exists as well |
There is, and I want to remove as much as I can. I didn't know about
I needed those for some of the template constraints and other in order to consume |
If they’re only for implementation they should be private. |
Said PR. |
|
TODO: rename module to rcslice.d and type name with rcslice. |
|
All: would rcarray be preferable to rcslice? |
2b4f7d5 to
ee96796
Compare
| setIsShared(support, true); | ||
| } | ||
|
|
||
| this(immutable ref typeof(this) rhs) immutable |
There was a problem hiding this comment.
Changing to
this(scope immutable ref typeof(this) rhs) immutable fix the scope error, but will make the ctor @system.
Adding a @trusted (For testing purposes only) to quickly mute all the complaints will pass all the tests. Why is the scope required and why is it making the function @system when used?
There was a problem hiding this comment.
Another way of bypassing the error, without any @trusted "magic" is to change the idup implementation from
immutable(rcarray!T) idup(this Q)()
{
return immutable rcarray!T(this);
}
to
immutable(rcarray!T) idup(this Q)()
{
static if (is(Q == immutable))
{
return this;
}
else
{
return immutable rcarray!T(this);
}
}
|
The alias localAllocator = shared PrefixAllocator.instance;
alias sharedAllocator = shared PrefixAllocator.instance;
|
Squashed commit of the following: commit ee96796 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Fri Mar 29 15:16:46 2019 +0200 Fix invalid support bug commit 8e2a813 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Thu Dec 6 18:21:57 2018 +0200 Make array usable in betterC commit ab1eef7 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Dec 4 16:29:00 2018 +0200 Leave bounds checking to underlying T[] support commit 82b1bbc Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Dec 4 16:28:04 2018 +0200 Mark isShared as the msb inside the ref count commit 4410979 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Thu Nov 29 14:14:54 2018 +0200 Use version (CoreUnittest) for stats allocator commit d0a8ae5 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 27 13:52:22 2018 +0200 Refactor idup commit a144462 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 27 13:50:26 2018 +0200 Refactor dup commit 97db995 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 17:24:30 2018 +0200 Rename to `rcarray` commit 4ac6812 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 17:15:46 2018 +0200 Comply with D_NoBoundsCheck commit 5d98a65 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 16:26:41 2018 +0200 DStyle: Add space between version ( commit 68191fa Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 16:17:44 2018 +0200 Make `each` compatible with Phobos' `each` commit 65c0fde Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 21:05:08 2018 +0000 Change from labels to inline access specifiers commit 5fa4cbd Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 16:48:24 2018 +0200 Remove array's internal range API commit 025b50f Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 15:25:05 2018 +0200 Make global symbols private commit 86ea7ed Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:53:57 2018 +0200 Implement opEquals and remove global equals fn commit 60b3143 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:27:06 2018 +0200 Allow toHash to infer safety commit 815942b Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:23:22 2018 +0200 Remove obsolete ctor commit 89b48a6 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 22:01:55 2018 +0000 Remove range deps commit d9c02b0 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:34:10 2018 +0000 Rename internal fields commit 6642656 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:07:28 2018 +0000 Import Unqual from core traits commit 039483d Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:05:52 2018 +0000 Make length behave as builtin array's commit a206494 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Sun Nov 11 21:46:11 2018 +0000 [WIP] Add @nogc array
This commit fixes rcarray for class types, storing class references (i.e. not class states). The previous code (both in dlang#2348 and in https://github.com/dlang-stdx/collections) was broken and allocated memory for a class *state* but used the memory to store *references*.
Squashed commit of the following: commit ee96796 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Fri Mar 29 15:16:46 2019 +0200 Fix invalid support bug commit 8e2a813 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Thu Dec 6 18:21:57 2018 +0200 Make array usable in betterC commit ab1eef7 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Dec 4 16:29:00 2018 +0200 Leave bounds checking to underlying T[] support commit 82b1bbc Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Dec 4 16:28:04 2018 +0200 Mark isShared as the msb inside the ref count commit 4410979 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Thu Nov 29 14:14:54 2018 +0200 Use version (CoreUnittest) for stats allocator commit d0a8ae5 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 27 13:52:22 2018 +0200 Refactor idup commit a144462 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 27 13:50:26 2018 +0200 Refactor dup commit 97db995 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 17:24:30 2018 +0200 Rename to `rcarray` commit 4ac6812 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 17:15:46 2018 +0200 Comply with D_NoBoundsCheck commit 5d98a65 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 16:26:41 2018 +0200 DStyle: Add space between version ( commit 68191fa Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 16:17:44 2018 +0200 Make `each` compatible with Phobos' `each` commit 65c0fde Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 21:05:08 2018 +0000 Change from labels to inline access specifiers commit 5fa4cbd Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 16:48:24 2018 +0200 Remove array's internal range API commit 025b50f Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 15:25:05 2018 +0200 Make global symbols private commit 86ea7ed Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:53:57 2018 +0200 Implement opEquals and remove global equals fn commit 60b3143 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:27:06 2018 +0200 Allow toHash to infer safety commit 815942b Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:23:22 2018 +0200 Remove obsolete ctor commit 89b48a6 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 22:01:55 2018 +0000 Remove range deps commit d9c02b0 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:34:10 2018 +0000 Rename internal fields commit 6642656 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:07:28 2018 +0000 Import Unqual from core traits commit 039483d Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:05:52 2018 +0000 Make length behave as builtin array's commit a206494 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Sun Nov 11 21:46:11 2018 +0000 [WIP] Add @nogc array
This commit fixes rcarray for class types, storing class references (i.e. not class states). The previous code (both in dlang#2348 and in https://github.com/dlang-stdx/collections) was broken and allocated memory for a class *state* but used the memory to store *references*.
Squashed commit of the following: commit ee96796 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Fri Mar 29 15:16:46 2019 +0200 Fix invalid support bug commit 8e2a813 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Thu Dec 6 18:21:57 2018 +0200 Make array usable in betterC commit ab1eef7 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Dec 4 16:29:00 2018 +0200 Leave bounds checking to underlying T[] support commit 82b1bbc Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Dec 4 16:28:04 2018 +0200 Mark isShared as the msb inside the ref count commit 4410979 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Thu Nov 29 14:14:54 2018 +0200 Use version (CoreUnittest) for stats allocator commit d0a8ae5 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 27 13:52:22 2018 +0200 Refactor idup commit a144462 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 27 13:50:26 2018 +0200 Refactor dup commit 97db995 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 17:24:30 2018 +0200 Rename to `rcarray` commit 4ac6812 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 17:15:46 2018 +0200 Comply with D_NoBoundsCheck commit 5d98a65 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 16:26:41 2018 +0200 DStyle: Add space between version ( commit 68191fa Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 26 16:17:44 2018 +0200 Make `each` compatible with Phobos' `each` commit 65c0fde Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 21:05:08 2018 +0000 Change from labels to inline access specifiers commit 5fa4cbd Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 16:48:24 2018 +0200 Remove array's internal range API commit 025b50f Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 15:25:05 2018 +0200 Make global symbols private commit 86ea7ed Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:53:57 2018 +0200 Implement opEquals and remove global equals fn commit 60b3143 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:27:06 2018 +0200 Allow toHash to infer safety commit 815942b Author: Eduard Staniloiu <edi33416@gmail.com> Date: Tue Nov 20 14:23:22 2018 +0200 Remove obsolete ctor commit 89b48a6 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 22:01:55 2018 +0000 Remove range deps commit d9c02b0 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:34:10 2018 +0000 Rename internal fields commit 6642656 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:07:28 2018 +0000 Import Unqual from core traits commit 039483d Author: Eduard Staniloiu <edi33416@gmail.com> Date: Mon Nov 12 15:05:52 2018 +0000 Make length behave as builtin array's commit a206494 Author: Eduard Staniloiu <edi33416@gmail.com> Date: Sun Nov 11 21:46:11 2018 +0000 [WIP] Add @nogc array
This commit fixes rcarray for class types, storing class references (i.e. not class states). The previous code (both in dlang#2348 and in https://github.com/dlang-stdx/collections) was broken and allocated memory for a class *state* but used the memory to store *references*.
This PR adds a
@nogc nothrow pure @safeimplementation of a generic array that mimics the behaviour of the built-in array (T[]).This array implementation makes use of the Copy Constructor PR. By doing so, it both tests the implementation and proves it's usefulness.
I know this is a lengthy PR, but please bear with me, as there are a lot of unittests.
And now, as Andrei says "destroy()"