45 """ |
50 """ |
46 def __init__(self, module, name, file, lineno): |
51 def __init__(self, module, name, file, lineno): |
47 """ |
52 """ |
48 Constructor |
53 Constructor |
49 |
54 |
50 @param module name of the module containing this class |
55 @param module name of the module containing this object |
51 @param name name of this class |
56 @type str |
|
57 @param name name of this object |
|
58 @type str |
52 @param file filename containing this object |
59 @param file filename containing this object |
53 @param lineno linenumber of the class definition |
60 @type str |
|
61 @param lineno linenumber of the object definition |
|
62 @type int |
54 """ |
63 """ |
55 _ClbrBase.__init__(self, module, name, file, lineno) |
64 _ClbrBase.__init__(self, module, name, file, lineno) |
56 self.methods = {} |
65 self.methods = {} |
57 self.attributes = {} |
66 self.attributes = {} |
58 self.classes = {} |
67 self.classes = {} |
60 |
69 |
61 def _addmethod(self, name, function): |
70 def _addmethod(self, name, function): |
62 """ |
71 """ |
63 Protected method to add information about a method. |
72 Protected method to add information about a method. |
64 |
73 |
65 @param name name of method to be added (string) |
74 @param name name of method to be added |
|
75 @type str |
66 @param function Function object to be added |
76 @param function Function object to be added |
|
77 @type Function |
67 """ |
78 """ |
68 self.methods[name] = function |
79 self.methods[name] = function |
69 |
80 |
70 def _getmethod(self, name): |
81 def _getmethod(self, name): |
71 """ |
82 """ |
72 Protected method to retrieve a method by name. |
83 Protected method to retrieve a method by name. |
73 |
84 |
74 @param name name of the method (string) |
85 @param name name of the method (string) |
75 @return the named method or None |
86 @type str |
|
87 @return the named method |
|
88 @rtype Function or None |
76 """ |
89 """ |
77 try: |
90 try: |
78 return self.methods[name] |
91 return self.methods[name] |
79 except KeyError: |
92 except KeyError: |
80 return None |
93 return None |
81 |
94 |
82 def _addglobal(self, attr): |
95 def _addglobal(self, attr): |
83 """ |
96 """ |
84 Protected method to add information about global variables. |
97 Protected method to add information about global variables. |
85 |
98 |
86 @param attr Attribute object to be added (Attribute) |
99 @param attr Attribute object to be added |
|
100 @type Attribute |
87 """ |
101 """ |
88 if attr.name not in self.globals: |
102 if attr.name not in self.globals: |
89 self.globals[attr.name] = attr |
103 self.globals[attr.name] = attr |
90 else: |
104 else: |
91 self.globals[attr.name].addAssignment(attr.lineno) |
105 self.globals[attr.name].addAssignment(attr.lineno) |
92 |
106 |
93 def _getglobal(self, name): |
107 def _getglobal(self, name): |
94 """ |
108 """ |
95 Protected method to retrieve a global variable by name. |
109 Protected method to retrieve a global variable by name. |
96 |
110 |
97 @param name name of the global variable (string) |
111 @param name name of the global variable |
98 @return the named global variable or None |
112 @type str |
|
113 @return the named global variable |
|
114 @rtype Attribute or None |
99 """ |
115 """ |
100 try: |
116 try: |
101 return self.globals[name] |
117 return self.globals[name] |
102 except KeyError: |
118 except KeyError: |
103 return None |
119 return None |
104 |
120 |
105 def _addattribute(self, attr): |
121 def _addattribute(self, attr): |
106 """ |
122 """ |
107 Protected method to add information about attributes. |
123 Protected method to add information about attributes. |
108 |
124 |
109 @param attr Attribute object to be added (Attribute) |
125 @param attr Attribute object to be added |
|
126 @type Attribute |
110 """ |
127 """ |
111 if attr.name not in self.attributes: |
128 if attr.name not in self.attributes: |
112 self.attributes[attr.name] = attr |
129 self.attributes[attr.name] = attr |
113 else: |
130 else: |
114 self.attributes[attr.name].addAssignment(attr.lineno) |
131 self.attributes[attr.name].addAssignment(attr.lineno) |
115 |
132 |
116 def _getattribute(self, name): |
133 def _getattribute(self, name): |
117 """ |
134 """ |
118 Protected method to retrieve an attribute by name. |
135 Protected method to retrieve an attribute by name. |
119 |
136 |
120 @param name name of the attribute (string) |
137 @param name name of the attribute |
121 @return the named attribute or None |
138 @type str |
|
139 @return the named attribute |
|
140 @rtype Attribute or None |
122 """ |
141 """ |
123 try: |
142 try: |
124 return self.attributes[name] |
143 return self.attributes[name] |
125 except KeyError: |
144 except KeyError: |
126 return None |
145 return None |
141 """ |
162 """ |
142 def isPrivate(self): |
163 def isPrivate(self): |
143 """ |
164 """ |
144 Public method to check, if the visibility is Private. |
165 Public method to check, if the visibility is Private. |
145 |
166 |
146 @return flag indicating Private visibility (boolean) |
167 @return flag indicating Private visibility |
|
168 @rtype bool |
147 """ |
169 """ |
148 return self.visibility == 0 |
170 return self.visibility == 0 |
149 |
171 |
150 def isProtected(self): |
172 def isProtected(self): |
151 """ |
173 """ |
152 Public method to check, if the visibility is Protected. |
174 Public method to check, if the visibility is Protected. |
153 |
175 |
154 @return flag indicating Protected visibility (boolean) |
176 @return flag indicating Protected visibility |
|
177 @rtype bool |
155 """ |
178 """ |
156 return self.visibility == 1 |
179 return self.visibility == 1 |
157 |
180 |
158 def isPublic(self): |
181 def isPublic(self): |
159 """ |
182 """ |
160 Public method to check, if the visibility is Public. |
183 Public method to check, if the visibility is Public. |
161 |
184 |
162 @return flag indicating Public visibility (boolean) |
185 @return flag indicating Public visibility |
|
186 @rtype bool |
163 """ |
187 """ |
164 return self.visibility == 2 |
188 return self.visibility == 2 |
165 |
189 |
166 def setPrivate(self): |
190 def setPrivate(self): |
167 """ |
191 """ |
188 """ |
212 """ |
189 def __init__(self, module, name, file, lineno): |
213 def __init__(self, module, name, file, lineno): |
190 """ |
214 """ |
191 Constructor |
215 Constructor |
192 |
216 |
193 @param module name of the module containing this class |
217 @param module name of the module containing this attribute |
194 @param name name of this class |
218 @type str |
|
219 @param name name of this attribute |
|
220 @type str |
195 @param file filename containing this attribute |
221 @param file filename containing this attribute |
196 @param lineno linenumber of the class definition |
222 @type str |
|
223 @param lineno line number of the attribute definition |
|
224 @type int |
197 """ |
225 """ |
198 _ClbrBase.__init__(self, module, name, file, lineno) |
226 _ClbrBase.__init__(self, module, name, file, lineno) |
199 |
227 |
200 self.linenos = [lineno] |
228 self.linenos = [lineno] |
201 |
229 |
202 def addAssignment(self, lineno): |
230 def addAssignment(self, lineno): |
203 """ |
231 """ |
204 Public method to add another assignment line number. |
232 Public method to add another assignment line number. |
205 |
233 |
206 @param lineno linenumber of the additional attribute assignment |
234 @param lineno line number of the additional attribute assignment |
207 (integer) |
235 @type int |
208 """ |
236 """ |
209 if lineno not in self.linenos: |
237 if lineno not in self.linenos: |
210 self.linenos.append(lineno) |
238 self.linenos.append(lineno) |
211 |
239 |
212 |
240 |
217 def __init__(self, module, name, superClasses, file, lineno): |
245 def __init__(self, module, name, superClasses, file, lineno): |
218 """ |
246 """ |
219 Constructor |
247 Constructor |
220 |
248 |
221 @param module name of the module containing this class |
249 @param module name of the module containing this class |
|
250 @type str |
222 @param name name of this class |
251 @param name name of this class |
|
252 @type str |
223 @param superClasses list of class names this class is inherited from |
253 @param superClasses list of class names this class is inherited from |
|
254 @type list of str |
224 @param file filename containing this class |
255 @param file filename containing this class |
225 @param lineno linenumber of the class definition |
256 @type str |
|
257 @param lineno line number of the class definition |
|
258 @type int |
226 """ |
259 """ |
227 ClbrBase.__init__(self, module, name, file, lineno) |
260 ClbrBase.__init__(self, module, name, file, lineno) |
228 if superClasses is None: |
261 if superClasses is None: |
229 superClasses = [] |
262 superClasses = [] |
230 self.super = superClasses |
263 self.super = superClasses |
237 def __init__(self, module, name, file, lineno): |
270 def __init__(self, module, name, file, lineno): |
238 """ |
271 """ |
239 Constructor |
272 Constructor |
240 |
273 |
241 @param module name of the module containing this module |
274 @param module name of the module containing this module |
|
275 @type str |
242 @param name name of this module |
276 @param name name of this module |
|
277 @type str |
243 @param file filename containing this module |
278 @param file filename containing this module |
244 @param lineno linenumber of the module definition |
279 @type str |
|
280 @param lineno line number of the module definition |
|
281 @type int |
245 """ |
282 """ |
246 ClbrBase.__init__(self, module, name, file, lineno) |
283 ClbrBase.__init__(self, module, name, file, lineno) |
247 |
284 |
248 |
285 |
249 class Function(ClbrBase): |
286 class Function(ClbrBase): |
258 modifierType=General, annotation=""): |
295 modifierType=General, annotation=""): |
259 """ |
296 """ |
260 Constructor |
297 Constructor |
261 |
298 |
262 @param module name of the module containing this function |
299 @param module name of the module containing this function |
|
300 @type str |
263 @param name name of this function |
301 @param name name of this function |
264 @param file filename containing this class |
302 @type str |
265 @param lineno linenumber of the class definition |
303 @param file filename containing this function |
266 @param signature parameterlist of the method |
304 @type str |
267 @param separator string separating the parameters |
305 @param lineno line number of the function definition |
|
306 @type int |
|
307 @param signature parameter list of the function |
|
308 @type str |
|
309 @param separator string separating the parameters of the function |
|
310 @type str |
268 @param modifierType type of the function |
311 @param modifierType type of the function |
269 @param annotation return annotation |
312 @type int |
|
313 @param annotation function return annotation |
|
314 @type str |
270 """ |
315 """ |
271 ClbrBase.__init__(self, module, name, file, lineno) |
316 ClbrBase.__init__(self, module, name, file, lineno) |
272 self.parameters = [e.strip() for e in signature.split(separator)] |
317 self.parameters = [e.strip() for e in signature.split(separator)] |
273 self.modifier = modifierType |
318 self.modifier = modifierType |
274 self.annotation = annotation |
319 self.annotation = annotation |
280 """ |
325 """ |
281 def __init__(self, module, file, lineno, coding): |
326 def __init__(self, module, file, lineno, coding): |
282 """ |
327 """ |
283 Constructor |
328 Constructor |
284 |
329 |
285 @param module name of the module containing this module |
330 @param module name of the module containing this coding statement |
286 @param file filename containing this module |
331 @type str |
287 @param lineno linenumber of the module definition |
332 @param file filename containing this coding statement |
|
333 @type str |
|
334 @param lineno line number of the coding definition |
|
335 @type int |
288 @param coding character coding of the source file |
336 @param coding character coding of the source file |
|
337 @type str |
289 """ |
338 """ |
290 ClbrBase.__init__(self, module, "Coding", file, lineno) |
339 ClbrBase.__init__(self, module, "Coding", file, lineno) |
291 self.coding = coding |
340 self.coding = coding |
|
341 |
|
342 |
|
343 class Enum(ClbrBase): |
|
344 """ |
|
345 Class to represent an enum definition. |
|
346 """ |
|
347 def __init__(self, module, name, file, lineno): |
|
348 """ |
|
349 Constructor |
|
350 |
|
351 @param module name of the module containing this enum |
|
352 @type str |
|
353 @param name name of this enum |
|
354 @type str |
|
355 @param file filename containing this enum |
|
356 @type str |
|
357 @param lineno line number of the enum definition |
|
358 @type int |
|
359 """ |
|
360 ClbrBase.__init__(self, module, name, file, lineno) |