More commits to sync working copy
[gnome.introspection-doc-generator] / JSDOC / Introspect / Basic.js
index 9a6a2fe..74b340d 100644 (file)
@@ -4,12 +4,10 @@ GI      = imports.gi.GIRepository;
 GLib    = imports.gi.GLib;
 xml     = imports.libxml;
 //GObject = imports.gi.GObject;
+imports['Object.js'].load(Object);
 
-console = imports['console.js'].console;
-JSDOC   = imports['JSDOC.js'].JSDOC;
-Roo     = imports['Roo.js'].Roo;
-
-
+console     = imports['console.js'].console;
+JSDOC       = imports['JSDOC.js'].JSDOC;
 Introspect = imports['JSDOC/Introspect.js'].Introspect;
 
 
@@ -19,132 +17,134 @@ Introspect = imports['JSDOC/Introspect.js'].Introspect;
  */
 
 
-Basic = function( ) {
-     // never called?
-}
-Roo.apply(Basic.prototype, {
-    
-    typeToName : function (type_info) {
-        var ty = GI.type_tag_to_string( GI.type_info_get_tag(type_info));
-        
-        if ((ty == 'void') && GI.type_info_is_pointer(type_info)) {
-            return 'void*'; // it's a fake string?!?!!? - slightly naughty...
-        }
-        if (ty == 'array') {
-            // array of what!?!?
-            var param_type = GI.type_info_get_param_type (type_info, 0);
-            var atype = GI.type_info_get_tag(param_type);
-            if (atype == GI.ITypeTag.UINT8) {
-                return 'utf8';
-            }
-            
-                        
-            return ty;
-        }
-        if (ty != 'interface') {
-            return ty;
-        }
-        var interface_info = GI.type_info_get_interface (type_info);   
-        var interface_type = GI.base_info_get_type (interface_info);
-        if (interface_type  == GI.IInfoType.CALLBACK) {
-            // callback.. 
-            var Callback = Introspect.Callback ;
-            var ret=  new Callback(interface_info, this, false, false);
-            ret.alias = GI.base_info_get_namespace(interface_info) + '.' + GI.base_info_get_name(interface_info);
-            return ret;
-             
-            
-        }
-
-        return  GI.base_info_get_namespace(interface_info) + '.' + GI.base_info_get_name(interface_info);
-        
+Basic = Object.define(
+    function( ) {
+         // never called?
     },
-    
-    directions : [ "in", "out"," inout"],
-    
-    argsToArrays : function(m,  returnArray) 
+    Object,
     {
         
-        var outIntoReturn = false;
-        if (returnArray && returnArray.length == 1 && returnArray[0].type == 'void') {
-            outIntoReturn = true;
-        }
+        typeToName : function (type_info) {
+            var ty = GI.type_tag_to_string( GI.type_info_get_tag(type_info));
+            
+            if ((ty == 'void') && GI.type_info_is_pointer(type_info)) {
+                return 'void*'; // it's a fake string?!?!!? - slightly naughty...
+            }
+            if (ty == 'array') {
+                // array of what!?!?
+                var param_type = GI.type_info_get_param_type (type_info, 0);
+                var atype = GI.type_info_get_tag(param_type);
+                if (atype == GI.ITypeTag.UINT8) {
+                    return 'utf8';
+                }
+                
+                            
+                return ty;
+            }
+            if (ty != 'interface') {
+                return ty;
+            }
+            var interface_info = GI.type_info_get_interface (type_info);       
+            var interface_type = GI.base_info_get_type (interface_info);
+            if (interface_type  == GI.IInfoType.CALLBACK) {
+                // callback.. 
+                var Callback = Introspect.Callback ;
+                var ret=  new Callback(interface_info, this, false, false);
+                ret.alias = GI.base_info_get_namespace(interface_info) + '.' + GI.base_info_get_name(interface_info);
+                return ret;
+                 
+                
+            }
+
+            return  GI.base_info_get_namespace(interface_info) + '.' + GI.base_info_get_name(interface_info);
+            
+        },
         
-        var outArg = {
-            name : 'out_values',
-            ns : '',
-            type : 'Object',
-            direction : 'out',
-            be_null :  true, // in theory..
-            desc : "Return Object, use an empty Object, and the properties will get set as follows",
-            properties : []
-        };
+        directions : [ "in", "out"," inout"],
         
-        var args = [];
-        var firstOut = -1;
-        for(var a_i  =0; a_i   < GI.callable_info_get_n_args(m); a_i++) {
-            var arg = GI.callable_info_get_arg(m, a_i);
+        argsToArrays : function(m,  returnArray) 
+        {
             
-            var direction = this.directions[GI.arg_info_get_direction(arg)];
+            var outIntoReturn = false;
+            if (returnArray && returnArray.length == 1 && returnArray[0].type == 'void') {
+                outIntoReturn = true;
+            }
             
-            var add = {
-                name : GI.base_info_get_name(arg),
-                ns : GI.base_info_get_namespace(arg),
-                type : this.typeToName(GI.arg_info_get_type(arg)),
-                direction : direction,
-                be_null :  GI.arg_info_may_be_null(arg) || GI.arg_info_is_optional(arg),
-                desc : GI.base_info_get_attribute(arg, 'doc') || ''
+            var outArg = {
+                name : 'out_values',
+                ns : '',
+                type : 'Object',
+                direction : 'out',
+                be_null :  true, // in theory..
+                desc : "Return Object, use an empty Object, and the properties will get set as follows",
+                properties : []
             };
             
-            
-            add.alias = add.ns + '.' + add.name;
-            
-            if (direction == 'out') {
-                firstOut = firstOut  > -1 ? firstOut : a_i;
-                if (outIntoReturn) {
-                    returnArray.push(add);
-                } else {
-                    outArg.properties.push(add);
+            var args = [];
+            var firstOut = -1;
+            for(var a_i  =0; a_i   < GI.callable_info_get_n_args(m); a_i++) {
+                var arg = GI.callable_info_get_arg(m, a_i);
+                
+                var direction = this.directions[GI.arg_info_get_direction(arg)];
+                
+                var add = {
+                    name : GI.base_info_get_name(arg),
+                    ns : GI.base_info_get_namespace(arg),
+                    type : this.typeToName(GI.arg_info_get_type(arg)),
+                    direction : direction,
+                    be_null :  GI.arg_info_may_be_null(arg) || GI.arg_info_is_optional(arg),
+                    desc : GI.base_info_get_attribute(arg, 'doc') || ''
+                };
+                
+                
+                add.alias = add.ns + '.' + add.name;
+                
+                if (direction == 'out') {
+                    firstOut = firstOut  > -1 ? firstOut : a_i;
+                    if (outIntoReturn) {
+                        returnArray.push(add);
+                    } else {
+                        outArg.properties.push(add);
+                    }
                 }
+                
+                
+                args.push(add);
             }
             
-            
-            args.push(add);
-        }
-        
-        // drop all the 'out args from the end of args..
-        if (returnArray) {
-                
-            while (true) {
-                if (!args.length) {
+            // drop all the 'out args from the end of args..
+            if (returnArray) {
+                    
+                while (true) {
+                    if (!args.length) {
+                        break;
+                    }
+                    var l = args.pop(); // drop!
+                    if (l.direction == 'out') {
+                        // got an out arg..
+                        continue;
+                    }
+                    args.push(l); // put it back in (it's not a out).
                     break;
+                    
                 }
-                var l = args.pop(); // drop!
-                if (l.direction == 'out') {
-                    // got an out arg..
-                    continue;
+            }
+            if (outArg.properties.length) {
+                // put the out arg in there...
+                if (firstOut >= args.length) {
+                    args.push(outArg);
+                } else {
+                    args[firstOut]  = outArg;
                 }
-                args.push(l); // put it back in (it's not a out).
-                break;
-                
             }
-        }
-        if (outArg.properties.length) {
-            // put the out arg in there...
-            if (firstOut >= args.length) {
-                args.push(outArg);
-            } else {
-                args[firstOut]  = outArg;
+            
+             
+            // remove void return....
+            
+            if (returnArray && returnArray.length > 1 && returnArray[0].type == 'void') {
+                returnArray.shift();
             }
+            
+            return args;
         }
-        
-         
-        // remove void return....
-        
-        if (returnArray && returnArray.length > 1 && returnArray[0].type == 'void') {
-            returnArray.shift();
-        }
-        
-        return args;
-    }
 });