1 //<script type="text/javascript">
7 * this.data = new BuildLists();
14 // see if we can build the insertion tree for gtk - using introspection
16 // it should build the tree of feasible insertions, then we will have to manually prune it..
19 // a) what the inherited types are
20 // b) what methods are available for each type, that include a reference to another type..
22 // let's start with types..
23 GIRepository = imports.gi.GIRepository;
24 GLib = imports.gi.GLib;
26 // we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
27 GIRepository.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
30 imports.searchPath.push('../gnome.introspection-doc-generator');
32 XObject = imports.XObject.XObject;
33 File = imports.File.File;
35 // Introspecion specific..
36 NameSpace = imports.Introspect.NameSpace.NameSpace;
40 function BuildLists () {
43 var ns_list = [ 'Gtk' ] ; //NameSpace.namespaces();
45 ns_list = ns_list.sort();
46 // let's try and load them, so we find out early what will fail.
47 print("loading library to make sure it works.");
51 ns_list.forEach(function(ns_name) {
52 var core = imports.gi[ns_name];
53 var ns = NameSpace.ns(ns_name); // fetch all the elements in namespace...
54 ns['objects'].forEach( function(n) {
55 var odata = NameSpace.factory('Class', ns_name, n);
56 classes[odata.alias] = odata;
59 ns['interfaces'].forEach( function(n) {
60 var odata =NameSpace.factory('Interface', ns_name, n);
61 classes[odata.alias] = odata;
66 print("Looping throught namespaces");
68 var implementations = {};
74 for (cls in classes) {
75 var odata = classes[cls];
78 implementations[odata.alias] = odata.titleType == 'Class' ? odata.childClasses : odata.implementedBy;
79 //print(JSON.stringify(odata.methods,null,4));
80 odata.methods.forEach(function(m) {
82 m.params.forEach(function(p) {
84 if (!p.type || typeof(classes[p.type]) == 'undefined') {
89 if (!p.type || typeof(classes[p.type]) == 'undefined') {
92 if (allchildren.indexOf(p.type) < 0) {
93 allchildren.push(p.type);
96 if (typeof(methods[cls]) == 'undefined') {
100 if (typeof(methods[cls][p.type]) == 'undefined') {
101 methods[cls][p.type] = [];
103 var fullname = m.memberOf + '.' + m.name;
104 if (allmethods.indexOf(fullname) < 0) {
105 allmethods.push(fullname);
108 if (methods[cls][p.type].indexOf(fullname) > -1) {
111 methods[cls][p.type].push(fullname);
118 //for(method in odata.methods) {
119 // print(method.name);
124 this.methods = methods;
125 this.allmethods = allmethods;
126 this.allchildren = allchildren;
128 this.implementations = implementations;
130 //print(JSON.stringify(methods,null,4));
131 //print(JSON.stringify(implementations,null,4));
142 // we now have a list of classes / methods that can be used..
143 // we now need a ui to flag stuff as "don't bother with"