Created
December 3, 2019 21:16
-
-
Save spotco/bbac2c2527bf897616bdf48d5d40524a to your computer and use it in GitHub Desktop.
resource_id_unique.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| file_lines = open(sys.argv[1],'r').read().split("\n") | |
| prefix_to_keys = {} | |
| for line in file_lines: | |
| tokens = line.split(" ") | |
| key = tokens[1] | |
| prefix = key[0:3] | |
| if not prefix in prefix_to_keys: | |
| prefix_to_keys[prefix] = {} | |
| keys = prefix_to_keys[prefix] | |
| keys[key] = len(keys) | |
| for prefix in sorted(prefix_to_keys.keys()): | |
| keys = prefix_to_keys[prefix] | |
| for key, value in keys.items(): | |
| offset = 0 | |
| if prefix == "IDD": #APS_NEXT_RESOURCE_VALUE | |
| offset = 1000 | |
| elif prefix == "IDM": #APS_NEXT_COMMAND_VALUE | |
| offset = 0x8000 | |
| elif prefix == "IDC": #APS_NEXT_CONTROL_VALUE | |
| offset = 1 | |
| elif prefix == "IDS": #APS_NEXT_SYMED_VALUE | |
| offset = 2000 | |
| print("#define %s %d" % (key, value + offset)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment