From 46b147b7abb1b2e0f994d3fd9200550bb4fd82dd Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 26 Jun 2018 06:21:10 +0200 Subject: [PATCH 1/3] Use the phobos:allocator package --- dub.json | 5 ++++- source/stdx/collections/array.d | 16 ++++++++-------- source/stdx/collections/common.d | 28 ++++++++++++++-------------- source/stdx/collections/dlist.d | 14 +++++++------- source/stdx/collections/hashtable.d | 10 +++++----- source/stdx/collections/rcstring.d | 10 +++++----- source/stdx/collections/slist.d | 14 +++++++------- 7 files changed, 50 insertions(+), 47 deletions(-) diff --git a/dub.json b/dub.json index db5aea2..2d7bc6b 100644 --- a/dub.json +++ b/dub.json @@ -11,5 +11,8 @@ "--unittest-examples", "--min-protection=Protected" ], - "-ddoxTool": "scod" + "-ddoxTool": "scod", + "dependencies": { + "phobos:allocator": "~master" + } } diff --git a/source/stdx/collections/array.d b/source/stdx/collections/array.d index ff7cd81..8425c2e 100644 --- a/source/stdx/collections/array.d +++ b/source/stdx/collections/array.d @@ -7,9 +7,9 @@ debug(CollectionArray) import std.stdio; version(unittest) { - import std.experimental.allocator.mallocator; - import std.experimental.allocator.building_blocks.stats_collector; - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator.mallocator; + import stdx.allocator.building_blocks.stats_collector; + import stdx.allocator : RCIAllocator, RCISharedAllocator, allocatorObject, sharedAllocatorObject; import std.stdio; @@ -19,9 +19,9 @@ version(unittest) /// struct Array(T) { - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator : RCIAllocator, RCISharedAllocator, make, dispose, stateSize; - import std.experimental.allocator.building_blocks.affix_allocator; + import stdx.allocator.building_blocks.affix_allocator; import std.traits : isImplicitlyConvertible, Unqual, isArray; import std.range.primitives : isInputRange, isInfinite, ElementType, hasLength; import std.conv : emplace; @@ -137,7 +137,7 @@ public: static if (is(T == int)) @safe unittest { - import std.experimental.allocator : theAllocator, processAllocator; + import stdx.allocator : theAllocator, processAllocator; auto a = Array!int(theAllocator); auto ca = const Array!int(processAllocator); @@ -1782,7 +1782,7 @@ void testConstness(RCISharedAllocator allocator) @safe unittest { import std.conv; - import std.experimental.allocator : processAllocator; + import stdx.allocator : processAllocator; SCAlloc statsCollectorAlloc; // TODO: StatsCollector needs to be made shareable //auto _allocator = sharedAllocatorObject(&statsCollectorAlloc); @@ -1819,7 +1819,7 @@ void testWithStruct(RCIAllocator allocator, RCISharedAllocator sharedAlloc) @safe unittest { import std.conv; - import std.experimental.allocator : processAllocator; + import stdx.allocator : processAllocator; SCAlloc statsCollectorAlloc; { auto _allocator = (() @trusted => allocatorObject(&statsCollectorAlloc))(); diff --git a/source/stdx/collections/common.d b/source/stdx/collections/common.d index 6f46065..dfbdbd9 100644 --- a/source/stdx/collections/common.d +++ b/source/stdx/collections/common.d @@ -13,13 +13,13 @@ if (isInputRange!Collection) package static auto threadAllocatorObject() { - import std.experimental.allocator : RCIAllocator; + import stdx.allocator : RCIAllocator; static @nogc nothrow RCIAllocator wrapAllocatorObject() { - import std.experimental.allocator.gc_allocator : GCAllocator; - import std.experimental.allocator : allocatorObject; + import stdx.allocator.gc_allocator : GCAllocator; + import stdx.allocator : allocatorObject; return allocatorObject(GCAllocator.instance); } @@ -30,13 +30,13 @@ package static auto threadAllocatorObject() package static auto processAllocatorObject() { - import std.experimental.allocator : RCISharedAllocator; + import stdx.allocator : RCISharedAllocator; static @nogc nothrow RCISharedAllocator wrapAllocatorObject() { - import std.experimental.allocator.gc_allocator : GCAllocator; - import std.experimental.allocator : sharedAllocatorObject; + import stdx.allocator.gc_allocator : GCAllocator; + import stdx.allocator : sharedAllocatorObject; return sharedAllocatorObject(GCAllocator.instance); } @@ -47,9 +47,9 @@ package static auto processAllocatorObject() package struct AllocatorHandler { - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator : RCIAllocator, RCISharedAllocator, dispose, stateSize, theAllocator, processAllocator; - import std.experimental.allocator.building_blocks.affix_allocator; + import stdx.allocator.building_blocks.affix_allocator; import std.conv : emplace; import core.atomic : atomicOp; import std.algorithm.mutation : move; @@ -403,14 +403,14 @@ version(unittest) package static struct Impure { - import std.experimental.allocator : RCIAllocator, theAllocator; + import stdx.allocator : RCIAllocator, theAllocator; RCIAllocator _a; @safe this(int id) { _a = theAllocator; } } package static struct ImpureDtor { - import std.experimental.allocator : RCIAllocator, theAllocator; + import stdx.allocator : RCIAllocator, theAllocator; RCIAllocator _a; @nogc nothrow pure @safe this(int x) {} @safe ~this() { _a = theAllocator; } @@ -434,9 +434,9 @@ version(unittest) unittest { - import std.experimental.allocator.mallocator; - import std.experimental.allocator.building_blocks.stats_collector; - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator.mallocator; + import stdx.allocator.building_blocks.stats_collector; + import stdx.allocator : RCIAllocator, RCISharedAllocator, allocatorObject, sharedAllocatorObject, processAllocator, theAllocator; import std.conv : to; import std.stdio; @@ -492,7 +492,7 @@ unittest unittest { - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator : RCIAllocator, RCISharedAllocator, allocatorObject, sharedAllocatorObject, processAllocator, theAllocator; import std.stdio; diff --git a/source/stdx/collections/dlist.d b/source/stdx/collections/dlist.d index 0ec43a1..cf94a31 100644 --- a/source/stdx/collections/dlist.d +++ b/source/stdx/collections/dlist.d @@ -7,9 +7,9 @@ debug(CollectionDList) import std.stdio; version(unittest) { - import std.experimental.allocator.mallocator; - import std.experimental.allocator.building_blocks.stats_collector; - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator.mallocator; + import stdx.allocator.building_blocks.stats_collector; + import stdx.allocator : RCIAllocator, RCISharedAllocator, allocatorObject, sharedAllocatorObject; private alias SCAlloc = StatsCollector!(Mallocator, Options.bytesUsed); @@ -18,9 +18,9 @@ version(unittest) /// struct DList(T) { - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator : RCIAllocator, RCISharedAllocator, theAllocator, processAllocator, make, dispose, stateSize; - import std.experimental.allocator.building_blocks.affix_allocator; + import stdx.allocator.building_blocks.affix_allocator; import std.traits : isImplicitlyConvertible; import std.range.primitives : isInputRange, ElementType; import std.variant : Algebraic; @@ -1684,7 +1684,7 @@ void testConstness(RCISharedAllocator allocator) @safe unittest { import std.conv; - import std.experimental.allocator : processAllocator; + import stdx.allocator : processAllocator; SCAlloc statsCollectorAlloc; { // TODO: StatsCollector need to be made shareable @@ -1804,7 +1804,7 @@ void testWithStruct(RCIAllocator allocator, RCISharedAllocator sharedAlloc) @safe unittest { import std.conv; - import std.experimental.allocator : processAllocator; + import stdx.allocator : processAllocator; SCAlloc statsCollectorAlloc; { auto _allocator = (() @trusted => allocatorObject(&statsCollectorAlloc))(); diff --git a/source/stdx/collections/hashtable.d b/source/stdx/collections/hashtable.d index dcdecdb..02c45a8 100644 --- a/source/stdx/collections/hashtable.d +++ b/source/stdx/collections/hashtable.d @@ -7,9 +7,9 @@ debug(CollectionHashtable) import std.stdio; version(unittest) { - import std.experimental.allocator.mallocator; - import std.experimental.allocator.building_blocks.stats_collector; - import std.experimental.allocator : allocatorObject, + import stdx.allocator.mallocator; + import stdx.allocator.building_blocks.stats_collector; + import stdx.allocator : allocatorObject, RCIAllocator, RCISharedAllocator; private alias SCAlloc = StatsCollector!(Mallocator, Options.bytesUsed); @@ -18,7 +18,7 @@ version(unittest) /// struct Hashtable(K, V) { - import std.experimental.allocator : RCIAllocator, RCISharedAllocator; + import stdx.allocator : RCIAllocator, RCISharedAllocator; import std.traits : isImplicitlyConvertible; import std.typecons : Tuple, Nullable; import std.algorithm.mutation : move; @@ -92,7 +92,7 @@ public: static if (is(K == int)) @safe unittest { - import std.experimental.allocator : theAllocator, processAllocator; + import stdx.allocator : theAllocator, processAllocator; auto h = Hashtable!(int, int)(theAllocator); auto ch = const Hashtable!(int, int)(processAllocator); diff --git a/source/stdx/collections/rcstring.d b/source/stdx/collections/rcstring.d index 8f3e3c3..cb0363f 100644 --- a/source/stdx/collections/rcstring.d +++ b/source/stdx/collections/rcstring.d @@ -23,9 +23,9 @@ debug(CollectionRCString) import std.stdio; version(unittest) { - import std.experimental.allocator.mallocator; - import std.experimental.allocator.building_blocks.stats_collector; - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator.mallocator; + import stdx.allocator.building_blocks.stats_collector; + import stdx.allocator : RCIAllocator, RCISharedAllocator, allocatorObject, sharedAllocatorObject; import std.algorithm.mutation : move; import std.stdio; @@ -76,7 +76,7 @@ public: /// @safe unittest { - import std.experimental.allocator : theAllocator, processAllocator; + import stdx.allocator : theAllocator, processAllocator; auto a = RCString(theAllocator); auto ca = const RCString(processAllocator); @@ -154,7 +154,7 @@ public: /// @safe unittest { - import std.experimental.allocator : theAllocator, processAllocator; + import stdx.allocator : theAllocator, processAllocator; // Create a list from a list of ints auto a = RCString(theAllocator, '1', '2', '3'); diff --git a/source/stdx/collections/slist.d b/source/stdx/collections/slist.d index 5532772..298bc1b 100644 --- a/source/stdx/collections/slist.d +++ b/source/stdx/collections/slist.d @@ -7,9 +7,9 @@ debug(CollectionSList) import std.stdio; version(unittest) { - import std.experimental.allocator.mallocator; - import std.experimental.allocator.building_blocks.stats_collector; - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator.mallocator; + import stdx.allocator.building_blocks.stats_collector; + import stdx.allocator : RCIAllocator, RCISharedAllocator, allocatorObject, sharedAllocatorObject; private alias SCAlloc = StatsCollector!(Mallocator, Options.bytesUsed); @@ -18,9 +18,9 @@ version(unittest) /// struct SList(T) { - import std.experimental.allocator : RCIAllocator, RCISharedAllocator, + import stdx.allocator : RCIAllocator, RCISharedAllocator, theAllocator, processAllocator, make, dispose, stateSize; - import std.experimental.allocator.building_blocks.affix_allocator; + import stdx.allocator.building_blocks.affix_allocator; import std.traits : isImplicitlyConvertible; import std.range.primitives : isInputRange, ElementType; import std.variant : Algebraic; @@ -1189,7 +1189,7 @@ void testConstness(RCISharedAllocator allocator) @safe unittest { import std.conv; - import std.experimental.allocator : processAllocator; + import stdx.allocator : processAllocator; SCAlloc statsCollectorAlloc; { // TODO: StatsCollector need to be made shareable @@ -1454,7 +1454,7 @@ void testWithStruct(RCIAllocator allocator, RCISharedAllocator sharedAlloc) @safe unittest { import std.conv; - import std.experimental.allocator : processAllocator; + import stdx.allocator : processAllocator; SCAlloc statsCollectorAlloc; { auto _allocator = (() @trusted => allocatorObject(&statsCollectorAlloc))(); From 3337267241ea13e573097b342cc25578cd78cd30 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 26 Jun 2018 06:22:18 +0200 Subject: [PATCH 2/3] Test with latest DMD/LDC --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08f0a8c..82759f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,10 @@ os: - linux language: d d: - - ldc + - dmd matrix: include: - - d: dmd-nightly + - d: dmd script: - dub test --compiler=$DC --build=unittest-cov #- dub build -b ddox From 5d7d1607d21c5962312549a448d8ea7549cc9141 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 26 Jun 2018 10:31:07 +0200 Subject: [PATCH 3/3] Track dub.selections.json --- dub.selections.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 dub.selections.json diff --git a/dub.selections.json b/dub.selections.json new file mode 100644 index 0000000..0936828 --- /dev/null +++ b/dub.selections.json @@ -0,0 +1,6 @@ +{ + "fileVersion": 1, + "versions": { + "phobos": "~master" + } +}