Commit 8c3afc04 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

parent 7037c152
...@@ -205,8 +205,8 @@ endif() ...@@ -205,8 +205,8 @@ endif()
# -- utility functions --------------------------------------------------------- # -- utility functions ---------------------------------------------------------
# adds a consistency check that verifies that `cpp_file` is still valid by # generates the implementation file for the enum that contains to_string,
# re-generating the file and comparing it to the existing file # from_string and from_integer
function(caf_add_enum_type target enum_name) function(caf_add_enum_type target enum_name)
string(REPLACE "." "/" path "${enum_name}") string(REPLACE "." "/" path "${enum_name}")
set(hpp_file "${CMAKE_CURRENT_SOURCE_DIR}/caf/${path}.hpp") set(hpp_file "${CMAKE_CURRENT_SOURCE_DIR}/caf/${path}.hpp")
......
# seeks the beginning of the enum while also keeping track of namespaces # seeks the beginning of the enum while also keeping track of namespaces
macro(seek_mode) macro(seek_enum_mode)
if(line MATCHES "^namespace ") if(line MATCHES "^namespace ")
string(REGEX REPLACE "^namespace ([a-zA-Z0-9:_]+).*$" "\\1" tmp "${line}") string(REGEX REPLACE "^namespace ([a-zA-Z0-9:_]+).*$" "\\1" tmp "${line}")
list(APPEND namespaces "${tmp}") list(APPEND namespaces "${tmp}")
...@@ -11,12 +11,12 @@ macro(seek_mode) ...@@ -11,12 +11,12 @@ macro(seek_mode)
set(is_enum_class TRUE) set(is_enum_class TRUE)
endif() endif()
string(REGEX REPLACE "^enum (class )?([0-9a-zA-Z_]+).*$" "\\2" enum_name "${line}") string(REGEX REPLACE "^enum (class )?([0-9a-zA-Z_]+).*$" "\\2" enum_name "${line}")
set(mode "scan") set(mode "read_values")
endif() endif()
endmacro() endmacro()
# scans the input for case labels # scans the input for enum values
macro(scan_mode) macro(read_values_mode)
if(line MATCHES "^}") if(line MATCHES "^}")
set(mode "generate") set(mode "generate")
elseif(line MATCHES "^[0-9a-zA-Z_]+") elseif(line MATCHES "^[0-9a-zA-Z_]+")
...@@ -107,14 +107,14 @@ function(main) ...@@ -107,14 +107,14 @@ function(main)
set(enum_values "") set(enum_values "")
set(is_enum_class FALSE) set(is_enum_class FALSE)
file(STRINGS "${INPUT_FILE}" lines) file(STRINGS "${INPUT_FILE}" lines)
set(mode "seek") set(mode "seek_enum")
foreach(line IN LISTS lines) foreach(line IN LISTS lines)
string(REGEX REPLACE "^(.+)(//.*)?" "\\1" line "${line}") string(REGEX REPLACE "^(.+)(//.*)?" "\\1" line "${line}")
string(STRIP "${line}" line) string(STRIP "${line}" line)
if(mode STREQUAL seek) if(mode STREQUAL seek_enum)
seek_mode() seek_enum_mode()
elseif(mode STREQUAL scan) elseif(mode STREQUAL read_values)
scan_mode() read_values_mode()
else() else()
# reached the end # reached the end
if(NOT enum_name) if(NOT enum_name)
......
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