~otheb/bare

2e14339b677d15c6b73683942084f67917f1ee06 — Olie Ayre 3 months ago 46c2422 master
Support enums
1 files changed, 6 insertions(+), 1 deletions(-)

M bare.d
M bare.d => bare.d +6 -1
@@ 76,7 76,12 @@ ubyte[] writeb( string v ) { return wruint( v.length ) ~ cast(ubyte[])v ; }
void readb(T)( ref ubyte[] data ) if ( is( T == void ) ) { return ; }
// no write as it is useless

// NOTE: use *uint methods for enums
T readb(T)( ref ubyte[] data ) if ( is( T == enum ) ) {
	return cast(T)data.rduint ;
}
ubyte[] writeb(T)( T v ) if ( is( T == enum ) ) {
	return wruint( cast(ulong)v ) ;
}

// NOTE: data and data<length> use array aggregate methods