mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Add ToJSVAL overload template for array of uknown bound
this commit fix and error in HWDetect when the libraries versions use only MAJOR.MINOR like zlib in some linux os that is "1.3" that need char[4] (1.3\0) conversion from Script::ToJSVal. this commit create an overload template that matches "references to array of uknown bound" and forward it to existing const char* / const wchar_t* specializations. this bug was reported by Vantha.
This commit is contained in:
parent
9150c20818
commit
4ef2bb77f2
2 changed files with 11 additions and 34 deletions
|
|
@ -258,40 +258,6 @@ template<> void Script::ToJSVal<const char*>(const ScriptRequest& rq, JS::Mutab
|
|||
ret.setUndefined();
|
||||
}
|
||||
|
||||
#define TOJSVAL_CHAR(N) \
|
||||
template<> void Script::ToJSVal<wchar_t[N]>(const ScriptRequest& rq, JS::MutableHandleValue ret, const wchar_t (&val)[N]) \
|
||||
{ \
|
||||
ToJSVal(rq, ret, static_cast<const wchar_t*>(val)); \
|
||||
} \
|
||||
template<> void Script::ToJSVal<char[N]>(const ScriptRequest& rq, JS::MutableHandleValue ret, const char (&val)[N]) \
|
||||
{ \
|
||||
ToJSVal(rq, ret, static_cast<const char*>(val)); \
|
||||
}
|
||||
|
||||
TOJSVAL_CHAR(3)
|
||||
TOJSVAL_CHAR(5)
|
||||
TOJSVAL_CHAR(6)
|
||||
TOJSVAL_CHAR(7)
|
||||
TOJSVAL_CHAR(8)
|
||||
TOJSVAL_CHAR(9)
|
||||
TOJSVAL_CHAR(10)
|
||||
TOJSVAL_CHAR(11)
|
||||
TOJSVAL_CHAR(12)
|
||||
TOJSVAL_CHAR(13)
|
||||
TOJSVAL_CHAR(14)
|
||||
TOJSVAL_CHAR(15)
|
||||
TOJSVAL_CHAR(16)
|
||||
TOJSVAL_CHAR(17)
|
||||
TOJSVAL_CHAR(18)
|
||||
TOJSVAL_CHAR(19)
|
||||
TOJSVAL_CHAR(20)
|
||||
TOJSVAL_CHAR(24)
|
||||
TOJSVAL_CHAR(29)
|
||||
TOJSVAL_CHAR(33)
|
||||
TOJSVAL_CHAR(35)
|
||||
TOJSVAL_CHAR(256)
|
||||
#undef TOJSVAL_CHAR
|
||||
|
||||
template<> void Script::ToJSVal<CStrW>(const ScriptRequest& rq, JS::MutableHandleValue ret, const CStrW& val)
|
||||
{
|
||||
ToJSVal(rq, ret, static_cast<const std::wstring&>(val));
|
||||
|
|
|
|||
|
|
@ -68,6 +68,17 @@ bool FromJSVal(const ScriptRequest& rq, JS::HandleValue v, std::optional<T>& out
|
|||
*/
|
||||
template<typename T> void ToJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret, T const& val);
|
||||
|
||||
template<std::size_t N>
|
||||
void ToJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret, const char (&val)[N])
|
||||
{
|
||||
ToJSVal(rq, ret, static_cast<const char*>(val));
|
||||
}
|
||||
template<std::size_t N>
|
||||
void ToJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret, const wchar_t (&val)[N])
|
||||
{
|
||||
ToJSVal(rq, ret, static_cast<const wchar_t*>(val));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void ToJSVal<JS::PersistentRootedValue>(const ScriptRequest&, JS::MutableHandleValue handle,
|
||||
const JS::PersistentRootedValue& a)
|
||||
|
|
|
|||
Loading…
Reference in a new issue