Closed ColdenCullen closed 10 years ago
I'd be happy to write a unittest or two. I'll push them as soon as I can.
The issue I was having was with code like this:
enum Foo { Bar, Baz }
auto decereal = new Decerealizer( /* data */ );
auto foo = decereal.value!Foo;
auto foo = decereal.value!Foo;
throws an error, saying grain does not match any function template declaration. Adding my case for enums, the build succeeds.
Really? With which compiler? I just wrote this unit test and it passes without your pull request:
import unit_threaded;
import cerealed;
private enum MyEnum { Foo, Bar, Baz };
void testEnum() {
auto enc = new Cerealiser;
enc ~= MyEnum.Bar;
enc ~= MyEnum.Baz;
enc ~= MyEnum.Foo;
checkEqual(enc.bytes, [0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0]);
auto dec = new Decerealizer(enc.bytes);
checkEqual(dec.value!MyEnum, MyEnum.Bar);
checkEqual(dec.value!MyEnum, MyEnum.Baz);
checkEqual(dec.value!MyEnum, MyEnum.Foo);
}
I'm on DMD 2.064.2 on OSX.
A simpler solution, if it is just a platform issue, would be to add enum as an acceptable case to an existing implementation of grain.
Not a platform issue, just tried your test case and it fails to compile as you said. Merging it in. Thanks!
Thanks for the help resolving this!
Your commit broke things a bit (one test failed and my new test didn't even compile) but I just fixed it. Once again, thanks.
It'd be nice to have a test case to go along with it. What code doesn't compile as it is now, exactly?