Adds std namespace to shared_ptr usages in scriptinterface and simulation.

This was SVN commit r25528.
This commit is contained in:
vladislavbelov
2021-05-22 19:30:18 +00:00
parent d9d19543b5
commit b927f163d6
13 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ void GCSliceCallbackHook(JSContext* UNUSED(cx), JS::GCProgress progress, const J
#endif
}
shared_ptr<ScriptContext> ScriptContext::CreateContext(int contextSize, int heapGrowthBytesGCTrigger)
std::shared_ptr<ScriptContext> ScriptContext::CreateContext(int contextSize, int heapGrowthBytesGCTrigger)
{
return std::make_shared<ScriptContext>(contextSize, heapGrowthBytesGCTrigger);
}
+1 -1
View File
@@ -50,7 +50,7 @@ public:
* @param contextSize Maximum size in bytes of the new context
* @param heapGrowthBytesGCTrigger Size in bytes of cumulated allocations after which a GC will be triggered
*/
static shared_ptr<ScriptContext> CreateContext(
static std::shared_ptr<ScriptContext> CreateContext(
int contextSize = DEFAULT_CONTEXT_SIZE,
int heapGrowthBytesGCTrigger = DEFAULT_HEAP_GROWTH_BYTES_GCTRIGGER);
+5 -5
View File
@@ -54,12 +54,12 @@
struct ScriptInterface_impl
{
ScriptInterface_impl(const char* nativeScopeName, const shared_ptr<ScriptContext>& context);
ScriptInterface_impl(const char* nativeScopeName, const std::shared_ptr<ScriptContext>& context);
~ScriptInterface_impl();
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
// members have to be called before the context destructor.
shared_ptr<ScriptContext> m_context;
std::shared_ptr<ScriptContext> m_context;
friend ScriptRequest;
private:
@@ -302,7 +302,7 @@ bool ScriptInterface::Math_random(JSContext* cx, uint argc, JS::Value* vp)
return true;
}
ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const shared_ptr<ScriptContext>& context) :
ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const std::shared_ptr<ScriptContext>& context) :
m_context(context), m_cx(context->GetGeneralJSContext()), m_glob(context->GetGeneralJSContext()), m_nativeScope(context->GetGeneralJSContext())
{
JS::RealmCreationOptions creationOpt;
@@ -342,7 +342,7 @@ ScriptInterface_impl::~ScriptInterface_impl()
m_context->UnRegisterRealm(JS::GetObjectRealmOrNull(m_glob));
}
ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr<ScriptContext>& context) :
ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugName, const std::shared_ptr<ScriptContext>& context) :
m(std::make_unique<ScriptInterface_impl>(nativeScopeName, context))
{
// Profiler stats table isn't thread-safe, so only enable this on the main thread
@@ -436,7 +436,7 @@ JSContext* ScriptInterface::GetGeneralJSContext() const
return m->m_context->GetGeneralJSContext();
}
shared_ptr<ScriptContext> ScriptInterface::GetContext() const
std::shared_ptr<ScriptContext> ScriptInterface::GetContext() const
{
return m->m_context;
}
+2 -2
View File
@@ -83,7 +83,7 @@ public:
* @param debugName Name of this interface for CScriptStats purposes.
* @param context ScriptContext to use when initializing this interface.
*/
ScriptInterface(const char* nativeScopeName, const char* debugName, const shared_ptr<ScriptContext>& context);
ScriptInterface(const char* nativeScopeName, const char* debugName, const std::shared_ptr<ScriptContext>& context);
~ScriptInterface();
@@ -128,7 +128,7 @@ public:
* ScriptInterface::Request and use the context from that.
*/
JSContext* GetGeneralJSContext() const;
shared_ptr<ScriptContext> GetContext() const;
std::shared_ptr<ScriptContext> GetContext() const;
/**
* Load global scripts that most script interfaces need,
+2 -2
View File
@@ -54,7 +54,7 @@
class CSimulation2Impl
{
public:
CSimulation2Impl(CUnitManager* unitManager, shared_ptr<ScriptContext> cx, CTerrain* terrain) :
CSimulation2Impl(CUnitManager* unitManager, std::shared_ptr<ScriptContext> cx, CTerrain* terrain) :
m_SimContext(), m_ComponentManager(m_SimContext, cx),
m_EnableOOSLog(false), m_EnableSerializationTest(false), m_RejoinTestTurn(-1), m_TestingRejoin(false),
m_MapSettings(cx->GetGeneralJSContext()), m_InitAttributes(cx->GetGeneralJSContext())
@@ -636,7 +636,7 @@ void CSimulation2Impl::DumpState()
////////////////////////////////////////////////////////////////
CSimulation2::CSimulation2(CUnitManager* unitManager, shared_ptr<ScriptContext> cx, CTerrain* terrain) :
CSimulation2::CSimulation2(CUnitManager* unitManager, std::shared_ptr<ScriptContext> cx, CTerrain* terrain) :
m(new CSimulation2Impl(unitManager, cx, terrain))
{
}
+1 -1
View File
@@ -50,7 +50,7 @@ class CSimulation2
public:
// TODO: CUnitManager should probably be handled automatically by this
// module, but for now we'll have it passed in externally instead
CSimulation2(CUnitManager* unitManager, shared_ptr<ScriptContext> cx, CTerrain* terrain);
CSimulation2(CUnitManager* unitManager, std::shared_ptr<ScriptContext> cx, CTerrain* terrain);
~CSimulation2();
void EnableSerializationTest();
@@ -87,7 +87,7 @@ private:
NONCOPYABLE(CAIPlayer);
public:
CAIPlayer(CAIWorker& worker, const std::wstring& aiName, player_id_t player, u8 difficulty, const std::wstring& behavior,
shared_ptr<ScriptInterface> scriptInterface) :
std::shared_ptr<ScriptInterface> scriptInterface) :
m_Worker(worker), m_AIName(aiName), m_Player(player), m_Difficulty(difficulty), m_Behavior(behavior),
m_ScriptInterface(scriptInterface), m_Obj(scriptInterface->GetGeneralJSContext())
{
@@ -203,7 +203,7 @@ private:
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
// members have to be called before the context destructor.
shared_ptr<ScriptInterface> m_ScriptInterface;
std::shared_ptr<ScriptInterface> m_ScriptInterface;
JS::PersistentRootedValue m_Obj;
std::vector<Script::StructuredClone > m_Commands;
@@ -365,7 +365,7 @@ public:
const size_t img_size = w * h * bpp/8;
const size_t hdr_size = tex_hdr_size(filename);
shared_ptr<u8> buf;
std::shared_ptr<u8> buf;
AllocateAligned(buf, hdr_size+img_size, maxSectorSize);
Tex t;
if (t.wrap(w, h, bpp, flags, buf, hdr_size) < 0)
@@ -455,7 +455,7 @@ public:
bool AddPlayer(const std::wstring& aiName, player_id_t player, u8 difficulty, const std::wstring& behavior)
{
shared_ptr<CAIPlayer> ai = std::make_shared<CAIPlayer>(*this, aiName, player, difficulty, behavior, m_ScriptInterface);
std::shared_ptr<CAIPlayer> ai = std::make_shared<CAIPlayer>(*this, aiName, player, difficulty, behavior, m_ScriptInterface);
if (!ai->Initialise())
return false;
@@ -816,17 +816,17 @@ private:
// Take care to keep this declaration before heap rooted members. Destructors of heap rooted
// members have to be called before the context destructor.
shared_ptr<ScriptContext> m_ScriptContext;
std::shared_ptr<ScriptContext> m_ScriptContext;
shared_ptr<ScriptInterface> m_ScriptInterface;
std::shared_ptr<ScriptInterface> m_ScriptInterface;
boost::rand48 m_RNG;
u32 m_TurnNum;
JS::PersistentRootedValue m_EntityTemplates;
bool m_HasLoadedEntityTemplates;
std::map<VfsPath, JS::Heap<JS::Value> > m_PlayerMetadata;
std::vector<shared_ptr<CAIPlayer> > m_Players; // use shared_ptr just to avoid copying
std::map<VfsPath, JS::Heap<JS::Value>> m_PlayerMetadata;
std::vector<std::shared_ptr<CAIPlayer>> m_Players; // use shared_ptr just to avoid copying
bool m_HasSharedComponent;
JS::PersistentRootedValue m_SharedAIObj;
@@ -722,7 +722,7 @@ void LongPathfinder::ComputeJPSPath(const HierarchicalPathfinder& hierPath, enti
// Needs to lock for construction, or several threads might try doing that at the same time.
static std::mutex JPCMutex;
std::unique_lock<std::mutex> lock(JPCMutex);
std::map<pass_class_t, shared_ptr<JumpPointCache> >::const_iterator it = m_JumpPointCache.find(passClass);
std::map<pass_class_t, std::shared_ptr<JumpPointCache>>::const_iterator it = m_JumpPointCache.find(passClass);
if (it != m_JumpPointCache.end())
state.jpc = it->second.get();
+1 -1
View File
@@ -282,7 +282,7 @@ private:
// This is thread-safe as it is order independent (no change in the output of the function for a given set of params).
// Obviously, this means that the cache should actually be a cache and not return different results
// from what would happen if things hadn't been cached.
mutable std::map<pass_class_t, shared_ptr<JumpPointCache> > m_JumpPointCache;
mutable std::map<pass_class_t, std::shared_ptr<JumpPointCache>> m_JumpPointCache;
};
#endif // INCLUDED_LONGPATHFINDER
@@ -54,7 +54,7 @@ public:
JS::PersistentRootedValue msg;
};
CComponentManager::CComponentManager(CSimContext& context, shared_ptr<ScriptContext> cx, bool skipScriptFunctions) :
CComponentManager::CComponentManager(CSimContext& context, std::shared_ptr<ScriptContext> cx, bool skipScriptFunctions) :
m_NextScriptComponentTypeId(CID__LastNative),
m_ScriptInterface("Engine", "Simulation", cx),
m_SimContext(context), m_CurrentlyHotloading(false)
+1 -1
View File
@@ -74,7 +74,7 @@ private:
};
public:
CComponentManager(CSimContext&, shared_ptr<ScriptContext> cx, bool skipScriptFunctions = false);
CComponentManager(CSimContext&, std::shared_ptr<ScriptContext> cx, bool skipScriptFunctions = false);
~CComponentManager();
void LoadComponentTypes();
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -55,7 +55,7 @@ class ComponentTestHelper
bool m_isSystemEntityInit = false;
public:
ComponentTestHelper(shared_ptr<ScriptContext> scriptContext) :
ComponentTestHelper(std::shared_ptr<ScriptContext> scriptContext) :
m_Context(), m_ComponentManager(m_Context, scriptContext), m_Cmp(NULL)
{
m_ComponentManager.LoadComponentTypes();
+1 -1
View File
@@ -31,7 +31,7 @@ class TestSimulation2 : public CxxTest::TestSuite
{
void copyFile(const VfsPath& src, const VfsPath& dst)
{
shared_ptr<u8> data;
std::shared_ptr<u8> data;
size_t size = 0;
TS_ASSERT_OK(g_VFS->LoadFile(src, data, size));
TS_ASSERT_OK(g_VFS->CreateFile(dst, data, size));