(lno, lines, filename)
| 435 | |
| 436 | |
| 437 | def parse_function(lno, lines, filename): |
| 438 | |
| 439 | start_paren = 0 |
| 440 | end_paren = 0 |
| 441 | signature = '' |
| 442 | |
| 443 | global orphaned_export |
| 444 | orphaned_export = False |
| 445 | |
| 446 | while lno < len(lines): |
| 447 | line = lines[lno].strip() |
| 448 | lno += 1 |
| 449 | if line.startswith('//'): |
| 450 | continue |
| 451 | |
| 452 | start_paren += line.count('(') |
| 453 | end_paren += line.count(')') |
| 454 | |
| 455 | sig_line = line.replace('TORRENT_EXPORT ', '') \ |
| 456 | .replace('TORRENT_EXTRA_EXPORT', '') \ |
| 457 | .replace('TORRENT_V3_EXPLICIT', '') \ |
| 458 | .replace('TORRENT_COUNTER_NOEXCEPT', '') \ |
| 459 | .split('//')[0].strip() |
| 460 | if signature != '': |
| 461 | sig_line = '\n ' + sig_line |
| 462 | signature += sig_line |
| 463 | if verbose: |
| 464 | print('fun %s' % line) |
| 465 | |
| 466 | if start_paren > 0 and start_paren == end_paren: |
| 467 | if signature[-1] != ';': |
| 468 | # we also need to consume the function body |
| 469 | start_paren = 0 |
| 470 | end_paren = 0 |
| 471 | for i in range(len(signature)): |
| 472 | if signature[i] == '(': |
| 473 | start_paren += 1 |
| 474 | elif signature[i] == ')': |
| 475 | end_paren += 1 |
| 476 | |
| 477 | if start_paren > 0 and start_paren == end_paren: |
| 478 | for k in range(i, len(signature)): |
| 479 | if signature[k] == ':' or signature[k] == '{': |
| 480 | signature = signature[0:k].strip() |
| 481 | break |
| 482 | break |
| 483 | |
| 484 | lno = consume_block(lno - 1, lines) |
| 485 | signature += ';' |
| 486 | ret = [{'file': filename[11:], 'signatures': set([signature]), 'names': set( |
| 487 | [signature.split('(')[0].split(' ')[-1].strip() + '()'])}, lno] |
| 488 | if first_item(ret[0]['names']) == '()': |
| 489 | return [None, lno] |
| 490 | return ret |
| 491 | if len(signature) > 0: |
| 492 | print('\x1b[31mFAILED TO PARSE FUNCTION\x1b[0m %s\nline: %d\nfile: %s' % (signature, lno, filename)) |
| 493 | return [None, lno] |
| 494 |
no test coverage detected