JSDOC/Introspect/Class.js
[gnome.introspection-doc-generator] / JSDOC / Introspect / Class.js
1 //<script type="text/javascript">
2 //Gtk = imports.gi.Gtk;
3 GI      = imports.gi.GIRepository;
4 GLib    = imports.gi.GLib;
5 xml     = imports.libxml;
6 //GObject = imports.gi.GObject;
7 imports['Object.js'].load(Object);
8
9 console = imports['console.js'].console;
10
11
12
13 Introspect = imports['JSDOC/Introspect.js'].Introspect;
14 Base = imports['JSDOC/Introspect/Base.js'].Base;
15
16 XObject = imports.XObject.XObject;
17 console = imports.console.console;
18
19
20 NameSpace = imports.NameSpace.NameSpace;
21 Basic = imports.Basic.Basic;
22
23
24
25
26 /**
27  * Class
28  */
29
30
31
32
33 Class = XObject.define(
34     function(ns, name) {
35         Base.call(this, ns, name);
36         this.loadExtends();
37         this.loadImplements();
38         //console.log("CREATED(Class) " + this.alias);
39     },
40     Base, 
41     {
42         titleType : 'Class',
43         
44         loadExtends : function()
45         {
46             var bi = this.getBI();
47             
48             var pi = GI.object_info_get_parent(bi);
49             this.extendsClasses = [];
50             if (!pi) {
51                 return;
52             }
53             this.parent = Introspect.factory(
54                 'Class',
55                 GI.base_info_get_namespace(pi),
56                 GI.base_info_get_name(pi)
57             );
58             
59             this.extendsClasses = [ this.parent ];
60             
61             
62             this.parent.extendsClasses.map(function(p) {
63                 this.extendsClasses.push(p);
64             },this);
65             
66             
67             
68         },
69         loadImplements : function()
70         {
71             var bb = this.getBI();
72             this.implementInterfaces = [];
73             
74             var iflist = [];
75             for(var i =0; i < GI.object_info_get_n_interfaces(bb); i++) {
76                
77                 var prop = GI.object_info_get_interface(bb,i);
78                  
79                 
80                 var iface = Introspect.factory(
81                     'Interface', 
82                     GI.base_info_get_namespace(prop) , GI.base_info_get_name(prop)
83                 );
84                 
85                 
86                 if (iflist.indexOf(iface.alias) < 0) {
87                     //console.log("ADDING IFACE " + iface.alias);
88                     iflist.push(iface.alias);
89                     this.implementInterfaces.push(iface);
90                 }
91             }
92             // ask the first of the parents.. - which will have it loaded already
93             if (this.extendsClasses.length) {
94                 
95                 //this.extendsClasses[0].loadImplements();
96                 
97                 this.extendsClasses[0].implementInterfaces.map( function(si) {
98                     
99                     if (iflist.indexOf(si.alias) < 0) {
100                         //console.log("From extends ("+ si.alias + ") IFACE " + si.alias);
101                         iflist.push(si.alias);
102                         this.implementInterfaces.push(si);
103                     }
104                 },this);
105                 
106             }
107             //console.dump(iflist);
108             if (this.alias == 'Atk.NoOpObject') {
109             //    throw "exut";
110                }
111            // console.dump(this.implementInterfaces);
112         },
113         
114         
115         
116         
117         load : function()
118         {
119             if (this._loaded) {
120                 return; // already loaded..
121             }
122             
123             if (this.parent) { // load up parents first
124                 this.parent.load();
125             }
126             this.implementInterfaces.map(function(iface) {
127                 iface.load();
128             });
129             
130             
131             //console.log("load(Class) " + this.alias);
132             // my props..
133             var props = [];
134             this.genericBuildList('object', 'property', props, 'properties');
135             this.genericBuildList('object', 'field', props, 'properties');
136
137             this.genericExtends(  props, 'properties');    
138             this.genericImplements( props, 'properties');    
139            
140             var signals = [];
141             this.genericBuildList('object', 'signal', signals, 'signals');
142             this.genericExtends(  signals, 'signals');    
143             this.genericImplements( signals, 'signals');    
144             
145             
146             Introspect.references[this.alias] = Introspect.references[this.alias] || [];
147             if (this.alias == 'GObject.Object') {
148                 this._loaded = true;
149                 return;
150             }
151             
152             
153             this.constructors.push({
154                 name : '', // not really...
155                 params:   this.properties.length ?  [ { type :  'Object', be_null :  true,  name : 'properties' } ] : [],
156                 returns :  [],
157                 isConstructor : true,
158                 isStatic : false,
159                 memberOf : this.alias,
160                 exceptions : [],
161                 // in theory..
162                 desc : ''
163             });
164             
165             
166             var methods = [];
167             this.genericBuildList('object', 'method', methods, 'methods');
168             // dont inherit functiosn or consturctors...
169             
170             this.genericExtends(  methods, 'methods');    
171             this.genericImplements( methods, 'methods');    
172             
173             
174             
175             //console.log("loaded(Class) " + this.alias);
176               
177             this._loaded  = true;
178         }
179          
180          
181         
182         
183         
184 });