Intial import
[gnome.introspection-doc-generator] / JSDOC / Introspect / Base.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
13 Introspect = imports['JSDOC/Introspect.js'].Introspect;
14 Basic = imports['JSDOC/Introspect/Basic.js'].Basic;
15
16
17
18
19 /**
20  * Base  types methods/interfaces/structs/unions etc.
21  */
22
23
24
25
26
27 Base = function(ns, name) {
28     // fake should not happen?
29     
30     
31     if (typeof(name) == 'undefined') {
32         var ar = ns.split('.');
33         ns = ar[0];
34         name = ar[1];
35     }
36     this.ns = ns;
37     this.name = name;
38     this.alias = ns + '.' + name;
39     //console.log("CREATE(Base) " + this.alias);
40     this._loaded = false;
41     
42     
43     // reset all of these..
44     this.signals = [];
45     this.methods = [];
46     this.constructors = [];
47     this.functions= [];
48    
49     this.values = []; // for enum;g;
50     this.constants = [];
51     
52     this.properties = [];
53     this.implementInterfaces = []; // obect - which interface it implements.
54     this.implementedBy = []; // interface - which object uses it.
55     this.extendsClasses = []; // what it extends...
56     this.childClasses = []; // what 
57      this.desc = Introspect.doc(this.alias );
58     
59     
60 }
61 Roo.extend(Base, Basic, {
62     titleType: 'Unknown',
63     name :  '',
64     ns : '',
65    
66     signals : [],
67     methods : [],
68     constructors : [],
69     functions: [],
70    
71     values : [], // for enum
72     constants : [],
73     
74     properties : [],
75     implementInterfaces : [], // obect - which interface it implements.
76     implementedBy : [], // interface - which object uses it.
77     extendsClasses : [], // what it extends...
78     childClasses : [], // what 
79     
80     
81     
82     
83     getBI : function()  {
84         
85         var gi = GI.IRepository.get_default();
86         return gi.find_by_name(this.ns, this.name);
87     },
88      // on, getwhat, simple list (name), variable to add to.
89     genericBuildList : function( onwhat, type, keylist, saveto)
90     {
91         
92         //console.log(this.alias +" - ADDING :" + type);
93         //if (this[saveto].length) {
94         //    Seed.print( "EROROR = it's alreayd loaded why?");
95             //throw "oops";
96         //   }
97         var bb = this.getBI();
98         var _this = this;
99        //console.log("ADD " + type[0].toUpperCase() + type.substring(1));
100         var cls = Introspect[type[0].toUpperCase() + type.substring(1)]; // ucfirst.
101         if (!cls) {
102             console.log("COULD NOT FIND Introspect: " + type[0].toUpperCase() + type.substring(1));
103            }
104             
105         var plural = type + 's';
106         plural = plural == 'propertys' ? 'properties' : plural;
107         
108         
109         for(var i =0; i < GI[onwhat + '_info_get_n_' + plural ](bb); i++) {            
110             var add= new cls(GI[onwhat + '_info_get_' + type ](bb,i), this, saveto, keylist);
111             //console.log("CLS :" + this.alias + " EL: " + add.name);
112         }
113          
114         
115     },
116     // loop through and add stuff from extends..
117     genericExtends :  function(  keylist,  saveto)   
118     {
119         // do not overlay gobject props or methods etc.
120         
121         if (!this.extendsClasses.length) {
122             return;
123         }
124         if (this.extendsClasses[0].alias == 'GObject.Object') {
125             return;
126         }
127             
128         
129         var _this = this;
130         
131         this.extendsClasses[0].load();
132         Roo.each(this.extendsClasses[0][saveto], function(prop) {
133             if (keylist.indexOf(prop.name) < 0) {
134                 _this[saveto].push(prop);
135                 keylist.push(prop.name);
136             }
137         },this);
138         
139     },
140     // loop through and add stuff from implements..
141     genericImplements :  function(  keylist,  saveto)   {
142     
143         var _this = this;
144         Roo.each(this.implementInterfaces, function(iface) {
145             
146             iface.load();
147             
148             Roo.each(iface[saveto], function(prop) {
149                 if (keylist.indexOf(prop.name) < 0) {
150                     _this[saveto].push(prop);
151                     keylist.push(prop.name);
152                 }
153             },this);
154             
155         }, this);
156         
157     },
158             
159         
160     
161 });
162
163