Intial import
[gnome.introspection-doc-generator] / JSDOC / Introspect / Method.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  * Methods, functiosn or consturctors
17  */
18
19
20
21
22 Method = function(m, memberOf, saveto, keylist) {
23     this.propertyType  = 'Method';
24     
25     var flags = GI.function_info_get_flags (m);
26     var n = GI.base_info_get_name(m);
27     var n_original = n + '';
28     // posibly add: sink, 
29     if (n.match(/_(ref|unref)$/) || n.match(/^(ref|unref|weakref|weakunref)$/)) {
30         return false; // skip these!
31     }
32     
33     if (n == 'new') {
34         n = 'c_new';
35     }
36
37     
38     var retval = [ { 
39             name : 0, 
40             type :  this.typeToName(GI.callable_info_get_return_type(m)),
41             desc : Introspect.doc(memberOf.alias + '.' + n_original + '.return-value')
42     } ];
43     
44     
45     
46     var args = this.argsToArrays(m, retval);
47     
48     
49     if ((n == 'c_new') && !args.length && memberOf.constructors.length) {
50         
51         memberOf.constructors[0].doc = Introspect.doc(memberOf.alias + '.' + n_original);
52         
53         return false; // skip.
54     }
55     
56
57     
58     
59     
60     //console.log(GI.base_info_get_name(m));
61    // console.dump(GI.base_info_get_attribute(m, 'doc') );
62    
63      // this is a bit messy, as we probably loose the doc's on new..
64    
65     
66     Roo.apply(this, {
67         name : n,
68         params: args,
69         returns :  retval,
70         isConstructor : flags & GI.IFunctionInfoFlags.IS_CONSTRUCTOR,
71         isStatic : !(flags & GI.IFunctionInfoFlags.IS_METHOD),
72         memberOf : memberOf.alias,
73         exceptions : [],
74         desc : Introspect.doc(memberOf.alias + '.' + n_original)
75     });
76     // add descriptions to the arguments..
77     Roo.each(this.params, function(p) {
78         
79         
80         p.desc = Introspect.doc(memberOf.alias + '.' + n_original + '.' + p.name);
81         //Seed.print(memberOf.alias + '.' + n_original + '.' + p.name + ':' +  p.desc);
82         
83     });
84     
85     
86         // collect references...
87     var addedto = [ memberOf.alias ]; // do not add to self...
88    
89      for(var i =0; i < args.length;i++) {
90         var ty = args[i].type;
91         if (typeof(ty) != 'string' || ty.indexOf('.') < 0) {
92             continue;
93         }
94         if (addedto.indexOf(ty) > -1) {
95             continue;
96         }
97         
98         
99         
100         Introspect.references[ty] = Introspect.references[ty] || [];
101         Introspect.references[ty].push(this);
102         addedto.push(ty);
103     }
104     
105     
106      // decide what to add to...
107      
108     if (this.isConstructor) {
109         
110         if (this.name.match(/^new_/)) {
111             this.name = this.name.substring(4);
112         }
113         
114         
115         memberOf.constructors.push(this);
116         return;
117     }
118     // return values  = only applicable to non-constructors..
119     for(var i =0; i < retval.length;i++) {
120         var ty = retval[i].type;
121         if (typeof(ty) != 'string' || ty.indexOf('.') < 0) {
122             continue;
123         }
124         if (addedto.indexOf(ty) > -1) {
125             continue;
126         }
127         
128         
129         
130         Introspect.references[ty] = Introspect.references[ty] || [];
131         Introspect.references[ty].push(this);
132         addedto.push(ty);
133     }
134     
135     
136     if (this.isStatic) {
137         
138         memberOf.functions.push(this);
139         return;
140     }
141         
142         
143     memberOf.methods.push(this);
144     keylist.push(this.name);
145         
146     
147         
148 }
149
150
151 Roo.extend(Method,Basic);