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')

View File

@@ -16,7 +16,7 @@ namespace Acore::Impl::EnumUtilsImpl
|* data for enum 'ColorTypes' in 'AppenderConsole.h' auto-generated *|
\********************************************************************/
template <>
EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
AC_API_EXPORT EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
{
switch (value)
{
@@ -40,10 +40,10 @@ EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
}
template <>
size_t EnumUtils<ColorTypes>::Count() { return 15; }
AC_API_EXPORT size_t EnumUtils<ColorTypes>::Count() { return 15; }
template <>
ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
AC_API_EXPORT ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
{
switch (index)
{
@@ -67,7 +67,7 @@ ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
}
template <>
size_t EnumUtils<ColorTypes>::ToIndex(ColorTypes value)
AC_API_EXPORT size_t EnumUtils<ColorTypes>::ToIndex(ColorTypes value)
{
switch (value)
{

View File

@@ -16,7 +16,7 @@ namespace Acore::Impl::EnumUtilsImpl
|* data for enum 'LogLevel' in 'LogCommon.h' auto-generated *|
\************************************************************/
template <>
EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
AC_API_EXPORT EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
{
switch (value)
{
@@ -32,10 +32,10 @@ EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
}
template <>
size_t EnumUtils<LogLevel>::Count() { return 7; }
AC_API_EXPORT size_t EnumUtils<LogLevel>::Count() { return 7; }
template <>
LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
AC_API_EXPORT LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
{
switch (index)
{
@@ -51,7 +51,7 @@ LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
}
template <>
size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
AC_API_EXPORT size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
{
switch (value)
{
@@ -70,7 +70,7 @@ size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
|* data for enum 'AppenderType' in 'LogCommon.h' auto-generated *|
\****************************************************************/
template <>
EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
AC_API_EXPORT EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
{
switch (value)
{
@@ -83,10 +83,10 @@ EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
}
template <>
size_t EnumUtils<AppenderType>::Count() { return 4; }
AC_API_EXPORT size_t EnumUtils<AppenderType>::Count() { return 4; }
template <>
AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
AC_API_EXPORT AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
{
switch (index)
{
@@ -99,7 +99,7 @@ AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
}
template <>
size_t EnumUtils<AppenderType>::ToIndex(AppenderType value)
AC_API_EXPORT size_t EnumUtils<AppenderType>::ToIndex(AppenderType value)
{
switch (value)
{