diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ext_depends/D-YAML.meta | 2 | ||||
-rw-r--r-- | src/ext_depends/D-YAML/.travis.yml | 41 | ||||
-rw-r--r-- | src/ext_depends/D-YAML/source/dyaml/node.d | 105 | ||||
-rw-r--r-- | src/ext_depends/d2sqlite3.meta | 2 | ||||
-rw-r--r-- | src/ext_depends/d2sqlite3/.github/workflows/main.yaml | 4 | ||||
-rw-r--r-- | src/ext_depends/d2sqlite3/source/d2sqlite3/database.d | 8 | ||||
-rw-r--r-- | src/ext_depends/d2sqlite3/source/d2sqlite3/statement.d | 12 |
7 files changed, 114 insertions, 60 deletions
diff --git a/src/ext_depends/D-YAML.meta b/src/ext_depends/D-YAML.meta index 22193e0..acad016 100644 --- a/src/ext_depends/D-YAML.meta +++ b/src/ext_depends/D-YAML.meta @@ -1,3 +1,3 @@ -D-YAML ddd418fa +D-YAML ff5ec445 https://github.com/dlang-community/D-YAML Boost Software License 1.0 (BSL-1.0) diff --git a/src/ext_depends/D-YAML/.travis.yml b/src/ext_depends/D-YAML/.travis.yml deleted file mode 100644 index 7e284b6..0000000 --- a/src/ext_depends/D-YAML/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -dist: xenial -sudo: false - -language: d -os: - - linux -d: - - dmd - - ldc - -branches: - only: - - master - -before_install: - - sudo apt-get install python3-pip python3-setuptools - - pip3 install 'meson==0.48.2' - -install: - - mkdir .ntmp && curl -L https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip -o .ntmp/ninja-linux.zip - - unzip .ntmp/ninja-linux.zip -d .ntmp - -before_script: - - export PATH=$PATH:$PWD/.ntmp - -script: - - meson build && ninja -j8 -C build - - ninja -j8 -C build test -v - - dub build - - "dub build dyaml:benchmark" - - "dub build dyaml:constructor" - - "dub build dyaml:getting-started" - - "dub build dyaml:representer" - - "dub build dyaml:resolver" - - "dub build dyaml:testsuite" - - "dub build dyaml:tojson" - - "dub build dyaml:yaml_gen" - - "dub build dyaml:yaml_stats" - - dub test --build=unittest-cov -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/src/ext_depends/D-YAML/source/dyaml/node.d b/src/ext_depends/D-YAML/source/dyaml/node.d index 24a62a4..5cb318e 100644 --- a/src/ext_depends/D-YAML/source/dyaml/node.d +++ b/src/ext_depends/D-YAML/source/dyaml/node.d @@ -498,17 +498,17 @@ struct Node * the value is out of range of requested type. */ inout(T) get(T, Flag!"stringConversion" stringConversion = Yes.stringConversion)() inout - if (allowed!(Unqual!T) || hasNodeConstructor!(Unqual!T)) + if (allowed!(Unqual!T) || hasNodeConstructor!(inout(Unqual!T)) || (!hasIndirections!(Unqual!T) && hasNodeConstructor!(Unqual!T))) { if(isType!(Unqual!T)){return getValue!T;} static if(!allowed!(Unqual!T)) { - static if (hasSimpleNodeConstructor!T) + static if (hasSimpleNodeConstructor!(Unqual!T) || hasSimpleNodeConstructor!(inout(Unqual!T))) { alias params = AliasSeq!(this); } - else static if (hasExpandedNodeConstructor!T) + else static if (hasExpandedNodeConstructor!(Unqual!T) || hasExpandedNodeConstructor!(inout(Unqual!T))) { alias params = AliasSeq!(this, tag_); } @@ -592,6 +592,35 @@ struct Node ". Expected: " ~ typeid(T).toString, startMark_); } } + /// ditto + T get(T)() const + if (hasIndirections!(Unqual!T) && hasNodeConstructor!(Unqual!T) && (!hasNodeConstructor!(inout(Unqual!T)))) + { + static if (hasSimpleNodeConstructor!T) + { + alias params = AliasSeq!(this); + } + else static if (hasExpandedNodeConstructor!T) + { + alias params = AliasSeq!(this, tag_); + } + else + { + static assert(0, "Unknown Node constructor?"); + } + static if (is(T == class)) + { + return new T(params); + } + else static if (is(T == struct)) + { + return T(params); + } + else + { + static assert(0, "Unhandled user type"); + } + } /// Automatic type conversion @safe unittest { @@ -2469,7 +2498,7 @@ template hasSimpleNodeConstructor(T) } else static if (is(T == class)) { - enum hasSimpleNodeConstructor = is(typeof(new inout T(Node.init))); + enum hasSimpleNodeConstructor = is(typeof(new T(Node.init))); } else enum hasSimpleNodeConstructor = false; } @@ -2481,8 +2510,74 @@ template hasExpandedNodeConstructor(T) } else static if (is(T == class)) { - enum hasExpandedNodeConstructor = is(typeof(new inout T(Node.init, ""))); + enum hasExpandedNodeConstructor = is(typeof(new T(Node.init, ""))); } else enum hasExpandedNodeConstructor = false; } enum castableToNode(T) = (is(T == struct) || is(T == class)) && is(typeof(T.opCast!Node()) : Node); + +@safe unittest +{ + import dyaml : Loader, Node; + + static struct Foo + { + string[] bars; + + this(const Node node) + { + foreach(value; node["bars"].sequence) + { + bars ~= value.as!string; + } + } + } + + Loader.fromString(`{ bars: ["a", "b"] }`) + .load + .as!(Foo); +} +@safe unittest +{ + import dyaml : Loader, Node; + import std : split, to; + + static class MyClass + { + int x, y, z; + + this(Node node) + { + auto parts = node.as!string().split(":"); + x = parts[0].to!int; + y = parts[1].to!int; + z = parts[2].to!int; + } + } + + auto loader = Loader.fromString(`"1:2:3"`); + Node node = loader.load(); + auto mc = node.get!MyClass; +} +@safe unittest +{ + import dyaml : Loader, Node; + import std : split, to; + + static class MyClass + { + int x, y, z; + + this(Node node) + { + auto parts = node.as!string().split(":"); + x = parts[0].to!int; + y = parts[1].to!int; + z = parts[2].to!int; + } + } + + auto loader = Loader.fromString(`"1:2:3"`); + const node = loader.load(); + auto mc = node.get!MyClass; +} diff --git a/src/ext_depends/d2sqlite3.meta b/src/ext_depends/d2sqlite3.meta index 2661c82..3c1e4b5 100644 --- a/src/ext_depends/d2sqlite3.meta +++ b/src/ext_depends/d2sqlite3.meta @@ -1,3 +1,3 @@ -d2sqlite3 052bc41c +d2sqlite3 f5bc20b8 https://github.com/dlang-community/d2sqlite3 Boost Software License 1.0 (BSL-1.0) diff --git a/src/ext_depends/d2sqlite3/.github/workflows/main.yaml b/src/ext_depends/d2sqlite3/.github/workflows/main.yaml index 28eaebe..f915693 100644 --- a/src/ext_depends/d2sqlite3/.github/workflows/main.yaml +++ b/src/ext_depends/d2sqlite3/.github/workflows/main.yaml @@ -58,12 +58,12 @@ jobs: dub --version # Build and run the tests - - name: '[POSIX] Build & test Agora' + - name: '[POSIX] Build & test' if: runner.os != 'Windows' #continue-on-error: matrix.dc == 'ldc-master' || matrix.dc == 'dmd-master' run: dub test -c ci - - name: '[Windows] Build & test Agora' + - name: '[Windows] Build & test' if: runner.os == 'Windows' #continue-on-error: matrix.dc == 'ldc-master' || matrix.dc == 'dmd-master' shell: cmd diff --git a/src/ext_depends/d2sqlite3/source/d2sqlite3/database.d b/src/ext_depends/d2sqlite3/source/d2sqlite3/database.d index 7aebe63..93a6509 100644 --- a/src/ext_depends/d2sqlite3/source/d2sqlite3/database.d +++ b/src/ext_depends/d2sqlite3/source/d2sqlite3/database.d @@ -1184,7 +1184,7 @@ version (_UnlockNotify) /// Unlocks the handler, state is one of SQLITE_LOCKED or SQLITE_OK void emit(int res) nothrow in { assert(res == SQLITE_LOCKED || res == SQLITE_OK); } - body + do { try { @@ -1208,7 +1208,7 @@ version (_UnlockNotify) /// Result after wait is finished @property int result() const out (result) { assert(result == SQLITE_OK || result == SQLITE_LOCKED); } - body { return res; } + do { return res; } } } else @@ -1238,7 +1238,7 @@ version (_UnlockNotify) /// Constructor this(Duration max = 1000.msecs) in { assert(max > Duration.zero); } - body + do { maxDuration = max; } @@ -1271,7 +1271,7 @@ version (_UnlockNotify) /// Result after wait is finished @property int result() const out (result) { assert(result == SQLITE_OK || result == SQLITE_LOCKED); } - body + do { return res; } diff --git a/src/ext_depends/d2sqlite3/source/d2sqlite3/statement.d b/src/ext_depends/d2sqlite3/source/d2sqlite3/statement.d index 14fe855..8cf6a38 100644 --- a/src/ext_depends/d2sqlite3/source/d2sqlite3/statement.d +++ b/src/ext_depends/d2sqlite3/source/d2sqlite3/statement.d @@ -162,7 +162,7 @@ public: { assert(index > 0 && index <= p.paramCount, "parameter index out of range"); } - body + do { assert(p.handle); @@ -239,7 +239,7 @@ public: { assert(name.length); } - body + do { assert(p.handle); auto index = sqlite3_bind_parameter_index(p.handle, name.toStringz); @@ -255,7 +255,7 @@ public: { assert(Args.length == this.parameterCount, "parameter count mismatch"); } - body + do { foreach (index, _; Args) bind(index + 1, args[index]); @@ -342,7 +342,7 @@ public: static if (__traits(compiles, obj.length)) assert(obj.length == this.parameterCount, "parameter count mismatch"); } - body + do { static if (__traits(compiles, { foreach (string k, ref v; obj) {} })) { @@ -377,7 +377,7 @@ public: { assert(index > 0 && index <= p.paramCount, "parameter index out of range"); } - body + do { assert(p.handle); return sqlite3_bind_parameter_name(p.handle, index).to!string; @@ -394,7 +394,7 @@ public: { assert(name.length); } - body + do { assert(p.handle); return sqlite3_bind_parameter_index(p.handle, name.toStringz); |