msoucy / dproto

D Protocol Buffer mixins to create structures at compile time
Boost Software License 1.0
37 stars 16 forks source link

Add support for syntax statement #94

Closed WebDrake closed 8 years ago

WebDrake commented 8 years ago

This enables support for the syntax statement described in the proto2 and proto3 spec: https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#syntax https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#syntax

ProtoPackage has been extended with a new syntax field to store the new information now read by ParseProtoSchema.

No effort has been made to do anything other than read the statement; future uses of the syntax information have been left for future work.

Fixes msoucy/dproto#92.

coveralls commented 8 years ago

Coverage Status

Changes Unknown when pulling cf6558f21717784f4fecda4518e587ca7d863c96 on WebDrake:syntax into \ on msoucy:master**.

msoucy commented 8 years ago

Whoops. I had something extremely similar to this, on a local branch... but I like your error messages and tests better.

WebDrake commented 8 years ago

One question about the error messages -- when I tried to verify they were working correctly, I got some rather weird compiler output. For example if I tried

mixin ProtocolBufferFromString!syntaxNoEquals;

(... i.e. the first of the incorrect cases in the unittests), I got as compiler output:

/usr/include/d/std/exception.d(535): Error: uncaught CTFE exception object.Throwable("")
import/dproto/dproto.d(38):        called from here: ParseProtoSchema("<none>", "\x0a        syntax \"proto2\";\x0a    ")
import/dproto/dproto.d(38): Error: argument to mixin must be a string, not (ParseProtoSchema("<none>", "\x0a        syntax \"proto2\";\x0a    ").toD()) of type string
import/dproto/unittests.d(916): Error: mixin dproto.unittests.__unittestL889_44.ProtocolBufferFromString!"\x0a        syntax \"proto2\";\x0a    " error instantiating
ldc2 failed with exit code 1.

... which was not the nice error message I'd tried to write. Note, I'm using ldc 0.17.1 to build, on Ubuntu 16.04.

I meant to raise this after pushing the patch, but you were quicker than I expected with the merge button :-)

msoucy commented 8 years ago

Hah, sorry. Itchy trigger finger I guess.

I have a local commit that adds an error message in that particular spot, so it should fix the issue.