From d988d3b22deec23eaebaab69086359225bf0b314 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 2 Dec 2010 17:05:15 +0800 Subject: [PATCH] tools/build_gtk_tree.js --- tools/build_gtk_tree.js | 110 ++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 50 deletions(-) diff --git a/tools/build_gtk_tree.js b/tools/build_gtk_tree.js index 90a7a408d..23b6c0567 100644 --- a/tools/build_gtk_tree.js +++ b/tools/build_gtk_tree.js @@ -25,66 +25,76 @@ File = imports.File.File; NameSpace = imports.Introspect.NameSpace.NameSpace; Link = imports.Introspect.Link.Link; -var ns_list = [ 'Gtk' ] ; //NameSpace.namespaces(); + + +function BuildLists () { -ns_list = ns_list.sort(); -// let's try and load them, so we find out early what will fail. -print("loading library to make sure it works."); - -var classes = {}; - -ns_list.forEach(function(ns_name) { - var core = imports.gi[ns_name]; - var ns = NameSpace.ns(ns_name); // fetch all the elements in namespace... - ns['objects'].forEach( function(n) { - var odata = NameSpace.factory('Class', ns_name, n); - classes[odata.alias] = odata; - - }); - ns['interfaces'].forEach( function(n) { - var odata =NameSpace.factory('Interface', ns_name, n); - classes[odata.alias] = odata; + + var ns_list = [ 'Gtk' ] ; //NameSpace.namespaces(); + + ns_list = ns_list.sort(); + // let's try and load them, so we find out early what will fail. + print("loading library to make sure it works."); + + var classes = {}; + + ns_list.forEach(function(ns_name) { + var core = imports.gi[ns_name]; + var ns = NameSpace.ns(ns_name); // fetch all the elements in namespace... + ns['objects'].forEach( function(n) { + var odata = NameSpace.factory('Class', ns_name, n); + classes[odata.alias] = odata; + + }); + ns['interfaces'].forEach( function(n) { + var odata =NameSpace.factory('Interface', ns_name, n); + classes[odata.alias] = odata; + }); }); -}); -print("Looping throught namespaces"); -var ns_idx = []; -var implementations = {}; -var methods = {} - -for (cls in classes) { - var odata = classes[cls]; - methods[cls] = {} + print("Looping throught namespaces"); + var ns_idx = []; + var implementations = {}; + var methods = {} - implementations[odata.alias] = odata.titleType == 'Class' ? odata.childClasses : odata.implementedBy; - //print(JSON.stringify(odata.methods,null,4)); - odata.methods.forEach(function(m) { - - m.params.forEach(function(p) { - - if (!p.type || typeof(classes[p.type]) == 'undefined') { - return; - } - if (typeof(methods[cls][p.type]) == 'undefined') { - methods[cls][p.type] = []; - } - if (methods[cls][p.type].indexOf(m.name) > -1) { - return; - } - methods[cls][p.type].push(m.name); + for (cls in classes) { + var odata = classes[cls]; + methods[cls] = {} + + implementations[odata.alias] = odata.titleType == 'Class' ? odata.childClasses : odata.implementedBy; + //print(JSON.stringify(odata.methods,null,4)); + odata.methods.forEach(function(m) { + + m.params.forEach(function(p) { + + if (!p.type || typeof(classes[p.type]) == 'undefined') { + return; + } + if (typeof(methods[cls][p.type]) == 'undefined') { + methods[cls][p.type] = []; + } + if (methods[cls][p.type].indexOf(m.name) > -1) { + return; + } + methods[cls][p.type].push(m.name); + + }); }); + //for(method in odata.methods) { + // print(method.name); + //} - }); - //for(method in odata.methods) { - // print(method.name); - //} - + + } + this.methods = methods; + this.implementations = implementations; + //print(JSON.stringify(methods,null,4)); + //print(JSON.stringify(implementations,null,4)); } -print(JSON.stringify(methods,null,4)); -print(JSON.stringify(implementations,null,4)); + // we now have a list of classes / methods that can be used.. // we now need a ui to flag stuff as "don't bother with" -- 2.39.2