X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=Introspect%2FNameSpace.js;h=1a20fb70aa8595b1b47bb0a6932ce342e25d822d;hp=bb9590e24614f637859d183dc9c85c09f6b651dc;hb=HEAD;hpb=759a6789f27c5bbec919b2057a72e43c780110ea diff --git a/Introspect/NameSpace.js b/Introspect/NameSpace.js index bb9590e..1a20fb7 100644 --- a/Introspect/NameSpace.js +++ b/Introspect/NameSpace.js @@ -3,13 +3,31 @@ GI = imports.gi.GIRepository; GLib = imports.gi.GLib; xml = imports.libxml; - +File = imports.File.File; XObject = imports.XObject.XObject; console = imports.console.console; - +// BC/FC +if (!GI.Repository) { + GI.Repository = GI.IRepository; + GI.FunctionInfoFlags = GI.IFunctionInfoFlags ; + GI.InfoType = GI.IInfoType; + GI.TypeTag= GI.ITypeTag; + + GI.IBaseInfo.prototype.get_name = function(n) { + return GI.base_info_get_name(this, n); + } + GI.IBaseInfo.prototype.get_namespace = function(n) { + return GI.base_info_get_namespace(this, n); + } + GI.IBaseInfo.prototype.get_attribute = function( n) { + return GI.base_info_get_attribute(this, n); + } +} + + NameSpace = { @@ -27,31 +45,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 +96,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); - - var info_type = GI.base_info_get_type (info); + 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 ? GI.base_info_get_type(info) : info.get_type(); + // print("Type: " + info_type); switch(info_type) { case GI.InfoType.OBJECT: ret.objects.push(info.get_name()); @@ -131,7 +142,7 @@ NameSpace = { continue; } } - + //print ("SCAN NAMESPACES ALL DONE"); var gi = GI.Repository.get_default(); var ver = gi.get_version(ns); @@ -147,12 +158,12 @@ 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); + // print("clsGatherInterfaces: " + ns + ", " + cls); var gi = GI.Repository.get_default(); var bb = gi.find_by_name(ns, cls); var fullname = ns+'.'+cls; @@ -163,7 +174,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 +190,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];