python-autopxd2 icon indicating copy to clipboard operation
python-autopxd2 copied to clipboard

It seems that autopxd occasionally can't handle characters in enum

Open Poiuzy opened this issue 2 years ago • 0 comments

When I execute the command: autopxd test.h

// test.h
typedef enum
{
    SDL_SCANCODE_CAPSLOCK = 57,
} SDL_Scancode;

#define SDLK_SCANCODE_MASK (1<<30)
#define SDL_SCANCODE_TO_KEYCODE(X)  (X | SDLK_SCANCODE_MASK)

typedef enum
{
    SDLK_z = 'z',
    SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK),
} SDL_KeyCode;

an error was thrown

File "D:/msys64/ucrt64/lib/python3.11/site-packages/autopxd/writer.py", line 125, in visit_Enum
    value = str(int(value, base=0) + 1)
                ^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 0: "'z'"

It seems that autopxd occasionally can't handle characters in enum.

Poiuzy avatar Oct 14 '23 09:10 Poiuzy