reset to working status
[gnome.introspection-doc-generator] / Introspect / Class.js
diff --git a/Introspect/Class.js b/Introspect/Class.js
new file mode 100644 (file)
index 0000000..dba5f90
--- /dev/null
@@ -0,0 +1,176 @@
+//<script type="text/javascript">
+//Gtk = imports.gi.Gtk;
+GI      = imports.gi.GIRepository;
+GLib    = imports.gi.GLib;
+xml     = imports.libxml;
+//GObject = imports.gi.GObject;
+XObject = imports.XObject.XObject;
+console = imports.console.console;
+NameSpace = imports.NameSpace.NameSpace;
+
+Base = imports.Base.Base;
+
+
+
+
+/**
+ * Class
+ */
+
+
+
+
+Class = XObject.define(
+    function(ns, name) {
+        Base.call(this, ns, name);
+        this.loadExtends();
+        this.loadImplements();
+        //console.log("CREATED(Class) " + this.alias);
+    },
+    Base, 
+    {
+        titleType : 'Class',
+        
+        loadExtends : function()
+        {
+            var bi = this.getBI();
+            
+            var pi = GI.object_info_get_parent(bi);
+            this.extendsClasses = [];
+            if (!pi) {
+                return;
+            }
+            this.parent = NameSpace.factory(
+                'Class',
+                GI.base_info_get_namespace(pi),
+                GI.base_info_get_name(pi)
+            );
+            
+            this.extendsClasses = [ this.parent ];
+            
+            
+            this.parent.extendsClasses.map(function(p) {
+                this.extendsClasses.push(p);
+            },this);
+            
+            
+            
+        },
+        loadImplements : function()
+        {
+            var bb = this.getBI();
+            this.implementInterfaces = [];
+            
+            var iflist = [];
+            for(var i =0; i < GI.object_info_get_n_interfaces(bb); i++) {
+               
+                var prop = GI.object_info_get_interface(bb,i);
+                 
+                
+                var iface = NameSpace.factory(
+                    'Interface', 
+                    GI.base_info_get_namespace(prop) , GI.base_info_get_name(prop)
+                );
+                
+                
+                if (iflist.indexOf(iface.alias) < 0) {
+                    //console.log("ADDING IFACE " + iface.alias);
+                    iflist.push(iface.alias);
+                    this.implementInterfaces.push(iface);
+                }
+            }
+            // ask the first of the parents.. - which will have it loaded already
+            if (this.extendsClasses.length) {
+                
+                //this.extendsClasses[0].loadImplements();
+                
+                this.extendsClasses[0].implementInterfaces.map( function(si) {
+                    
+                    if (iflist.indexOf(si.alias) < 0) {
+                        //console.log("From extends ("+ si.alias + ") IFACE " + si.alias);
+                        iflist.push(si.alias);
+                        this.implementInterfaces.push(si);
+                    }
+                },this);
+                
+            }
+            //console.dump(iflist);
+            if (this.alias == 'Atk.NoOpObject') {
+            //    throw "exut";
+               }
+           // console.dump(this.implementInterfaces);
+        },
+        
+        
+        
+        
+        load : function()
+        {
+            if (this._loaded) {
+                return; // already loaded..
+            }
+            
+            if (this.parent) { // load up parents first
+                this.parent.load();
+            }
+            this.implementInterfaces.map(function(iface) {
+                iface.load();
+            });
+            
+            
+            //console.log("load(Class) " + this.alias);
+            // my props..
+            var props = [];
+            this.genericBuildList('object', 'property', props, 'properties');
+            this.genericBuildList('object', 'field', props, 'properties');
+
+            this.genericExtends(  props, 'properties');    
+            this.genericImplements( props, 'properties');    
+           
+            var signals = [];
+            this.genericBuildList('object', 'signal', signals, 'signals');
+            this.genericExtends(  signals, 'signals');    
+            this.genericImplements( signals, 'signals');    
+            
+            
+            NameSpace.references[this.alias] = NameSpace.references[this.alias] || [];
+            if (this.alias == 'GObject.Object') {
+                this._loaded = true;
+                return;
+            }
+            
+            
+            this.constructors.push({
+                name : '', // not really...
+                params:   this.properties.length ?  [ { type :  'Object', be_null :  true,  name : 'properties' } ] : [],
+                returns :  [],
+                isConstructor : true,
+                isStatic : false,
+                memberOf : this.alias,
+                exceptions : [],
+                // in theory..
+                desc : ''
+            });
+            
+            
+            var methods = [];
+            this.genericBuildList('object', 'method', methods, 'methods');
+            // dont inherit functiosn or consturctors...
+            
+            this.genericExtends(  methods, 'methods');    
+            this.genericImplements( methods, 'methods');    
+            
+            
+            
+            //console.log("loaded(Class) " + this.alias);
+              
+            this._loaded  = true;
+        }
+         
+         
+        
+        
+        
+});