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