Console Refactor

This commit is contained in:
Lukas Aldershaab 2023-04-23 10:39:54 +02:00
parent 626de074cc
commit 89b0c7f73b
89 changed files with 1883 additions and 1553 deletions

View file

@ -26,12 +26,13 @@
#include "console/simBase.h"
#include "console/engineAPI.h"
#include "math/mMath.h"
#include "console/script.h"
#include "console/stringStack.h"
#include "gui/buttons/guiIconButtonCtrl.h"
inline ConsoleValue RunScript(const char* str)
{
return std::move(Con::evaluate(str, false, NULL));
return std::move(Con::evaluate(str, false, NULL).value);
}
using ::testing::Matcher;

View file

@ -7,12 +7,10 @@
#include "console/simBase.h"
#include "console/engineAPI.h"
#include "math/mMath.h"
#include "console/script.h"
#include "console/stringStack.h"
#include "console/consoleInternal.h"
// Stupid globals not declared in a header
extern ExprEvalState gEvalState;
using ::testing::Matcher;
using ::testing::TypedEq;
@ -25,10 +23,10 @@ protected:
void SetUp() override
{
}
};
TEST_F(ConsoleTest, executef)
@ -176,7 +174,7 @@ TEST_F(ConsoleTest, execute)
{
Con::evaluate("function testScriptExecuteFunction(%a,%b) {return %a SPC %b;}\nfunction testScriptExecuteFunction(%a,%b,%this) {return %a SPC %b;}\r\n", false, "testExecute");
U32 startStackPos = gEvalState.getStackDepth();
U32 startStackPos = Con::getFrameStack().size();
U32 startStringStackPos = STR.mStart;
// const char* versions of execute should maintain stack
@ -187,7 +185,7 @@ TEST_F(ConsoleTest, execute)
EXPECT_STREQ(returnValue, "1 2") <<
"execute should return 1 2";
EXPECT_EQ(gEvalState.getStackDepth(), startStackPos) <<
EXPECT_EQ(Con::getFrameStack().size(), startStackPos) <<
"execute should restore stack";
returnValue = Con::execute(4, argvObject);
@ -195,6 +193,6 @@ TEST_F(ConsoleTest, execute)
EXPECT_STREQ(returnValue, "1 2") <<
"execute should return 1 2";
EXPECT_EQ(gEvalState.getStackDepth(), startStackPos) <<
EXPECT_EQ(Con::getFrameStack().size(), startStackPos) <<
"execute should restore stack";
}

View file

@ -7,6 +7,7 @@
#include "console/simBase.h"
#include "console/engineAPI.h"
#include "math/mMath.h"
#include "console/script.h"
using ::testing::Matcher;
using ::testing::TypedEq;

View file

@ -25,6 +25,7 @@
#include "console/simBase.h"
#include "console/consoleTypes.h"
#include "console/runtimeClassRep.h"
#include "console/script.h"
class RuntimeRegisteredSimObject : public SimObject
{

View file

@ -23,7 +23,7 @@
#include "app/mainLoop.h"
#include "console/console.h"
#include "console/codeBlock.h"
#include "console/script.h"
#include "console/engineAPI.h"
#include "console/consoleInternal.h"
#include "gfx/gfxInit.h"
@ -32,6 +32,8 @@
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
//-----------------------------------------------------------------------------
class TorqueUnitTestListener : public ::testing::EmptyTestEventListener
@ -195,9 +197,9 @@ DefineEngineFunction(addUnitTest, void, (const char* function), ,
U32 ln = __LINE__;
if (entry != NULL)
{
file = entry->mCode->name;
file = entry->mModule->getName();
U32 inst;
entry->mCode->findBreakLine(entry->mFunctionOffset, ln, inst);
entry->mModule->findBreakLine(entry->mFunctionOffset, ln, inst);
}
else
{
@ -210,9 +212,9 @@ DefineEngineFunction(addUnitTest, void, (const char* function), ,
String scriptFileMessage(const char* message)
{
Dictionary* frame = &gEvalState.getCurrentFrame();
CodeBlock* code = frame->code;
const char* scriptLine = code->getFileLine(frame->ip);
Dictionary* frame = Con::getCurrentStackFrame();
Con::Module* module = frame->module;
const char* scriptLine = module->getFileLine(frame->ip);
return String::ToString("at %s: %s", scriptLine, message);
}