Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memory deprecations #2714

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ authors "Sönke Ludwig" "Martin Nowak" "Matthias Dondorff" "Sebastian Wilzbach"
"more than 80 contributors total"
copyright "Copyright © 2012-2016 rejectedsoftware e.K., Copyright © 2012-2014 Matthias Dondorff"
license "MIT"
dflags "-preview=in" platform="ldc"
dflags "-preview=in" platform="dmd"
dflags "-fpreview=in" platform="gdc"

targetPath "bin"

Expand Down
16 changes: 8 additions & 8 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ import std.typecons : Tuple, tuple;
CommandGroup[] getCommands() @safe pure nothrow
{
return [
CommandGroup("Package creation",
CommandGroup("Package creation", [
new InitCommand
),
CommandGroup("Build, test and run",
]),
CommandGroup("Build, test and run", [
new RunCommand,
new BuildCommand,
new TestCommand,
Expand All @@ -55,8 +55,8 @@ CommandGroup[] getCommands() @safe pure nothrow
new DescribeCommand,
new CleanCommand,
new DustmiteCommand
),
CommandGroup("Package management",
]),
CommandGroup("Package management", [
new FetchCommand,
new AddCommand,
new RemoveCommand,
Expand All @@ -72,7 +72,7 @@ CommandGroup[] getCommands() @safe pure nothrow
new ListOverridesCommand,
new CleanCachesCommand,
new ConvertCommand,
)
])
];
}

Expand Down Expand Up @@ -900,10 +900,10 @@ struct CommandGroup {
/// List of commands contained in this group
Command[] commands;

this(string caption, Command[] commands...) @safe pure nothrow
this(return string caption, return Command[] commands) @safe pure nothrow
{
this.caption = caption;
this.commands = commands.dup;
this.commands = commands;
}
}

Expand Down
20 changes: 11 additions & 9 deletions source/dub/dependency.d
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ struct Version {

/** Constructs a new `Version` from its string representation.
*/
this(string vers) @safe pure
this(return string vers) @safe pure
{
enforce(vers.length > 1, "Version strings must not be empty.");
if (vers[0] != branchPrefix)
Expand All @@ -789,7 +789,7 @@ struct Version {
This method is equivalent to calling the constructor and is used as an
endpoint for the serialization framework.
*/
static Version fromString(string vers) @safe pure { return Version(vers); }
static Version fromString(return string vers) @safe pure { return Version(vers); }

bool opEquals(in Version oth) const scope @safe pure
{
Expand Down Expand Up @@ -922,7 +922,7 @@ public struct VersionRange
}

/// Modify in place
public void merge (const VersionRange o) @safe
public void merge (return const VersionRange o) @safe scope
{
int acmp = m_versA.opCmp(o.m_versA);
int bcmp = m_versB.opCmp(o.m_versB);
Expand Down Expand Up @@ -955,7 +955,7 @@ public struct VersionRange
assert(!VersionRange.fromString("<1.0.0").matchesAny);
}

public static VersionRange fromString (string ves) @safe
public static VersionRange fromString (return string ves) @safe
{
static import std.string;

Expand Down Expand Up @@ -1012,10 +1012,10 @@ public struct VersionRange
enforce(cmpa == ">" || cmpa == ">=",
"First comparison operator expected to be either > or >=, not " ~ cmpa);
assert(ves[idx2] == ' ');
string v2 = ves[idx2+1..$];
VersionRange ret;
ret.m_versA = Version(ves[0..idx2]);
ret.m_inclusiveA = cmpa == ">=";
string v2 = ves[idx2+1..$];
auto cmpb = skipComp(v2);
enforce(cmpb == "<" || cmpb == "<=",
"Second comparison operator expected to be either < or <=, not " ~ cmpb);
Expand Down Expand Up @@ -1080,17 +1080,19 @@ public struct VersionRange
}

private static bool isDigit(char ch) @safe { return ch >= '0' && ch <= '9'; }
private static string skipComp(ref string c) @safe {
private static string skipComp(scope string c) @safe {
size_t idx = 0;
while (idx < c.length && !isDigit(c[idx]) && c[idx] != Version.branchPrefix) idx++;
enforce(idx < c.length, "Expected version number in version spec: "~c);
string cmp = idx==c.length-1||idx==0? ">=" : c[0..idx];
c = c[idx..$];
switch(cmp) {
default: enforce(false, "No/Unknown comparison specified: '"~cmp~"'"); return ">=";
case ">=": goto case; case ">": goto case;
case "<=": goto case; case "<": goto case;
case "==": return cmp;
case ">=": return ">=";
case ">": return ">";
case "<=": return "<=";
case "<": return "<";
case "==": return "==";
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/dub/internal/undead/xml.d
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@ class DocumentParser : ElementParser
class ElementParser
{
alias Handler = void delegate(string);
alias ElementHandler = void delegate(in Element element);
alias ElementHandler = void delegate(scope const Element element);
alias ParserHandler = void delegate(ElementParser parser);

private
Expand Down Expand Up @@ -2850,7 +2850,7 @@ EOS";
assert(xml.tag.attr["thing"] == "What & Up");
};

xml.onEndTag["Test"] = (in Element e) {
xml.onEndTag["Test"] = (scope const Element e) {
assert(e.text() == "What & Up Second");
};
xml.parse();
Expand Down
2 changes: 1 addition & 1 deletion source/dub/package_.d
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ class Package {
FIXME: The `platform` parameter is currently ignored, as the
`"subConfigurations"` field doesn't support platform suffixes.
*/
string getSubConfiguration(string config, in Package dependency, in BuildPlatform platform)
string getSubConfiguration(string config, scope const Package dependency, in BuildPlatform platform)
const {
bool found = false;
foreach(ref c; m_info.configurations){
Expand Down
2 changes: 1 addition & 1 deletion source/dub/packagesuppliers/maven.d
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MavenRegistryPackageSupplier : PackageSupplier {
auto xml = new DocumentParser(xmlData);

xml.onStartTag["versions"] = (ElementParser xml) {
xml.onEndTag["version"] = (in Element e) {
xml.onEndTag["version"] = (scope const Element e) {
json["versions"] ~= serializeToJson(["name": packageId, "version": e.text]);
};
xml.parse();
Expand Down
16 changes: 8 additions & 8 deletions source/dub/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ enum ListBuildSettingsFormat {
deprecated("Use `dub.packagemanager : PlacementLocation` instead")
public alias PlacementLocation = dub.packagemanager.PlacementLocation;

void processVars(ref BuildSettings dst, in Project project, in Package pack,
void processVars(ref BuildSettings dst, scope const Project project, in Package pack,
BuildSettings settings, in GeneratorSettings gsettings, bool include_target_settings = false)
{
string[string] processVerEnvs(in string[string] targetEnvs, in string[string] defaultEnvs)
Expand Down Expand Up @@ -1363,13 +1363,13 @@ void processVars(ref BuildSettings dst, in Project project, in Package pack,
}
}

string[] processVars(bool glob = false)(in Project project, in Package pack, in GeneratorSettings gsettings, in string[] vars, bool are_paths = false, in string[string][] extraVers = null)
string[] processVars(bool glob = false)(scope const Project project, in Package pack, in GeneratorSettings gsettings, in string[] vars, bool are_paths = false, in string[string][] extraVers = null)
{
auto ret = appender!(string[])();
processVars!glob(ret, project, pack, gsettings, vars, are_paths, extraVers);
return ret.data;
}
void processVars(bool glob = false)(ref Appender!(string[]) dst, in Project project, in Package pack, in GeneratorSettings gsettings, in string[] vars, bool are_paths = false, in string[string][] extraVers = null)
void processVars(bool glob = false)(ref Appender!(string[]) dst, scope const Project project, in Package pack, in GeneratorSettings gsettings, in string[] vars, bool are_paths = false, in string[string][] extraVers = null)
{
static if (glob)
alias process = processVarsWithGlob!(Project, Package);
Expand All @@ -1379,7 +1379,7 @@ void processVars(bool glob = false)(ref Appender!(string[]) dst, in Project proj
dst.put(process(var, project, pack, gsettings, are_paths, extraVers));
}

string processVars(Project, Package)(string var, in Project project, in Package pack, in GeneratorSettings gsettings, bool is_path, in string[string][] extraVers = null)
string processVars(Project, Package)(string var, scope const Project project, in Package pack, in GeneratorSettings gsettings, bool is_path, in string[string][] extraVers = null)
{
var = var.expandVars!(varName => getVariable(varName, project, pack, gsettings, extraVers));
if (!is_path)
Expand All @@ -1390,13 +1390,13 @@ string processVars(Project, Package)(string var, in Project project, in Package
else
return p.toNativeString();
}
string[string] processVars(bool glob = false)(in Project project, in Package pack, in GeneratorSettings gsettings, in string[string] vars, in string[string][] extraVers = null)
string[string] processVars(bool glob = false)(scope const Project project, in Package pack, in GeneratorSettings gsettings, in string[string] vars, in string[string][] extraVers = null)
{
string[string] ret;
processVars!glob(ret, project, pack, gsettings, vars, extraVers);
return ret;
}
void processVars(bool glob = false)(ref string[string] dst, in Project project, in Package pack, in GeneratorSettings gsettings, in string[string] vars, in string[string][] extraVers)
void processVars(bool glob = false)(ref string[string] dst, scope const Project project, in Package pack, in GeneratorSettings gsettings, in string[string] vars, in string[string][] extraVers)
{
static if (glob)
alias process = processVarsWithGlob!(Project, Package);
Expand All @@ -1406,7 +1406,7 @@ void processVars(bool glob = false)(ref string[string] dst, in Project project,
dst[k] = process(var, project, pack, gsettings, false, extraVers);
}

private string[] processVarsWithGlob(Project, Package)(string var, in Project project, in Package pack, in GeneratorSettings gsettings, bool is_path, in string[string][] extraVers)
private string[] processVarsWithGlob(Project, Package)(string var, scope const Project project, in Package pack, in GeneratorSettings gsettings, bool is_path, in string[string][] extraVers)
{
assert(is_path, "can't glob something that isn't a path");
string res = processVars(var, project, pack, gsettings, is_path, extraVers);
Expand Down Expand Up @@ -1552,7 +1552,7 @@ package(dub) immutable buildSettingsVars = [
"ARCH", "PLATFORM", "PLATFORM_POSIX", "BUILD_TYPE"
];

private string getVariable(Project, Package)(string name, in Project project, in Package pack, in GeneratorSettings gsettings, in string[string][] extraVars = null)
private string getVariable(Project, Package)(string name, scope const Project project, in Package pack, in GeneratorSettings gsettings, in string[string][] extraVars = null)
{
import dub.internal.utils : getDUBExePath;
import std.process : environment, escapeShellFileName;
Expand Down
6 changes: 3 additions & 3 deletions source/dub/semver.d
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ unittest {

See_Also: `expandVersion`
*/
string bumpVersion(string ver)
string bumpVersion(scope string ver)
pure {
// Cut off metadata and prerelease information.
auto mi = ver.indexOfAny("+-");
Expand Down Expand Up @@ -273,7 +273,7 @@ unittest {
With 0.x.y releases, any release can break.
With x.y.z releases, only major releases can break.
*/
string bumpIncompatibleVersion(string ver)
string bumpIncompatibleVersion(scope string ver)
pure {
// Cut off metadata and prerelease information.
auto mi = ver.indexOfAny("+-");
Expand Down Expand Up @@ -304,7 +304,7 @@ unittest {

See_Also: `bumpVersion`
*/
string expandVersion(string ver)
string expandVersion(scope string ver)
pure {
auto mi = ver.indexOfAny("+-");
auto sub = "";
Expand Down
Loading