From 367ea52be96a4b0f6b2ddf93bf9831b8938adccd Mon Sep 17 00:00:00 2001 From: Not-Nik Date: Fri, 22 May 2020 22:07:31 +1000 Subject: [PATCH] Delete unneeded raylib-headers/math-funcs.py (replaced by lib/generate_functions.py) --- raylib-headers/math-funcs.py | 54 ------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 raylib-headers/math-funcs.py diff --git a/raylib-headers/math-funcs.py b/raylib-headers/math-funcs.py deleted file mode 100644 index ee91ce0..0000000 --- a/raylib-headers/math-funcs.py +++ /dev/null @@ -1,54 +0,0 @@ -import re - -""" -Automatic utility for extracting function definitions from raymath.h -and translating them to zig. This can technically be used for raylib.h -as well when setting prefix = "RLAPI " and possibly also for all other -raylib headers -""" - -raymath = open("raymath.h") - -prefix = "RMDEF " - -# Some c types have a different size on different systems -# and zig knows that so we tell it to get the system specific size for us -def c_to_zig_type(type: str) -> str: - if type == "float": type = "f32" - if type == "int": type = "c_int" - if type == "unsigned int": type = "c_uint" - if type == "long": type = "c_long" - if type == "void": type = "c_void" - return type - -def fix_pointer(name: str, type: str): - if name.startswith("*"): - name = name[1:] - type = "[*c]" + type - return name, type - -for line in raymath.readlines(): - if line.startswith(prefix): - # each (.*) is some variable value - result = re.search(prefix + "(.*) (.*)start_arg(.*)end_arg", line.replace("(", "start_arg").replace(")", "end_arg")) - - # get whats in the (.*)'s - return_type = result.group(1) - func_name = result.group(2) - arguments = result.group(3) - - func_name, return_type = fix_pointer(func_name, return_type) - - return_type = c_to_zig_type(return_type) - zig_arguments = [] - for arg in arguments.split(", "): - if arg == "void": break - arg_type = " ".join(arg.split(" ")[0:-1]) # everything but the last element (for stuff like "const Vector3") - arg_type = arg_type.replace("const ", "") # zig doesn't like const in function arguments that aren't pointer and really we don't need const - arg_type = c_to_zig_type(arg_type) - arg_name = arg.split(" ")[-1] # last element should be the name - arg_name, arg_type = fix_pointer(arg_name, arg_type) - zig_arguments.append(arg_name + ": " + arg_type) # put everything together - zig_arguments = ", ".join(zig_arguments) - print("pub extern fn " + func_name + "(" + zig_arguments + ") " + return_type + ";") -