mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
Add: support for std::string parameters in the script API
This commit is contained in:
parent
98972a0748
commit
77177f7e8b
@ -631,6 +631,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
|||||||
string(APPEND TYPES "a")
|
string(APPEND TYPES "a")
|
||||||
elseif("${PARAM}" MATCHES "^Text")
|
elseif("${PARAM}" MATCHES "^Text")
|
||||||
string(APPEND TYPES ".")
|
string(APPEND TYPES ".")
|
||||||
|
elseif("${PARAM}" MATCHES "^std::string")
|
||||||
|
string(APPEND TYPES ".")
|
||||||
else()
|
else()
|
||||||
string(APPEND TYPES "x")
|
string(APPEND TYPES "x")
|
||||||
endif()
|
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>
|
template <typename Titem>
|
||||||
struct Param<Array<Titem>> {
|
struct Param<Array<Titem>> {
|
||||||
static inline Array<Titem> Get(HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr)
|
static inline Array<Titem> Get(HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user