mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 13:55:34 +00:00
compile fixes.
This commit is contained in:
parent
50df52ecfc
commit
02447f0996
20 changed files with 3207 additions and 3168 deletions
|
|
@ -228,7 +228,7 @@ bool VDataTable::getValue( SimObject *pObject, const String &pFieldName, String
|
||||||
case VDataTable::k_TypeExpression :
|
case VDataTable::k_TypeExpression :
|
||||||
{
|
{
|
||||||
// Evaluate.
|
// Evaluate.
|
||||||
pValue = Con::evaluate( fieldValue, false ).getStringValue();
|
pValue = Con::evaluate( fieldValue, false ).getString();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2638,23 +2638,25 @@ DefineEngineStringlyVariadicMethod(afxMagicSpell, setTimeFactor, void, 3, 4, "(F
|
||||||
"@ingroup AFX")
|
"@ingroup AFX")
|
||||||
{
|
{
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
object->setTimeFactor(dAtof(argv[2]));
|
object->setTimeFactor(argv[2].getFloat());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
F32 value = argv[3].getFloat();
|
||||||
|
|
||||||
if (dStricmp(argv[2], "overall") == 0)
|
if (dStricmp(argv[2], "overall") == 0)
|
||||||
object->setTimeFactor(dAtof(argv[3]));
|
object->setTimeFactor(dAtof(argv[3]));
|
||||||
else if (dStricmp(argv[2], "casting") == 0)
|
else if (dStricmp(argv[2], "casting") == 0)
|
||||||
object->setTimeFactor(afxMagicSpell::CASTING_PHRASE, dAtof(argv[3]));
|
object->setTimeFactor(afxMagicSpell::CASTING_PHRASE, value);
|
||||||
else if (dStricmp(argv[2], "launch") == 0)
|
else if (dStricmp(argv[2], "launch") == 0)
|
||||||
object->setTimeFactor(afxMagicSpell::LAUNCH_PHRASE, dAtof(argv[3]));
|
object->setTimeFactor(afxMagicSpell::LAUNCH_PHRASE, value);
|
||||||
else if (dStricmp(argv[2], "delivery") == 0)
|
else if (dStricmp(argv[2], "delivery") == 0)
|
||||||
object->setTimeFactor(afxMagicSpell::DELIVERY_PHRASE, dAtof(argv[3]));
|
object->setTimeFactor(afxMagicSpell::DELIVERY_PHRASE, value);
|
||||||
else if (dStricmp(argv[2], "impact") == 0)
|
else if (dStricmp(argv[2], "impact") == 0)
|
||||||
object->setTimeFactor(afxMagicSpell::IMPACT_PHRASE, dAtof(argv[3]));
|
object->setTimeFactor(afxMagicSpell::IMPACT_PHRASE, value);
|
||||||
else if (dStricmp(argv[2], "linger") == 0)
|
else if (dStricmp(argv[2], "linger") == 0)
|
||||||
object->setTimeFactor(afxMagicSpell::LINGER_PHRASE, dAtof(argv[3]));
|
object->setTimeFactor(afxMagicSpell::LINGER_PHRASE, value);
|
||||||
else
|
else
|
||||||
Con::errorf("afxMagicSpell::setTimeFactor() -- unknown spell phrase [%s].", argv[2].getStringValue());
|
Con::errorf("afxMagicSpell::setTimeFactor() -- unknown spell phrase [%s].", argv[2].getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -874,7 +874,7 @@ DefineEngineStringlyVariadicFunction(echoThru, const char*, 2, 0, "(string passt
|
||||||
for (i = 2; i < argc; i++)
|
for (i = 2; i < argc; i++)
|
||||||
dStrcat(ret, argv[i], len + 1);
|
dStrcat(ret, argv[i], len + 1);
|
||||||
|
|
||||||
Con::printf("%s -- [%s]", ret, argv[1].getStringValue());
|
Con::printf("%s -- [%s]", ret, argv[1].getString());
|
||||||
ret[0] = 0;
|
ret[0] = 0;
|
||||||
|
|
||||||
return argv[1];
|
return argv[1];
|
||||||
|
|
@ -894,7 +894,7 @@ DefineEngineStringlyVariadicFunction(warnThru, const char*, 2, 0, "(string passt
|
||||||
for(i = 2; i < argc; i++)
|
for(i = 2; i < argc; i++)
|
||||||
dStrcat(ret, argv[i], len + 1);
|
dStrcat(ret, argv[i], len + 1);
|
||||||
|
|
||||||
Con::warnf("%s -- [%s]", ret, argv[1].getStringValue());
|
Con::warnf("%s -- [%s]", ret, argv[1].getString());
|
||||||
ret[0] = 0;
|
ret[0] = 0;
|
||||||
|
|
||||||
return argv[1];
|
return argv[1];
|
||||||
|
|
@ -914,7 +914,7 @@ DefineEngineStringlyVariadicFunction(errorThru, const char*, 2, 0, "(string pass
|
||||||
for(i = 2; i < argc; i++)
|
for(i = 2; i < argc; i++)
|
||||||
dStrcat(ret, argv[i], len + 1);
|
dStrcat(ret, argv[i], len + 1);
|
||||||
|
|
||||||
Con::errorf("%s -- [%s]", ret, argv[1].getStringValue());
|
Con::errorf("%s -- [%s]", ret, argv[1].getString());
|
||||||
ret[0] = 0;
|
ret[0] = 0;
|
||||||
|
|
||||||
return argv[1];
|
return argv[1];
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@
|
||||||
#include "console/debugOutputConsumer.h"
|
#include "console/debugOutputConsumer.h"
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
#include "console/codeInterpreter.h"
|
|
||||||
|
|
||||||
#include "gfx/bitmap/gBitmap.h"
|
#include "gfx/bitmap/gBitmap.h"
|
||||||
#include "gfx/gFont.h"
|
#include "gfx/gFont.h"
|
||||||
|
|
@ -229,9 +228,6 @@ void StandardMainLoop::init()
|
||||||
ManagedSingleton< ThreadManager >::createSingleton();
|
ManagedSingleton< ThreadManager >::createSingleton();
|
||||||
FrameAllocator::init(TORQUE_FRAME_SIZE); // See comments in torqueConfig.h
|
FrameAllocator::init(TORQUE_FRAME_SIZE); // See comments in torqueConfig.h
|
||||||
|
|
||||||
// Initialize the TorqueScript interpreter.
|
|
||||||
CodeInterpreter::init();
|
|
||||||
|
|
||||||
// Yell if we can't initialize the network.
|
// Yell if we can't initialize the network.
|
||||||
if(!Net::init())
|
if(!Net::init())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -456,6 +456,8 @@ expr
|
||||||
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, NULL); }
|
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, NULL); }
|
||||||
| VAR '[' aidx_expr ']'
|
| VAR '[' aidx_expr ']'
|
||||||
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, $3 ); }
|
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, $3 ); }
|
||||||
|
;
|
||||||
|
/*
|
||||||
| rwDEFINE '(' var_list_decl ')' '{' statement_list '}'
|
| rwDEFINE '(' var_list_decl ')' '{' statement_list '}'
|
||||||
{
|
{
|
||||||
const U32 bufLen = 64;
|
const U32 bufLen = 64;
|
||||||
|
|
@ -471,7 +473,7 @@ expr
|
||||||
|
|
||||||
$$ = StrConstNode::alloc( $1.lineNumber, (UTF8*)fName, false );
|
$$ = StrConstNode::alloc( $1.lineNumber, (UTF8*)fName, false );
|
||||||
}
|
}
|
||||||
;
|
*/
|
||||||
|
|
||||||
slot_acc
|
slot_acc
|
||||||
: expr '.' IDENT
|
: expr '.' IDENT
|
||||||
|
|
@ -551,9 +553,12 @@ funcall_expr
|
||||||
{ $$ = FuncCallExprNode::alloc( $1.lineNumber, $3.value, $1.value, $5, false); }
|
{ $$ = FuncCallExprNode::alloc( $1.lineNumber, $3.value, $1.value, $5, false); }
|
||||||
| expr '.' IDENT '(' expr_list_decl ')'
|
| expr '.' IDENT '(' expr_list_decl ')'
|
||||||
{ $1->append($5); $$ = FuncCallExprNode::alloc( $1->dbgLineNumber, $3.value, NULL, $1, true); }
|
{ $1->append($5); $$ = FuncCallExprNode::alloc( $1->dbgLineNumber, $3.value, NULL, $1, true); }
|
||||||
|
;
|
||||||
|
/*
|
||||||
| expr '(' expr_list_decl ')'
|
| expr '(' expr_list_decl ')'
|
||||||
{ $$ = FuncPointerCallExprNode::alloc( $1->dbgLineNumber, $1, $3); }
|
{ $$ = FuncPointerCallExprNode::alloc( $1->dbgLineNumber, $1, $3); }
|
||||||
;
|
;
|
||||||
|
*/
|
||||||
|
|
||||||
assert_expr
|
assert_expr
|
||||||
: rwASSERT '(' expr ')'
|
: rwASSERT '(' expr ')'
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -565,7 +565,7 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeBlock::compileExec(StringTableEntry fileName, const char *inString, ConsoleValue &returnValue, bool noCalls, S32 setFrame)
|
ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame)
|
||||||
{
|
{
|
||||||
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
|
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
|
||||||
|
|
||||||
|
|
@ -619,7 +619,7 @@ void CodeBlock::compileExec(StringTableEntry fileName, const char *inString, Con
|
||||||
if (!gStatementList)
|
if (!gStatementList)
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
return;
|
return std::move(ConsoleValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
resetTables();
|
resetTables();
|
||||||
|
|
@ -653,7 +653,7 @@ void CodeBlock::compileExec(StringTableEntry fileName, const char *inString, Con
|
||||||
if (lastIp + 1 != codeSize)
|
if (lastIp + 1 != codeSize)
|
||||||
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
||||||
|
|
||||||
exec(0, fileName, NULL, 0, 0, noCalls, NULL, returnValue, setFrame);
|
return std::move(exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -420,7 +420,7 @@ void ExprEvalState::setStringVariable(const char *val)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
U32 gExecCount = 0;
|
U32 gExecCount = 0;
|
||||||
void CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace, U32 argc, ConsoleValue* argv, bool noCalls, StringTableEntry packageName, ConsoleValue& returnValue, S32 setFrame)
|
ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace, U32 argc, ConsoleValue* argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
|
||||||
{
|
{
|
||||||
#ifdef TORQUE_DEBUG
|
#ifdef TORQUE_DEBUG
|
||||||
U32 stackStart = STR.mStartStackSize;
|
U32 stackStart = STR.mStartStackSize;
|
||||||
|
|
@ -432,6 +432,7 @@ void CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace,
|
||||||
U32 i;
|
U32 i;
|
||||||
|
|
||||||
U32 iterDepth = 0;
|
U32 iterDepth = 0;
|
||||||
|
ConsoleValue returnValue;
|
||||||
|
|
||||||
incRefCount();
|
incRefCount();
|
||||||
F64* curFloatTable;
|
F64* curFloatTable;
|
||||||
|
|
@ -1738,9 +1739,8 @@ void CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace,
|
||||||
{
|
{
|
||||||
if (nsEntry->mFunctionOffset)
|
if (nsEntry->mFunctionOffset)
|
||||||
{
|
{
|
||||||
ConsoleValue ret;
|
const char* ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage).getString();
|
||||||
nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage, ret);
|
STR.setStringValue(ret);
|
||||||
STR.setStringValue(ret.getString());
|
|
||||||
}
|
}
|
||||||
else // no body
|
else // no body
|
||||||
STR.setStringValue("");
|
STR.setStringValue("");
|
||||||
|
|
@ -2128,6 +2128,10 @@ execFinished:
|
||||||
AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec");
|
AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec");
|
||||||
AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec");
|
AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (returnValue.getType() == ConsoleValueType::cvNone)
|
||||||
|
returnValue.setStringTableEntry(StringTable->EmptyString());
|
||||||
|
return std::move(returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ char* ConsoleValue::convertToBuffer() const
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ConsoleValue::getConsoleData() const
|
||||||
|
{
|
||||||
|
return Con::getData(type, ct->dataPtr, 0, ct->enumTable);
|
||||||
|
}
|
||||||
|
|
||||||
ConsoleDocFragment* ConsoleDocFragment::smFirst;
|
ConsoleDocFragment* ConsoleDocFragment::smFirst;
|
||||||
ExprEvalState gEvalState;
|
ExprEvalState gEvalState;
|
||||||
StmtNode *gStatementList;
|
StmtNode *gStatementList;
|
||||||
|
|
|
||||||
|
|
@ -158,25 +158,12 @@ class ConsoleValue
|
||||||
|
|
||||||
char* convertToBuffer() const;
|
char* convertToBuffer() const;
|
||||||
|
|
||||||
TORQUE_FORCEINLINE bool isStringType() const
|
|
||||||
{
|
|
||||||
return type == ConsoleValueType::cvString || type == ConsoleValueType::cvSTEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
TORQUE_FORCEINLINE bool isNumberType() const
|
|
||||||
{
|
|
||||||
return type == ConsoleValueType::cvFloat || type == ConsoleValueType::cvInteger;
|
|
||||||
}
|
|
||||||
|
|
||||||
TORQUE_FORCEINLINE bool hasAllocatedData() const
|
TORQUE_FORCEINLINE bool hasAllocatedData() const
|
||||||
{
|
{
|
||||||
return type == ConsoleValueType::cvString || type >= ConsoleValueType::cvConsoleValueType;
|
return type == ConsoleValueType::cvString || isConsoleType();
|
||||||
}
|
}
|
||||||
|
|
||||||
TORQUE_FORCEINLINE const char* getConsoleData() const
|
const char* getConsoleData() const;
|
||||||
{
|
|
||||||
return Con::getData(type, ct->dataPtr, 0, ct->enumTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
TORQUE_FORCEINLINE void cleanupData()
|
TORQUE_FORCEINLINE void cleanupData()
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +179,7 @@ public:
|
||||||
type = ConsoleValueType::cvNone;
|
type = ConsoleValueType::cvNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleValue(ConsoleValue&& ref)
|
ConsoleValue(ConsoleValue&& ref) noexcept
|
||||||
{
|
{
|
||||||
cleanupData();
|
cleanupData();
|
||||||
type = ref.type;
|
type = ref.type;
|
||||||
|
|
@ -209,7 +196,7 @@ public:
|
||||||
f = ref.f;
|
f = ref.f;
|
||||||
break;
|
break;
|
||||||
case cvSTEntry:
|
case cvSTEntry:
|
||||||
TORQUE_CASE_FALLTHROUGH
|
TORQUE_CASE_FALLTHROUGH;
|
||||||
case cvString:
|
case cvString:
|
||||||
s = ref.s;
|
s = ref.s;
|
||||||
break;
|
break;
|
||||||
|
|
@ -229,6 +216,12 @@ public:
|
||||||
cleanupData();
|
cleanupData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORQUE_FORCEINLINE void reset()
|
||||||
|
{
|
||||||
|
cleanupData();
|
||||||
|
type = ConsoleValueType::cvNone;
|
||||||
|
}
|
||||||
|
|
||||||
TORQUE_FORCEINLINE F64 getFloat() const
|
TORQUE_FORCEINLINE F64 getFloat() const
|
||||||
{
|
{
|
||||||
AssertFatal(type == ConsoleValueType::cvNone, "Attempted to access ConsoleValue when it has no value!");
|
AssertFatal(type == ConsoleValueType::cvNone, "Attempted to access ConsoleValue when it has no value!");
|
||||||
|
|
@ -263,6 +256,11 @@ public:
|
||||||
return getConsoleData();
|
return getConsoleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORQUE_FORCEINLINE operator const char* () const
|
||||||
|
{
|
||||||
|
return getString();
|
||||||
|
}
|
||||||
|
|
||||||
TORQUE_FORCEINLINE bool getBool() const
|
TORQUE_FORCEINLINE bool getBool() const
|
||||||
{
|
{
|
||||||
AssertFatal(type == ConsoleValueType::cvNone, "Attempted to access ConsoleValue when it has no value!");
|
AssertFatal(type == ConsoleValueType::cvNone, "Attempted to access ConsoleValue when it has no value!");
|
||||||
|
|
@ -290,6 +288,11 @@ public:
|
||||||
i = val;
|
i = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORQUE_FORCEINLINE void setString(const char* val)
|
||||||
|
{
|
||||||
|
setString(val, dStrlen(val));
|
||||||
|
}
|
||||||
|
|
||||||
TORQUE_FORCEINLINE void setString(const char* val, S32 len)
|
TORQUE_FORCEINLINE void setString(const char* val, S32 len)
|
||||||
{
|
{
|
||||||
cleanupData();
|
cleanupData();
|
||||||
|
|
@ -315,11 +318,11 @@ public:
|
||||||
s = const_cast<char*>(val);
|
s = const_cast<char*>(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
TORQUE_FORCEINLINE void setConsoleData(S32 consoleType, void* dataPtr, EnumTable* enumTable)
|
TORQUE_FORCEINLINE void setConsoleData(S32 consoleType, void* dataPtr, const EnumTable* enumTable)
|
||||||
{
|
{
|
||||||
cleanupData();
|
cleanupData();
|
||||||
type = ConsoleValueType::cvSTEntry;
|
type = ConsoleValueType::cvSTEntry;
|
||||||
ct = new ConsoleValueConsoleType{ dataPtr, enumTable };
|
ct = new ConsoleValueConsoleType{ dataPtr, const_cast<EnumTable*>(enumTable) };
|
||||||
}
|
}
|
||||||
|
|
||||||
TORQUE_FORCEINLINE S32 getType() const
|
TORQUE_FORCEINLINE S32 getType() const
|
||||||
|
|
@ -327,6 +330,21 @@ public:
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORQUE_FORCEINLINE bool isStringType() const
|
||||||
|
{
|
||||||
|
return type == ConsoleValueType::cvString || type == ConsoleValueType::cvSTEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
TORQUE_FORCEINLINE bool isNumberType() const
|
||||||
|
{
|
||||||
|
return type == ConsoleValueType::cvFloat || type == ConsoleValueType::cvInteger;
|
||||||
|
}
|
||||||
|
|
||||||
|
TORQUE_FORCEINLINE bool isConsoleType() const
|
||||||
|
{
|
||||||
|
return type >= ConsoleValueType::cvConsoleValueType;
|
||||||
|
}
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static S32 getConstantBufferCount() { return (S32)ConversionBufferSize / StringSize; }
|
static S32 getConstantBufferCount() { return (S32)ConversionBufferSize / StringSize; }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -480,8 +480,6 @@ Dictionary::Entry::Entry(StringTableEntry in_name)
|
||||||
|
|
||||||
Dictionary::Entry::~Entry()
|
Dictionary::Entry::~Entry()
|
||||||
{
|
{
|
||||||
value.cleanup();
|
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
delete notify;
|
delete notify;
|
||||||
}
|
}
|
||||||
|
|
@ -560,20 +558,13 @@ Dictionary::Entry* Dictionary::addVariable(const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry *ent = add(StringTable->insert(name));
|
Entry *ent = add(StringTable->insert(name));
|
||||||
|
|
||||||
if (ent->value.type <= ConsoleValue::TypeInternalString &&
|
|
||||||
ent->value.bufferLen > 0)
|
|
||||||
dFree(ent->value.sval);
|
|
||||||
|
|
||||||
ent->value.type = type;
|
|
||||||
ent->value.dataPtr = dataPtr;
|
|
||||||
ent->mUsage = usage;
|
ent->mUsage = usage;
|
||||||
|
|
||||||
// Fetch enum table, if any.
|
// Fetch enum table, if any.
|
||||||
|
|
||||||
ConsoleBaseType* conType = ConsoleBaseType::getType(type);
|
ConsoleBaseType* conType = ConsoleBaseType::getType(type);
|
||||||
AssertFatal(conType, "Dictionary::addVariable - invalid console type");
|
AssertFatal(conType, "Dictionary::addVariable - invalid console type");
|
||||||
ent->value.enumTable = conType->getEnumTable();
|
ent->value.setConsoleData(type, dataPtr, conType->getEnumTable());
|
||||||
|
|
||||||
return ent;
|
return ent;
|
||||||
}
|
}
|
||||||
|
|
@ -1303,9 +1294,11 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, ExprEvalSta
|
||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case StringCallbackType:
|
case StringCallbackType:
|
||||||
|
{
|
||||||
const char* str = cb.mStringCallbackFunc(state->thisObject, argc, argv);
|
const char* str = cb.mStringCallbackFunc(state->thisObject, argc, argv);
|
||||||
result.setString(str, dStrlen(str));
|
result.setString(str, dStrlen(str));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case IntCallbackType:
|
case IntCallbackType:
|
||||||
result.setInt(cb.mIntCallbackFunc(state->thisObject, argc, argv));
|
result.setInt(cb.mIntCallbackFunc(state->thisObject, argc, argv));
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,6 @@ public:
|
||||||
|
|
||||||
typedef VectorPtr<Namespace::Entry *>::iterator NamespaceEntryListIterator;
|
typedef VectorPtr<Namespace::Entry *>::iterator NamespaceEntryListIterator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Dictionary
|
class Dictionary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -307,7 +305,6 @@ public:
|
||||||
mUsage = NULL;
|
mUsage = NULL;
|
||||||
mIsConstant = false;
|
mIsConstant = false;
|
||||||
mNext = NULL;
|
mNext = NULL;
|
||||||
value.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry(StringTableEntry name);
|
Entry(StringTableEntry name);
|
||||||
|
|
@ -317,7 +314,7 @@ public:
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
name = NULL;
|
name = NULL;
|
||||||
value.cleanup();
|
value.reset();
|
||||||
if (notify)
|
if (notify)
|
||||||
delete notify;
|
delete notify;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1187,8 +1187,7 @@ public:
|
||||||
if (Con::isMainThread())
|
if (Con::isMainThread())
|
||||||
{
|
{
|
||||||
ConsoleStackFrameSaver sav; sav.save();
|
ConsoleStackFrameSaver sav; sav.save();
|
||||||
CSTK.reserveValues(mArgc + sizeof...(ArgTs), mArgv);
|
mArgv[ 0 ].setStringTableEntry(mCallbackName);
|
||||||
mArgv[ 0 ].value->setStackStringValue(mCallbackName);
|
|
||||||
|
|
||||||
Helper::marshallEach(mArgc, mArgv, args...);
|
Helper::marshallEach(mArgc, mArgv, args...);
|
||||||
|
|
||||||
|
|
@ -1199,7 +1198,7 @@ public:
|
||||||
SimConsoleThreadExecCallback cb;
|
SimConsoleThreadExecCallback cb;
|
||||||
SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(mArgc + sizeof...(ArgTs), NULL, false, &cb);
|
SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(mArgc + sizeof...(ArgTs), NULL, false, &cb);
|
||||||
evt->populateArgs(mArgv);
|
evt->populateArgs(mArgv);
|
||||||
mArgv[ 0 ].value->setStackStringValue(mCallbackName);
|
mArgv[ 0 ].setStringTableEntry(mCallbackName);
|
||||||
|
|
||||||
Helper::marshallEach(mArgc, mArgv, args...);
|
Helper::marshallEach(mArgc, mArgv, args...);
|
||||||
|
|
||||||
|
|
@ -1233,7 +1232,6 @@ public:
|
||||||
if (Con::isMainThread())
|
if (Con::isMainThread())
|
||||||
{
|
{
|
||||||
ConsoleStackFrameSaver sav; sav.save();
|
ConsoleStackFrameSaver sav; sav.save();
|
||||||
CSTK.reserveValues(mArgc+sizeof...(ArgTs), mArgv);
|
|
||||||
mArgv[ 0 ].setString(simCB, dStrlen(simCB));
|
mArgv[ 0 ].setString(simCB, dStrlen(simCB));
|
||||||
|
|
||||||
Helper::marshallEach(mArgc, mArgv, args...);
|
Helper::marshallEach(mArgc, mArgv, args...);
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ static void dumpVariable( Stream& stream,
|
||||||
{
|
{
|
||||||
// Skip variables defined in script.
|
// Skip variables defined in script.
|
||||||
|
|
||||||
if( entry->value.type < 0 )
|
if( !entry->value.isConsoleType() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Skip internals... don't export them.
|
// Skip internals... don't export them.
|
||||||
|
|
@ -149,7 +149,7 @@ static void dumpVariable( Stream& stream,
|
||||||
|
|
||||||
// Skip variables for which we can't decipher their type.
|
// Skip variables for which we can't decipher their type.
|
||||||
|
|
||||||
ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.type );
|
ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.getType() );
|
||||||
if( !type )
|
if( !type )
|
||||||
{
|
{
|
||||||
Con::errorf( "Can't find type for variable '%s'", entry->name );
|
Con::errorf( "Can't find type for variable '%s'", entry->name );
|
||||||
|
|
|
||||||
104
Engine/source/console/optimizer.cpp
Normal file
104
Engine/source/console/optimizer.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2013 GarageGames, LLC
|
||||||
|
// Copyright (c) 2021 TGEMIT Authors & Contributors
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
// deal in the Software without restriction, including without limitation the
|
||||||
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
// sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "console/console.h"
|
||||||
|
#include "console/codeBlock.h"
|
||||||
|
|
||||||
|
static bool isLiteralNumber(ExprNode* node)
|
||||||
|
{
|
||||||
|
ExprNodeName name = node->getExprNodeNameEnum();
|
||||||
|
return name == NameFloatNode || name == NameIntNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static F64 getFloatValue(ExprNode* node)
|
||||||
|
{
|
||||||
|
if (node->getExprNodeNameEnum() == NameFloatNode)
|
||||||
|
return static_cast<FloatNode*>(node)->value;
|
||||||
|
return (F64)static_cast<IntNode*>(node)->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static S32 getIntValue(ExprNode* node)
|
||||||
|
{
|
||||||
|
if (node->getExprNodeNameEnum() == NameFloatNode)
|
||||||
|
return (S32)static_cast<FloatNode*>(node)->value;
|
||||||
|
return static_cast<IntNode*>(node)->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FloatBinaryExprNode::optimize()
|
||||||
|
{
|
||||||
|
// Perform constant folding
|
||||||
|
if (isLiteralNumber(right) && isLiteralNumber(left))
|
||||||
|
{
|
||||||
|
F64 rightValue = getFloatValue(right);
|
||||||
|
F64 leftValue = getFloatValue(left);
|
||||||
|
F64 result = 0.0;
|
||||||
|
|
||||||
|
switch (op)
|
||||||
|
{
|
||||||
|
case '+':
|
||||||
|
result = leftValue + rightValue;
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
result = leftValue - rightValue;
|
||||||
|
break;
|
||||||
|
case '*':
|
||||||
|
result = leftValue * rightValue;
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
if (rightValue != 0.0)
|
||||||
|
result = leftValue / rightValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
optimizedNode = FloatNode::alloc(dbgLineNumber, result);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IntBinaryExprNode::optimize()
|
||||||
|
{
|
||||||
|
if (op == '%' && left->getExprNodeNameEnum() == NameVarNode && isLiteralNumber(right))
|
||||||
|
{
|
||||||
|
// %a % intconst
|
||||||
|
S32 val = getIntValue(right);
|
||||||
|
switch (val)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
op = '&';
|
||||||
|
optimizedNode = IntNode::alloc(dbgLineNumber, 1);
|
||||||
|
return true;
|
||||||
|
case 4:
|
||||||
|
op = '&';
|
||||||
|
optimizedNode = IntNode::alloc(dbgLineNumber, 3);
|
||||||
|
return true;
|
||||||
|
case 8:
|
||||||
|
op = '&';
|
||||||
|
optimizedNode = IntNode::alloc(dbgLineNumber, 7);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -2962,7 +2962,7 @@ DefineEngineStringlyVariadicMethod( SimObject, call, const char*, 3, 0, "( strin
|
||||||
"@param args Zero or more arguments for the method.\n"
|
"@param args Zero or more arguments for the method.\n"
|
||||||
"@return The result of the method call." )
|
"@return The result of the method call." )
|
||||||
{
|
{
|
||||||
argv[1] = argv[2];
|
argv[1].setString(argv[2], dStrlen(argv[2]));
|
||||||
return Con::execute( object, argc - 1, argv + 1 );
|
return Con::execute( object, argc - 1, argv + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3065,9 +3065,9 @@ DefineEngineStringlyVariadicMethod( SimObject,schedule, S32, 4, 0, "( float time
|
||||||
"@param args The arguments with which to call the method.\n"
|
"@param args The arguments with which to call the method.\n"
|
||||||
"@return The numeric ID of the created schedule. Can be used to cancel the call.\n" )
|
"@return The numeric ID of the created schedule. Can be used to cancel the call.\n" )
|
||||||
{
|
{
|
||||||
U32 timeDelta = U32(dAtof(argv[2]));
|
U32 timeDelta = U32(argv[2].getFloat());
|
||||||
argv[2] = argv[3];
|
argv[2].setString(argv[3].getString());
|
||||||
argv[3] = argv[1];
|
argv[3].setString(argv[1].getString());
|
||||||
SimConsoleEvent *evt = new SimConsoleEvent(argc - 2, argv + 2, true);
|
SimConsoleEvent *evt = new SimConsoleEvent(argc - 2, argv + 2, true);
|
||||||
S32 ret = Sim::postEvent(object, evt, Sim::getCurrentTime() + timeDelta);
|
S32 ret = Sim::postEvent(object, evt, Sim::getCurrentTime() + timeDelta);
|
||||||
// #ifdef DEBUG
|
// #ifdef DEBUG
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifdef 0
|
#if 0
|
||||||
|
|
||||||
#ifdef TORQUE_TESTS_ENABLED
|
#ifdef TORQUE_TESTS_ENABLED
|
||||||
#include "testing/unitTesting.h"
|
#include "testing/unitTesting.h"
|
||||||
|
|
|
||||||
|
|
@ -361,10 +361,8 @@ void GuiGameListMenuCtrl::onRenderSliderOption(Row* row, Point2I currentOffset)
|
||||||
// calculate text to be at the center between the arrows
|
// calculate text to be at the center between the arrows
|
||||||
GFont* font = profile->mFont;
|
GFont* font = profile->mFont;
|
||||||
|
|
||||||
ConsoleValue val;
|
char stringVal[32];
|
||||||
val.setFloatValue(row->mValue);
|
dSprintf(stringVal, 32, "%f", row->mValue);
|
||||||
|
|
||||||
const char* stringVal = val.getStringValue();
|
|
||||||
|
|
||||||
S32 textWidth = font->getStrWidth(stringVal);
|
S32 textWidth = font->getStrWidth(stringVal);
|
||||||
S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
|
S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ DefineEngineStringlyVariadicMethod(CustomShaderFeatureData, writeLine, void, 3,
|
||||||
"@param args Zero or more arguments for the method.\n"
|
"@param args Zero or more arguments for the method.\n"
|
||||||
"@return The result of the method call.")
|
"@return The result of the method call.")
|
||||||
{
|
{
|
||||||
object->writeLine(argv[2], argc - 3, argv + 3);
|
object->writeLine(argv[2].getString(), argc - 3, argv + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(CustomShaderFeatureData, hasFeature, bool, (String name), (""), "")
|
DefineEngineMethod(CustomShaderFeatureData, hasFeature, bool, (String name), (""), "")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue