Fix 'SyntaxWarning: invalid escape sequence' when running gendynapi.py

main
Susko3 2024-03-28 20:14:56 +01:00 committed by Sam Lantinga
parent 6cf71ca9a9
commit d785a647a4
1 changed files with 13 additions and 13 deletions

View File

@ -55,14 +55,14 @@ def main():
# Get list of SDL headers # Get list of SDL headers
sdl_list_includes = get_header_list() sdl_list_includes = get_header_list()
reg_externC = re.compile('.*extern[ "]*C[ "].*') reg_externC = re.compile(r'.*extern[ "]*C[ "].*')
reg_comment_remove_content = re.compile('\/\*.*\*/') reg_comment_remove_content = re.compile(r'\/\*.*\*/')
reg_parsing_function = re.compile('(.*SDLCALL[^\(\)]*) ([a-zA-Z0-9_]+) *\((.*)\) *;.*') reg_parsing_function = re.compile(r'(.*SDLCALL[^\(\)]*) ([a-zA-Z0-9_]+) *\((.*)\) *;.*')
#eg: #eg:
# void (SDLCALL *callback)(void*, int) # void (SDLCALL *callback)(void*, int)
# \1(\2)\3 # \1(\2)\3
reg_parsing_callback = re.compile('([^\(\)]*)\(([^\(\)]+)\)(.*)') reg_parsing_callback = re.compile(r'([^\(\)]*)\(([^\(\)]+)\)(.*)')
for filename in sdl_list_includes: for filename in sdl_list_includes:
if args.debug: if args.debug:
@ -160,13 +160,13 @@ def main():
func = func.replace(" SDL_MALLOC", ""); func = func.replace(" SDL_MALLOC", "");
func = func.replace(" SDL_ALLOC_SIZE2(1, 2)", ""); func = func.replace(" SDL_ALLOC_SIZE2(1, 2)", "");
func = func.replace(" SDL_ALLOC_SIZE(2)", ""); func = func.replace(" SDL_ALLOC_SIZE(2)", "");
func = re.sub(" SDL_ACQUIRE\(.*\)", "", func); func = re.sub(r" SDL_ACQUIRE\(.*\)", "", func);
func = re.sub(" SDL_ACQUIRE_SHARED\(.*\)", "", func); func = re.sub(r" SDL_ACQUIRE_SHARED\(.*\)", "", func);
func = re.sub(" SDL_TRY_ACQUIRE\(.*\)", "", func); func = re.sub(r" SDL_TRY_ACQUIRE\(.*\)", "", func);
func = re.sub(" SDL_TRY_ACQUIRE_SHARED\(.*\)", "", func); func = re.sub(r" SDL_TRY_ACQUIRE_SHARED\(.*\)", "", func);
func = re.sub(" SDL_RELEASE\(.*\)", "", func); func = re.sub(r" SDL_RELEASE\(.*\)", "", func);
func = re.sub(" SDL_RELEASE_SHARED\(.*\)", "", func); func = re.sub(r" SDL_RELEASE_SHARED\(.*\)", "", func);
func = re.sub(" SDL_RELEASE_GENERIC\(.*\)", "", func); func = re.sub(r" SDL_RELEASE_GENERIC\(.*\)", "", func);
# Should be a valid function here # Should be a valid function here
match = reg_parsing_function.match(func) match = reg_parsing_function.match(func)
@ -427,7 +427,7 @@ def check_comment():
# Parse 'sdl_dynapi_procs_h' file to find existing functions # Parse 'sdl_dynapi_procs_h' file to find existing functions
def find_existing_procs(): def find_existing_procs():
reg = re.compile('SDL_DYNAPI_PROC\([^,]*,([^,]*),.*\)') reg = re.compile(r'SDL_DYNAPI_PROC\([^,]*,([^,]*),.*\)')
ret = [] ret = []
input = open(SDL_DYNAPI_PROCS_H) input = open(SDL_DYNAPI_PROCS_H)
@ -444,7 +444,7 @@ def find_existing_procs():
# Get list of SDL headers # Get list of SDL headers
def get_header_list(): def get_header_list():
reg = re.compile('^.*\.h$') reg = re.compile(r'^.*\.h$')
ret = [] ret = []
tmp = os.listdir(SDL_INCLUDE_DIR) tmp = os.listdir(SDL_INCLUDE_DIR)