Changeset View
Changeset View
Standalone View
Standalone View
source/gui/scripting/GuiScriptConversions.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* The color depends on the predefined color database stored in the current GUI page. | * The color depends on the predefined color database stored in the current GUI page. | ||||
*/ | */ | ||||
template<> bool ScriptInterface::FromJSVal<CGUIColor>(JSContext* cx, JS::HandleValue v, CGUIColor& out) = delete; | template<> bool ScriptInterface::FromJSVal<CGUIColor>(JSContext* cx, JS::HandleValue v, CGUIColor& out) = delete; | ||||
template<> void ScriptInterface::ToJSVal<CSize>(JSContext* cx, JS::MutableHandleValue ret, const CSize& val) | template<> void ScriptInterface::ToJSVal<CSize>(JSContext* cx, JS::MutableHandleValue ret, const CSize& val) | ||||
{ | { | ||||
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(ret, "width", val.cx, "height", val.cy); | CreateObject(cx, ret, "width", val.cx, "height", val.cy); | ||||
} | } | ||||
template<> bool ScriptInterface::FromJSVal<CSize>(JSContext* cx, JS::HandleValue v, CSize& out) | template<> bool ScriptInterface::FromJSVal<CSize>(JSContext* cx, JS::HandleValue v, CSize& out) | ||||
{ | { | ||||
if (!v.isObject()) | if (!v.isObject()) | ||||
{ | { | ||||
JS_ReportError(cx, "CSize value must be an object!"); | JS_ReportError(cx, "CSize value must be an object!"); | ||||
return false; | return false; | ||||
Show All 11 Lines | if (!FromJSProperty(cx, v, "height", out.cy)) | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
template<> void ScriptInterface::ToJSVal<CPos>(JSContext* cx, JS::MutableHandleValue ret, const CPos& val) | template<> void ScriptInterface::ToJSVal<CPos>(JSContext* cx, JS::MutableHandleValue ret, const CPos& val) | ||||
{ | { | ||||
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(ret, "x", val.x, "y", val.y); | CreateObject(cx, ret, "x", val.x, "y", val.y); | ||||
} | } | ||||
template<> bool ScriptInterface::FromJSVal<CPos>(JSContext* cx, JS::HandleValue v, CPos& out) | template<> bool ScriptInterface::FromJSVal<CPos>(JSContext* cx, JS::HandleValue v, CPos& out) | ||||
{ | { | ||||
if (!v.isObject()) | if (!v.isObject()) | ||||
{ | { | ||||
JS_ReportError(cx, "CPos value must be an object!"); | JS_ReportError(cx, "CPos value must be an object!"); | ||||
return false; | return false; | ||||
Show All 11 Lines | if (!FromJSProperty(cx, v, "y", out.y)) | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
template<> void ScriptInterface::ToJSVal<CRect>(JSContext* cx, JS::MutableHandleValue ret, const CRect& val) | template<> void ScriptInterface::ToJSVal<CRect>(JSContext* cx, JS::MutableHandleValue ret, const CRect& val) | ||||
{ | { | ||||
ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject( | CreateObject( | ||||
cx, | |||||
ret, | ret, | ||||
"left", val.left, | "left", val.left, | ||||
"right", val.right, | "right", val.right, | ||||
"top", val.top, | "top", val.top, | ||||
"bottom", val.bottom); | "bottom", val.bottom); | ||||
} | } | ||||
template<> void ScriptInterface::ToJSVal<CClientArea>(JSContext* cx, JS::MutableHandleValue ret, const CClientArea& val) | template<> void ScriptInterface::ToJSVal<CClientArea>(JSContext* cx, JS::MutableHandleValue ret, const CClientArea& val) | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator