diff --git a/CppHeaderParser/CppHeaderParser.py b/CppHeaderParser/CppHeaderParser.py index 04073fa..007d78a 100644 --- a/CppHeaderParser/CppHeaderParser.py +++ b/CppHeaderParser/CppHeaderParser.py @@ -2346,6 +2346,10 @@ def _evaluate_method_stack(self): ) newMethod["parent"] = None self.functions.append(newMethod) + + # Reset template once it has been used + self.curTemplate = None + global parseHistory parseHistory.append( { @@ -2549,6 +2553,7 @@ def _evaluate_class_stack(self): self._get_location(self.nameStack), self.curAccessSpecifier, ) + self.curTemplate = None newClass["declaration_method"] = self.nameStack[0] self.classes_order.append(newClass) # good idea to save ordering self.stack = [] # fixes if class declared with ';' in closing brace diff --git a/test/test_CppHeaderParser.py b/test/test_CppHeaderParser.py index a4b545b..9656437 100644 --- a/test/test_CppHeaderParser.py +++ b/test/test_CppHeaderParser.py @@ -3978,5 +3978,37 @@ def test_fn(self): self.assertEqual("N1::N2", c["namespace"]) +class TemplateMustBeCleared(unittest.TestCase): + def setUp(self): + self.cppHeader = CppHeaderParser.CppHeader( + """ +template class LinearPlantInversionFeedforward { +public: + template + LinearPlantInversionFeedforward( + const LinearSystem &plant, units::second_t dt) + : LinearPlantInversionFeedforward(plant.A(), plant.B(), dt) {} + + LinearPlantInversionFeedforward( + const Eigen::Matrix &A, + const Eigen::Matrix &B, units::second_t dt) + : m_dt(dt) { + DiscretizeAB(A, B, dt, &m_A, &m_B); + + m_r.setZero(); + Reset(m_r); + } +}; +""", + "string", + ) + + def test_fn(self): + c = self.cppHeader.classes["LinearPlantInversionFeedforward"] + self.assertEqual("LinearPlantInversionFeedforward", c["name"]) + self.assertEqual("template", c["methods"]["public"][0]["template"]) + self.assertEqual(False, c["methods"]["public"][1]["template"]) + + if __name__ == "__main__": unittest.main() 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