tools/build_gtk_tree.js
[app.Builder.js] / tools / build_gtk_tree.js
1 //<script type="text/javascript">
2
3 // see if we can build the insertion tree for gtk - using introspection
4
5 // it should build the tree of feasible insertions, then we will have to manually prune it..
6
7 // it needs to know
8 // a) what the inherited types are
9 // b) what methods are available for each type, that include a reference to another type..
10
11 // let's start with types.. 
12 GIRepository = imports.gi.GIRepository;
13 GLib        = imports.gi.GLib;
14
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');
17
18
19 imports.searchPath.push('../../gnome.introspection-doc-generator');
20
21 XObject     = imports.XObject.XObject;
22 File        = imports.File.File; 
23  
24 // Introspecion specific..
25 NameSpace   = imports.Introspect.NameSpace.NameSpace; 
26 Link        = imports.Introspect.Link.Link; 
27
28 var ns_list = [ 'Gtk' ] ; //NameSpace.namespaces();
29  
30 ns_list = ns_list.sort();
31 // let's try and load them, so we find out early what will fail.
32 print("loading library to make sure it works.");
33 ns_list.forEach(function(ns_name) {   
34     var  core = imports.gi[ns_name];
35     var ns = NameSpace.ns(ns_name); // fetch all the elements in namespace...
36     ns['objects'].forEach( function(n) {
37         NameSpace.factory('Class', ns_name, n);
38     }
39     ns['interfaces'].forEach( function(n) {
40         NameSpace.factory('Interface', ns_name, n);
41     }
42 });
43
44
45 print("Looping throught namespaces");
46 var ns_idx = [];
47 var implementations = {};
48 ns_list.forEach(function(ns_name) 
49 {
50     
51     //if (ns_idx.length) {         return ;/* do one - for testing */ } 
52     
53     var  core = imports.gi[ns_name];
54     var idx = { name: ns_name}; 
55     print("START:" + ns_name);
56    
57     var ns = NameSpace.ns(ns_name); // fetch all the elements in namespace...
58     // as a type => list of them..
59     
60    
61     
62     
63     
64     
65       
66        
67     ns['objects'].forEach( function(n) {
68         
69        print('NameSpace.factory(Class,'+ns_name+'.'+n+')');
70         var odata =   NameSpace.factory('Class', ns_name, n);
71         implementations[odata.alias] = odata.childClasses;
72         //print(JSON.stringify(odata.childClasses,null,4));
73     });
74     ns['interfaces'].forEach( function(n) {
75         
76         print('NameSpace.factory(Interface,'+ns_name+'.'+n+')');
77         var odata =   NameSpace.factory('Interface', ns_name, n);
78         implementations[odata.alias] = odata.implementedBy;
79         //print(JSON.stringify(odata.implementedBy,null,4));
80     });
81          // what we are interested in..
82         
83          
84     
85     
86 });
87 print(JSON.stringify(implementations,null,4));