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