Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/scripting/MessageTypeConversions.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 35 Lines | #define GET_MSG_PROPERTY(type, name) \ | ||||
type name; \ | type name; \ | ||||
{ \ | { \ | ||||
if (! JS_GetProperty(rq.cx, obj, #name, &prop)) \ | if (! JS_GetProperty(rq.cx, obj, #name, &prop)) \ | ||||
return NULL; \ | return NULL; \ | ||||
if (! Script::FromJSVal(rq, prop, name)) \ | if (! Script::FromJSVal(rq, prop, name)) \ | ||||
return NULL; \ | return NULL; \ | ||||
} | } | ||||
JS::Value CMessage::ToJSValCached(const ScriptInterface& scriptInterface) const | JS::Value CMessage::ToJSValCached(const ScriptRequest& rq, const ScriptInterface& scriptInterface) const | ||||
{ | { | ||||
ScriptRequest rq(scriptInterface); | |||||
if (!m_Cached) | if (!m_Cached) | ||||
m_Cached.reset(new JS::PersistentRootedValue(rq.cx, ToJSVal(scriptInterface))); | m_Cached.reset(new JS::PersistentRootedValue(rq.cx, ToJSVal(scriptInterface))); | ||||
return m_Cached->get(); | return m_Cached->get(); | ||||
} | } | ||||
//////////////////////////////// | //////////////////////////////// | ||||
▲ Show 20 Lines • Show All 518 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator