1 //<script type="text/javascript">
3 // see if we can build the insertion tree for gtk - using introspection
5 // it should build the tree of feasible insertions, then we will have to manually prune it..
8 // a) what the inherited types are
9 // b) what methods are available for each type, that include a reference to another type..
11 // let's start with types..
12 GIRepository = imports.gi.GIRepository;
13 GLib = imports.gi.GLib;
15 // we add this in, as it appears to get lost sometimes if we set it using the ENV. variable in builder.sh
16 GIRepository.IRepository.prepend_search_path(GLib.get_home_dir() + '/.Builder/girepository-1.1');
19 imports.searchPath.push('../../gnome.introspection-doc-generator');
21 XObject = imports.XObject.XObject;
22 File = imports.File.File;
24 // Introspecion specific..
25 NameSpace = imports.Introspect.NameSpace.NameSpace;
26 Link = imports.Introspect.Link.Link;
30 function BuildLists () {
33 var ns_list = [ 'Gtk' ] ; //NameSpace.namespaces();
35 ns_list = ns_list.sort();
36 // let's try and load them, so we find out early what will fail.
37 print("loading library to make sure it works.");
41 ns_list.forEach(function(ns_name) {
42 var core = imports.gi[ns_name];
43 var ns = NameSpace.ns(ns_name); // fetch all the elements in namespace...
44 ns['objects'].forEach( function(n) {
45 var odata = NameSpace.factory('Class', ns_name, n);
46 classes[odata.alias] = odata;
49 ns['interfaces'].forEach( function(n) {
50 var odata =NameSpace.factory('Interface', ns_name, n);
51 classes[odata.alias] = odata;
56 print("Looping throught namespaces");
58 var implementations = {};
61 for (cls in classes) {
62 var odata = classes[cls];
65 implementations[odata.alias] = odata.titleType == 'Class' ? odata.childClasses : odata.implementedBy;
66 //print(JSON.stringify(odata.methods,null,4));
67 odata.methods.forEach(function(m) {
69 m.params.forEach(function(p) {
71 if (!p.type || typeof(classes[p.type]) == 'undefined') {
74 if (typeof(methods[cls][p.type]) == 'undefined') {
75 methods[cls][p.type] = [];
77 if (methods[cls][p.type].indexOf(m.name) > -1) {
80 methods[cls][p.type].push(m.name);
85 //for(method in odata.methods) {
86 // print(method.name);
91 this.methods = methods;
92 this.implementations = implementations;
93 //print(JSON.stringify(methods,null,4));
94 //print(JSON.stringify(implementations,null,4));
99 // we now have a list of classes / methods that can be used..
100 // we now need a ui to flag stuff as "don't bother with"