From d20f739fe8e9570b14ac7dbc9996d64478cd1c83 Mon Sep 17 00:00:00 2001 From: Stephen Hansen Date: Wed, 26 Oct 2022 21:42:31 -0400 Subject: [PATCH 1/2] Fix enum parsing bug with decimals as char values --- CppHeaderParser/CppHeaderParser.py | 3 ++- test/TestSampleClass.h | 1 + test/test_CppHeaderParser.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CppHeaderParser/CppHeaderParser.py b/CppHeaderParser/CppHeaderParser.py index a13ad2e..a07ad6e 100644 --- a/CppHeaderParser/CppHeaderParser.py +++ b/CppHeaderParser/CppHeaderParser.py @@ -1350,7 +1350,8 @@ def resolve_enum_values(self, values): # Remove single quotes from single quoted chars (unless part of some expression if len(a) == 3 and a[0] == "'" and a[2] == "'": a = v["value"] = a[1] - if a.lower().startswith("0x"): + a = i = ord(a) + elif a.lower().startswith("0x"): try: i = a = int(a, 16) except: diff --git a/test/TestSampleClass.h b/test/TestSampleClass.h index 439635c..aebae3c 100644 --- a/test/TestSampleClass.h +++ b/test/TestSampleClass.h @@ -73,6 +73,7 @@ namespace Alpha Z_B = 0x2B, Z_C = 'j', Z_D, + Z_E = '9', } Zebra; }; diff --git a/test/test_CppHeaderParser.py b/test/test_CppHeaderParser.py index 46eaaeb..ac93501 100644 --- a/test/test_CppHeaderParser.py +++ b/test/test_CppHeaderParser.py @@ -418,6 +418,7 @@ def test_values(self): {"name": "Z_B", "raw_value": "0x2B", "value": 43}, {"name": "Z_C", "raw_value": "j", "value": 106}, {"name": "Z_D", "value": 107}, + {"name": "Z_E", "raw_value": "9", "value": 57}, ], ) From fd528bb8a4f77e20c8813f6d6e284b73e7995f98 Mon Sep 17 00:00:00 2001 From: Stephen Hansen Date: Wed, 26 Oct 2022 21:53:00 -0400 Subject: [PATCH 2/2] adding an integer to the enum test --- test/TestSampleClass.h | 1 + test/test_CppHeaderParser.py | 1 + 2 files changed, 2 insertions(+) diff --git a/test/TestSampleClass.h b/test/TestSampleClass.h index aebae3c..45efef7 100644 --- a/test/TestSampleClass.h +++ b/test/TestSampleClass.h @@ -74,6 +74,7 @@ namespace Alpha Z_C = 'j', Z_D, Z_E = '9', + Z_F = 9, } Zebra; }; diff --git a/test/test_CppHeaderParser.py b/test/test_CppHeaderParser.py index ac93501..d91edca 100644 --- a/test/test_CppHeaderParser.py +++ b/test/test_CppHeaderParser.py @@ -419,6 +419,7 @@ def test_values(self): {"name": "Z_C", "raw_value": "j", "value": 106}, {"name": "Z_D", "value": 107}, {"name": "Z_E", "raw_value": "9", "value": 57}, + {"name": "Z_F", "value": 9}, ], ) 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