Introspect/NameSpace.js
[gnome.introspection-doc-generator] / Introspect / NameSpace.js
index 3158093..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;
 
@@ -12,7 +12,6 @@ console = imports.console.console;
  
 
 NameSpace = {
-    
    
     references : { }, 
     
@@ -28,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.IRepository.get_default();
-        var pth = GI.IRepository.get_search_path ();
+        
+        var gi = GI.Repository.get_default();
+        var pth = GI.Repository.get_search_path();
         
         scanGir(pth[0]);
         ret.sort();
@@ -63,7 +53,7 @@ NameSpace = {
         
         
     ns:  function(ns) {
-        var gi = GI.IRepository.get_default();
+        var gi = GI.Repository.get_default();
         ret = {
             titleType: 'Namespace',
             ns: ns,
@@ -90,39 +80,41 @@ NameSpace = {
      
         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.IInfoType.OBJECT:
-                    ret.objects.push(GI.base_info_get_name(info));
-                    this.clsGatherInterfaces(ns , GI.base_info_get_name(info));
+                case  GI.InfoType.OBJECT:
+                    ret.objects.push(info.get_name());
+                    this.clsGatherInterfaces(ns , info.get_name());
                     continue;
-                 case  GI.IInfoType.INTERFACE:
-                    ret.interfaces.push(GI.base_info_get_name(info));
+                 case  GI.InfoType.INTERFACE:
+                    ret.interfaces.push(info.get_name());
                     continue;
-                case  GI.IInfoType.FUNCTION:
+                case  GI.InfoType.FUNCTION:
                     new imports.Method.Method(info, ret, 'functions', []);    
                     continue;
                 
-                case  GI.IInfoType.CALLBACK:
+                case  GI.InfoType.CALLBACK:
                    // new Introspect.Callback(info, ret, 'callbacks', []);
                     continue;
                 
-                case  GI.IInfoType.ENUM:
-                case  GI.IInfoType.FLAGS:
-                    ret.enums.push(GI.base_info_get_name(info));
+                case  GI.InfoType.ENUM:
+                case  GI.InfoType.FLAGS:
+                    ret.enums.push(info.get_name());
                     continue;
-                case  GI.IInfoType.STRUCT:
+                case  GI.InfoType.STRUCT:
                     if (GI.struct_info_is_gtype_struct (info)) {
                         continue;
                     }
 
-                    ret.structs.push(GI.base_info_get_name(info));
+                    ret.structs.push(info.get_name());
                     continue;
-                case  GI.IInfoType.UNION:
-                    ret.unions.push(GI.base_info_get_name(info));
+                case  GI.InfoType.UNION:
+                    ret.unions.push(info.get_name());
                     continue;
-                case  GI.IInfoType.CONSTANT:
+                case  GI.InfoType.CONSTANT:
                     new imports.Constant.Constant(info, ret, 'values', []);
                     
                     continue;
@@ -132,11 +124,11 @@ NameSpace = {
                     continue;
             }
         }
-        
+        print ("SCAN NAMESPACE ALL DONE");
                 
-        var gi = GI.IRepository.get_default();
-        var ver = gi.get_version(ns);
-        var pth = GI.IRepository.get_search_path ();
+        var gi = GI.Repository.get_default();
+        var ver = GI.Repository.get_version(gi,ns);
+        var pth = GI.Repository.get_search_path ();
         var gir_path = pth[0].replace(/lib\/girepository-1.0/, 'share\/gir-1.0');
        //console.log(fn);
         ret.gir_file = gir_path + '/'+ ns + '-' + ver + '.gir';
@@ -148,12 +140,13 @@ NameSpace = {
     },
  
     
-  
+
     // store all the interfaces, so we can show a list of them later...
     // called when you list the namespace
     clsGatherInterfaces : function(ns, cls)
     {
-        var gi = GI.IRepository.get_default();
+       // print("clsGatherInterfaces: " + ns + ", " + cls);
+        var gi = GI.Repository.get_default();
         var bb = gi.find_by_name(ns, cls);
         var fullname = ns+'.'+cls;
         this.ifaceList = this.ifaceList || { };
@@ -163,7 +156,7 @@ NameSpace = {
            
             var prop = GI.object_info_get_interface(bb,i);
            
-            var add =  GI.base_info_get_namespace(prop) +'.' + GI.base_info_get_name(prop);
+            var add =  prop.get_namespace() +'.' + prop.get_name();
             this.ifaceList[add] = this.ifaceList[add] || [];
             if (this.ifaceList[add].indexOf(fullname) < 0) {
                 this.ifaceList[add].push(fullname);
@@ -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];
         
@@ -197,7 +192,7 @@ NameSpace = {
         }
         
         console.log("LOAD DOCS: " + ns);
-        var gi = GI.IRepository.get_default();
+        var gi = GI.Repository.get_default();
         var ver = gi.get_version(ns);
         if (!ver) {
             this.comments[ns] = {};
@@ -255,7 +250,7 @@ NameSpace = {
             }
         }
         
-        var pth = GI.IRepository.get_search_path ();
+        var pth = GI.Repository.get_search_path ();
         
         
         var gir_path = pth[0].replace(/lib\/girepository-1.0/, 'share\/gir-1.0');
@@ -288,7 +283,7 @@ NameSpace = {
         return this.registry[ns +'.' + name];
     }
         
-});
+};