diff --git a/CppHeaderParser/CppHeaderParser.py b/CppHeaderParser/CppHeaderParser.py index 2825efb..8a31464 100644 --- a/CppHeaderParser/CppHeaderParser.py +++ b/CppHeaderParser/CppHeaderParser.py @@ -2458,11 +2458,38 @@ def _evaluate_property_stack(self, clearStack=True, addToVar=None): self.nameStack, ". Separating processing", ) - orig_nameStack = self.nameStack[:] + i = leftMostComma - 2 # start right before the first var name + typeFound = [] + typeEndIndex = 0 + + while not i < 0: # find the type by assuming that the first non-ptr/ref related word before the first varname has to be the end of the type stack + if self.nameStack[i] == "*" or self.nameStack[i] == "&": + if i > 0 and self.nameStack[i - 1] == "const": # handle declarations like "int const& const_int_ref;" correctly + i -= 1; # skip next const + else: # the real type declaration starts (ends) at index i + typeEndIndex = i + 1 + typeFound.extend(self.nameStack[0:i + 1]) - type_nameStack = orig_nameStack[: leftMostComma - 1] - for name in orig_nameStack[leftMostComma - 1 :: 2]: - self.nameStack = type_nameStack + [name] + break + + i-= 1 + + nameStacks = [] + currStack = typeFound.copy() + + for word in self.nameStack[typeEndIndex:]: + if word == ",": + nameStacks.append(currStack) + currStack = typeFound.copy() # reset currStack + continue + + currStack.append(word) + + if not currStack == typeFound: # add last var in the list + nameStacks.append(currStack) + + for nameStack in nameStacks: + self.nameStack = nameStack self._evaluate_property_stack( clearStack=False, addToVar=addToVar ) diff --git a/test/TestSampleClass.h b/test/TestSampleClass.h index 439635c..ad89f52 100644 --- a/test/TestSampleClass.h +++ b/test/TestSampleClass.h @@ -52,7 +52,7 @@ class SampleClass: public BaseSampleClass double prop7; //!< prop7 description //!< with two lines - + /// prop8 description int prop8; }; @@ -642,6 +642,7 @@ class Grape int a, b,c; map d; map e, f; + const int* g, const& h, const* i, j; }; // Bug BitBucket #14 @@ -719,7 +720,7 @@ struct Lemon virtual void foo() final; virtual void foo2(); }; - + struct Lime final : Lemon { void abc(); @@ -749,12 +750,12 @@ union olive { // Sourceforge bug 61 typedef struct -{ - enum BeetEnum : int - { +{ + enum BeetEnum : int + { FAIL = 0, PASS = 1 - }; + }; } BeetStruct; void set_callback(int* b, long (*callback) (struct test_st *, int, const char*, int long, long, long)); diff --git a/test/test_CppHeaderParser.py b/test/test_CppHeaderParser.py index 1be0344..9e025a5 100644 --- a/test/test_CppHeaderParser.py +++ b/test/test_CppHeaderParser.py @@ -1752,7 +1752,7 @@ class functions_TestCase(unittest.TestCase): def setUp(self): self.cppHeader = CppHeaderParser.CppHeader( """\ - void global_funct1(int i); + void global_funct1(int i); int global_funct2(void); """, "string", @@ -1787,7 +1787,7 @@ class functions2_TestCase(unittest.TestCase): def setUp(self): self.cppHeader = CppHeaderParser.CppHeader( """\ - void global_funct1(int i); + void global_funct1(int i); int global_funct2(void){ // do something } @@ -2171,6 +2171,45 @@ def test_f_exists(self): self.cppHeader.classes["Grape"]["properties"]["public"][5]["name"], "f" ) + def test_g_exists(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][6]["name"], "g" + ) + + def test_g_type(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][6]["type"], "const int *" + ) + + def test_h_exists(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][7]["name"], "h" + ) + + def test_h_type(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][7]["type"], "const int const &" + ) + + def test_i_exists(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][8]["name"], "i" + ) + + def test_i_type(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][8]["type"], "const int const *" + ) + + def test_j_exists(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][9]["name"], "j" + ) + + def test_j_type(self): + self.assertEqual( + self.cppHeader.classes["Grape"]["properties"]["public"][9]["type"], "const int" + ) # Bug BitBucket #14 class Avacado_TestCase(unittest.TestCase): @@ -2433,7 +2472,7 @@ def setUp(self): virtual void foo() final; virtual void foo2(); }; - + struct Lime final : Lemon { void abc(); @@ -3488,7 +3527,7 @@ class StaticAssert_TestCase(unittest.TestCase): def setUp(self): self.cppHeader = CppHeaderParser.CppHeader( """ -static_assert(sizeof(int) == 4, +static_assert(sizeof(int) == 4, "integer size is wrong" "for some reason"); """, @@ -3511,7 +3550,7 @@ def setUp(self): } void fn(); - + std::vector m_stuff; }; @@ -3859,7 +3898,7 @@ def setUp(self): template class A { public: typedef B C; - + A(); protected: 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