Skip to content

Commit

Permalink
Small fix. Write each class to seperate file
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Dec 22, 2020
1 parent 7f58450 commit 9491a7a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
6 changes: 6 additions & 0 deletions tools/standardTextToCode/parseTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
45 changes: 17 additions & 28 deletions tools/standardTextToCode/writeTablesC++.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 9491a7a

Please sign in to comment.