Skip to content

Commit d20f739

Browse files
author
Stephen Hansen
committed
Fix enum parsing bug with decimals as char values
1 parent 7dfe473 commit d20f739

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,8 @@ def resolve_enum_values(self, values):
13501350
# Remove single quotes from single quoted chars (unless part of some expression
13511351
if len(a) == 3 and a[0] == "'" and a[2] == "'":
13521352
a = v["value"] = a[1]
1353-
if a.lower().startswith("0x"):
1353+
a = i = ord(a)
1354+
elif a.lower().startswith("0x"):
13541355
try:
13551356
i = a = int(a, 16)
13561357
except:

test/TestSampleClass.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace Alpha
7373
Z_B = 0x2B,
7474
Z_C = 'j',
7575
Z_D,
76+
Z_E = '9',
7677
} Zebra;
7778
};
7879

test/test_CppHeaderParser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ def test_values(self):
418418
{"name": "Z_B", "raw_value": "0x2B", "value": 43},
419419
{"name": "Z_C", "raw_value": "j", "value": 106},
420420
{"name": "Z_D", "value": 107},
421+
{"name": "Z_E", "raw_value": "9", "value": 57},
421422
],
422423
)
423424

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy