Reflection no longer part of markup. Some tokeniser not done on markup.
This commit is contained in:
parent
af0cf9bbc1
commit
385478d89e
28
cfg/qt.cfg
28
cfg/qt.cfg
|
@ -24,6 +24,7 @@
|
|||
<block name="onFocusedChanged"/>
|
||||
<block name="onSubmittedNewStatusChanged"/>
|
||||
<block name="onCreationCompleted"/>
|
||||
<block name="onFileSelected"/>
|
||||
<!-- code block structure in QML is:
|
||||
onClicked: {
|
||||
call(var)
|
||||
|
@ -33,6 +34,15 @@
|
|||
name token so we skip them -->
|
||||
</codeblocks>
|
||||
|
||||
<codeblocks>
|
||||
<block name="function"/>
|
||||
<!-- code block structure in QML is:
|
||||
funnction x(args): {
|
||||
call(var)
|
||||
} -->
|
||||
<structure offset="2" start="{" end="}"/>
|
||||
</codeblocks>
|
||||
|
||||
<!-- Qt Properties have the format :
|
||||
Q_PROPERTY(<type> <name> READ <func> WRITE <func> NOTIFY <func>)
|
||||
the READ/WRITE/NOTIFY parts are optional -->
|
||||
|
@ -52,21 +62,9 @@
|
|||
</markup>
|
||||
|
||||
<!-- qt can call methods as strings using invokeMethod -->
|
||||
<markup ext=".c" reporterrors="true">
|
||||
<reflection>
|
||||
<call arg="4">invokeMethod</call>
|
||||
</reflection>
|
||||
</markup>
|
||||
<markup ext=".cpp" reporterrors="true">
|
||||
<reflection>
|
||||
<call arg="4">invokeMethod</call>
|
||||
</reflection>
|
||||
</markup>
|
||||
<markup ext=".cxx" reporterrors="true">
|
||||
<reflection>
|
||||
<call arg="4">invokeMethod</call>
|
||||
</reflection>
|
||||
</markup>
|
||||
<reflection>
|
||||
<call arg="4">invokeMethod</call>
|
||||
</reflection>
|
||||
|
||||
<!-- the SLOT/SIGNAL methods can be cause false-positives for pure
|
||||
virtual functions being called in the constructor because it sees
|
||||
|
|
|
@ -100,11 +100,15 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
|
|||
// parsing of library code to find called functions
|
||||
if (settings->library.isexecutableblock(FileName, tok->str())) {
|
||||
const Token * markupVarToken = tok->tokAt(settings->library.blockstartoffset(FileName));
|
||||
int scope = 1;
|
||||
int scope = 0;
|
||||
bool start = true;
|
||||
// find all function calls in library code (starts with '(', not if or while etc)
|
||||
while (scope) {
|
||||
while (scope || start) {
|
||||
if (markupVarToken->str() == settings->library.blockstart(FileName)) {
|
||||
scope++;
|
||||
if (start) {
|
||||
start = false;
|
||||
}
|
||||
} else if (markupVarToken->str() == settings->library.blockend(FileName))
|
||||
scope--;
|
||||
else if (!settings->library.iskeyword(FileName, markupVarToken->str())) {
|
||||
|
@ -163,8 +167,8 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
|
|||
}
|
||||
}
|
||||
|
||||
if (settings->library.isreflection(FileName, tok->str())) {
|
||||
const int index = settings->library.reflectionArgument(FileName, tok->str());
|
||||
if (settings->library.isreflection(tok->str())) {
|
||||
const int index = settings->library.reflectionArgument(tok->str());
|
||||
if (index >= 0) {
|
||||
const Token * funcToken = tok->tokAt(index);
|
||||
if (funcToken) {
|
||||
|
|
|
@ -195,6 +195,19 @@ bool Library::load(const tinyxml2::XMLDocument &doc)
|
|||
}
|
||||
}
|
||||
|
||||
else if (strcmp(node->Name(), "reflection") == 0) {
|
||||
for (const tinyxml2::XMLElement *reflectionnode = node->FirstChildElement(); reflectionnode; reflectionnode = reflectionnode->NextSiblingElement()) {
|
||||
if (strcmp(reflectionnode->Name(), "call") != 0)
|
||||
return false;
|
||||
|
||||
const char * const argString = reflectionnode->Attribute("arg");
|
||||
if (!argString)
|
||||
return false;
|
||||
|
||||
_reflection[reflectionnode->GetText()] = atoi(argString);
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(node->Name(), "markup") == 0) {
|
||||
const char * const extension = node->Attribute("ext");
|
||||
if (!extension)
|
||||
|
@ -245,19 +258,6 @@ bool Library::load(const tinyxml2::XMLDocument &doc)
|
|||
}
|
||||
}
|
||||
|
||||
else if (strcmp(markupnode->Name(), "reflection") == 0) {
|
||||
for (const tinyxml2::XMLElement *reflectionnode = markupnode->FirstChildElement(); reflectionnode; reflectionnode = reflectionnode->NextSiblingElement()) {
|
||||
if (strcmp(reflectionnode->Name(), "call") != 0)
|
||||
return false;
|
||||
|
||||
const char * const argString = reflectionnode->Attribute("arg");
|
||||
if (!argString)
|
||||
return false;
|
||||
|
||||
_reflection[extension][reflectionnode->GetText()] = atoi(argString);
|
||||
}
|
||||
}
|
||||
|
||||
else if (strcmp(markupnode->Name(), "codeblocks") == 0) {
|
||||
for (const tinyxml2::XMLElement *blocknode = markupnode->FirstChildElement(); blocknode; blocknode = blocknode->NextSiblingElement()) {
|
||||
if (strcmp(blocknode->Name(), "block") == 0)
|
||||
|
|
|
@ -248,22 +248,18 @@ public:
|
|||
return (it != _importers.end() && it->second.count(importer) > 0);
|
||||
}
|
||||
|
||||
bool isreflection(const std::string& file, const std::string &token) const {
|
||||
const std::map<std::string,std::map<std::string,int> >::const_iterator it
|
||||
= _reflection.find(Path::getFilenameExtensionInLowerCase(file));
|
||||
return (it != _reflection.end() && it->second.count(token));
|
||||
bool isreflection(const std::string &token) const {
|
||||
const std::map<std::string,int>::const_iterator it
|
||||
= _reflection.find(token);
|
||||
return it != _reflection.end();
|
||||
}
|
||||
|
||||
int reflectionArgument(const std::string& file, const std::string &token) const {
|
||||
int reflectionArgument(const std::string &token) const {
|
||||
int argIndex = -1;
|
||||
const std::map<std::string,std::map<std::string,int> >::const_iterator it
|
||||
= _reflection.find(Path::getFilenameExtensionInLowerCase(file));
|
||||
const std::map<std::string,int>::const_iterator it
|
||||
= _reflection.find(token);
|
||||
if (it != _reflection.end()) {
|
||||
const std::map<std::string,int>::const_iterator it2 =
|
||||
it->second.find(token);
|
||||
if (it2 != it->second.end()) {
|
||||
argIndex = it2->second;
|
||||
}
|
||||
argIndex = it->second;
|
||||
}
|
||||
return argIndex;
|
||||
}
|
||||
|
@ -338,7 +334,7 @@ private:
|
|||
std::map<std::string, CodeBlock> _executableblocks; // keywords for blocks of executable code
|
||||
std::map<std::string, ExportedFunctions> _exporters; // keywords that export variables/functions to libraries (meta-code/macros)
|
||||
std::map<std::string, std::set<std::string> > _importers; // keywords that import variables/functions
|
||||
std::map<std::string, std::map<std::string,int> > _reflection; // invocation of reflection
|
||||
std::map<std::string,int> _reflection; // invocation of reflection
|
||||
std::map<std::string, std::pair<bool, bool> > _formatstr; // Parameters for format string checking
|
||||
|
||||
|
||||
|
|
|
@ -1590,9 +1590,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
}
|
||||
|
||||
Token::isCPP(isCPP());
|
||||
|
||||
if (simplifyTokenList1()) {
|
||||
|
||||
if (simplifyTokenList1(FileName)) {
|
||||
createSymbolDatabase();
|
||||
|
||||
// Use symbol database to identify rvalue references. Split && to & &. This is safe, since it doesn't delete any tokens (which might be referenced by symbol database)
|
||||
|
@ -3018,7 +3016,7 @@ bool Tokenizer::simplifySizeof()
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Tokenizer::simplifyTokenList1()
|
||||
bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||
{
|
||||
if (_settings->terminated())
|
||||
return false;
|
||||
|
@ -3146,7 +3144,8 @@ bool Tokenizer::simplifyTokenList1()
|
|||
// ";a+=b;" => ";a=a+b;"
|
||||
simplifyCompoundAssignment();
|
||||
|
||||
if (hasComplicatedSyntaxErrorsInTemplates()) {
|
||||
if (!_settings->library.markupFile(FileName)
|
||||
&& hasComplicatedSyntaxErrorsInTemplates()) {
|
||||
list.deallocateTokens();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -103,10 +103,13 @@ public:
|
|||
/**
|
||||
* Basic simplification of tokenlist
|
||||
*
|
||||
* @param FileName The filename to run; used to do
|
||||
* markup checks.
|
||||
*
|
||||
* @return false if there is an error that requires aborting
|
||||
* the checking of this file.
|
||||
*/
|
||||
bool simplifyTokenList1();
|
||||
bool simplifyTokenList1(const char FileName[]);
|
||||
|
||||
/**
|
||||
* Most aggressive simplification of tokenlist
|
||||
|
|
Loading…
Reference in New Issue