1
0
Fork 0

Codechange: Make the squirrel-exporter skip function bodies.

pull/14051/head
frosch 2025-04-20 14:11:06 +02:00 committed by frosch
parent 26de3404a4
commit 6256b55671
1 changed files with 14 additions and 1 deletions

View File

@ -68,6 +68,7 @@ macro(reset_reader)
unset(START_SQUIRREL_DEFINE_ON_NEXT_LINE)
set(CLS_LEVEL 0)
unset(CLS_IN_API)
set(BRACE_LEVEL 0)
endmacro()
reset_reader()
@ -539,6 +540,14 @@ foreach(LINE IN LISTS SOURCE_LINES)
continue()
endif()
# Count braces to skip function bodies
string(REGEX REPLACE "[^{]" "" OPENING_BRACES "${LINE}")
string(LENGTH "${OPENING_BRACES}" OPENING_BRACES)
string(REGEX REPLACE "[^}]" "" CLOSING_BRACES "${LINE}")
string(LENGTH "${CLOSING_BRACES}" CLOSING_BRACES)
set(OLD_BRACE_LEVEL "${BRACE_LEVEL}")
math(EXPR BRACE_LEVEL "${BRACE_LEVEL} + ${OPENING_BRACES} - ${CLOSING_BRACES}")
# Add enums
if(IN_ENUM)
string(REGEX MATCH "([^, ]+)" ENUM_VALUE "${LINE}")
@ -567,6 +576,10 @@ foreach(LINE IN LISTS SOURCE_LINES)
continue()
endif()
if(OLD_BRACE_LEVEL)
continue()
endif()
# Add a const (non-enum) value
if("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
list(APPEND CONST_VALUES "${CMAKE_MATCH_1}")
@ -591,7 +604,7 @@ foreach(LINE IN LISTS SOURCE_LINES)
endif()
unset(IS_STATIC)
if("${LINE}" MATCHES "static")
if("${LINE}" MATCHES "static ")
set(IS_STATIC TRUE)
endif()