generate gjs documentation, run under gjs
[gnome.introspection-doc-generator] / Introspect / Method.js
index 0b1ad48..7d1caa1 100644 (file)
@@ -1,13 +1,12 @@
 //<script type="text/javascript">
+const GI      = imports.gi.GIRepository;
 
-GI      = imports.gi.GIRepository;
 
+const XObject     = imports.XObject.XObject;
+const console     = imports.console.console;
 
-XObject     = imports.XObject.XObject;
-console     = imports.console.console;
-NameSpace   = imports.NameSpace.NameSpace;
-
-Basic        = imports.Basic.Basic;
+const NameSpace   = imports.Introspect.NameSpace.NameSpace;
+const Basic       = imports.Introspect.Basic.Basic;
 
   
 /**
@@ -17,7 +16,7 @@ Basic        = imports.Basic.Basic;
 
 
 
-Method = XObject.define(
+var Method = XObject.define(
     function(m, memberOf, saveto, keylist) {
         this.propertyType  = 'Method';
         
@@ -28,40 +27,31 @@ Method = XObject.define(
         if (n.match(/_(ref|unref)$/) || n.match(/^(ref|unref|weakref|weakunref)$/)) {
             return false; // skip these!
         }
-        
-        if (n == 'new') {
+
+        if(n == 'new') {
             n = 'c_new';
         }
 
-        
         var retval = [ { 
                 name : 0, 
                 type :  this.typeToName(GI.callable_info_get_return_type(m)),
                 desc : NameSpace.doc(memberOf.alias + '.' + n_original + '.return-value')
         } ];
-        
-        
-        
+
         var args = this.argsToArrays(m, retval);
-        
-        
+
         if ((n == 'c_new') && !args.length && memberOf.constructors.length) {
-            
+
             memberOf.constructors[0].doc = NameSpace.doc(memberOf.alias + '.' + n_original);
-            
+
             return false; // skip.
         }
-        
 
-        
-        
-        
         //console.log(GI.base_info_get_name(m));
-       // console.dump(GI.base_info_get_attribute(m, 'doc') );
-       
-         // this is a bit messy, as we probably loose the doc's on new..
-       
-        
+        // console.dump(GI.base_info_get_attribute(m, 'doc') );
+
+        // this is a bit messy, as we probably loose the doc's on new..
+
         XObject.extend(this, {
             name : n,
             params: args,
@@ -74,46 +64,38 @@ Method = XObject.define(
         });
         // add descriptions to the arguments..
         this.params.map(function(p) {
-            
-            
             p.desc = NameSpace.doc(memberOf.alias + '.' + n_original + '.' + p.name);
             //Seed.print(memberOf.alias + '.' + n_original + '.' + p.name + ':' +  p.desc);
-            
         });
-        
-        
-            // collect references...
+
+        // collect references...
         var addedto = [ memberOf.alias ]; // do not add to self...
-       
-         for(var i =0; i < args.length;i++) {
+
+        for(var i =0; i < args.length;i++) {
             var ty = args[i].type;
             if (typeof(ty) != 'string' || ty.indexOf('.') < 0) {
                 continue;
             }
+
             if (addedto.indexOf(ty) > -1) {
                 continue;
             }
-            
-            
-            
             NameSpace.references[ty] = NameSpace.references[ty] || [];
             NameSpace.references[ty].push(this);
             addedto.push(ty);
         }
-        
-        
-         // decide what to add to...
-         
+
+        // decide what to add to...
         if (this.isConstructor) {
-            
             if (this.name.match(/^new_/)) {
                 this.name = this.name.substring(4);
             }
-            
-            
             memberOf.constructors.push(this);
-            return;
+
+            //return;
+            return true;
         }
+
         // return values  = only applicable to non-constructors..
         for(var i =0; i < retval.length;i++) {
             var ty = retval[i].type;
@@ -123,28 +105,24 @@ Method = XObject.define(
             if (addedto.indexOf(ty) > -1) {
                 continue;
             }
-            
-            
-            
             NameSpace.references[ty] = NameSpace.references[ty] || [];
             NameSpace.references[ty].push(this);
             addedto.push(ty);
         }
-        
-        
+
         if (this.isStatic) {
-            
             memberOf.functions.push(this);
-            return;
+            //return;
+            return true;
         }
-            
-            
+
         memberOf.methods.push(this);
         keylist.push(this.name);
-            
-        
-            
+
+        return true;
     },
-    Basic, 
-    { }
+
+    Basic,
+
+    {}
 );
\ No newline at end of file