1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 07:07:13 +02:00

Extend notification script loading with support for context.

This replaces the second argument from callback. Initial implementation was missing this feature.
This commit is contained in:
Sandu Liviu Catalin
2021-07-04 02:19:37 +03:00
parent 494aed47bf
commit 3c30b9c7a2
4 changed files with 43 additions and 15 deletions

View File

@ -148,9 +148,10 @@ void ScriptSrc::Process()
}
// ------------------------------------------------------------------------------------------------
ScriptSrc::ScriptSrc(const String & path, Function & cb, bool delay, bool info) // NOLINT(modernize-pass-by-value)
ScriptSrc::ScriptSrc(const String & path, Function & cb, LightObj & ctx, bool delay, bool info) // NOLINT(modernize-pass-by-value)
: mExec()
, mFunc(std::move(cb))
, mCtx(std::move(ctx))
, mPath(path)
, mData()
, mLine()

View File

@ -27,6 +27,7 @@ struct ScriptSrc
// --------------------------------------------------------------------------------------------
Script mExec{}; // Reference to the script object.
Function mFunc{}; // Callback to invoke after script was executed.
LightObj mCtx{}; // Object to be passed over to the callback as context.
String mPath{}; // Path to the script file.
String mData{}; // The contents of the script file.
Line mLine{}; // List of lines of code in the data.
@ -41,7 +42,7 @@ struct ScriptSrc
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
explicit ScriptSrc(const String & path, Function & cb, bool delay = false, bool info = false);
explicit ScriptSrc(const String & path, Function & cb, LightObj & ctx, bool delay = false, bool info = false);
/* --------------------------------------------------------------------------------------------
* Copy constructor.