Mercurial > projects > qtd
comparison d2/qtd/Attribute.d @ 350:31520b2c0b3c
Removed dependency on parent trait and stringof
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Thu, 20 May 2010 15:49:08 +0300 |
parents | 29ea6511681f |
children |
comparison
equal
deleted
inserted
replaced
349:925386e0e780 | 350:31520b2c0b3c |
---|---|
56 | 56 |
57 /** | 57 /** |
58 When mixed in an aggregate, converts a compile-time tuple of name-value pairs to | 58 When mixed in an aggregate, converts a compile-time tuple of name-value pairs to |
59 members of that aggregate. | 59 members of that aggregate. |
60 */ | 60 */ |
61 struct NameValueTupleToFields(A...) | 61 mixin template NameValueTupleToFields(A...) |
62 { | 62 { |
63 | 63 |
64 } | 64 } |
65 | 65 |
66 version (QtdUnittest) | 66 version (QtdUnittest) |
190 { | 190 { |
191 // BUG: needs to be generalized to accept any parent | 191 // BUG: needs to be generalized to accept any parent |
192 mixin Attribute!(typeof(this), attrClass, opts | AttributeOptions.inner, A); | 192 mixin Attribute!(typeof(this), attrClass, opts | AttributeOptions.inner, A); |
193 } | 193 } |
194 | 194 |
195 // ditto | 195 /// ditto |
196 mixin template InnerAttribute(string attrClass, A...) | 196 mixin template InnerAttribute(string attrClass, A...) |
197 { | 197 { |
198 // BUG: needs to be generalized to accept any parent | |
199 mixin InnerAttribute!(attrClass, AttributeOptions.none, A); | 198 mixin InnerAttribute!(attrClass, AttributeOptions.none, A); |
200 } | 199 } |
201 | 200 |
202 private mixin template AttributeImpl(alias symbol, string attrClass, AttributeOptions opts, size_t index, A...) | 201 private mixin template AttributeImpl(alias symbol, string attrClass, AttributeOptions opts, size_t index, A...) |
203 { | 202 { |
333 mixin InnerAttribute!("someAttribute", MetaVariantAttribute, "22", foo, 33); | 332 mixin InnerAttribute!("someAttribute", MetaVariantAttribute, "22", foo, 33); |
334 } | 333 } |
335 | 334 |
336 auto attr = cast(MetaVariantAttribute) meta!(C).attributes[0]; | 335 auto attr = cast(MetaVariantAttribute) meta!(C).attributes[0]; |
337 assert(attr.name == "someAttribute"); | 336 assert(attr.name == "someAttribute"); |
338 assert(qttr.length == 2); | 337 assert(attr.length == 2); |
339 assert(attr.values[0] == "22"); | 338 assert(attr.values[0] == "22"); |
340 assert(attr.values[1] == 33); | 339 assert(attr.values[1] == 33); |
341 } | 340 } |
342 } | 341 } |
343 | 342 |