Utilities/ClassBrowsers/idlclbr.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1509
c0b5e693b0eb
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
35 ^ 35 ^
36 (?P<MethodIndent> [ \t]* ) 36 (?P<MethodIndent> [ \t]* )
37 (?: oneway [ \t]+ )? 37 (?: oneway [ \t]+ )?
38 (?: [a-zA-Z0-9_:]+ | void ) [ \t]* 38 (?: [a-zA-Z0-9_:]+ | void ) [ \t]*
39 (?P<MethodName> [a-zA-Z_] [a-zA-Z0-9_]* ) 39 (?P<MethodName> [a-zA-Z_] [a-zA-Z0-9_]* )
40 [ \t]* 40 [ \t]*
41 \( 41 \(
42 (?P<MethodSignature> [^)]*? ) 42 (?P<MethodSignature> [^)]*? )
43 \); 43 \);
44 [ \t]* 44 [ \t]*
45 ) 45 )
81 [ \t]* } [ \t]* ; 81 [ \t]* } [ \t]* ;
82 ) 82 )
83 """, re.VERBOSE | re.DOTALL | re.MULTILINE).search 83 """, re.VERBOSE | re.DOTALL | re.MULTILINE).search
84 84
85 # function to replace comments 85 # function to replace comments
86 _commentsub = re.compile(r"""//[^\n]*\n|//[^\n]*$""").sub 86 _commentsub = re.compile(r"""//[^\n]*\n|//[^\n]*$""").sub
87 # function to normalize whitespace 87 # function to normalize whitespace
88 _normalize = re.compile(r"""[ \t]{2,}""").sub 88 _normalize = re.compile(r"""[ \t]{2,}""").sub
89 89
90 _modules = {} # cache of modules we've seen 90 _modules = {} # cache of modules we've seen
91 91
92
92 class VisibilityMixin(ClbrBaseClasses.ClbrVisibilityMixinBase): 93 class VisibilityMixin(ClbrBaseClasses.ClbrVisibilityMixinBase):
93 """ 94 """
94 Mixin class implementing the notion of visibility. 95 Mixin class implementing the notion of visibility.
95 """ 96 """
96 def __init__(self): 97 def __init__(self):
97 """ 98 """
98 Method to initialize the visibility. 99 Method to initialize the visibility.
99 """ 100 """
100 self.setPublic() 101 self.setPublic()
102
101 103
102 class Module(ClbrBaseClasses.Module, VisibilityMixin): 104 class Module(ClbrBaseClasses.Module, VisibilityMixin):
103 """ 105 """
104 Class to represent a CORBA IDL module. 106 Class to represent a CORBA IDL module.
105 """ 107 """
112 @param file filename containing this class 114 @param file filename containing this class
113 @param lineno linenumber of the class definition 115 @param lineno linenumber of the class definition
114 """ 116 """
115 ClbrBaseClasses.Module.__init__(self, module, name, file, lineno) 117 ClbrBaseClasses.Module.__init__(self, module, name, file, lineno)
116 VisibilityMixin.__init__(self) 118 VisibilityMixin.__init__(self)
119
117 120
118 class Interface(ClbrBaseClasses.Class, VisibilityMixin): 121 class Interface(ClbrBaseClasses.Class, VisibilityMixin):
119 """ 122 """
120 Class to represent a CORBA IDL interface. 123 Class to represent a CORBA IDL interface.
121 """ 124 """
130 @param lineno linenumber of the interface definition 133 @param lineno linenumber of the interface definition
131 """ 134 """
132 ClbrBaseClasses.Class.__init__(self, module, name, super, file, lineno) 135 ClbrBaseClasses.Class.__init__(self, module, name, super, file, lineno)
133 VisibilityMixin.__init__(self) 136 VisibilityMixin.__init__(self)
134 137
138
135 class Function(ClbrBaseClasses.Function, VisibilityMixin): 139 class Function(ClbrBaseClasses.Function, VisibilityMixin):
136 """ 140 """
137 Class to represent a CORBA IDL function. 141 Class to represent a CORBA IDL function.
138 """ 142 """
139 def __init__(self, module, name, file, lineno, signature = '', separator = ','): 143 def __init__(self, module, name, file, lineno, signature='', separator=','):
140 """ 144 """
141 Constructor 145 Constructor
142 146
143 @param module name of the module containing this function 147 @param module name of the module containing this function
144 @param name name of this function 148 @param name name of this function
145 @param file filename containing this class 149 @param file filename containing this class
146 @param lineno linenumber of the class definition 150 @param lineno linenumber of the class definition
147 @param signature parameterlist of the method 151 @param signature parameterlist of the method
148 @param separator string separating the parameters 152 @param separator string separating the parameters
149 """ 153 """
150 ClbrBaseClasses.Function.__init__(self, module, name, file, lineno, 154 ClbrBaseClasses.Function.__init__(self, module, name, file, lineno,
151 signature, separator) 155 signature, separator)
152 VisibilityMixin.__init__(self) 156 VisibilityMixin.__init__(self)
157
153 158
154 class Attribute(ClbrBaseClasses.Attribute, VisibilityMixin): 159 class Attribute(ClbrBaseClasses.Attribute, VisibilityMixin):
155 """ 160 """
156 Class to represent a CORBA IDL attribute. 161 Class to represent a CORBA IDL attribute.
157 """ 162 """
164 @param file filename containing this attribute 169 @param file filename containing this attribute
165 @param lineno linenumber of the class definition 170 @param lineno linenumber of the class definition
166 """ 171 """
167 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) 172 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno)
168 VisibilityMixin.__init__(self) 173 VisibilityMixin.__init__(self)
174
169 175
170 def readmodule_ex(module, path=[]): 176 def readmodule_ex(module, path=[]):
171 ''' 177 '''
172 Read a CORBA IDL file and return a dictionary of classes, functions and modules. 178 Read a CORBA IDL file and return a dictionary of classes, functions and modules.
173 179
194 # not CORBA IDL source, can't do anything with this module 200 # not CORBA IDL source, can't do anything with this module
195 _modules[module] = dict 201 _modules[module] = dict
196 return dict 202 return dict
197 203
198 _modules[module] = dict 204 _modules[module] = dict
199 classstack = [] # stack of (class, indent) pairs 205 classstack = [] # stack of (class, indent) pairs
200 indent = 0 206 indent = 0
201 try: 207 try:
202 src = Utilities.readEncodedFile(file)[0] 208 src = Utilities.readEncodedFile(file)[0]
203 except (UnicodeError, IOError): 209 except (UnicodeError, IOError):
204 # can't do anything with this module 210 # can't do anything with this module
244 dict_counts[meth_name] += 1 250 dict_counts[meth_name] += 1
245 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) 251 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name])
246 else: 252 else:
247 dict_counts[meth_name] = 0 253 dict_counts[meth_name] = 0
248 dict[meth_name] = f 254 dict[meth_name] = f
249 classstack.append((f, thisindent)) # Marker for nested fns 255 classstack.append((f, thisindent)) # Marker for nested fns
250 256
251 elif m.start("String") >= 0: 257 elif m.start("String") >= 0:
252 pass 258 pass
253 259
254 elif m.start("Comment") >= 0: 260 elif m.start("Comment") >= 0:

eric ide

mercurial