mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 14:24:43 +00:00
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2011 Wildfire Games.
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -90,6 +90,16 @@ template<> bool ScriptInterface::FromJSVal<u16>(JSContext* cx, jsval v, u16& out
|
||||
return true;
|
||||
}
|
||||
|
||||
template<> bool ScriptInterface::FromJSVal<u8>(JSContext* cx, jsval v, u8& out)
|
||||
{
|
||||
uint16 ret;
|
||||
WARN_IF_NOT(JSVAL_IS_NUMBER(v), v);
|
||||
if (!JS_ValueToUint16(cx, v, &ret))
|
||||
return false;
|
||||
out = (u8)ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
// NOTE: we can't define a jsval specialisation, because that conflicts with integer types
|
||||
template<> bool ScriptInterface::FromJSVal<CScriptVal>(JSContext* UNUSED(cx), jsval v, CScriptVal& out)
|
||||
{
|
||||
@@ -196,6 +206,11 @@ template<> jsval ScriptInterface::ToJSVal<u16>(JSContext* UNUSED(cx), const u16&
|
||||
return INT_TO_JSVAL(val);
|
||||
}
|
||||
|
||||
template<> jsval ScriptInterface::ToJSVal<u8>(JSContext* UNUSED(cx), const u8& val)
|
||||
{
|
||||
return INT_TO_JSVAL(val);
|
||||
}
|
||||
|
||||
template<> jsval ScriptInterface::ToJSVal<u32>(JSContext* cx, const u32& val)
|
||||
{
|
||||
if (val <= JSVAL_INT_MAX)
|
||||
|
||||
Reference in New Issue
Block a user