From 9491a7a55cadbc8e54dc8327cd15b8795981adf1 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Tue, 22 Dec 2020 23:36:24 +0100 Subject: [PATCH] Small fix. Write each class to seperate file --- tools/standardTextToCode/parseTables.py | 6 +++ tools/standardTextToCode/writeTablesC++.py | 45 ++++++++-------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/tools/standardTextToCode/parseTables.py b/tools/standardTextToCode/parseTables.py index b940f2ce7..384da360b 100644 --- a/tools/standardTextToCode/parseTables.py +++ b/tools/standardTextToCode/parseTables.py @@ -31,6 +31,7 @@ def cleanCondition(text : str): text = text.replace("\n", "") text = text.replace("\t", "") text = text.replace("\u2212", "-") + text = text.replace('−', '-') if (text.find("\xa0") != -1): raise SyntaxError("There still is a char to replace in the condition. This must be cleaned up first.") return text @@ -40,6 +41,7 @@ def cleanArgument(text : str): text = text.replace("\xa0]", "]") text = text.replace("\xa0", " ") text = text.replace("\u2212", "-") + text = text.replace('−', '-') if (text.find("\xa0") != -1): raise SyntaxError("There still is a char to replace in the argument. This must be cleaned up first.") return text @@ -54,18 +56,22 @@ def cleanComment(text : str): text = text.replace("( ", "(") text = text.replace(" )", ")") text = text.replace("\u2212", "-") + text = text.replace('−', '-') if (text.find("\xa0") != -1): raise SyntaxError("There still is a char to replace in the comment. This must be cleaned up first.") return text def cleanConditionPart(text : str): text = text.strip() text = text.replace("\xa0−\xa0", " - ") + text = text.replace('−', '-') if (text.find("\xa0") != -1): raise SyntaxError("There still is a char to replace in the condition. This must be cleaned up first.") return text def cleanIncrement(text : str): text = text.strip() text = text.replace("-\xa0-", "--") + text = text.replace("−\xa0−", "--") + text = text.replace('−', '-') if (text.find("\xa0") != -1): raise SyntaxError("There still is a char to replace in the increment. This must be cleaned up first.") return text diff --git a/tools/standardTextToCode/writeTablesC++.py b/tools/standardTextToCode/writeTablesC++.py index 05b248ca2..425725392 100644 --- a/tools/standardTextToCode/writeTablesC++.py +++ b/tools/standardTextToCode/writeTablesC++.py @@ -4,9 +4,9 @@ from pathlib import Path class OutputFile: - def __init__(self, name, classes, dependencies): + def __init__(self, name, classname, dependencies): self.name = name - self.classes = classes + self.classname = classname self.dependencies = dependencies self.tables = [] @@ -155,35 +155,24 @@ def writeTablesToCpp(parsedTables, path): writeOutCommonClasses(open(path + "/common.h", "w")) - vvcOutputFiles = [ - OutputFile("vps", ["video_parameter_set_rbsp"], ["ptl", "dpb_parameters", "general_hrd_parameters", "ols_hrd_parameters"]), - OutputFile("sps", ["seq_parameter_set_rbsp"], ["ptl", "dpb_parameters", "ref_pic_list_struct", "general_hrd_parameters", "ols_hrd_parameters", "vui"]), - OutputFile("pps", ["pic_parameter_set_rbsp"], []), - OutputFile("ptl", ["profile_tier_level"], []), - OutputFile("dpb_parameters", ["dpb_parameters"], []), - OutputFile("general_hrd_parameters", ["general_hrd_parameters"], []), - OutputFile("ols_hrd_parameters", ["ols_hrd_parameters"], []), - OutputFile("vui", ["vui_parameters"], []), - OutputFile("other", [], []) - ] + # vvcOutputFiles = [ + # OutputFile("vps", "video_parameter_set_rbsp", ["ptl", "dpb_parameters", "general_hrd_parameters", "ols_hrd_parameters"]), + # OutputFile("sps", "seq_parameter_set_rbsp", ["ptl", "dpb_parameters", "ref_pic_list_struct", "general_hrd_parameters", "ols_hrd_parameters", "vui"]), + # OutputFile("pps", "pic_parameter_set_rbsp", []), + # OutputFile("ptl", "profile_tier_level", []), + # OutputFile("dpb_parameters", "dpb_parameters", []), + # OutputFile("general_hrd_parameters", "general_hrd_parameters", []), + # OutputFile("ols_hrd_parameters", "ols_hrd_parameters", []), + # OutputFile("vui", "vui_parameters", []), + # OutputFile("other", "", []) + # ] for table in parsedTables: assert(type(table) == ContainerTable) - print(table.name) - # Sort the tables into the output files - for outFile in vvcOutputFiles: - for includeClass in outFile.classes: - if (includeClass == table.name): - outFile.tables.append(table) - break - if (outFile.name == "other"): - outFile.tables.append(table) - - for outFile in vvcOutputFiles: - files = (HeaderFile(path, outFile.name, outFile.dependencies), CppFile(path, outFile.name)) - for table in outFile.tables: - writeTableToFiles(table, files) - + print(f"Writing {table.name}") + files = (HeaderFile(path, table.name, []), CppFile(path, table.name)) + writeTableToFiles(table, files) + def main(): parsedTables = pickle.load(open("tempPiclkle.p", "rb")) writeTablesToCpp(parsedTables, "cpp")