From 1b41b8e2e7558b859da5c0b2167cdd712b383f78 Mon Sep 17 00:00:00 2001 From: Matt Soucy Date: Sun, 17 Jul 2016 18:38:46 -0400 Subject: [PATCH 1/4] Clean up deprecation warnings --- import/dproto/attributes.d | 4 +++- import/dproto/intermediate.d | 10 ++++------ import/dproto/parse.d | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/import/dproto/attributes.d b/import/dproto/attributes.d index 62140c5..7ecec71 100644 --- a/import/dproto/attributes.d +++ b/import/dproto/attributes.d @@ -76,8 +76,10 @@ template ProtoAccessors() void deserialize(R)(auto ref R __r) if(isProtoInputRange!R) { - import dproto.attributes : getAnnotation; import std.traits; + import dproto.attributes; + import painlesstraits : getAnnotation; + while(!__r.empty()) { auto __msgdata = __r.readVarint(); bool __matched = false; diff --git a/import/dproto/intermediate.d b/import/dproto/intermediate.d index 4eaaf08..cbbd3be 100644 --- a/import/dproto/intermediate.d +++ b/import/dproto/intermediate.d @@ -52,16 +52,14 @@ struct MessageType { } } else { sink.formattedWrite("static struct %s {\n", name); + + // Methods for serialization and deserialization. + sink("static import dproto.attributes;\n"); + sink(`mixin dproto.attributes.ProtoAccessors;`); } foreach(et; enumTypes) et.toString(sink, fmt); foreach(mt; messageTypes) mt.toString(sink, fmt); foreach(field; fields) field.toString(sink, fmt); - - // Methods for serialization and deserialization. - if(fmt.spec != 'p') { - sink(`static import dproto.attributes;`); - sink(`mixin dproto.attributes.ProtoAccessors;`); - } sink("}\n"); } diff --git a/import/dproto/parse.d b/import/dproto/parse.d index cd2ba03..7d18d5f 100644 --- a/import/dproto/parse.d +++ b/import/dproto/parse.d @@ -9,7 +9,7 @@ module dproto.parse; import dproto.exception; import dproto.intermediate; -static import dproto.serialize; +import dproto.serialize : isBuiltinType; import std.algorithm; import std.array; @@ -165,7 +165,7 @@ ProtoPackage ParseProtoSchema(const string name_, string data_) { return; } else { static if( hasMember!(Context, "fields") ) { - if(dproto.serialize.isBuiltinType(label)) { + if(isBuiltinType(label)) { context.fields ~= readField("optional", label); return; } From 5820abb39b00bf193b32c63688c88c0d9078f67d Mon Sep 17 00:00:00 2001 From: Matt Soucy Date: Sun, 17 Jul 2016 19:22:56 -0400 Subject: [PATCH 2/4] Remove incorrect deprecation message --- import/dproto/attributes.d | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/import/dproto/attributes.d b/import/dproto/attributes.d index 7ecec71..da9cf18 100644 --- a/import/dproto/attributes.d +++ b/import/dproto/attributes.d @@ -108,11 +108,12 @@ template ProtoAccessors() template ProtoFields(alias self) { - import std.typetuple : Filter, TypeTuple; + import std.typetuple : Filter, TypeTuple, Erase; alias Field(alias F) = Identity!(__traits(getMember, self, F)); alias HasProtoField(alias F) = hasValueAnnotation!(Field!F, ProtoField); - alias ProtoFields = Filter!(HasProtoField, TypeTuple!(__traits(allMembers, typeof(self)))); + alias AllMembers = TypeTuple!(__traits(allMembers, typeof(self))); + alias ProtoFields = Filter!(HasProtoField, Erase!("dproto", AllMembers)); } template protoDefault(T) { From 61bc587a9201aac75c3211e947357643388c4899 Mon Sep 17 00:00:00 2001 From: Matt Soucy Date: Sun, 17 Jul 2016 19:51:33 -0400 Subject: [PATCH 3/4] Use modern compilers in Travis --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6bca8ff..d1754f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,13 @@ sudo: false language: d d: - dmd - - dmd-2.067.0 + - dmd-2.071.1 - dmd-2.066.1 - gdc - gdc-4.9.3 - ldc - - ldc-0.15.1 + - ldc-1.0.0 + - ldc-0.17.1 before_install: - dub fetch doveralls script: From c9076d52623cce3272e047ed0a9fd28d1f69bd0e Mon Sep 17 00:00:00 2001 From: Matt Soucy Date: Sun, 17 Jul 2016 19:56:32 -0400 Subject: [PATCH 4/4] Moved examples to Dub Scripts --- examples/{simple_file => }/proto/person.proto | 0 examples/{simple/source/app.d => simple.d} | 19 ++++++++++--------- examples/simple/dub.json | 12 ------------ .../source/app.d => simple_file.d} | 14 ++++++++++++-- examples/simple_file/dub.json | 15 --------------- 5 files changed, 22 insertions(+), 38 deletions(-) rename examples/{simple_file => }/proto/person.proto (100%) rename examples/{simple/source/app.d => simple.d} (79%) mode change 100644 => 100755 delete mode 100644 examples/simple/dub.json rename examples/{simple_file/source/app.d => simple_file.d} (71%) mode change 100644 => 100755 delete mode 100644 examples/simple_file/dub.json diff --git a/examples/simple_file/proto/person.proto b/examples/proto/person.proto similarity index 100% rename from examples/simple_file/proto/person.proto rename to examples/proto/person.proto diff --git a/examples/simple/source/app.d b/examples/simple.d old mode 100644 new mode 100755 similarity index 79% rename from examples/simple/source/app.d rename to examples/simple.d index 533216e..d46d87f --- a/examples/simple/source/app.d +++ b/examples/simple.d @@ -1,10 +1,11 @@ -/******************************************************************************* - * An simple example for dproto - * - * Authors: Bjarne Leif Bruhn - * Date: Nov 24, 2013 - * Version: 1.0.0 - */ +#!/usr/bin/env dub +/+ dub.sdl: + name "dproto_simple" + description "A simple dproto example" + dependency "dproto" path=".." + author "Bjarne Leif Bruhn" + author "Matt Soucy" ++/ import std.stdio; import dproto.dproto; @@ -29,7 +30,7 @@ mixin ProtocolBufferFromString!" repeated PhoneNumber phone = 4; } "; - + int main() { @@ -37,7 +38,7 @@ int main() person.name = "John Doe"; person.id = 1234; person.email = "jdoe@example.com"; - + ubyte[] serializedObject = person.serialize(); Person person2 = Person(serializedObject); diff --git a/examples/simple/dub.json b/examples/simple/dub.json deleted file mode 100644 index e2875c1..0000000 --- a/examples/simple/dub.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "dproto_simple", - "description": "An simple dproto example", - "homepage": "https://github.com/msoucy/dproto", - "copyright": "Copyright © 2013, Bjarne Leif Bruhn", - "authors": [ - "Bjarne Leif Bruhn" - ], - "dependencies": { - "dproto": {"path": "../.."} - } -} diff --git a/examples/simple_file/source/app.d b/examples/simple_file.d old mode 100644 new mode 100755 similarity index 71% rename from examples/simple_file/source/app.d rename to examples/simple_file.d index 974eead..81a1cad --- a/examples/simple_file/source/app.d +++ b/examples/simple_file.d @@ -1,3 +1,13 @@ +#!/usr/bin/env dub +/+ dub.sdl: + name "dproto_simple" + description "A simple dproto example with proto file support" + dependency "dproto" path=".." + author "Bjarne Leif Bruhn" + author "Matt Soucy" + stringImportPaths "proto" ++/ + /******************************************************************************* * An simple example for dproto * @@ -10,7 +20,7 @@ import std.stdio; import dproto.dproto; mixin ProtocolBuffer!"person.proto"; - + int main() { @@ -18,7 +28,7 @@ int main() person.name = "John Doe"; person.id = 1234; person.email = "jdoe@example.com"; - + ubyte[] serializedObject = person.serialize(); Person person2 = Person(serializedObject); diff --git a/examples/simple_file/dub.json b/examples/simple_file/dub.json deleted file mode 100644 index e9d5e12..0000000 --- a/examples/simple_file/dub.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "dproto_simple_file", - "description": "An simple example with proto file import.", - "homepage": "https://github.com/msoucy/dproto", - "copyright": "Copyright © 2013, Bjarne Leif Bruhn", - "authors": [ - "Bjarne Leif Bruhn" - ], - "dependencies": { - "dproto": {"path": "../.."} - }, - "stringImportPaths": [ - "proto" - ] -}