mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-22 11:25:45 +00:00
Improve JS Exception handling.
- Check for pending exceptions after function calls and script executions. - Call LOGERROR instead of JS_ReportError when there is a conversion error in FromJSVal, since that can only be called from C++ (where JS errors don't really make sense). Instead, C++ callers of FromJSVal should handle the failure and, themselves, either report an error or simply do something else. - Wrap JS_ReportError since that makes updating it later easier. This isn't a systematical fix since ToJSVal also ought return a boolean for failures, and we probably should trigger errors instead of warnings on 'implicit' conversions, rather a preparation diff. Part of the SM52 migration, stage: SM45 compatible (actually SM52 incompatible, too). Based on a patch by: Itms Comments by: Vladislavbelov, Stan` Refs #742, #4893 Differential Revision: https://code.wildfiregames.com/D3093 This was SVN commit r24187.
This commit is contained in:
@@ -26,7 +26,7 @@ CComponentTypeScript::CComponentTypeScript(const ScriptInterface& scriptInterfac
|
||||
m_ScriptInterface(scriptInterface), m_Instance(scriptInterface.GetJSRuntime(), instance)
|
||||
{
|
||||
// Cache the property detection for efficiency
|
||||
ScriptInterface::Request rq(m_ScriptInterface);
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
|
||||
m_HasCustomSerialize = m_ScriptInterface.HasProperty(m_Instance, "Serialize");
|
||||
m_HasCustomDeserialize = m_ScriptInterface.HasProperty(m_Instance, "Deserialize");
|
||||
@@ -54,7 +54,7 @@ void CComponentTypeScript::Deinit()
|
||||
|
||||
void CComponentTypeScript::HandleMessage(const CMessage& msg, bool global)
|
||||
{
|
||||
ScriptInterface::Request rq(m_ScriptInterface);
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
|
||||
const char* name = global ? msg.GetScriptGlobalHandlerName() : msg.GetScriptHandlerName();
|
||||
|
||||
@@ -70,7 +70,7 @@ void CComponentTypeScript::Serialize(ISerializer& serialize)
|
||||
if (m_HasNullSerialize)
|
||||
return;
|
||||
|
||||
ScriptInterface::Request rq(m_ScriptInterface);
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
|
||||
// Support a custom "Serialize" function, which returns a new object that will be
|
||||
// serialized instead of the component itself
|
||||
@@ -89,7 +89,7 @@ void CComponentTypeScript::Serialize(ISerializer& serialize)
|
||||
|
||||
void CComponentTypeScript::Deserialize(const CParamNode& paramNode, IDeserializer& deserialize, entity_id_t ent)
|
||||
{
|
||||
ScriptInterface::Request rq(m_ScriptInterface);
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
|
||||
m_ScriptInterface.SetProperty(m_Instance, "entity", (int)ent, true, false);
|
||||
m_ScriptInterface.SetProperty(m_Instance, "template", paramNode, true, false);
|
||||
|
||||
Reference in New Issue
Block a user