Don't use std::shared_ptr in ScriptInterface

Differential Revision: https://code.wildfiregames.com/D5159
This was SVN commit r27945.
This commit is contained in:
phosit
2023-11-19 20:13:19 +00:00
parent e33aafc4e2
commit 1bccfef6fb
20 changed files with 96 additions and 86 deletions
+10 -2
View File
@@ -83,7 +83,15 @@ 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 std::shared_ptr<ScriptContext>& context);
ScriptInterface(const char* nativeScopeName, const char* debugName, ScriptContext& context);
template<typename Context>
ScriptInterface(const char* nativeScopeName, const char* debugName, Context&& context) :
ScriptInterface(nativeScopeName, debugName, *context)
{
static_assert(std::is_lvalue_reference_v<Context>, "`ScriptInterface` doesn't take ownership "
"of the context.");
}
/**
* Alternate constructor. This creates the new Realm in the same Compartment as the neighbor scriptInterface.
@@ -137,7 +145,7 @@ public:
* ScriptInterface::Request and use the context from that.
*/
JSContext* GetGeneralJSContext() const;
std::shared_ptr<ScriptContext> GetContext() const;
ScriptContext& GetContext() const;
/**
* Load global scripts that most script interfaces need,