Commit 451917ca authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Updated CMake script to generate pipeline registration file to (limitedly) support namespaces.

parent dc1b0b16
...@@ -37,13 +37,12 @@ MACRO(WRITE_PIPELINE_REGISTRATION FileName) ...@@ -37,13 +37,12 @@ MACRO(WRITE_PIPELINE_REGISTRATION FileName)
LIST(APPEND PipelineRegistrationSource "#include \"${IncludeFile}\"\n" ) LIST(APPEND PipelineRegistrationSource "#include \"${IncludeFile}\"\n" )
ENDFOREACH() ENDFOREACH()
LIST(APPEND PipelineRegistrationSource "\nnamespace campvis {\n" ) LIST(APPEND PipelineRegistrationSource "\n// Instantiate templated PipelineRegistrars to register the pipelines.\n" )
LIST(APPEND PipelineRegistrationSource "\t// Instantiate templated PipelineRegistrars to register the pipelines.\n" )
FOREACH(ClassName ${PipelineRegistrationClassNames}) FOREACH(ClassName ${PipelineRegistrationClassNames})
LIST(APPEND PipelineRegistrationSource "\ttemplate class PipelineRegistrar<${ClassName}>\;\n" ) LIST(APPEND PipelineRegistrationSource "template class campvis::PipelineRegistrar<${ClassName}>\;\n" )
ENDFOREACH() ENDFOREACH()
LIST(APPEND PipelineRegistrationSource "}\n\n" ) LIST(APPEND PipelineRegistrationSource "\n" )
FILE(WRITE ${FileName} ${PipelineRegistrationSource}) FILE(WRITE ${FileName} ${PipelineRegistrationSource})
ENDMACRO(WRITE_PIPELINE_REGISTRATION) ENDMACRO(WRITE_PIPELINE_REGISTRATION)
...@@ -55,15 +54,25 @@ MACRO(PARSE_HEADER_FOR_PIPELINE FileName) ...@@ -55,15 +54,25 @@ MACRO(PARSE_HEADER_FOR_PIPELINE FileName)
SET(NameRegex "[A-Za-z0-9_]+") SET(NameRegex "[A-Za-z0-9_]+")
SET(FullyQualifiedNameRegex "(::)?(${NameRegex}::)*${NameRegex}") SET(FullyQualifiedNameRegex "(::)?(${NameRegex}::)*${NameRegex}")
SET(BaseClassListRegex "((public|private|protected)( virtual)? ${FullyQualifiedNameRegex}, )*") SET(BaseClassListRegex "((public|private|protected)( virtual)? ${FullyQualifiedNameRegex}, )*")
SET(NamespaceRegex "namespace (${NameRegex}) {")
SET(ClassRegex "class (${NameRegex}) ?: ${BaseClassListRegex}public ${FullyQualifiedNameRegex}Pipeline") SET(ClassRegex "class (${NameRegex}) ?: ${BaseClassListRegex}public ${FullyQualifiedNameRegex}Pipeline")
# Find the namespace nesting of this class (very simplified parsing)
SET(FullNamespace "")
STRING(REGEX MATCHALL ${NamespaceRegex} namespaces ${content})
FOREACH(n ${namespaces})
# Extract namespace name and concatenate
STRING(REGEX REPLACE ${NamespaceRegex} "\\1" RESULT ${n})
SET(FullNamespace "${FullNamespace}${RESULT}::")
ENDFOREACH()
# Find all class definitions inheriting from a Pipeline # Find all class definitions inheriting from a Pipeline
STRING(REGEX MATCHALL ${ClassRegex} 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 ${ClassRegex} "\\1" RESULT ${m}) STRING(REGEX REPLACE ${ClassRegex} "\\1" RESULT ${m})
ADD_PIPELINE_REGISTRATION(${FileName} ${RESULT}) ADD_PIPELINE_REGISTRATION(${FileName} "${FullNamespace}${RESULT}")
ENDFOREACH() ENDFOREACH()
ENDMACRO(PARSE_HEADER_FOR_PIPELINE) ENDMACRO(PARSE_HEADER_FOR_PIPELINE)
......
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