Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPPParser fix for std::function parameter #4013

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions CppParser/src/Symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Poco/String.h"
#include <cctype>
#include <cstddef>
#include <iostream>


namespace Poco {
Expand Down Expand Up @@ -167,14 +168,25 @@ 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;
while (pos > 0 && decl[pos] != '[') --pos;
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 ->, >>
Expand Down Expand Up @@ -211,7 +223,35 @@ std::string Symbol::extractName(const std::string& decl)
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<bool(int, int)> 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 << "end " << pos << std::endl;

std::cout << decl << pos << std::endl;

return decl.substr(pos, end - pos + 1);
}
else
return std::string();
}
Expand Down