Add: support for std::string parameters in the script API

pull/562/head
Rubidium 1 year ago committed by rubidium42
parent 98972a0748
commit 77177f7e8b

@ -631,6 +631,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
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()

@ -91,6 +91,20 @@ namespace SQConvert {
}
};
template <> struct Param<const std::string &> {
static inline const std::string Get(HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr)
{
/* Convert what-ever there is as parameter to a string */
sq_tostring(vm, index);
const SQChar *tmp;
sq_getstring(vm, -1, &tmp);
std::string result = StrMakeValid(tmp);
sq_poptop(vm);
return result;
}
};
template <typename Titem>
struct Param<Array<Titem>> {
static inline Array<Titem> Get(HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr)

Loading…
Cancel
Save