mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-07 13:20:25 +00:00
Use string_view in register methods
This commit is contained in:
parent
ad7fb3d13f
commit
1cea604257
@ -51,11 +51,11 @@ namespace Compiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Extensions::registerFunction(
|
void Extensions::registerFunction(
|
||||||
const std::string& keyword, ScriptReturn returnType, ScriptArgs argumentType, int code, int codeExplicit)
|
std::string_view keyword, ScriptReturn returnType, std::string_view argumentType, int code, int codeExplicit)
|
||||||
{
|
{
|
||||||
Function function;
|
Function function;
|
||||||
|
|
||||||
if (argumentType.find('/') == std::string::npos)
|
if (argumentType.find('/') == std::string_view::npos)
|
||||||
{
|
{
|
||||||
function.mSegment = 5;
|
function.mSegment = 5;
|
||||||
assert(code >= 33554432 && code <= 67108863);
|
assert(code >= 33554432 && code <= 67108863);
|
||||||
@ -73,7 +73,7 @@ namespace Compiler
|
|||||||
mKeywords.emplace(keyword, keywordIndex);
|
mKeywords.emplace(keyword, keywordIndex);
|
||||||
|
|
||||||
function.mReturn = returnType;
|
function.mReturn = returnType;
|
||||||
function.mArguments = std::move(argumentType);
|
function.mArguments = argumentType;
|
||||||
function.mCode = code;
|
function.mCode = code;
|
||||||
function.mCodeExplicit = codeExplicit;
|
function.mCodeExplicit = codeExplicit;
|
||||||
|
|
||||||
@ -81,11 +81,11 @@ namespace Compiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Extensions::registerInstruction(
|
void Extensions::registerInstruction(
|
||||||
const std::string& keyword, ScriptArgs argumentType, int code, int codeExplicit)
|
std::string_view keyword, std::string_view argumentType, int code, int codeExplicit)
|
||||||
{
|
{
|
||||||
Instruction instruction;
|
Instruction instruction;
|
||||||
|
|
||||||
if (argumentType.find('/') == std::string::npos)
|
if (argumentType.find('/') == std::string_view::npos)
|
||||||
{
|
{
|
||||||
instruction.mSegment = 5;
|
instruction.mSegment = 5;
|
||||||
assert(code >= 33554432 && code <= 67108863);
|
assert(code >= 33554432 && code <= 67108863);
|
||||||
@ -102,7 +102,7 @@ namespace Compiler
|
|||||||
|
|
||||||
mKeywords.emplace(keyword, keywordIndex);
|
mKeywords.emplace(keyword, keywordIndex);
|
||||||
|
|
||||||
instruction.mArguments = std::move(argumentType);
|
instruction.mArguments = argumentType;
|
||||||
instruction.mCode = code;
|
instruction.mCode = code;
|
||||||
instruction.mCodeExplicit = codeExplicit;
|
instruction.mCodeExplicit = codeExplicit;
|
||||||
|
|
||||||
|
@ -80,15 +80,16 @@ namespace Compiler
|
|||||||
/// \param explicitReference In: has explicit reference; Out: set to false, if
|
/// \param explicitReference In: has explicit reference; Out: set to false, if
|
||||||
/// explicit reference is not available for this instruction.
|
/// explicit reference is not available for this instruction.
|
||||||
|
|
||||||
void registerFunction(const std::string& keyword, ScriptReturn returnType, ScriptArgs argumentType, int code,
|
void registerFunction(std::string_view keyword, ScriptReturn returnType, std::string_view argumentType,
|
||||||
int codeExplicit = -1);
|
int code, int codeExplicit = -1);
|
||||||
///< Register a custom function
|
///< Register a custom function
|
||||||
/// - keyword must be all lower case.
|
/// - keyword must be all lower case.
|
||||||
/// - keyword must be unique
|
/// - keyword must be unique
|
||||||
/// - if explicit references are not supported, segment5codeExplicit must be set to -1
|
/// - if explicit references are not supported, segment5codeExplicit must be set to -1
|
||||||
/// \note Currently only segment 3 and segment 5 opcodes are supported.
|
/// \note Currently only segment 3 and segment 5 opcodes are supported.
|
||||||
|
|
||||||
void registerInstruction(const std::string& keyword, ScriptArgs argumentType, int code, int codeExplicit = -1);
|
void registerInstruction(
|
||||||
|
std::string_view keyword, std::string_view argumentType, int code, int codeExplicit = -1);
|
||||||
///< Register a custom instruction
|
///< Register a custom instruction
|
||||||
/// - keyword must be all lower case.
|
/// - keyword must be all lower case.
|
||||||
/// - keyword must be unique
|
/// - keyword must be unique
|
||||||
|
Loading…
x
Reference in New Issue
Block a user