mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Move Script* classes to Script namespace
- Rename ScriptEngine, ScriptContext, ScriptInterface, ScriptRequest to
Script::Engine, Script::Context, Script::Interface, Script::Request
- Remove 'Script' prefix from filenames:
ScriptContext.* → Context.*
ScriptInterface.* → Interface.*
ScriptRequest.* → Request.*
ScriptEngine.* → Engine.*
ScriptConversions.* → Conversions.*
ScriptExceptions.* → Exceptions.*
ScriptForward.* → ForwardDeclarations.*
ScriptStats.* → Stats.*
- Update all includes, forward declarations, and friend classes
- Use namespace Script { ... } in .cpp definitions to avoid repetitive
Script:: prefix (keeping global callbacks outside)
- Rename internal implementation structs:
ScriptInterface_impl → Interface_impl
ScriptFunction → Function
- Update copyright year to 2026 in all touched files
- Suppress pre-existing cppcheck warnings (uninitvar, nullPointer, unknown
macro) by adding them to suppressions-list.txt (these are not caused
by this refactor)
Fixes #7516
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "network/NetMessage.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "scriptinterface/JSON.h"
|
||||
#include "scriptinterface/ScriptRequest.h"
|
||||
#include "scriptinterface/Request.h"
|
||||
#include "simulation2/serialization/BinarySerializer.h"
|
||||
#include "simulation2/serialization/StdDeserializer.h"
|
||||
#include "simulation2/serialization/StdSerializer.h"
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
class ScriptInterface;
|
||||
namespace Script { class Interface; }
|
||||
|
||||
class CBufferBinarySerializerImpl
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
class CBufferBinarySerializer : public CBinarySerializer<CBufferBinarySerializerImpl>
|
||||
{
|
||||
public:
|
||||
CBufferBinarySerializer(const ScriptInterface& scriptInterface, u8* buffer) :
|
||||
CBufferBinarySerializer(const Script::Interface& scriptInterface, u8* buffer) :
|
||||
CBinarySerializer<CBufferBinarySerializerImpl>(scriptInterface, buffer)
|
||||
{
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
class CLengthBinarySerializer : public CBinarySerializer<CLengthBinarySerializerImpl>
|
||||
{
|
||||
public:
|
||||
CLengthBinarySerializer(const ScriptInterface& scriptInterface) :
|
||||
CLengthBinarySerializer(const Script::Interface& scriptInterface) :
|
||||
CBinarySerializer<CLengthBinarySerializerImpl>(scriptInterface)
|
||||
{
|
||||
}
|
||||
@@ -116,18 +116,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
CSimulationMessage::CSimulationMessage(const ScriptInterface& scriptInterface) :
|
||||
CSimulationMessage::CSimulationMessage(const Script::Interface& scriptInterface) :
|
||||
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(scriptInterface)
|
||||
{
|
||||
ScriptRequest rq(scriptInterface);
|
||||
Script::Request rq(scriptInterface);
|
||||
m_Data.init(rq.cx);
|
||||
}
|
||||
|
||||
CSimulationMessage::CSimulationMessage(const ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data) :
|
||||
CSimulationMessage::CSimulationMessage(const Script::Interface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data) :
|
||||
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(scriptInterface),
|
||||
m_Client(client), m_Player(player), m_Turn(turn)
|
||||
{
|
||||
ScriptRequest rq(scriptInterface);
|
||||
Script::Request rq(scriptInterface);
|
||||
m_Data.init(rq.cx, data);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ CSimulationMessage::CSimulationMessage(const CSimulationMessage& orig) :
|
||||
m_Turn(orig.m_Turn),
|
||||
CNetMessage(orig)
|
||||
{
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
m_Data.init(rq.cx, orig.m_Data);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ size_t CSimulationMessage::GetSerializedLength() const
|
||||
|
||||
CStr CSimulationMessage::ToString() const
|
||||
{
|
||||
std::string source = Script::ToString(ScriptRequest(m_ScriptInterface), const_cast<JS::PersistentRootedValue*>(&m_Data));
|
||||
std::string source = Script::ToString(Script::Request(m_ScriptInterface), const_cast<JS::PersistentRootedValue*>(&m_Data));
|
||||
|
||||
std::stringstream stream;
|
||||
stream << "CSimulationMessage { m_Client: " << m_Client << ", m_Player: " << m_Player << ", m_Turn: " << m_Turn << ", m_Data: " << source << " }";
|
||||
@@ -195,17 +195,17 @@ CStr CSimulationMessage::ToString() const
|
||||
}
|
||||
|
||||
|
||||
CGameSetupMessage::CGameSetupMessage(const ScriptInterface& scriptInterface) :
|
||||
CGameSetupMessage::CGameSetupMessage(const Script::Interface& scriptInterface) :
|
||||
CNetMessage(NMT_GAME_SETUP), m_ScriptInterface(scriptInterface)
|
||||
{
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
m_Data.init(rq.cx);
|
||||
}
|
||||
|
||||
CGameSetupMessage::CGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue data) :
|
||||
CGameSetupMessage::CGameSetupMessage(const Script::Interface& scriptInterface, JS::HandleValue data) :
|
||||
CNetMessage(NMT_GAME_SETUP), m_ScriptInterface(scriptInterface)
|
||||
{
|
||||
ScriptRequest rq(m_ScriptInterface);
|
||||
Script::Request rq(m_ScriptInterface);
|
||||
m_Data.init(rq.cx, data);
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ size_t CGameSetupMessage::GetSerializedLength() const
|
||||
|
||||
CStr CGameSetupMessage::ToString() const
|
||||
{
|
||||
std::string source = Script::ToString(ScriptRequest(m_ScriptInterface), const_cast<JS::PersistentRootedValue*>(&m_Data));
|
||||
std::string source = Script::ToString(Script::Request(m_ScriptInterface), const_cast<JS::PersistentRootedValue*>(&m_Data));
|
||||
|
||||
std::stringstream stream;
|
||||
stream << "CGameSetupMessage { m_Data: " << source << " }";
|
||||
|
||||
Reference in New Issue
Block a user