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][p.type]) == 'undefined') {
97 methods[cls][p.type] = [];
99 var fullname = m.memberOf + '.' + m.name;
100 if (allmethods.indexOf(fullname) < 0) {
101 allmethods.push(fullname);
104 if (methods[cls][p.type].indexOf(fullname) > -1) {
107 methods[cls][p.type].push(fullname);
114 //for(method in odata.methods) {
115 // print(method.name);
120 this.methods = methods;
121 this.allmethods = allmethods;
122 this.allchildren = allchildren;
124 this.implementations = implementations;
126 //print(JSON.stringify(methods,null,4));
127 //print(JSON.stringify(implementations,null,4));
132 // we now have a list of classes / methods that can be used..
133 // we now need a ui to flag stuff as "don't bother with"