update examples so they can compile again, and make them visible to dub

This commit is contained in:
Cameron Ross 2018-04-27 00:17:09 -03:00 committed by Petar Kirov
parent b44f96bd9f
commit 4680e1b5b2
15 changed files with 57 additions and 54 deletions

View file

@ -7,5 +7,14 @@
"license": "Boost 1.0", "license": "Boost 1.0",
"dependencies": { "tinyendian" : { "version" : "~>0.1.0" } }, "dependencies": { "tinyendian" : { "version" : "~>0.1.0" } },
"homepage": "https://github.com/dlang-community/D-YAML", "homepage": "https://github.com/dlang-community/D-YAML",
"copyright": "Copyright © 2011-2014, Ferdinand Majerech" "copyright": "Copyright © 2011-2014, Ferdinand Majerech",
"subPackages": [
"examples/constructor",
"examples/getting_started",
"examples/representer",
"examples/resolver",
"examples/yaml_bench",
"examples/yaml_gen",
"examples/yaml_stats"
]
} }

View file

@ -5,6 +5,6 @@
"mainSourceFile": "main.d", "mainSourceFile": "main.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0"}, "dyaml": { "version" : "*"}
}, }
} }

View file

@ -1,6 +1,6 @@
import std.stdio; import std.stdio;
import std.string; import std.string;
import dyaml.all; import dyaml;
struct Color struct Color
{ {

View file

@ -5,6 +5,6 @@
"mainSourceFile": "main.d", "mainSourceFile": "main.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0" }, "dyaml": { "version" : "*" }
}, }
} }

View file

@ -1,5 +1,5 @@
import std.stdio; import std.stdio;
import dyaml.all; import dyaml;
void main() void main()
{ {

View file

@ -5,6 +5,6 @@
"mainSourceFile": "main.d", "mainSourceFile": "main.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0" }, "dyaml": { "version" : "*" }
}, }
} }

View file

@ -1,5 +1,5 @@
import std.stdio; import std.stdio;
import dyaml.all; import dyaml;
struct Color struct Color
{ {
@ -16,7 +16,7 @@ struct Color
} }
} }
Node representColor(ref Node node, Representer representer) Node representColor(ref Node node, Representer representer) @safe
{ {
//The node is guaranteed to be Color as we add representer for Color. //The node is guaranteed to be Color as we add representer for Color.
Color color = node.as!Color; Color color = node.as!Color;

View file

@ -5,6 +5,6 @@
"mainSourceFile": "main.d", "mainSourceFile": "main.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0" }, "dyaml": { "version" : "*" }
}, }
} }

View file

@ -1,6 +1,6 @@
import std.stdio; import std.stdio;
import std.string; import std.string;
import dyaml.all; import dyaml;
struct Color struct Color
{ {

View file

@ -1,16 +1,10 @@
{ {
"name": "yaml_bench", "name": "benchmark",
"targetType": "executable", "targetType": "executable",
"sourceFiles": ["yaml_bench.d"], "sourceFiles": ["yaml_bench.d"],
"mainSourceFile": "yaml_bench.d", "mainSourceFile": "yaml_bench.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0" }, "dyaml": { "version" : "*" }
},
"buildTypes":
{
"debug": { "buildOptions": ["debugMode", "debugInfoC"] },
"release": { "buildOptions": ["releaseMode", "optimize", "inline", "noBoundsCheck"] },
"profile": { "buildOptions": ["releaseMode", "optimize", "noBoundsCheck", "debugInfoC"] }
} }
} }

View file

@ -1,32 +1,32 @@
module dyaml.yaml_bench; module dyaml.yaml_bench;
//Benchmark that loads, and optionally extracts data from and/or emits a YAML file. //Benchmark that loads, and optionally extracts data from and/or emits a YAML file.
import std.conv; import std.conv;
import std.datetime; import std.datetime;
import std.stdio; import std.stdio;
import std.string; import std.string;
import dyaml.all; import dyaml;
///Print help information. ///Print help information.
void help() void help()
{ {
string help = string help =
"D:YAML benchmark\n" "D:YAML benchmark\n"~
"Copyright (C) 2011-2014 Ferdinand Majerech\n" "Copyright (C) 2011-2014 Ferdinand Majerech\n"~
"Usage: yaml_bench [OPTION ...] [YAML_FILE]\n" "Usage: yaml_bench [OPTION ...] [YAML_FILE]\n"~
"\n" "\n"~
"Loads and optionally extracts data and/or dumps a YAML file.\n" "Loads and optionally extracts data and/or dumps a YAML file.\n"~
"\n" "\n"~
"Available options:\n" "Available options:\n"~
" -h --help Show this help information.\n" " -h --help Show this help information.\n"~
" -g --get Extract data from the file (using Node.as()).\n" " -g --get Extract data from the file (using Node.as()).\n"~
" -d --dump Dump the loaded data (to YAML_FILE.dump).\n" " -d --dump Dump the loaded data (to YAML_FILE.dump).\n"~
" -r --runs=NUM Repeat parsing the file NUM times.\n" " -r --runs=NUM Repeat parsing the file NUM times.\n"~
" --reload Reload the file from the diskl on every repeat\n" " --reload Reload the file from the diskl on every repeat\n"~
" By default, the file is loaded to memory once\n" " By default, the file is loaded to memory once\n"~
" and repeatedly parsed from memory.\n" " and repeatedly parsed from memory.\n"~
" -s --scan-only Do not execute the entire parsing process, only\n" " -s --scan-only Do not execute the entire parsing process, only\n"~
" scanning. Overrides '--dump'.\n"; " scanning. Overrides '--dump'.\n";
writeln(help); writeln(help);
} }
@ -71,10 +71,10 @@ void main(string[] args)
string file = null; string file = null;
//Parse command line args //Parse command line args
foreach(arg; args[1 .. $]) foreach(arg; args[1 .. $])
{ {
auto parts = arg.split("="); auto parts = arg.split("=");
if(arg[0] == '-') switch(parts[0]) if(arg[0] == '-') switch(parts[0])
{ {
case "--help", "-h": help(); return; case "--help", "-h": help(); return;
case "--get", "-g": get = true; break; case "--get", "-g": get = true; break;
@ -88,8 +88,8 @@ void main(string[] args)
{ {
if(file !is null) if(file !is null)
{ {
writeln("\nUnknown argument or file specified twice: ", arg, "\n\n"); writeln("\nUnknown argument or file specified twice: ", arg, "\n\n");
help(); help();
return; return;
} }
@ -98,8 +98,8 @@ void main(string[] args)
} }
if(file is null) if(file is null)
{ {
writeln("\nFile not specified.\n\n"); writeln("\nFile not specified.\n\n");
help(); help();
return; return;
} }

View file

@ -5,6 +5,6 @@
"mainSourceFile": "yaml_gen.d", "mainSourceFile": "yaml_gen.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0" }, "dyaml": { "version" : "*" }
}, }
} }

View file

@ -8,7 +8,7 @@ import std.math;
import std.random; import std.random;
import std.stdio; import std.stdio;
import std.string; import std.string;
import dyaml.all; import dyaml;
Node config; Node config;
@ -220,7 +220,7 @@ Node pairs(bool root, bool complex, Node range, string tag)
{ {
auto key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : []))); auto key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : [])));
// Maps can't contain duplicate keys // Maps can't contain duplicate keys
while(tag.endsWith("map") && keys[0 .. i].canFind(key)) while(tag.endsWith("map") && keys[0 .. i].canFind(key))
{ {
key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : []))); key = generateNode(randomType(typesScalarKey ~ (complex ? typesCollection : [])));
} }

View file

@ -5,6 +5,6 @@
"mainSourceFile": "yaml_stats.d", "mainSourceFile": "yaml_stats.d",
"dependencies": "dependencies":
{ {
"dyaml": { "version" : "~>0.5.0" }, "dyaml": { "version" : "*" }
}, }
} }

View file

@ -3,7 +3,7 @@
import std.stdio; import std.stdio;
import std.string; import std.string;
import dyaml.all; import dyaml;
///Collects statistics about a YAML document and returns them as string. ///Collects statistics about a YAML document and returns them as string.
@ -66,8 +66,8 @@ string statistics(ref Node document)
"\nMappings: %s" ~ "\nMappings: %s" ~
"\n\nAverage sequence length: %s" ~ "\n\nAverage sequence length: %s" ~
"\nAverage mapping length: %s" ~ "\nAverage mapping length: %s" ~
"\n\n%s", "\n\n%s",
nodes, scalars, sequences, mappings, nodes, scalars, sequences, mappings,
sequences == 0.0 ? 0.0 : cast(real)seqItems / sequences, sequences == 0.0 ? 0.0 : cast(real)seqItems / sequences,
mappings == 0.0 ? 0.0 : cast(real)mapPairs / mappings, mappings == 0.0 ? 0.0 : cast(real)mapPairs / mappings,
tagStats); tagStats);