import tango.io.Stdout; struct Attribute { char[] name_; char[] type_; } char[] implementAttrs( Attribute[] attributes ) { char[] result; foreach( a; attributes ) { result ~= a.type_ ~ " " ~ a.name_ ~ "_;\n" ~ "public " ~ a.type_ ~ " " ~ a.name_ ~ "() { return " ~ a.name_ ~ "_; }\n" ~ "public void " ~ a.name_ ~ "( " ~ a.type_ ~ " v ) { " ~ a.name_ ~ "_ = v; }\n"; } return result; } class MeetingPlace { typedef int Color; mixin( implementAttrs( [ Attribute( "remaining", "uint" ), Attribute( "creaturesInPlace", "uint" ), Attribute( "color", "Color" ) ] ) ); this( uint remaining ) { remaining_ = remaining; creaturesInPlace_ = 0; color_ = 0; } } void main() { auto meetingPlace = new MeetingPlace( 100 ); meetingPlace.creaturesInPlace = 30; meetingPlace.color = 3; assert( meetingPlace.remaining == 100 ); assert( meetingPlace.creaturesInPlace == 30 ); assert( meetingPlace.color == 3 ); } // vim:ts=2:sts=2:sw=2:expandtab:fenc=utf-8: