feat(Core/Apps): add support dynamic lib for EnumUtils (#6120)

This commit is contained in:
Kargatum
2021-06-01 22:58:01 +07:00
committed by GitHub
parent d398c34c61
commit 584b8d908e
3 changed files with 26 additions and 26 deletions

View File

@@ -36,7 +36,7 @@ def processFile(path, filename):
if input is None:
print('Failed to open %s.h' % filename)
return
file = input.read()
enums = []
@@ -46,22 +46,22 @@ def processFile(path, filename):
values = []
for value in EnumValuesPattern.finditer(enum.group(3)):
valueData = value.group(0)
valueNameMatch = EnumValueNamePattern.search(valueData)
if valueNameMatch is None:
if EnumValueSkipLinePattern.search(valueData) is None:
print('Name of value not found: %s' % repr(valueData))
continue
valueName = valueNameMatch.group(1)
valueCommentMatch = EnumValueCommentPattern.search(valueData)
valueComment = None
if valueCommentMatch:
valueComment = valueCommentMatch.group(1)
valueTitle = None
valueDescription = None
if valueComment is not None:
if CommentSkipFormat.match(valueComment) is not None:
continue
@@ -71,20 +71,20 @@ def processFile(path, filename):
valueDescription = commentMatch.group(6)
else:
valueDescription = valueComment
if valueTitle is None:
valueTitle = valueName
if valueDescription is None:
valueDescription = ''
values.append((valueName, valueTitle, valueDescription))
enums.append((prefix + name, prefix, values))
print('%s.h: Enum %s parsed with %d values' % (filename, name, len(values)))
if not enums:
return
print('Done parsing %s.h (in %s)\n' % (filename, path))
output = open('%s/enuminfo_%s.cpp' % (path, filename), 'w')
if output is None:
@@ -107,7 +107,7 @@ def processFile(path, filename):
output.write('|* ' + tag + ' *|\n')
output.write('\\*' + ('*'*(len(tag)+2)) + '*/\n')
output.write('template <>\n')
output.write('EnumText EnumUtils<%s>::ToString(%s value)\n' % (name, name))
output.write('AC_API_EXPORT EnumText EnumUtils<%s>::ToString(%s value)\n' % (name, name))
output.write('{\n')
output.write(' switch (value)\n')
output.write(' {\n')
@@ -118,10 +118,10 @@ def processFile(path, filename):
output.write('}\n')
output.write('\n')
output.write('template <>\n')
output.write('size_t EnumUtils<%s>::Count() { return %d; }\n' % (name, len(values)))
output.write('AC_API_EXPORT size_t EnumUtils<%s>::Count() { return %d; }\n' % (name, len(values)))
output.write('\n')
output.write('template <>\n')
output.write('%s EnumUtils<%s>::FromIndex(size_t index)\n' % (name, name))
output.write('AC_API_EXPORT %s EnumUtils<%s>::FromIndex(size_t index)\n' % (name, name))
output.write('{\n')
output.write(' switch (index)\n')
output.write(' {\n')
@@ -132,7 +132,7 @@ def processFile(path, filename):
output.write('}\n')
output.write('\n')
output.write('template <>\n')
output.write('size_t EnumUtils<%s>::ToIndex(%s value)\n' % (name, name))
output.write('AC_API_EXPORT size_t EnumUtils<%s>::ToIndex(%s value)\n' % (name, name))
output.write('{\n')
output.write(' switch (value)\n')
output.write(' {\n')