mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 22:52:18 +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
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ps/CLogger.h"
|
||||
#include "scriptinterface/FunctionWrapper.h"
|
||||
#include "scriptinterface/Object.h"
|
||||
#include "scriptinterface/ScriptRequest.h"
|
||||
#include "scriptinterface/Request.h"
|
||||
|
||||
#include <js/CallAndConstruct.h>
|
||||
#include <js/GlobalObject.h>
|
||||
@@ -44,11 +44,11 @@ void UnhandledRejectedPromise(JSContext* cx, bool, JS::HandleObject promise,
|
||||
if (state == JS::PromiseRejectionHandlingState::Handled)
|
||||
return;
|
||||
|
||||
const ScriptRequest rq{cx};
|
||||
const Script::Request rq{cx};
|
||||
JS::RootedValue reason(cx, JS::GetPromiseResult(promise));
|
||||
|
||||
std::string asString;
|
||||
ScriptFunction::Call(rq, reason, "toString", asString);
|
||||
Script::Function::Call(rq, reason, "toString", asString);
|
||||
std::string stack;
|
||||
Script::GetProperty(rq, reason, "stack", stack);
|
||||
LOGERROR("An unhandled promise got rejected:\n%s\n%s", asString, stack);
|
||||
@@ -59,7 +59,7 @@ void JobQueue::runJobs(JSContext*)
|
||||
while (!m_Jobs.empty())
|
||||
{
|
||||
QueueElement& element = m_Jobs.front();
|
||||
ScriptRequest rq{element.scriptInterface};
|
||||
Script::Request rq{element.scriptInterface};
|
||||
JS::RootedObject localJob{rq.cx, element.job};
|
||||
m_Jobs.pop();
|
||||
|
||||
@@ -79,7 +79,7 @@ bool JobQueue::enqueuePromiseJob(JSContext* cx, JS::HandleObject, JS::HandleObje
|
||||
{
|
||||
try
|
||||
{
|
||||
m_Jobs.push({ScriptRequest{cx}.GetScriptInterface(), JS::PersistentRootedObject{cx, job}});
|
||||
m_Jobs.push({Script::Request{cx}.GetScriptInterface(), JS::PersistentRootedObject{cx, job}});
|
||||
return true;
|
||||
}
|
||||
catch (...)
|
||||
|
||||
Reference in New Issue
Block a user