version 2.28.1
CMake pip_code_model now accept optional NAME field PIByteArray helpers: * piSerialize * piDeserialize
This commit is contained in:
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
|||||||
project(pip)
|
project(pip)
|
||||||
set(pip_MAJOR 2)
|
set(pip_MAJOR 2)
|
||||||
set(pip_MINOR 28)
|
set(pip_MINOR 28)
|
||||||
set(pip_REVISION 0)
|
set(pip_REVISION 1)
|
||||||
set(pip_SUFFIX )
|
set(pip_SUFFIX )
|
||||||
set(pip_COMPANY SHS)
|
set(pip_COMPANY SHS)
|
||||||
set(pip_DOMAIN org.SHS)
|
set(pip_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[[
|
#[[
|
||||||
|
|
||||||
pip_code_model(<out_var> file0 [file1 ...] [OPTIONS opt0 [opt1 ...] ])
|
pip_code_model(<out_var> file0 [file1 ...] [OPTIONS opt0 [opt1 ...] ] [NAME name])
|
||||||
|
|
||||||
Generate code model files for source files file0 [file1 ...]
|
Generate code model files for source files file0 [file1 ...]
|
||||||
|
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
Relative files pathes read from CMAKE_CURRENT_SOURCE_DIR
|
Relative files pathes read from CMAKE_CURRENT_SOURCE_DIR
|
||||||
You should add ${<out_var>} to your target
|
You should add ${<out_var>} to your target
|
||||||
|
|
||||||
|
If NAME specified then "<name>.h" and "<name>.cpp" files will be generated instead
|
||||||
|
of default "ccm_<PROJECT_NAME>"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,30 +21,32 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
macro(PIP_EXTRACT_OPTIONS _pip_files _pip_options _abs)
|
macro(PIP_EXTRACT_OPTIONS _pip_files _pip_options _name _abs)
|
||||||
set(${_pip_files})
|
set(${_pip_files})
|
||||||
set(${_pip_options})
|
set(${_pip_options})
|
||||||
set(_PIP_DOING_OPTIONS FALSE)
|
set(_cur_opt 0)
|
||||||
foreach(_currentArg ${ARGN})
|
foreach(_currentArg ${ARGN})
|
||||||
if("x${_currentArg}" STREQUAL "xABSOLUTE")
|
if ("x${_currentArg}" STREQUAL "xABSOLUTE")
|
||||||
set(${_abs} TRUE)
|
set(${_abs} TRUE)
|
||||||
else()
|
elseif ("x${_currentArg}" STREQUAL "xOPTIONS")
|
||||||
if("x${_currentArg}" STREQUAL "xOPTIONS")
|
set(_cur_opt 1)
|
||||||
set(_PIP_DOING_OPTIONS TRUE)
|
elseif ("x${_currentArg}" STREQUAL "xNAME")
|
||||||
else()
|
set(_cur_opt 2)
|
||||||
if(_PIP_DOING_OPTIONS)
|
elseif (_cur_opt EQUAL 1)
|
||||||
list(APPEND ${_pip_options} "${_currentArg}")
|
list(APPEND ${_pip_options} "${_currentArg}")
|
||||||
|
elseif (_cur_opt EQUAL 2)
|
||||||
|
set(${_name} "${_currentArg}")
|
||||||
|
set(_cur_opt 0)
|
||||||
else()
|
else()
|
||||||
list(APPEND ${_pip_files} "${_currentArg}")
|
list(APPEND ${_pip_files} "${_currentArg}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(pip_code_model RESULT)
|
macro(pip_code_model RESULT)
|
||||||
PIP_EXTRACT_OPTIONS(CCM_SRC OPTS ABS ${ARGN})
|
set(_name "ccm_${PROJECT_NAME}")
|
||||||
|
PIP_EXTRACT_OPTIONS(CCM_SRC OPTS _name ABS ${ARGN})
|
||||||
#message(STATUS "src = ${CCM_SRC}")
|
#message(STATUS "src = ${CCM_SRC}")
|
||||||
#message(STATUS "result = ${RESULT}")
|
#message(STATUS "result = ${RESULT}")
|
||||||
#message(STATUS "options = \"${CCM_OPTS}\"")
|
#message(STATUS "options = \"${CCM_OPTS}\"")
|
||||||
@@ -50,7 +54,7 @@ macro(pip_code_model RESULT)
|
|||||||
foreach(pi ${PIP_INCLUDES})
|
foreach(pi ${PIP_INCLUDES})
|
||||||
list(APPEND CMG_INCLUDES "-I${pi}")
|
list(APPEND CMG_INCLUDES "-I${pi}")
|
||||||
endforeach()
|
endforeach()
|
||||||
set(CCM_OUT ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME}.cpp)
|
set(CCM_OUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.cpp)
|
||||||
set(${RESULT} ${${RESULT}} ${CCM_OUT})
|
set(${RESULT} ${${RESULT}} ${CCM_OUT})
|
||||||
set(CCM_FILES)
|
set(CCM_FILES)
|
||||||
foreach(csrc ${CCM_SRC})
|
foreach(csrc ${CCM_SRC})
|
||||||
@@ -66,10 +70,10 @@ macro(pip_code_model RESULT)
|
|||||||
endif()
|
endif()
|
||||||
add_custom_command(OUTPUT ${CCM_OUT}
|
add_custom_command(OUTPUT ${CCM_OUT}
|
||||||
COMMAND ${PIP_CMG}
|
COMMAND ${PIP_CMG}
|
||||||
ARGS -q ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME} ${CMG_INCLUDES} ${CCM_FILES}
|
ARGS -q ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${CMG_INCLUDES} ${CCM_FILES}
|
||||||
DEPENDS ${CCM_SRC}
|
DEPENDS ${CCM_SRC}
|
||||||
WORKING_DIRECTORY ${PIP_DLL_DIR}
|
WORKING_DIRECTORY ${PIP_DLL_DIR}
|
||||||
COMMENT "Generating ccm_${PROJECT_NAME}.h, ccm_${PROJECT_NAME}.cpp"
|
COMMENT "Generating ${_name}.h, ${_name}.cpp"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|||||||
@@ -555,10 +555,27 @@ inline PIByteArray & operator >>(PIByteArray & s, T & ) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<> inline uint piHash(const PIByteArray & ba) {return ba.hash();}
|
template<> inline uint piHash(const PIByteArray & ba) {return ba.hash();}
|
||||||
template<> inline void piSwap(PIByteArray & f, PIByteArray & s) {f.swap(s);}
|
template<> inline void piSwap(PIByteArray & f, PIByteArray & s) {f.swap(s);}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T> PIByteArray piSerialize(const T & value) {
|
||||||
|
PIByteArray ret;
|
||||||
|
ret << value;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> T piDeserialize(const PIByteArray & data) {
|
||||||
|
T ret;
|
||||||
|
if (!data.isEmpty()) {
|
||||||
|
PIByteArray ba(data);
|
||||||
|
ba >> ret;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#undef _TYPENAME_
|
#undef _TYPENAME_
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user