Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator int() exits break mode in devcat debugger #1484

Closed
UltraEngine opened this issue Apr 18, 2023 · 2 comments
Closed

operator int() exits break mode in devcat debugger #1484

UltraEngine opened this issue Apr 18, 2023 · 2 comments

Comments

@UltraEngine
Copy link

UltraEngine commented Apr 18, 2023

If you bind any class with an operator int() method, it will cause an error with the devcat Lua debugger.

struct TESTCLASS
{
    operator int() const
    {
        return 0;
    }
};

L->new_usertype<TESTCLASS>("TESTCLASS");

When you debug any Lua program, variables appear correctly in the sidepanel display, but hovering the mouse over a variable will cause the program to exit break mode and continue executing: Any simple program will do it:

local a = 0-- <-- 2. Hover the mouse over the letter 'a' and the program will jump to step 3

local b = 0-- <-- 1. Set a breakpoint here

local c = 0-- <-- 3. Set breakpoint here

The reason I am using this operator is so I can do things like this in my C++ table class:

table t;
t["health"] = 100;
int h = t["health"];

This is probably the same problem I had when I tried to integrate nlohmann::json with sol.

@UltraEngine
Copy link
Author

Here is one possible solution, but it's ugly:

struct TESTCLASS
{
    operator int() const
    {
        return 0;
    }
};

struct TESTCLASSWRAPPER : private TESTCLASS
{};

L->new_usertype<TESTCLASSWRAPPER>("TESTCLASS");

UltraEngine added a commit to UltraEngine/tableplusplus that referenced this issue Apr 18, 2023
@UltraEngine
Copy link
Author

I was able to implement a fix for this using the wrapper technique described above. The debugger works correctly now with C++ tables.

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

No branches or pull requests

1 participant