mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 02:19:41 +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")
|
||||
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…
Reference in New Issue
Block a user