Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/scripting/MessageTypeConversions.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | #define GET_MSG_PROPERTY(type, name) \ | ||||
if (! JS_GetProperty(cx, obj, #name, &prop)) \ | if (! JS_GetProperty(cx, obj, #name, &prop)) \ | ||||
return NULL; \ | return NULL; \ | ||||
if (! ScriptInterface::FromJSVal(cx, prop, name)) \ | if (! ScriptInterface::FromJSVal(cx, prop, name)) \ | ||||
return NULL; \ | return NULL; \ | ||||
} | } | ||||
JS::Value CMessage::ToJSValCached(const ScriptInterface& scriptInterface) const | JS::Value CMessage::ToJSValCached(const ScriptInterface& scriptInterface) const | ||||
{ | { | ||||
if (!m_Cached) | if (!m_Cached.initialized()) | ||||
m_Cached.reset(new JS::PersistentRootedValue(scriptInterface.GetJSRuntime(), ToJSVal(scriptInterface))); | m_Cached.init(scriptInterface.GetJSRuntime(), ToJSVal(scriptInterface)); | ||||
return m_Cached->get(); | return m_Cached; | ||||
} | } | ||||
//////////////////////////////// | //////////////////////////////// | ||||
JS::Value CMessageTurnStart::ToJSVal(const ScriptInterface& scriptInterface) const | JS::Value CMessageTurnStart::ToJSVal(const ScriptInterface& scriptInterface) const | ||||
{ | { | ||||
TOJSVAL_SETUP(); | TOJSVAL_SETUP(); | ||||
return JS::ObjectValue(*obj); | return JS::ObjectValue(*obj); | ||||
▲ Show 20 Lines • Show All 499 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator