|
|
|
|
@@ -28,25 +28,27 @@ endmacro()
|
|
|
|
|
macro(dump_class_templates NAME)
|
|
|
|
|
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
|
|
|
|
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} *GetParam(ForceType<${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return (${NAME} *)instance; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} &GetParam(ForceType<${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return *(${NAME} *)instance; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} *GetParam(ForceType<const ${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return (${NAME} *)instance; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} &GetParam(ForceType<const ${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return *(${NAME} *)instance; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Param<${NAME} *> { static inline ${NAME} *Get(HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return (${NAME} *)instance; } };")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Param<${NAME} &> { static inline ${NAME} &Get(HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return *(${NAME} *)instance; } };")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Param<const ${NAME} *> { static inline const ${NAME} *Get(HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return (${NAME} *)instance; } };")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Param<const ${NAME} &> { static inline const ${NAME} &Get(HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return *(${NAME} *)instance; } };")
|
|
|
|
|
if("${NAME}" STREQUAL "ScriptEvent")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Return<${NAME} *> { static inline int Set(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; } };")
|
|
|
|
|
elseif("${NAME}" STREQUAL "ScriptText")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline Text *GetParam(ForceType<Text *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n if (sq_gettype(vm, index) == OT_INSTANCE) {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n return GetParam(ForceType<ScriptText *>(), vm, index, ptr);")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Param<Text *> {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n static inline Text *Get(HSQUIRRELVM vm, int index) {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n if (sq_gettype(vm, index) == OT_INSTANCE) {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n return Param<ScriptText *>::Get(vm, index);")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n if (sq_gettype(vm, index) == OT_STRING) {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n return new RawText(Param<const std::string &>::Get(vm, index));")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n return nullptr;")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n if (sq_gettype(vm, index) == OT_STRING) {")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n return new RawText(GetParam(ForceType<const char *>(), vm, index, ptr));")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n return nullptr;")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n };")
|
|
|
|
|
else()
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Return<${NAME} *> { static inline int Set(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; } };")
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
@@ -69,13 +71,23 @@ reset_reader()
|
|
|
|
|
|
|
|
|
|
file(STRINGS "${SCRIPT_API_FILE}" SOURCE_LINES)
|
|
|
|
|
|
|
|
|
|
set(NUM_LINE 0)
|
|
|
|
|
macro(doxygen_check)
|
|
|
|
|
if(NOT "${DOXYGEN_SKIP}" STREQUAL "")
|
|
|
|
|
message(FATAL_ERROR "${SCRIPT_API_FILE}:${NUM_LINE}: a DOXYGEN_API block was not properly closed")
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
foreach(LINE IN LISTS SOURCE_LINES)
|
|
|
|
|
math(EXPR NUM_LINE "${NUM_LINE} + 1")
|
|
|
|
|
# Ignore special doxygen blocks
|
|
|
|
|
if("${LINE}" MATCHES "^#ifndef DOXYGEN_API")
|
|
|
|
|
doxygen_check()
|
|
|
|
|
set(DOXYGEN_SKIP "next")
|
|
|
|
|
continue()
|
|
|
|
|
endif()
|
|
|
|
|
if("${LINE}" MATCHES "^#ifdef DOXYGEN_API")
|
|
|
|
|
doxygen_check()
|
|
|
|
|
set(DOXYGEN_SKIP "true")
|
|
|
|
|
continue()
|
|
|
|
|
endif()
|
|
|
|
|
@@ -84,10 +96,10 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|
|
|
|
continue()
|
|
|
|
|
endif()
|
|
|
|
|
if("${LINE}" MATCHES "^#else")
|
|
|
|
|
if("${DOXYGEN_SKIP}" STREQUAL "next")
|
|
|
|
|
if(DOXYGEN_SKIP STREQUAL "next")
|
|
|
|
|
set(DOXYGEN_SKIP "true")
|
|
|
|
|
else()
|
|
|
|
|
unset(DOXYGEN_SKIP)
|
|
|
|
|
elseif(DOXYGEN_SKIP STREQUAL "true")
|
|
|
|
|
set(DOXYGEN_SKIP "false")
|
|
|
|
|
endif()
|
|
|
|
|
continue()
|
|
|
|
|
endif()
|
|
|
|
|
@@ -297,8 +309,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|
|
|
|
endif()
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n /* Allow enums to be used as Squirrel parameters */")
|
|
|
|
|
foreach(ENUM IN LISTS ENUMS)
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${ENUM} GetParam(ForceType<${ENUM}>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (${ENUM})tmp; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${ENUM}>(HSQUIRRELVM vm, ${ENUM} res) { sq_pushinteger(vm, (int32)res); return 1; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Param<${ENUM}> { static inline ${ENUM} Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (${ENUM})tmp; } };")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n template <> struct Return<${ENUM}> { static inline int Set(HSQUIRRELVM vm, ${ENUM} res) { sq_pushinteger(vm, res); return 1; } };")
|
|
|
|
|
endforeach()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
@@ -330,13 +342,13 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ST_${APIUC}>() { return \"${API_CLS}\"; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ScriptType::${APIUC}>() { return \"${API_CLS}\"; }")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n")
|
|
|
|
|
|
|
|
|
|
# Then do the registration functions of the class.
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\nvoid SQ${API_CLS}_Register(Squirrel *engine)")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n{")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ST_${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ScriptType::${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
|
|
|
|
if("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
|
|
|
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine);")
|
|
|
|
|
else()
|
|
|
|
|
@@ -625,10 +637,12 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|
|
|
|
string(APPEND TYPES "p")
|
|
|
|
|
elseif("${PARAM}" MATCHES "^Array")
|
|
|
|
|
string(APPEND TYPES "a")
|
|
|
|
|
elseif("${PARAM}" MATCHES "^struct Array")
|
|
|
|
|
elseif("${PARAM}" MATCHES "^const Array")
|
|
|
|
|
string(APPEND TYPES "a")
|
|
|
|
|
elseif("${PARAM}" MATCHES "^Text")
|
|
|
|
|
string(APPEND TYPES ".")
|
|
|
|
|
elseif("${PARAM}" MATCHES "^std::string")
|
|
|
|
|
string(APPEND TYPES ".")
|
|
|
|
|
else()
|
|
|
|
|
string(APPEND TYPES "x")
|
|
|
|
|
endif()
|
|
|
|
|
@@ -664,4 +678,6 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
doxygen_check()
|
|
|
|
|
|
|
|
|
|
configure_file(${SCRIPT_API_SOURCE_FILE} ${SCRIPT_API_BINARY_FILE})
|
|
|
|
|
|