88// 08 Sep 09 Brian Frank Rework fandoc -> example
99//
1010
11- using fwt
12-
1311**
1412** Working with Pod, Type, Slot, Field, Method, and Symbol
1513** reflection APIs.
@@ -42,14 +40,14 @@ class Reflection
4240 Void types()
4341 {
4442 echo("\n --- types ---" )
45- pod := Pod.find("fwt " )
46- t := pod.type("Button " )
43+ pod := Pod.find("graphics " )
44+ t := pod.type("Point " )
4745 show("foo" .typeof, "get the type of the an object" )
4846 show(pod.types, "list the types in myPod" )
49- show(pod.type("Button " ), "find a type in pod by simple name" )
47+ show(pod.type("Point " ), "find a type in pod by simple name" )
5048 show(pod.type("Foo" , false ), "returns null if type not found" )
51- show(Type .find("fwt::Label " ), "lookup a type by its qualified name" )
52- show(Type .find("fwt ::Foo" , false ), "returns null if type not found" )
49+ show(Type .find("graphics::Point " ), "lookup a type by its qualified name" )
50+ show(Type .find("graphics ::Foo" , false ), "returns null if type not found" )
5351 show(Int #, "type literal for sys::Int" )
5452 show(Int ? []#, "type literal for sys::Int?[]" )
5553 show(t.fits(Num#), "reflective is/instanceof operator" )
@@ -69,13 +67,13 @@ class Reflection
6967 Void slots()
7068 {
7169 echo("\n --- slots ---" )
72- t := Type .find("fwt::Widget " )
73- s := t.slot("onFocus " )
74- show(t.slot("relayout " ), "lookup the slot called xyz on someType" )
70+ t := Type .find("web::WebClient " )
71+ s := t.slot("cookies " )
72+ show(t.slot("cookies " ), "lookup the slot called xyz on someType" )
7573 show(t.slots, "list all the slots on someType" )
76- show(Slot .find("fwt::Widget.enabled " ), "looukp a slot by its qualified name" )
77- show(Slot .find("fwt::Widget .foo" , false ), "returns null if slot not found" )
78- show(Widget#enabled, "slot literal" )
74+ show(Slot .find("web::WebClient.cookies " ), "looukp a slot by its qualified name" )
75+ show(Slot .find("web::WebClient. .foo" , false ), "returns null if slot not found" )
76+ show(Str #replace, "slot literal" )
7977 show(#main, "slot literal (in enclosing class)" )
8078 show(s.qname, "qualified name" )
8179 show(s.name, "unqualified simple name" )
@@ -109,16 +107,16 @@ class Reflection
109107 Void fields()
110108 {
111109 echo("\n --- fields ---" )
112- t := Type .find("fwt::Label " )
110+ t := Type .find("web::WebClient " )
113111 obj := t.make
114- f := t.field("text " )
115- show(t.field("fg " ), "lookup the field called xyz on someType" )
112+ f := t.field("followRedirects " )
113+ show(t.field("cookies " ), "lookup the field called xyz on someType" )
116114 show(t.field("x" , false ), "returns null if field not found" )
117115 show(t.fields, "list all the fields on someType" )
118- show(Slot .findField("fwt::Label.text " ), "looukp a field by its qualified name" )
119- show(Slot .findField("fwt::Label .foo" , false ), "returns null if field not found" )
116+ show(Slot .findField("web::WebClient.cookies " ), "looukp a field by its qualified name" )
117+ show(Slot .findField("web::WebClient .foo" , false ), "returns null if field not found" )
120118 show(f.type, "type of field" )
121- f.set(obj, "hi" ) // set instance field
119+ f.set(obj, true ) // set instance field
122120 show(f.get(obj), "get instance field" )
123121 show(Float #pi.get, "get static field" )
124122 }
@@ -131,6 +129,3 @@ class Reflection
131129 }
132130}
133131
134-
135-
136-
0 commit comments