Introspect/NameSpace.js
[gnome.introspection-doc-generator] / Introspect / NameSpace.js
index b3d015d..65a6dd9 100644 (file)
@@ -3,7 +3,7 @@
 GI      = imports.gi.GIRepository;
 GLib    = imports.gi.GLib;
 xml     = imports.libxml;
-
+File    = imports.File.File;
 
 XObject = imports.XObject.XObject;
 
@@ -27,31 +27,22 @@ NameSpace = {
             if (!GLib.file_test(dir, GLib.FileTest.EXISTS)) {
                 return;
             }
-            var gdir = GLib.dir_open(dir,0);
-            
-            while (true) {
-                
-                var fn = gdir.read_name ? gdir.read_name () : GLib.dir_read_name(gdir);
-           //      console.log('trying ' +  fn);
-                if (!fn) {
-                    gdir.close ? gdir.close() : GLib.dir_close(gdir);
-                    return;;
-                }
-                if (!fn.match(/.typelib$/)) {
-                    continue;
+            File.list(dir).forEach(function(fn) 
+            {
+                if (!fn.match(/\.typelib$/)) {
+                    return;
                 }
                 var par = fn.split('-').shift();
                  //console.log('trying ' +  par);
                 if (ret.indexOf(par) > -1) {
-                     continue;
+                     return;
                 }
                 ret.push(par);
-                
-                
-            } 
+            }); 
         }
+        
         var gi = GI.Repository.get_default();
-        var pth = GI.Repository.get_search_path ();
+        var pth = GI.Repository.get_search_path();
         
         scanGir(pth[0]);
         ret.sort();
@@ -87,10 +78,12 @@ NameSpace = {
             interfaces: [],
         };
      
-        for (var i=0; i <  GI.Repository.get_n_infos (gi,ns); i++ ) {
-            var info = GI.Repository.get_info (gi,ns, i);
-            
+        for (var i=0; i <  gi.get_n_infos (ns); i++ ) {
+            var info = gi.get_info (ns, i);
+           // print("NAME: " + info.get_name());
+            //continue;
             var info_type = GI.base_info_get_type (info);
+           // print("Type: " + info_type);
             switch(info_type) {
                 case  GI.InfoType.OBJECT:
                     ret.objects.push(info.get_name());
@@ -131,7 +124,7 @@ NameSpace = {
                     continue;
             }
         }
-        
+        print ("SCAN NAMESPACE ALL DONE");
                 
         var gi = GI.Repository.get_default();
         var ver = GI.Repository.get_version(gi,ns);
@@ -147,14 +140,14 @@ NameSpace = {
     },
  
     
-  
+
     // store all the interfaces, so we can show a list of them later...
     // called when you list the namespace
     clsGatherInterfaces : function(ns, cls)
     {
        // print("clsGatherInterfaces: " + ns + ", " + cls);
         var gi = GI.Repository.get_default();
-        var bb = GI.Repository.find_by_name(gi,ns, cls);
+        var bb = gi.find_by_name(ns, cls);
         var fullname = ns+'.'+cls;
         this.ifaceList = this.ifaceList || { };
          
@@ -179,7 +172,9 @@ NameSpace = {
         
    
     doc : function(what) {
+        print ("DOC: + " +what);
         var ns = what.split('.').shift();
+        return '';
         this.commentLoad(ns);
         return typeof(this.comments[ns][what]) == 'undefined' ?  '' : this.comments[ns][what];
         
@@ -198,7 +193,7 @@ NameSpace = {
         
         console.log("LOAD DOCS: " + ns);
         var gi = GI.Repository.get_default();
-        var ver = GI.Repository.get_version(gi,ns);
+        var ver = gi.get_version(ns);
         if (!ver) {
             this.comments[ns] = {};
             return;