Tentative de mise en place d'une classe dérivée

This commit is contained in:
Horde Nicolas 2021-07-06 15:21:03 +02:00
parent fe633ab032
commit e51bf45b53
3 changed files with 72 additions and 1265 deletions

View File

@ -130,6 +130,26 @@ void ScenarioWindow::adjustSize()
listview.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
}
//----------------------------------------------------------------------
// Classe FListViewEx
//----------------------------------------------------------------------
namespace finalcut
{
FListViewEx::FListViewEx (FWidget* parent)
: FListView{parent}
{
}
FListViewEx::~FListViewEx()
{
}
void FListViewEx::setindex(int index)
{
}
}
//----------------------------------------------------------------------
// Classe InstructionWindow
//----------------------------------------------------------------------
@ -159,6 +179,11 @@ void InstructionWindow::clear()
listview.redraw();
}
void InstructionWindow::setindex(int index)
{
listview.setindex(index);
}
void InstructionWindow::set(std::vector<std::array<std::string, 5>> src)
{
content=src;
@ -538,6 +563,17 @@ void VMEngine::Prepare(State *init, Code *code)
SetRegs(init, code);
}
int VMEngine::getEIP(Code *code)
{
int eip=-666;
err = uc_reg_read(uc, UC_X86_REG_EIP, &eip);
if (err != UC_ERR_OK)
log->append("Impossible de récupérer le registre: EIP");
if ((eip<code->address) || (eip>code->address+code->size))
eip=-666;
return eip;
}
void VMEngine::SetMem(State *init, Code *code)
{
@ -861,7 +897,7 @@ void Menu::initMenusCallBack()
Init.addCallback (
"clicked",
this,
&Menu::initIA
&Menu::verify
);
}
@ -949,11 +985,6 @@ void Menu::about()
AdjustWindows();
}
void Menu::initIA()
{
vm.Prepare(&goals[scenar.getselected()].init,code);
}
bool Menu::verify()
{
if (!code->assembled)
@ -962,7 +993,7 @@ bool Menu::verify()
return false;
}
if (!code->initialized)
initIA();
vm.Prepare(&goals[scenar.getselected()].init,code);
if (!code->initialized)
return false;
return true;
@ -970,15 +1001,23 @@ bool Menu::verify()
void Menu::refresh()
{
if (!code->initialized)
{
regs.set("En attente d'initialisation...");
debug.setindex(-666);
}
else
{
regs.set(vm.getRegs(goals[scenar.getselected()].level));
debug.setindex(vm.getEIP(code));
}
if (!code->executed)
{
finalcut::FApplication::setDarkTheme();
regs.set("En attente d'initialisation...");
}
else
{
finalcut::FApplication::setDefaultTheme();
regs.set(vm.getRegs(goals[scenar.getselected()].level));
}
auto root_widget = getRootWidget();
root_widget->resetColors();

26
ia86.h
View File

@ -167,6 +167,27 @@ class ScenarioWindow final : public finalcut::FDialog
finalcut::FListView listview{this};
};
namespace finalcut
{
class FListViewEx final : public finalcut::FListView
{
public:
// Using-declaration
using FWidget::setGeometry;
using FListViewItems = std::list<FListViewItem*>;
// Constructor
explicit FListViewEx (FWidget* = nullptr);
// Disable copy constructor
FListViewEx (const FListViewEx&) = delete;
// Destructor
~FListViewEx() override;
// Disable copy assignment operator (=)
FListViewEx& operator = (const FListViewEx&) = delete;
void setindex(int index);
};
}
class InstructionWindow final : public finalcut::FDialog
{
public:
@ -182,13 +203,14 @@ class InstructionWindow final : public finalcut::FDialog
std::vector<std::array<std::string, 5>> get();
void set(std::vector<std::array<std::string, 5>> src);
void clear();
void setindex(int index);
private:
// Method
std::vector<std::array<std::string, 5>> content;
void initLayout() override;
void adjustSize() override;
// Data members
finalcut::FListView listview{this};
finalcut::FListViewEx listview{this};
};
class TextEditWindow final : public finalcut::FDialog
@ -283,6 +305,7 @@ class VMEngine
void Prepare(State *init, Code *code);
void SetMem(State *init, Code *code);
void SetRegs(State *init, Code *code);
int getEIP(Code *code);
private:
void Init();
void Close();
@ -323,7 +346,6 @@ class Menu final : public finalcut::FDialog
void about();
void AdjustWindows();
void initWindows();
void initIA();
void initLayout() override;
void adjustSize() override;
// Event handler

1254
test.cpp

File diff suppressed because it is too large Load Diff