2020-03-22 00:45:04 +01:00
|
|
|
#pragma once
|
2016-06-17 02:15:02 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Base/Utility.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <vector>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
class Core;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Hold a information about loaded scripts as it's contents and executable code.
|
|
|
|
*/
|
|
|
|
class ScriptSrc
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2019-06-16 01:12:51 +02:00
|
|
|
typedef std::vector< std::pair< Uint32, Uint32 > > Line;
|
2016-06-17 02:15:02 +02:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Script mExec; // Reference to the script object.
|
|
|
|
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.
|
2016-06-18 19:29:28 +02:00
|
|
|
bool mInfo; // Whether this script contains line information.
|
|
|
|
bool mDelay; // Don't execute immediately after compilation.
|
2016-06-17 02:15:02 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Read file contents and calculate information about the lines of code.
|
|
|
|
*/
|
|
|
|
void Process();
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-18 19:29:28 +02:00
|
|
|
* Base constructor.
|
2016-06-17 02:15:02 +02:00
|
|
|
*/
|
2020-04-30 21:28:01 +02:00
|
|
|
ScriptSrc(HSQUIRRELVM vm, const String & path, bool delay = false, bool info = false);
|
2016-06-17 02:15:02 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy constructor.
|
|
|
|
*/
|
|
|
|
ScriptSrc(const ScriptSrc & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move constructor.
|
|
|
|
*/
|
|
|
|
ScriptSrc(ScriptSrc && o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy assignment operator.
|
|
|
|
*/
|
|
|
|
ScriptSrc & operator = (const ScriptSrc & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator.
|
|
|
|
*/
|
|
|
|
ScriptSrc & operator = (ScriptSrc && o) = default;
|
|
|
|
|
2019-06-16 01:20:18 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Fetches a line from the code. Can also triim whitespace at the beginning.
|
|
|
|
*/
|
|
|
|
String FetchLine(size_t line, bool trim = true) const;
|
2016-06-17 02:15:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|