| 648 | |
| 649 | |
| 650 | def load_objects_from_file(objfilename, checktypes): |
| 651 | objfile = io.open(objfilename, 'r', encoding='utf-8'); |
| 652 | in_insttype = False; |
| 653 | in_torque_insttype = False |
| 654 | in_torque_fulldef = False |
| 655 | |
| 656 | typestr = ''; |
| 657 | torque_typestr = '' |
| 658 | torque_fulldefstr = '' |
| 659 | uncommented_file = '' |
| 660 | |
| 661 | # |
| 662 | # Iterate the header file line-by-line to collect type and class |
| 663 | # information. For types, we accumulate a string representing the entire |
| 664 | # InstanceType enum definition and parse it later because it's easier to |
| 665 | # do so without the embedded newlines. |
| 666 | # |
| 667 | for line in objfile: |
| 668 | if (line.startswith('enum InstanceType : uint16_t {')): |
| 669 | in_insttype = True; |
| 670 | continue; |
| 671 | |
| 672 | if (line.startswith('#define TORQUE_ASSIGNED_INSTANCE_TYPE_LIST')): |
| 673 | in_torque_insttype = True |
| 674 | continue |
| 675 | |
| 676 | if (line.startswith('#define TORQUE_INSTANCE_CHECKERS_SINGLE_FULLY_DEFINED')): |
| 677 | in_torque_fulldef = True |
| 678 | continue |
| 679 | |
| 680 | if (in_insttype and line.startswith('};')): |
| 681 | in_insttype = False; |
| 682 | continue; |
| 683 | |
| 684 | if (in_torque_insttype and (not line or line.isspace())): |
| 685 | in_torque_insttype = False |
| 686 | continue |
| 687 | |
| 688 | if (in_torque_fulldef and (not line or line.isspace())): |
| 689 | in_torque_fulldef = False |
| 690 | continue |
| 691 | |
| 692 | pre = line.strip() |
| 693 | line = re.sub('// .*', '', line.strip()); |
| 694 | |
| 695 | if (in_insttype): |
| 696 | typestr += line; |
| 697 | continue; |
| 698 | |
| 699 | if (in_torque_insttype): |
| 700 | torque_typestr += line |
| 701 | continue |
| 702 | |
| 703 | if (in_torque_fulldef): |
| 704 | torque_fulldefstr += line |
| 705 | continue |
| 706 | |
| 707 | uncommented_file += '\n' + line |