diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/helper_file_generator.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py index 89d0788c..e64dd8a7 100644 --- a/scripts/helper_file_generator.py +++ b/scripts/helper_file_generator.py @@ -190,6 +190,24 @@ class HelperFileOutputGenerator(OutputGenerator): elif elem.tag == 'name': name = noneStr(elem.text) return (type, name) + # Extract length values from latexmath. Currently an inflexible solution that looks for specific + # patterns that are found in vk.xml. Will need to be updated when new patterns are introduced. + def parseLateXMath(self, source): + name = 'ERROR' + decoratedName = 'ERROR' + if 'mathit' in source: + # Matches expressions similar to 'latexmath:[$\lceil{\mathit{rasterizationSamples} \over 32}\rceil$]' + match = re.match(r'latexmath\s*\:\s*\[\s*\$\\l(\w+)\s*\{\s*\\mathit\s*\{\s*(\w+)\s*\}\s*\\over\s*(\d+)\s*\}\s*\\r(\w+)\$\s*\]', source) + if not match or match.group(1) != match.group(4): + raise 'Unrecognized latexmath expression' + name = match.group(2) + decoratedName = '{}/{}'.format(*match.group(2, 3)) + else: + # Matches expressions similar to 'latexmath : [$dataSize \over 4$]' + match = re.match(r'latexmath\s*\:\s*\[\s*\$\s*(\w+)\s*\\over\s*(\d+)\s*\$\s*\]', source) + name = match.group(1) + decoratedName = '{}/{}'.format(*match.group(1, 2)) + return name, decoratedName # # Retrieve the value of the len tag def getLen(self, param): @@ -203,6 +221,9 @@ class HelperFileOutputGenerator(OutputGenerator): result = len.split(',')[0] else: result = len + if 'latexmath' in len: + param_type, param_name = self.getTypeNameTuple(param) + len_name, result = self.parseLateXMath(len) # Spec has now notation for len attributes, using :: instead of platform specific pointer symbol result = str(result).replace('::', '->') return result |
