Remove previously deprecated modules

* tanya.network.uri
* tanya.network.inet
* tanya.memory.types
This commit is contained in:
Eugen Wissner 2017-06-30 04:19:20 +02:00
parent e79c75df81
commit e46e45ad5a
7 changed files with 15 additions and 1530 deletions

View File

@ -1,4 +1,3 @@
ignore: ignore:
- "source/tanya/async/event/iocp.d" - "source/tanya/async/event/iocp.d"
- "source/tanya/async/iocp.d" - "source/tanya/async/iocp.d"
- "source/tanya/memory/types.d"

View File

@ -23,7 +23,7 @@ import std.range;
import std.traits; import std.traits;
import tanya.memory; import tanya.memory;
package template Payload(T) private template Payload(T)
{ {
static if (is(T == class) || is(T == interface) || isArray!T) static if (is(T == class) || is(T == interface) || isArray!T)
{ {
@ -35,7 +35,7 @@ package template Payload(T)
} }
} }
package final class RefCountedStore(T) private final class RefCountedStore(T)
{ {
T payload; T payload;
size_t counter = 1; size_t counter = 1;
@ -68,14 +68,14 @@ package final class RefCountedStore(T)
} }
} }
package void separateDeleter(T)(RefCountedStore!T storage, private void separateDeleter(T)(RefCountedStore!T storage,
shared Allocator allocator) shared Allocator allocator)
{ {
allocator.dispose(storage.payload); allocator.dispose(storage.payload);
allocator.dispose(storage); allocator.dispose(storage);
} }
package void unifiedDeleter(T)(RefCountedStore!T storage, private void unifiedDeleter(T)(RefCountedStore!T storage,
shared Allocator allocator) shared Allocator allocator)
{ {
auto ptr1 = finalize(storage); auto ptr1 = finalize(storage);

View File

@ -1,301 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Smart pointers.
*
* $(RED Deprecated. Use $(D_PSYMBOL tanya.memory.smartref) instead.
* This module will be removed in 0.8.0.)
*
* Copyright: Eugene Wissner 2016-2017.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
deprecated("Use tanya.memory.smartref instead")
module tanya.memory.types;
import core.exception;
import std.algorithm.comparison;
import std.algorithm.mutation;
import std.conv;
import std.range;
import std.traits;
import tanya.memory;
public import tanya.memory.smartref : RefCounted, Payload;
version (unittest)
{
private struct B
{
int prop;
@disable this();
this(int param1) @nogc
{
prop = param1;
}
}
}
/**
* $(D_PSYMBOL Scoped) stores an object that gets destroyed at the end of its scope.
*
* Params:
* T = Value type.
*/
struct Scoped(T)
{
private Payload!T payload;
invariant
{
assert(payload is null || allocator_ !is null);
}
/**
* Takes ownership over $(D_PARAM value), setting the counter to 1.
* $(D_PARAM value) may be a pointer, an object or a dynamic array.
*
* Params:
* value = Value whose ownership is taken over.
* allocator = Allocator used to destroy the $(D_PARAM value) and to
* allocate/deallocate internal storage.
*
* Precondition: $(D_INLINECODE allocator !is null)
*/
this()(auto ref Payload!T value,
shared Allocator allocator = defaultAllocator)
{
this(allocator);
move(value, this.payload);
static if (__traits(isRef, value))
{
value = null;
}
}
/// Ditto.
this(shared Allocator allocator)
in
{
assert(allocator !is null);
}
body
{
this.allocator_ = allocator;
}
/**
* $(D_PSYMBOL Scoped) is noncopyable.
*/
@disable this(this);
/**
* Destroys the owned object.
*/
~this()
{
if (this.payload !is null)
{
allocator.dispose(this.payload);
}
}
/**
* Initialized this $(D_PARAM Scoped) and takes ownership over
* $(D_PARAM rhs).
*
* To reset $(D_PSYMBOL Scoped) assign $(D_KEYWORD null).
*
* If the allocator wasn't set before, $(D_PSYMBOL defaultAllocator) will
* be used. If you need a different allocator, create a new
* $(D_PSYMBOL Scoped) and assign it.
*
* Params:
* rhs = New object.
*
* Returns: $(D_KEYWORD this).
*/
ref typeof(this) opAssign()(auto ref Payload!T rhs)
{
allocator.dispose(this.payload);
move(rhs, this.payload);
return this;
}
/// Ditto.
ref typeof(this) opAssign(typeof(null))
{
allocator.dispose(this.payload);
return this;
}
/// Ditto.
ref typeof(this) opAssign(typeof(this) rhs)
{
swap(this.allocator_, rhs.allocator_);
swap(this.payload, rhs.payload);
return this;
}
/**
* Returns: Reference to the owned object.
*/
Payload!T get() pure nothrow @safe @nogc
{
return payload;
}
version (D_Ddoc)
{
/**
* Params:
* op = Operation.
*
* Dereferences the pointer. It is defined only for pointers, not for
* reference types like classes, that can be accessed directly.
*
* Returns: Reference to the pointed value.
*/
ref T opUnary(string op)()
if (op == "*");
}
else static if (isPointer!(Payload!T))
{
ref T opUnary(string op)()
if (op == "*")
{
return *payload;
}
}
mixin DefaultAllocator;
alias get this;
}
///
@nogc unittest
{
auto p = defaultAllocator.make!int(5);
auto s = Scoped!int(p, defaultAllocator);
assert(p is null);
assert(*s == 5);
}
///
@nogc unittest
{
static bool destroyed = false;
struct F
{
~this() @nogc
{
destroyed = true;
}
}
{
auto s = Scoped!F(defaultAllocator.make!F(), defaultAllocator);
}
assert(destroyed);
}
/**
* Constructs a new object of type $(D_PARAM T) and wraps it in a
* $(D_PSYMBOL Scoped) using $(D_PARAM args) as the parameter list for
* the constructor of $(D_PARAM T).
*
* Params:
* T = Type of the constructed object.
* A = Types of the arguments to the constructor of $(D_PARAM T).
* allocator = Allocator.
* args = Constructor arguments of $(D_PARAM T).
*
* Returns: Newly created $(D_PSYMBOL Scoped!T).
*
* Precondition: $(D_INLINECODE allocator !is null)
*/
Scoped!T scoped(T, A...)(shared Allocator allocator, auto ref A args)
if (!is(T == interface) && !isAbstractClass!T
&& !isAssociativeArray!T && !isArray!T)
in
{
assert(allocator !is null);
}
body
{
auto payload = allocator.make!(T, shared Allocator, A)(args);
return Scoped!T(payload, allocator);
}
/**
* Constructs a new array with $(D_PARAM size) elements and wraps it in a
* $(D_PSYMBOL Scoped).
*
* Params:
* T = Array type.
* size = Array size.
* allocator = Allocator.
*
* Returns: Newly created $(D_PSYMBOL Scoped!T).
*
* Precondition: $(D_INLINECODE allocator !is null
* && size <= size_t.max / ElementType!T.sizeof)
*/
Scoped!T scoped(T)(shared Allocator allocator, const size_t size)
@trusted
if (isArray!T)
in
{
assert(allocator !is null);
assert(size <= size_t.max / ElementType!T.sizeof);
}
body
{
auto payload = allocator.resize!(ElementType!T)(null, size);
return Scoped!T(payload, allocator);
}
private unittest
{
static assert(is(typeof(defaultAllocator.scoped!B(5))));
static assert(is(typeof(defaultAllocator.scoped!(int[])(5))));
}
private unittest
{
auto s = defaultAllocator.scoped!int(5);
assert(*s == 5);
s = null;
assert(s is null);
}
private unittest
{
auto s = defaultAllocator.scoped!int(5);
assert(*s == 5);
s = defaultAllocator.scoped!int(4);
assert(*s == 4);
}
private @nogc unittest
{
auto p1 = defaultAllocator.make!int(5);
auto p2 = p1;
auto rc = Scoped!int(p1, defaultAllocator);
assert(p1 is null);
assert(rc.get() is p2);
}
private @nogc unittest
{
auto rc = Scoped!int(defaultAllocator);
assert(rc.allocator is defaultAllocator);
}

View File

@ -13,7 +13,6 @@
module tanya.net.uri; module tanya.net.uri;
import std.ascii : isAlphaNum, isDigit; import std.ascii : isAlphaNum, isDigit;
import std.traits : isSomeString;
import std.uni : isAlpha, isNumber; import std.uni : isAlpha, isNumber;
import tanya.memory; import tanya.memory;
@ -151,9 +150,10 @@ struct URL
goto ParsePath; goto ParsePath;
} }
} }
else // certain schemas like mailto: and zlib: may not have any / after them else
{ {
// Schemas like mailto: and zlib: may not have any slash after
// them.
if (!parsePort(value[pos .. $])) if (!parsePort(value[pos .. $]))
{ {
this.scheme = value[0 .. pos]; this.scheme = value[0 .. pos];
@ -384,7 +384,7 @@ struct URL
assert(u.fragment == "fragment"); assert(u.fragment == "fragment");
} }
private unittest private @nogc unittest
{ {
auto u = URL("127.0.0.1"); auto u = URL("127.0.0.1");
assert(u.path == "127.0.0.1"); assert(u.path == "127.0.0.1");
@ -540,17 +540,11 @@ private @nogc unittest
* *
* Params: * Params:
* T = "scheme", "host", "port", "user", "pass", "path", "query", * T = "scheme", "host", "port", "user", "pass", "path", "query",
* "fragment" or $(D_KEYWORD null) for a struct with all components. * "fragment".
* source = The string containing the URL. * source = The string containing the URL.
* *
* Returns: Requested URL component. * Returns: Requested URL component.
*/ */
URL parseURL(const char[] source) @nogc
{
return URL(source);
}
/// Ditto.
auto parseURL(string T)(const char[] source) auto parseURL(string T)(const char[] source)
if (T == "scheme" if (T == "scheme"
|| T == "host" || T == "host"
@ -565,6 +559,12 @@ if (T == "scheme"
return mixin("ret." ~ T); return mixin("ret." ~ T);
} }
/// Ditto.
URL parseURL(const char[] source) @nogc
{
return URL(source);
}
/// ///
@nogc unittest @nogc unittest
{ {

View File

@ -1,19 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Internet utilities.
*
* $(RED Deprecated. Use $(D_PSYMBOL tanya.net.inet) instead.
* This module will be removed in 0.8.0.)
*
* Copyright: Eugene Wissner 2017.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
deprecated("Use tanya.net.inet instead")
module tanya.network.inet;
public import tanya.net.inet;

View File

@ -12,6 +12,4 @@
*/ */
module tanya.network; module tanya.network;
public import tanya.network.inet;
public import tanya.network.socket; public import tanya.network.socket;
public import tanya.network.url;

File diff suppressed because it is too large Load Diff