Utilities/ClassBrowsers/idlclbr.py

changeset 2997
7f0ef975da9e
parent 2965
d133c7edd88a
child 3030
4a0a82ddd9d2
child 3057
10516539f238
equal deleted inserted replaced
2996:c6f16f1b9958 2997:7f0ef975da9e
2 2
3 # Copyright (c) 2005 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2005 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Parse a CORBA IDL file and retrieve modules, interfaces, methods and attributes. 7 Parse a CORBA IDL file and retrieve modules, interfaces, methods and
8 8 attributes.
9 Parse enough of a CORBA IDL file to recognize module, interface and method definitions 9
10 and to find out the superclasses of an interface as well as its attributes. 10 Parse enough of a CORBA IDL file to recognize module, interface and method
11 definitions and to find out the superclasses of an interface as well as its
12 attributes.
11 13
12 It is based on the Python class browser found in this package. 14 It is based on the Python class browser found in this package.
13 """ 15 """
14 16
15 import re 17 import re
138 140
139 class Function(ClbrBaseClasses.Function, VisibilityMixin): 141 class Function(ClbrBaseClasses.Function, VisibilityMixin):
140 """ 142 """
141 Class to represent a CORBA IDL function. 143 Class to represent a CORBA IDL function.
142 """ 144 """
143 def __init__(self, module, name, file, lineno, signature='', separator=','): 145 def __init__(self, module, name, file, lineno, signature='',
146 separator=','):
144 """ 147 """
145 Constructor 148 Constructor
146 149
147 @param module name of the module containing this function 150 @param module name of the module containing this function
148 @param name name of this function 151 @param name name of this function
173 VisibilityMixin.__init__(self) 176 VisibilityMixin.__init__(self)
174 177
175 178
176 def readmodule_ex(module, path=[]): 179 def readmodule_ex(module, path=[]):
177 """ 180 """
178 Read a CORBA IDL file and return a dictionary of classes, functions and modules. 181 Read a CORBA IDL file and return a dictionary of classes, functions and
182 modules.
179 183
180 @param module name of the CORBA IDL file (string) 184 @param module name of the CORBA IDL file (string)
181 @param path path the file should be searched in (list of strings) 185 @param path path the file should be searched in (list of strings)
182 @return the resulting dictionary 186 @return the resulting dictionary
183 """ 187 """
239 classstack[-1][0].setEndLine(lineno - 1) 243 classstack[-1][0].setEndLine(lineno - 1)
240 del classstack[-1] 244 del classstack[-1]
241 if classstack: 245 if classstack:
242 # it's an interface/module method 246 # it's an interface/module method
243 cur_class = classstack[-1][0] 247 cur_class = classstack[-1][0]
244 if isinstance(cur_class, Interface) or isinstance(cur_class, Module): 248 if isinstance(cur_class, Interface) or \
249 isinstance(cur_class, Module):
245 # it's a method 250 # it's a method
246 f = Function(None, meth_name, 251 f = Function(None, meth_name,
247 file, lineno, meth_sig) 252 file, lineno, meth_sig)
248 cur_class._addmethod(meth_name, f) 253 cur_class._addmethod(meth_name, f)
249 # else it's a nested def 254 # else it's a nested def
253 # it's a function 258 # it's a function
254 f = Function(module, meth_name, 259 f = Function(module, meth_name,
255 file, lineno, meth_sig) 260 file, lineno, meth_sig)
256 if meth_name in dict_counts: 261 if meth_name in dict_counts:
257 dict_counts[meth_name] += 1 262 dict_counts[meth_name] += 1
258 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) 263 meth_name = "{0}_{1:d}".format(
264 meth_name, dict_counts[meth_name])
259 else: 265 else:
260 dict_counts[meth_name] = 0 266 dict_counts[meth_name] = 0
261 dict[meth_name] = f 267 dict[meth_name] = f
262 if not classstack: 268 if not classstack:
263 if lastGlobalEntry: 269 if lastGlobalEntry:

eric ide

mercurial