Skip to content

Commit

Permalink
STYLE: Inlined macro that was called once.
Browse files Browse the repository at this point in the history
the itk_wrap_submodule_all_generators macro is only called in
one file. By moving its code inline, the itk_load_submodule
macro becomes more readable.

itk_wrap_submodule_castxml was only called in one place
move its body inline to improve readability.

itk_wrap_submodule_swig_interface was only called in one place
it body was moved inline in itk_load_submodule for readability.

itk_wrap_submodule_DOC was only called in one place. Its body
was moved inline in itk_load_submodule for readability.

itk_wrap_include_all_generators was only called in one place.
Its body was moved into the itk_wrap_include macro.

itk_wrap_include_castxml and itk_wrap_include_swig_interface were
only called once. Their bodies were moved into the
itk_wrap_include macro.

itk_wrap_module_all_generators was only called in one place.
Its body was moved directly into the itk_wrap_module macro.

itk_wrap_module_swig_interface and itk_wrap_module_DOC contained
little code and were only called once. Their bodies were moved into
the itk_wrap_module macro.
  • Loading branch information
kian-weimer authored and hjmjohnson committed Mar 10, 2022
1 parent 00ac6f4 commit 38e30bc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 92 deletions.
41 changes: 0 additions & 41 deletions Wrapping/Generators/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
###############################################################################
# the macros in charge of dispatching to the language specific macros

macro(itk_wrap_module_all_generators library_name)
if(${module_prefix}_WRAP_CASTXML)
itk_wrap_module_castxml("${library_name}")
endif()
if(${module_prefix}_WRAP_SWIGINTERFACE)
itk_wrap_module_swig_interface("${library_name}")
endif()
if(${module_prefix}_WRAP_DOC)
itk_wrap_module_DOC("${library_name}")
endif()
if(${module_prefix}_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_module_python("${library_name}")
endif()
endmacro()


macro(itk_wrap_submodule_all_generators module)
if(${module_prefix}_WRAP_CASTXML)
itk_wrap_submodule_castxml("${module}")
endif()
if(${module_prefix}_WRAP_SWIGINTERFACE)
itk_wrap_submodule_swig_interface("${module}")
endif()
if(${module_prefix}_WRAP_DOC)
itk_wrap_submodule_DOC("${module}")
endif()
if(${module_prefix}_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_submodule_python("${module}" "${WRAPPER_LIBRARY_NAME}")
endif()
endmacro()


macro(itk_wrap_named_class_all_generators class swig_name)
if(${module_prefix}_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_named_class_python("${class}" "${swig_name}")
Expand All @@ -54,15 +22,6 @@ macro(itk_wrap_named_simple_class_all_generators class)
endmacro()


macro(itk_wrap_include_all_generators inc)
if(${module_prefix}_WRAP_CASTXML)
itk_wrap_include_castxml("${inc}")
endif()
if(${module_prefix}_WRAP_SWIGINTERFACE)
itk_wrap_include_swig_interface("${inc}")
endif()
endmacro()

macro(itk_wrap_template_all_generators name types)
if(${module_prefix}_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_template_python("${name}" "${types}")
Expand Down
16 changes: 0 additions & 16 deletions Wrapping/Generators/CastXML/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,12 @@ mark_as_advanced(CASTXML_EXECUTABLE)
set(ITK_WRAP_CASTXML_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "castxml source dir")


macro(itk_wrap_include_castxml include_file)
if("${include_file}" MATCHES "<.*>")
set(CASTXML_INCLUDES "${CASTXML_INCLUDES}#include ${include_file}\n")
else()
set(CASTXML_INCLUDES "${CASTXML_INCLUDES}#include \"${include_file}\"\n")
endif()
endmacro()


macro(itk_wrap_simple_type_castxml wrap_class swig_name)
set(CASTXML_TYPEDEFS "${CASTXML_TYPEDEFS} typedef ${wrap_class} ${swig_name};\n")
set(CASTXML_FORCE_INSTANTIATE "${CASTXML_FORCE_INSTANTIATE} (void)sizeof(${swig_name});\n")
endmacro()


macro(itk_wrap_submodule_castxml module)
# clear the typedefs and the includes
set(CASTXML_TYPEDEFS )
set(CASTXML_INCLUDES )
set(CASTXML_FORCE_INSTANTIATE )
endmacro()

macro(itk_end_wrap_submodule_castxml module)
# write the wrap_*.cxx file
#
Expand Down
11 changes: 0 additions & 11 deletions Wrapping/Generators/Doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ find_package(Doxygen REQUIRED)
set(ITK_WRAP_DOC_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "doc source dir")
set(ITK_WRAP_DOC_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "doc binary dir")

###############################################################################
macro(itk_wrap_module_DOC library_name)
set(ITK_WRAP_DOC_DOXYGEN_HEADERS ) # doxygen headers to process in this lib
set(ITK_WRAP_DOC_DOXYGEN_XML_FILES ) # xml files produced by doxygen in this lib
set(ITK_WRAP_DOC_DOCSTRING_FILES ) # swig docstring files produced by doxygen in this lib
endmacro()


###############################################################################
macro(itk_wrap_named_class_DOC class swig_name)
if("${WRAPPER_WRAP_METHOD}" STREQUAL "ENUM")
Expand Down Expand Up @@ -86,9 +78,6 @@ macro(itk_end_wrap_module_DOC)
)
endmacro()

macro(itk_wrap_submodule_DOC module)
set(ITK_WRAP_DOC_DOXY2SWIG_INPUT ) # the c++ name - swig names definitions
endmacro()

###############################################################################
# This macro is called once per module
Expand Down
21 changes: 0 additions & 21 deletions Wrapping/Generators/SwigInterface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,6 @@ set(ITK_WRAP_SWIGINTERFACE_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERN
set(WRAPPER_MASTER_INDEX_OUTPUT_DIR "${ITK_DIR}/Wrapping/Typedefs" CACHE INTERNAL "typedefs dir")
set(IGENERATOR "${CMAKE_CURRENT_SOURCE_DIR}/igenerator.py" CACHE INTERNAL "igenerator.py path" FORCE)

macro(itk_wrap_module_swig_interface library_name)
# store the content of the mdx file
set(SWIG_INTERFACE_MDX_CONTENT )
# store the content of the .i file for the module - a set of import of all the .i files generated for the module
set(SWIG_INTERFACE_MODULE_CONTENT )
# build a list of modules to create the igenerator custom command
set(SWIG_INTERFACE_MODULES )
endmacro()


macro(itk_wrap_include_swig_interface include_file)
list(APPEND SWIG_INTERFACE_INCLUDES ${include_file})
endmacro()


macro(itk_wrap_submodule_swig_interface module)
# store the content of the SwigInterface.h files - a set of #includes for that module
set(SWIG_INTERFACE_INCLUDES )
# typedefs for swig
set(SWIG_INTERFACE_TYPEDEFS )
endmacro()

macro(itk_end_wrap_submodule_swig_interface module)
# Global variables used:
Expand Down
54 changes: 51 additions & 3 deletions Wrapping/TypedefMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,28 @@ macro(itk_wrap_module library_name)
endif()

# Call the language support initialization function
itk_wrap_module_all_generators("${library_name}")
if(${module_prefix}_WRAP_CASTXML)
itk_wrap_module_castxml("${library_name}")
endif()

if(${module_prefix}_WRAP_SWIGINTERFACE)
# store the content of the mdx file
set(SWIG_INTERFACE_MDX_CONTENT )
# store the content of the .i file for the module - a set of import of all the .i files generated for the module
set(SWIG_INTERFACE_MODULE_CONTENT )
# build a list of modules to create the igenerator custom command
set(SWIG_INTERFACE_MODULES )
endif()

if(${module_prefix}_WRAP_DOC)
set(ITK_WRAP_DOC_DOXYGEN_HEADERS ) # doxygen headers to process in this lib
set(ITK_WRAP_DOC_DOXYGEN_XML_FILES ) # xml files produced by doxygen in this lib
set(ITK_WRAP_DOC_DOCSTRING_FILES ) # swig docstring files produced by doxygen in this lib
endif()

if(${module_prefix}_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_module_python("${library_name}")
endif()
endmacro()


Expand Down Expand Up @@ -562,7 +582,24 @@ macro(itk_load_submodule module)
endif()

# call generators specific macros which set several associated global variables
itk_wrap_submodule_all_generators("${module}")
if(${module_prefix}_WRAP_CASTXML)
# clear the typedefs and the includes
set(CASTXML_TYPEDEFS )
set(CASTXML_INCLUDES )
set(CASTXML_FORCE_INSTANTIATE )
endif()
if(${module_prefix}_WRAP_SWIGINTERFACE)
# store the content of the SwigInterface.h files - a set of #includes for that module
set(SWIG_INTERFACE_INCLUDES )
# typedefs for swig
set(SWIG_INTERFACE_TYPEDEFS )
endif()
if(${module_prefix}_WRAP_DOC)
set(ITK_WRAP_DOC_DOXY2SWIG_INPUT ) # the c++ name - swig names definitions
endif()
if(${module_prefix}_WRAP_PYTHON AND WRAPPER_LIBRARY_PYTHON)
itk_wrap_submodule_python("${module}" "${WRAPPER_LIBRARY_NAME}")
endif()

# WRAPPER_INCLUDE_FILES: contains a list of all files to include in the final cxx file
set(WRAPPER_INCLUDE_FILES )
Expand Down Expand Up @@ -871,12 +908,23 @@ macro(itk_wrap_include include_file)
${WRAPPER_INCLUDE_FILES}
${include_file}
)
itk_wrap_include_all_generators("${include_file}")

if(${module_prefix}_WRAP_CASTXML)
if("${include_file}" MATCHES "<.*>")
set(CASTXML_INCLUDES "${CASTXML_INCLUDES}#include ${include_file}\n")
else()
set(CASTXML_INCLUDES "${CASTXML_INCLUDES}#include \"${include_file}\"\n")
endif()
endif()
if(${module_prefix}_WRAP_SWIGINTERFACE)
list(APPEND SWIG_INTERFACE_INCLUDES ${include_file})
endif()
endif()

unset(already_included)
endmacro()


macro(itk_end_wrap_class)
# Parse through the list of WRAPPER_TEMPLATES set up by the macros at the bottom
# of this file, turning them into proper C++ type definitions suitable for
Expand Down

0 comments on commit 38e30bc

Please sign in to comment.