Skip to content

Conversation

@Mchan2003
Copy link
Collaborator

@Mchan2003 Mchan2003 commented Sep 15, 2025

Fixes #33

Copy link
Collaborator

@PhazonicRidley PhazonicRidley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good! One small design question, is there a reason you are using raw pointers for your states? Do they need to stay alive after exiting? If so, is there a reason you are using raw pointers over smart pointers

Copy link
Collaborator

@PhazonicRidley PhazonicRidley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good! Just some final tweaks :)

std::optional<std::reference_wrapper<State>> StateMachine::get_current_state()
{
if (m_current_state) {
return std::ref(**m_current_state);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use the deref operator directly on an optional, this is UB. Please use one of the following methods to safely get access to what optional is wrapping: https://en.cppreference.com/w/cpp/utility/optional.html

If you wish to just throw an exception if its nullopt, use .value()

expect(actual_state.has_value()) << "A State is initialized";

State& actual_state_ref = actual_state.value().get();
expect(typeid(actual_state_ref) == typeid(UserInputState))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add that % in front of your boolean expressions. This is so, if it errors it shows you the actual expression that was not true. Without that it will just show false

Example: https://godbolt.org/z/KMPr7ojfY

@kammce
Copy link
Member

kammce commented Nov 10, 2025

Whats the purpose of the state machine? Each state looks like its just another step in the process. Whats the need for polymorphism and interfaces? Why not just write a function that performs the steps.

  1. Read elf file and break apart
  2. Pass exception tables into functions to parse them
  3. Run algorithm to find all uncaught exceptions

I'm not sure where there are states here.

@Mchan2003 Mchan2003 self-assigned this Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State Machine boilerplate

4 participants