feat(Core/Apps): add support dynamic lib for EnumUtils (#6120)
This commit is contained in:
@@ -36,7 +36,7 @@ def processFile(path, filename):
|
|||||||
if input is None:
|
if input is None:
|
||||||
print('Failed to open %s.h' % filename)
|
print('Failed to open %s.h' % filename)
|
||||||
return
|
return
|
||||||
|
|
||||||
file = input.read()
|
file = input.read()
|
||||||
|
|
||||||
enums = []
|
enums = []
|
||||||
@@ -46,22 +46,22 @@ def processFile(path, filename):
|
|||||||
values = []
|
values = []
|
||||||
for value in EnumValuesPattern.finditer(enum.group(3)):
|
for value in EnumValuesPattern.finditer(enum.group(3)):
|
||||||
valueData = value.group(0)
|
valueData = value.group(0)
|
||||||
|
|
||||||
valueNameMatch = EnumValueNamePattern.search(valueData)
|
valueNameMatch = EnumValueNamePattern.search(valueData)
|
||||||
if valueNameMatch is None:
|
if valueNameMatch is None:
|
||||||
if EnumValueSkipLinePattern.search(valueData) is None:
|
if EnumValueSkipLinePattern.search(valueData) is None:
|
||||||
print('Name of value not found: %s' % repr(valueData))
|
print('Name of value not found: %s' % repr(valueData))
|
||||||
continue
|
continue
|
||||||
valueName = valueNameMatch.group(1)
|
valueName = valueNameMatch.group(1)
|
||||||
|
|
||||||
valueCommentMatch = EnumValueCommentPattern.search(valueData)
|
valueCommentMatch = EnumValueCommentPattern.search(valueData)
|
||||||
valueComment = None
|
valueComment = None
|
||||||
if valueCommentMatch:
|
if valueCommentMatch:
|
||||||
valueComment = valueCommentMatch.group(1)
|
valueComment = valueCommentMatch.group(1)
|
||||||
|
|
||||||
valueTitle = None
|
valueTitle = None
|
||||||
valueDescription = None
|
valueDescription = None
|
||||||
|
|
||||||
if valueComment is not None:
|
if valueComment is not None:
|
||||||
if CommentSkipFormat.match(valueComment) is not None:
|
if CommentSkipFormat.match(valueComment) is not None:
|
||||||
continue
|
continue
|
||||||
@@ -71,20 +71,20 @@ def processFile(path, filename):
|
|||||||
valueDescription = commentMatch.group(6)
|
valueDescription = commentMatch.group(6)
|
||||||
else:
|
else:
|
||||||
valueDescription = valueComment
|
valueDescription = valueComment
|
||||||
|
|
||||||
if valueTitle is None:
|
if valueTitle is None:
|
||||||
valueTitle = valueName
|
valueTitle = valueName
|
||||||
if valueDescription is None:
|
if valueDescription is None:
|
||||||
valueDescription = ''
|
valueDescription = ''
|
||||||
|
|
||||||
values.append((valueName, valueTitle, valueDescription))
|
values.append((valueName, valueTitle, valueDescription))
|
||||||
|
|
||||||
enums.append((prefix + name, prefix, values))
|
enums.append((prefix + name, prefix, values))
|
||||||
print('%s.h: Enum %s parsed with %d values' % (filename, name, len(values)))
|
print('%s.h: Enum %s parsed with %d values' % (filename, name, len(values)))
|
||||||
|
|
||||||
if not enums:
|
if not enums:
|
||||||
return
|
return
|
||||||
|
|
||||||
print('Done parsing %s.h (in %s)\n' % (filename, path))
|
print('Done parsing %s.h (in %s)\n' % (filename, path))
|
||||||
output = open('%s/enuminfo_%s.cpp' % (path, filename), 'w')
|
output = open('%s/enuminfo_%s.cpp' % (path, filename), 'w')
|
||||||
if output is None:
|
if output is None:
|
||||||
@@ -107,7 +107,7 @@ def processFile(path, filename):
|
|||||||
output.write('|* ' + tag + ' *|\n')
|
output.write('|* ' + tag + ' *|\n')
|
||||||
output.write('\\*' + ('*'*(len(tag)+2)) + '*/\n')
|
output.write('\\*' + ('*'*(len(tag)+2)) + '*/\n')
|
||||||
output.write('template <>\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('{\n')
|
||||||
output.write(' switch (value)\n')
|
output.write(' switch (value)\n')
|
||||||
output.write(' {\n')
|
output.write(' {\n')
|
||||||
@@ -118,10 +118,10 @@ def processFile(path, filename):
|
|||||||
output.write('}\n')
|
output.write('}\n')
|
||||||
output.write('\n')
|
output.write('\n')
|
||||||
output.write('template <>\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('\n')
|
||||||
output.write('template <>\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('{\n')
|
||||||
output.write(' switch (index)\n')
|
output.write(' switch (index)\n')
|
||||||
output.write(' {\n')
|
output.write(' {\n')
|
||||||
@@ -132,7 +132,7 @@ def processFile(path, filename):
|
|||||||
output.write('}\n')
|
output.write('}\n')
|
||||||
output.write('\n')
|
output.write('\n')
|
||||||
output.write('template <>\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('{\n')
|
||||||
output.write(' switch (value)\n')
|
output.write(' switch (value)\n')
|
||||||
output.write(' {\n')
|
output.write(' {\n')
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Acore::Impl::EnumUtilsImpl
|
|||||||
|* data for enum 'ColorTypes' in 'AppenderConsole.h' auto-generated *|
|
|* data for enum 'ColorTypes' in 'AppenderConsole.h' auto-generated *|
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
template <>
|
template <>
|
||||||
EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
|
AC_API_EXPORT EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@@ -40,10 +40,10 @@ EnumText EnumUtils<ColorTypes>::ToString(ColorTypes value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
size_t EnumUtils<ColorTypes>::Count() { return 15; }
|
AC_API_EXPORT size_t EnumUtils<ColorTypes>::Count() { return 15; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
|
AC_API_EXPORT ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -67,7 +67,7 @@ ColorTypes EnumUtils<ColorTypes>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
size_t EnumUtils<ColorTypes>::ToIndex(ColorTypes value)
|
AC_API_EXPORT size_t EnumUtils<ColorTypes>::ToIndex(ColorTypes value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Acore::Impl::EnumUtilsImpl
|
|||||||
|* data for enum 'LogLevel' in 'LogCommon.h' auto-generated *|
|
|* data for enum 'LogLevel' in 'LogCommon.h' auto-generated *|
|
||||||
\************************************************************/
|
\************************************************************/
|
||||||
template <>
|
template <>
|
||||||
EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
|
AC_API_EXPORT EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@@ -32,10 +32,10 @@ EnumText EnumUtils<LogLevel>::ToString(LogLevel value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
size_t EnumUtils<LogLevel>::Count() { return 7; }
|
AC_API_EXPORT size_t EnumUtils<LogLevel>::Count() { return 7; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
|
AC_API_EXPORT LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -51,7 +51,7 @@ LogLevel EnumUtils<LogLevel>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
|
AC_API_EXPORT size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@@ -70,7 +70,7 @@ size_t EnumUtils<LogLevel>::ToIndex(LogLevel value)
|
|||||||
|* data for enum 'AppenderType' in 'LogCommon.h' auto-generated *|
|
|* data for enum 'AppenderType' in 'LogCommon.h' auto-generated *|
|
||||||
\****************************************************************/
|
\****************************************************************/
|
||||||
template <>
|
template <>
|
||||||
EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
|
AC_API_EXPORT EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@@ -83,10 +83,10 @@ EnumText EnumUtils<AppenderType>::ToString(AppenderType value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
size_t EnumUtils<AppenderType>::Count() { return 4; }
|
AC_API_EXPORT size_t EnumUtils<AppenderType>::Count() { return 4; }
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
|
AC_API_EXPORT AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
@@ -99,7 +99,7 @@ AppenderType EnumUtils<AppenderType>::FromIndex(size_t index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
size_t EnumUtils<AppenderType>::ToIndex(AppenderType value)
|
AC_API_EXPORT size_t EnumUtils<AppenderType>::ToIndex(AppenderType value)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user