mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Deduplicate namespace opening in squirrel-exporter
parent
e0d8158957
commit
6482e16564
|
@ -25,6 +25,13 @@ macro(dump_fileheader)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(open_namespace)
|
||||||
|
if(NOT NAMESPACE_OPENED)
|
||||||
|
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||||
|
set(NAMESPACE_OPENED TRUE)
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
macro(dump_class_templates NAME)
|
macro(dump_class_templates NAME)
|
||||||
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
||||||
|
|
||||||
|
@ -305,32 +312,16 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
|
|
||||||
if("${APIUC}" STREQUAL "Template")
|
if("${APIUC}" STREQUAL "Template")
|
||||||
# First check whether we have enums to print
|
|
||||||
if(DEFINED ENUMS)
|
|
||||||
if(NOT NAMESPACE_OPENED)
|
|
||||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
|
||||||
set(NAMESPACE_OPENED TRUE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Then check whether we have structs/classes to print
|
# Then check whether we have structs/classes to print
|
||||||
if(DEFINED STRUCTS)
|
if(DEFINED STRUCTS)
|
||||||
if(NOT NAMESPACE_OPENED)
|
open_namespace()
|
||||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
|
||||||
set(NAMESPACE_OPENED TRUE)
|
|
||||||
endif()
|
|
||||||
string(APPEND SQUIRREL_EXPORT "\n\t/* Allow inner classes/structs to be used as Squirrel parameters */")
|
string(APPEND SQUIRREL_EXPORT "\n\t/* Allow inner classes/structs to be used as Squirrel parameters */")
|
||||||
foreach(STRUCT IN LISTS STRUCTS)
|
foreach(STRUCT IN LISTS STRUCTS)
|
||||||
dump_class_templates(${STRUCT})
|
dump_class_templates(${STRUCT})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT NAMESPACE_OPENED)
|
open_namespace()
|
||||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
|
||||||
set(NAMESPACE_OPENED TRUE)
|
|
||||||
else()
|
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
|
||||||
endif()
|
|
||||||
string(APPEND SQUIRREL_EXPORT "\n\t/* Allow ${CLS} to be used as Squirrel parameter */")
|
string(APPEND SQUIRREL_EXPORT "\n\t/* Allow ${CLS} to be used as Squirrel parameter */")
|
||||||
dump_class_templates(${CLS})
|
dump_class_templates(${CLS})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue