import os import time import json import subprocess class HeaderParser: def __init__(self, headerList, target, headerName): self.headerList = headerList self.path = target self.headerName = headerName self.outputPrefix = "asts/" + headerName self.astJsonFile = os.path.join(orig_dir, self.headerName + ".ast.json") with open(self.astJsonFile) as f: self.jsonRepr = json.load(f) orig_dir = os.path.abspath(os.path.dirname(__file__)) inputList = [] def parseAll(sdl3IncludePath, headerList): parsedList = [] for f in headerList: if f.endswith(".h"): headerName = f.split(".")[0] if "_" in headerName: headerName = headerName.split('_')[1] print(headerName) parsedList.append(os.path.join(sdl3IncludePath, f)) parsePath = os.path.join(sdl3IncludePath, 'SDL_gpu.h') # os.system(f"cheader2json convert {f} --prefix={self.headerName}") def parse(): global inputList sdl3IncludePath = os.path.join(orig_dir, 'SDL/include/SDL3') discoveredFiles = os.listdir(os.path.join(orig_dir, 'SDL/include/SDL3')) parsedList = [] parseAll(sdl3IncludePath, discoveredFiles) sdlHeaderList = [] for file in discoveredFiles: sdlHeaderList.append(os.path.join(sdl3IncludePath, file)) parsed = HeaderParser(sdlHeaderList, os.path.join(sdl3IncludePath, 'SDL_gpu.h'), "gpu") print("parsing list: ", inputList) if __name__ == "__main__": while True: parse()