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