245 classstack = [] # stack of (class, indent) pairs |
246 classstack = [] # stack of (class, indent) pairs |
246 conditionalsstack = [] # stack of indents of conditional defines |
247 conditionalsstack = [] # stack of indents of conditional defines |
247 deltastack = [] |
248 deltastack = [] |
248 deltaindent = 0 |
249 deltaindent = 0 |
249 deltaindentcalculated = 0 |
250 deltaindentcalculated = 0 |
250 src = Utilities.decode(f.read())[0] |
251 src = f.read() |
251 f.close() |
252 f.close() |
252 |
253 |
253 lineno, last_lineno_pos = 1, 0 |
254 lineno, last_lineno_pos = 1, 0 |
254 i = 0 |
255 i = 0 |
255 while 1: |
256 while True: |
256 m = _getnext(src, i) |
257 m = _getnext(src, i) |
257 if not m: |
258 if not m: |
258 break |
259 break |
259 start, i = m.span() |
260 start, i = m.span() |
260 |
261 |
296 cur_class._addmethod(meth_name, f) |
297 cur_class._addmethod(meth_name, f) |
297 else: |
298 else: |
298 # it's a function |
299 # it's a function |
299 f = Function(module, meth_name, |
300 f = Function(module, meth_name, |
300 file, lineno, meth_sig) |
301 file, lineno, meth_sig) |
301 if dict_counts.has_key(meth_name): |
302 if meth_name in dict_counts: |
302 dict_counts[meth_name] += 1 |
303 dict_counts[meth_name] += 1 |
303 meth_name = "%s_%d" % (meth_name, dict_counts[meth_name]) |
304 meth_name = "%s_%d" % (meth_name, dict_counts[meth_name]) |
304 else: |
305 else: |
305 dict_counts[meth_name] = 0 |
306 dict_counts[meth_name] = 0 |
306 dict[meth_name] = f |
307 dict[meth_name] = f |
338 # form module.class: |
339 # form module.class: |
339 # look in |
340 # look in |
340 # module for class |
341 # module for class |
341 m = c[-2] |
342 m = c[-2] |
342 c = c[-1] |
343 c = c[-1] |
343 if _modules.has_key(m): |
344 if m in _modules: |
344 d = _modules[m] |
345 d = _modules[m] |
345 if d.has_key(c): |
346 if c in d: |
346 n = d[c] |
347 n = d[c] |
347 names.append(n) |
348 names.append(n) |
348 inherit = names |
349 inherit = names |
349 # remember this class |
350 # remember this class |
350 cur_class = Class(module, class_name, inherit, |
351 cur_class = Class(module, class_name, inherit, |
351 file, lineno) |
352 file, lineno) |
352 if not classstack: |
353 if not classstack: |
353 if dict_counts.has_key(class_name): |
354 if class_name in dict_counts: |
354 dict_counts[class_name] += 1 |
355 dict_counts[class_name] += 1 |
355 class_name = "%s_%d" % (class_name, dict_counts[class_name]) |
356 class_name = "%s_%d" % (class_name, dict_counts[class_name]) |
356 else: |
357 else: |
357 dict_counts[class_name] = 0 |
358 dict_counts[class_name] = 0 |
358 dict[class_name] = cur_class |
359 dict[class_name] = cur_class |
378 variable_name = m.group("VariableName") |
379 variable_name = m.group("VariableName") |
379 lineno = lineno + src.count('\n', last_lineno_pos, start) |
380 lineno = lineno + src.count('\n', last_lineno_pos, start) |
380 last_lineno_pos = start |
381 last_lineno_pos = start |
381 if thisindent == 0: |
382 if thisindent == 0: |
382 # global variable |
383 # global variable |
383 if not dict.has_key("@@Globals@@"): |
384 if "@@Globals@@" not in dict: |
384 dict["@@Globals@@"] = \ |
385 dict["@@Globals@@"] = \ |
385 ClbrBaseClasses.ClbrBase(module, "Globals", file, lineno) |
386 ClbrBaseClasses.ClbrBase(module, "Globals", file, lineno) |
386 dict["@@Globals@@"]._addglobal( |
387 dict["@@Globals@@"]._addglobal( |
387 Attribute(module, variable_name, file, lineno)) |
388 Attribute(module, variable_name, file, lineno)) |
388 else: |
389 else: |
417 elif m.start("CodingLine") >= 0: |
418 elif m.start("CodingLine") >= 0: |
418 # a coding statement |
419 # a coding statement |
419 coding = m.group("Coding") |
420 coding = m.group("Coding") |
420 lineno = lineno + src.count('\n', last_lineno_pos, start) |
421 lineno = lineno + src.count('\n', last_lineno_pos, start) |
421 last_lineno_pos = start |
422 last_lineno_pos = start |
422 if not dict.has_key("@@Coding@@"): |
423 if "@@Coding@@" not in dict: |
423 dict["@@Coding@@"] = ClbrBaseClasses.Coding(module, file, lineno, coding) |
424 dict["@@Coding@@"] = ClbrBaseClasses.Coding(module, file, lineno, coding) |
424 |
425 |
425 else: |
426 else: |
426 assert 0, "regexp _getnext found something unexpected" |
427 assert 0, "regexp _getnext found something unexpected" |
427 |
428 |
428 if dict.has_key('__all__'): |
429 if '__all__' in dict: |
429 # set visibility of all top level elements |
430 # set visibility of all top level elements |
430 pubs = dict['__all__'] |
431 pubs = dict['__all__'] |
431 for key in dict.keys(): |
432 for key in list(list(dict.keys())): |
432 if key == '__all__' or key.startswith("@@"): |
433 if key == '__all__' or key.startswith("@@"): |
433 continue |
434 continue |
434 if key in pubs.identifiers: |
435 if key in pubs.identifiers: |
435 dict[key].setPublic() |
436 dict[key].setPublic() |
436 else: |
437 else: |