moved back to old acc
[vox.git] / test / syntax / classattr.vx
blob37045e2e5ea9e8f0183480d933ff1d5a8c618279
3 class Foo {
4     /* this would be a good place to place root information */
5     </
6         /* attributes are essentially tables with a fancy syntax, so
7            everything that is valid for tables is valid for attribs.
8            of course JSON syntax is supported as well, so you could write:
10                "Some Long Name": "Some Value"
12             as usual with Vox, semicolons are not needed as long as
13             the statement ends with an EOL.
14         */
15         Name = "Foo"
16         Description = "Does absolutely nothing"
17         Author = "beelzebub himself"
18         Readme = "http://localhost/vox/interactive.vml#p:syntax.attributes,w:Start"
19         Categories = ["tests", "tests/syntax", "examples"]
20     />
21     constructor();
23     </ Description = "Gives oldValue a newValue (hardy har)" />
24     function setSomeValue(newValue);
28 /* attributes can be iterated through by first
29    iterating through the members of a class
30    (as explained in classattr.vx, classes are 'special' tables),
31    and then, calling <classname>.getattributes(<membername>), which
32    will yield null if there are no attributes, or a table containing
33    key->value pairs.*/
34 foreach(member, val in Foo)
36     println("Member: %s (%s)".format(member.tostring(), val.tostring()))
37     Foo.getattributes(member).each(function(k, v)
38         println("    %s = %s".format(k.tostring(), v.tostring())))