Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/scripting/GuiScriptConversions.cpp
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | if (v.isString()) | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
// Parse as object | // Parse as object | ||||
return FromJSVal<CColor>(cx, v, out); | return FromJSVal<CColor>(cx, v, out); | ||||
} | } | ||||
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); | |||||
} | |||||
template<> bool ScriptInterface::FromJSVal<CSize>(JSContext* cx, JS::HandleValue v, CSize& out) | |||||
{ | |||||
if (!v.isObject()) | |||||
{ | |||||
JS_ReportError(cx, "CSize value must be an object!"); | |||||
return false; | |||||
} | |||||
if (!FromJSProperty(cx, v, "width", out.cx)) | |||||
{ | |||||
JS_ReportError(cx, "Failed to get CSize.cx property"); | |||||
return false; | |||||
} | |||||
if (!FromJSProperty(cx, v, "height", out.cy)) | |||||
{ | |||||
JS_ReportError(cx, "Failed to get CSize.cy property"); | |||||
return false; | |||||
} | |||||
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); | ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface->CreateObject(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()) | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator