The Squirrel interpreter. See http://www.squirrel-lang.org/
samples/classattributes.nut@0:97a4f8cc534c, 2014-12-16 (annotated)
- Committer:
- jhnwkmn
- Date:
- Tue Dec 16 10:20:34 2014 +0000
- Revision:
- 0:97a4f8cc534c
Initial import of Squirrel.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhnwkmn | 0:97a4f8cc534c | 1 | class Foo { |
jhnwkmn | 0:97a4f8cc534c | 2 | //constructor |
jhnwkmn | 0:97a4f8cc534c | 3 | constructor(a) |
jhnwkmn | 0:97a4f8cc534c | 4 | { |
jhnwkmn | 0:97a4f8cc534c | 5 | testy = ["stuff",1,2,3]; |
jhnwkmn | 0:97a4f8cc534c | 6 | } |
jhnwkmn | 0:97a4f8cc534c | 7 | //attributes of PrintTesty |
jhnwkmn | 0:97a4f8cc534c | 8 | </ test = "freakin attribute"/> |
jhnwkmn | 0:97a4f8cc534c | 9 | function PrintTesty() |
jhnwkmn | 0:97a4f8cc534c | 10 | { |
jhnwkmn | 0:97a4f8cc534c | 11 | foreach(i,val in testy) |
jhnwkmn | 0:97a4f8cc534c | 12 | { |
jhnwkmn | 0:97a4f8cc534c | 13 | ::print("idx = "+i+" = "+val+" \n"); |
jhnwkmn | 0:97a4f8cc534c | 14 | } |
jhnwkmn | 0:97a4f8cc534c | 15 | } |
jhnwkmn | 0:97a4f8cc534c | 16 | //attributes of testy |
jhnwkmn | 0:97a4f8cc534c | 17 | </ flippy = 10 , second = [1,2,3] /> |
jhnwkmn | 0:97a4f8cc534c | 18 | testy = null; |
jhnwkmn | 0:97a4f8cc534c | 19 | |
jhnwkmn | 0:97a4f8cc534c | 20 | } |
jhnwkmn | 0:97a4f8cc534c | 21 | |
jhnwkmn | 0:97a4f8cc534c | 22 | foreach(member,val in Foo) |
jhnwkmn | 0:97a4f8cc534c | 23 | { |
jhnwkmn | 0:97a4f8cc534c | 24 | ::print(member+"\n"); |
jhnwkmn | 0:97a4f8cc534c | 25 | local attr; |
jhnwkmn | 0:97a4f8cc534c | 26 | if((attr = Foo.getattributes(member)) != null) { |
jhnwkmn | 0:97a4f8cc534c | 27 | foreach(i,v in attr) |
jhnwkmn | 0:97a4f8cc534c | 28 | { |
jhnwkmn | 0:97a4f8cc534c | 29 | ::print("\t"+i+" = "+(typeof v)+"\n"); |
jhnwkmn | 0:97a4f8cc534c | 30 | } |
jhnwkmn | 0:97a4f8cc534c | 31 | } |
jhnwkmn | 0:97a4f8cc534c | 32 | else { |
jhnwkmn | 0:97a4f8cc534c | 33 | ::print("\t<no attributes>\n") |
jhnwkmn | 0:97a4f8cc534c | 34 | } |
jhnwkmn | 0:97a4f8cc534c | 35 | } |