Commit f51cf570 authored by Artur Grunau's avatar Artur Grunau
Browse files

Make the regex used to detect pipelines more permissive

Automatic pipeline registration would fail for certain valid ways of
declaring a pipeline:
- if the base pipeline class was qualified with a namespace
- if the pipeline inherited from additional classes
- if the declaration followed coding conventions different than CAMPVis'
  (e.g. no space before :, { on a new line)

Make the regex used to detect pipelines more permissive to handle the
above cases.

Closes #233
parent 0c73f0f7
...@@ -25,13 +25,19 @@ ENDMACRO(WRITE_PIPELINE_REGISTRATION) ...@@ -25,13 +25,19 @@ ENDMACRO(WRITE_PIPELINE_REGISTRATION)
MACRO(PARSE_HEADER_FOR_PIPELINE FileName) MACRO(PARSE_HEADER_FOR_PIPELINE FileName)
FILE(READ ${FileName} content) FILE(READ ${FileName} content)
# Build a regex matching pipeline declarations and extracting their names
SET(NameRegex "[A-Za-z0-9_]+")
SET(FullyQualifiedNameRegex "(::)?(${NameRegex}::)*${NameRegex}")
SET(BaseClassListRegex "((public|private|protected)( virtual)? ${FullyQualifiedNameRegex}, )*")
SET(ClassRegex "class (${NameRegex}) ?: ${BaseClassListRegex}public ${FullyQualifiedNameRegex}Pipeline")
# Find all class definitions inheriting from a Pipeline # Find all class definitions inheriting from a Pipeline
STRING(REGEX MATCHALL "class ([A-Za-z0-9_]+) : public [A-Za-z0-9_]+Pipeline {" matches ${content}) STRING(REGEX MATCHALL ${ClassRegex} matches ${content})
FOREACH(m ${matches}) FOREACH(m ${matches})
# Extract class name and register # Extract class name and register
STRING(REGEX REPLACE "(class )([A-Za-z0-9_]+)( : public [A-Za-z0-9_]+Pipeline {)" "\\2" RESULT ${m}) STRING(REGEX REPLACE ${ClassRegex} "\\1" RESULT ${m})
ADD_PIPELINE_REGISTRATION(${FileName} ${RESULT}) ADD_PIPELINE_REGISTRATION(${FileName} ${RESULT})
ENDFOREACH() ENDFOREACH()
ENDMACRO(PARSE_HEADER_FOR_PIPELINE) ENDMACRO(PARSE_HEADER_FOR_PIPELINE)
...@@ -214,4 +220,4 @@ MACRO(DEFINE_SOURCE_GROUPS_FROM_SUBDIR Files BasePath RemovePathPrefixes) ...@@ -214,4 +220,4 @@ MACRO(DEFINE_SOURCE_GROUPS_FROM_SUBDIR Files BasePath RemovePathPrefixes)
# MESSAGE(STATUS "${f} -> ${f_cat}") # MESSAGE(STATUS "${f} -> ${f_cat}")
ENDFOREACH() ENDFOREACH()
ENDMACRO(DEFINE_SOURCE_GROUPS_FROM_SUBDIR) ENDMACRO(DEFINE_SOURCE_GROUPS_FROM_SUBDIR)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment