7 public class Introspect.El : Object
21 public class Gtk : Palete {
33 // various loader methods..
37 //this.comments = { };
41 public override void load () {
43 this.loadUsageFile(Builder4.Application.configDirectory() + "/resources/GtkUsage.txt");
48 public string doc(string what) {
49 var ns = what.split(".")[0];
50 var gir = Gir.factory(ns);
53 //return typeof(this.comments[ns][what]) == 'undefined' ? '' : this.comments[ns][what];
56 // does not handle implements...
57 public override GirObject? getClass(string ename)
60 var es = ename.split(".");
61 var gir = Gir.factory(es[0]);
63 return gir.classes.get(es[1]);
67 public override Gee.HashMap<string,GirObject> getPropertiesFor(string ename, string type)
69 //print("Loading for " + ename);
73 // if (typeof(this.proplist[ename]) != 'undefined') {
74 //print("using cache");
75 // return this.proplist[ename][type];
77 // use introspection to get lists..
79 var es = ename.split(".");
80 var gir = Gir.factory(es[0]);
82 var cls = gir.classes.get(es[1]);
84 var ret = new Gee.HashMap<string,GirObject>();
86 //throw new Error.INVALID_VALUE( "Could not find class: " + ename);
91 //cls.parseSignals(); // ?? needed for add handler..
92 //cls.parseMethods(); // ?? needed for ??..
93 //cls.parseConstructors(); // ?? needed for ??..
107 throw new Error.INVALID_VALUE( "getPropertiesFor called with: " + type);
108 //var ret = new Gee.HashMap<string,GirObject>();
114 //cls.overlayInterfaces(gir);
119 public string[] getInheritsFor(string ename)
123 var cls = Gir.factoryFqn(ename);
125 if (cls == null || cls.nodetype != "Class") {
126 print("getInheritsFor:could not find cls: %s\n", ename);
130 return cls.inheritsToStringArray();
135 public override void fillPack(JsRender.Node node,JsRender.Node parent)
138 string inherits = string.joinv(" ",
139 this.getInheritsFor (node.fqn())) + " ";
140 inherits += node.fqn() + " ";
141 //print ("fillPack:Inherits : %s\n", inherits);
142 // parent.fqn() method ( node.fqn()
143 var methods = this.getPropertiesFor (parent.fqn(), "methods");
145 var res = new Gee.HashMap<string,string>();
146 var map = methods.map_iterator();
149 var n = map.get_key();
150 //print ("fillPack:checking method %s\n", n);
152 var meth = map.get_value();
153 if (meth.paramset == null || meth.paramset.params.size < 1) {
154 print ("fillPack:c -- no params\n");
158 var fp = meth.paramset.params.get(0);
160 var type = Gir.fqtypeLookup(fp.type, meth.ns);
161 print ("fillPack:first param type is %s\n", type);
164 if (!inherits.contains(" " + type + " ")) {
169 var pack = meth.name;
170 for(var i =1; i < meth.paramset.params.size; i++) {
171 var ty = Gir.fqtypeLookup(meth.paramset.params.get(i).type, meth.ns);
172 pack += "," + Gir.guessDefaultValueForType(ty);
175 print ("fillPack:add pack: -- %s\n",pack );
177 res.set(meth.name, pack);
185 if (res.has_key("pack_start")) {
186 node.props.set("* pack", res.get("pack_start"));
189 if (res.has_key("add")) {
190 node.props.set("* pack", res.get("add"));
193 var riter = res.map_iterator();
194 while(riter.next()) {
195 node.props.set("* pack", riter.get_value());