1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-29 22:15:32 +00:00

Changed things to use typedef ScriptARgs/ScriptReturn, which makes finding out what those weird strings meant much much easier

This commit is contained in:
Thomas 2014-04-29 12:52:08 -04:00
parent 2906ade531
commit 8f90dd43ec
2 changed files with 35 additions and 13 deletions

View file

@ -21,7 +21,7 @@ namespace Compiler
return iter->second;
}
bool Extensions::isFunction (int keyword, char& returnType, std::string& argumentType,
bool Extensions::isFunction (int keyword, ScriptReturn& returnType, ScriptArgs& argumentType,
bool& explicitReference) const
{
std::map<int, Function>::const_iterator iter = mFunctions.find (keyword);
@ -37,7 +37,7 @@ namespace Compiler
return true;
}
bool Extensions::isInstruction (int keyword, std::string& argumentType,
bool Extensions::isInstruction (int keyword, ScriptArgs& argumentType,
bool& explicitReference) const
{
std::map<int, Instruction>::const_iterator iter = mInstructions.find (keyword);
@ -52,8 +52,8 @@ namespace Compiler
return true;
}
void Extensions::registerFunction (const std::string& keyword, char returnType,
const std::string& argumentType, int code, int codeExplicit)
void Extensions::registerFunction (const std::string& keyword, ScriptReturn returnType,
const ScriptArgs& argumentType, int code, int codeExplicit)
{
Function function;
@ -83,7 +83,7 @@ namespace Compiler
}
void Extensions::registerInstruction (const std::string& keyword,
const std::string& argumentType, int code, int codeExplicit)
const ScriptArgs& argumentType, int code, int codeExplicit)
{
Instruction instruction;

View file

@ -11,14 +11,36 @@ namespace Compiler
{
class Literals;
/// \brief Collection of compiler extensions
/// Typedef for script arguments string
/** Every character reperesents an argument to the command. All arguments are required until a /, after which
every argument is optional. <BR>
Eg: fff/f represents 3 required floats followed by one optional float <BR>
f - Float <BR>
c - String <BR>
l - Integer <BR>
s - Short <BR>
S - Also string (Seemed to be mostly used for Cell Names) <BR>
x - none?
**/
typedef std::string ScriptArgs;
/// Typedef for script return char
/** The character represents the type of data being returned. <BR>
f - float <BR>
S - String (Cell names) <BR>
l - Integer
**/
typedef char ScriptReturn;
/// \brief Collection of compiler extensions
class Extensions
{
struct Function
{
char mReturn;
std::string mArguments;
ScriptArgs mArguments;
int mCode;
int mCodeExplicit;
int mSegment;
@ -26,7 +48,7 @@ namespace Compiler
struct Instruction
{
std::string mArguments;
ScriptArgs mArguments;
int mCode;
int mCodeExplicit;
int mSegment;
@ -46,21 +68,21 @@ namespace Compiler
/// - if no match is found 0 is returned.
/// - keyword must be all lower case.
bool isFunction (int keyword, char& returnType, std::string& argumentType,
bool isFunction (int keyword, ScriptReturn& returnType, ScriptArgs& argumentType,
bool& explicitReference) const;
///< Is this keyword registered with a function? If yes, return return and argument
/// types.
/// \param explicitReference In: has explicit reference; Out: set to false, if
/// explicit reference is not available for this instruction.
bool isInstruction (int keyword, std::string& argumentType,
bool isInstruction (int keyword, ScriptArgs& argumentType,
bool& explicitReference) const;
///< Is this keyword registered with a function? If yes, return argument types.
/// \param explicitReference In: has explicit reference; Out: set to false, if
/// explicit reference is not available for this instruction.
void registerFunction (const std::string& keyword, char returnType,
const std::string& argumentType, int code, int codeExplicit = -1);
void registerFunction (const std::string& keyword, ScriptReturn returnType,
const ScriptArgs& argumentType, int code, int codeExplicit = -1);
///< Register a custom function
/// - keyword must be all lower case.
/// - keyword must be unique
@ -68,7 +90,7 @@ namespace Compiler
/// \note Currently only segment 3 and segment 5 opcodes are supported.
void registerInstruction (const std::string& keyword,
const std::string& argumentType, int code, int codeExplicit = -1);
const ScriptArgs& argumentType, int code, int codeExplicit = -1);
///< Register a custom instruction
/// - keyword must be all lower case.
/// - keyword must be unique