From 51d7c6b86e6af8139e5e4bce3578b089293d8c9b Mon Sep 17 00:00:00 2001 From: Crafty-Codes Date: Fri, 21 Apr 2023 09:34:10 +0200 Subject: [PATCH 1/6] cppParser Symbol: added std::function case --- CppParser/src/Symbol.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index ad2f94f3b8..052b442091 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -210,8 +210,31 @@ std::string Symbol::extractName(const std::string& decl) pos -= 3; while (pos > 0 && isIdent(decl[pos - 1])) --pos; } - if (pos != std::string::npos) + if (pos != std::string::npos){ + // special case if pointer function + // bool example(int x, int y, std::function fcn); + if (decl[pos-2] == '<') + { + uint8_t skipArrow = 0; + while (pos < decl.size()) + { + if (decl[pos] == '<') + { + ++skipArrow; + }else if (decl[pos] == '>') + { + if (skipArrow == 0) + { + return decl.substr(pos+2, decl.size()-pos); + } + --skipArrow; + } + ++pos; + } + } + return decl.substr(pos, end - pos + 1); + } else return std::string(); } From 160ecff2cb73157c0ad135355e7b1acadd563bab Mon Sep 17 00:00:00 2001 From: Crafty-Codes Date: Wed, 3 May 2023 12:51:20 +0200 Subject: [PATCH 2/6] wip --- CppParser/src/Symbol.cpp | 48 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index 052b442091..8723a8348d 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -18,6 +18,7 @@ #include "Poco/String.h" #include #include +#include namespace Poco { @@ -210,28 +211,31 @@ std::string Symbol::extractName(const std::string& decl) pos -= 3; while (pos > 0 && isIdent(decl[pos - 1])) --pos; } - if (pos != std::string::npos){ - // special case if pointer function - // bool example(int x, int y, std::function fcn); - if (decl[pos-2] == '<') - { - uint8_t skipArrow = 0; - while (pos < decl.size()) - { - if (decl[pos] == '<') - { - ++skipArrow; - }else if (decl[pos] == '>') - { - if (skipArrow == 0) - { - return decl.substr(pos+2, decl.size()-pos); - } - --skipArrow; - } - ++pos; - } - } + if (pos != std::string::npos) + { + // // special case if pointer function + // // bool example(int x, int y, std::function fcn); + // if (decl[pos-2] == '<') + // { + // uint8_t skipArrow = 0; + // while (pos < decl.size()) + // { + // if (decl[pos] == '<') + // { + // ++skipArrow; + // }else if (decl[pos] == '>') + // { + // if (skipArrow == 0) + // { + // return decl.substr(pos+2, decl.size()-pos); + // } + // --skipArrow; + // } + // ++pos; + // } + // } + + std::cout << decl << std::endl; return decl.substr(pos, end - pos + 1); } From 2520b21ec286e6c0e8dc7aed1f14aef9431eb740 Mon Sep 17 00:00:00 2001 From: Crafty-Codes Date: Wed, 3 May 2023 12:59:09 +0200 Subject: [PATCH 3/6] wip --- CppParser/src/Symbol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index 8723a8348d..289a00c323 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -235,7 +235,7 @@ std::string Symbol::extractName(const std::string& decl) // } // } - std::cout << decl << std::endl; + std::cout << decl << " after" << decl.substr(pos, end - pos + 1) << std::endl; return decl.substr(pos, end - pos + 1); } From 456b47009c8e4f63b7a206c43726ee5b86c8ebe4 Mon Sep 17 00:00:00 2001 From: Crafty-Codes Date: Wed, 3 May 2023 13:12:03 +0200 Subject: [PATCH 4/6] wip --- CppParser/src/Symbol.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index 289a00c323..d7a1a9fb83 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -168,7 +168,15 @@ std::string Symbol::extractName(const std::string& decl) if ((gtPos == std::string::npos || gtPos > pos || (ltPos != std::string::npos && gtPos > ltPos)) && eqPos < pos && eqPos > 0 && decl[eqPos + 1] != '=') pos = eqPos - 1; } + + std::cout << "before: " << pos << std::endl; + + while (pos > 0 && std::isspace(decl[pos])) --pos; + + + std::cout << "middle: " << pos << std::endl; + while (pos > 0 && decl[pos] == ']') { --pos; @@ -176,6 +184,9 @@ std::string Symbol::extractName(const std::string& decl) if (pos > 0) --pos; while (pos > 0 && std::isspace(decl[pos])) --pos; } + + std::cout << "after: " << pos << std::endl; + // iterate over template (specialization) int nestedTemplateCount = 0; if (pos > 1 && decl[pos] == '>' && decl[pos-1] != '-' && decl[pos-1] != '>') // the operators ->, >> @@ -235,7 +246,7 @@ std::string Symbol::extractName(const std::string& decl) // } // } - std::cout << decl << " after" << decl.substr(pos, end - pos + 1) << std::endl; + std::cout << decl << " after " << decl.substr(pos, end - pos + 1) << std::endl; return decl.substr(pos, end - pos + 1); } From 1652ef824f14e2385b0306224bce27090c2d4cb0 Mon Sep 17 00:00:00 2001 From: Crafty-Codes Date: Wed, 3 May 2023 13:17:24 +0200 Subject: [PATCH 5/6] wip --- CppParser/src/Symbol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index d7a1a9fb83..e346a3b52a 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -246,7 +246,7 @@ std::string Symbol::extractName(const std::string& decl) // } // } - std::cout << decl << " after " << decl.substr(pos, end - pos + 1) << std::endl; + std::cout << "end " << pos << std::endl; return decl.substr(pos, end - pos + 1); } From a62c0475ac56c0bf01fdf23b051b2356cd4cc8ad Mon Sep 17 00:00:00 2001 From: Crafty-Codes Date: Wed, 3 May 2023 13:21:36 +0200 Subject: [PATCH 6/6] wip --- CppParser/src/Symbol.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index e346a3b52a..91306398f6 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -248,6 +248,8 @@ std::string Symbol::extractName(const std::string& decl) std::cout << "end " << pos << std::endl; + std::cout << decl << pos << std::endl; + return decl.substr(pos, end - pos + 1); } else