Skip to content

Commit 72dc4e8

Browse files
authored
Merge pull request #79 from stephen-hansen/decimal_char_enum_fix
Fix enum parsing bug regarding decimal digit characters
2 parents 7dfe473 + fd528bb commit 72dc4e8

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ namespace Alpha
7373
Z_B = 0x2B,
7474
Z_C = 'j',
7575
Z_D,
76+
Z_E = '9',
77+
Z_F = 9,
7678
} Zebra;
7779
};
7880

test/test_CppHeaderParser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ 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},
422+
{"name": "Z_F", "value": 9},
421423
],
422424
)
423425

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