Renamed Library private member variables

This commit is contained in:
Daniel Marjamäki 2018-06-17 16:39:10 +02:00
parent fb8e970419
commit dbf89856c0
2 changed files with 74 additions and 74 deletions

View File

@ -148,8 +148,8 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
int allocationId = 0; int allocationId = 0;
for (const tinyxml2::XMLElement *memorynode = node->FirstChildElement(); memorynode; memorynode = memorynode->NextSiblingElement()) { for (const tinyxml2::XMLElement *memorynode = node->FirstChildElement(); memorynode; memorynode = memorynode->NextSiblingElement()) {
if (strcmp(memorynode->Name(),"dealloc")==0) { if (strcmp(memorynode->Name(),"dealloc")==0) {
const std::map<std::string, AllocFunc>::const_iterator it = _dealloc.find(memorynode->GetText()); const std::map<std::string, AllocFunc>::const_iterator it = mDealloc.find(memorynode->GetText());
if (it != _dealloc.end()) { if (it != mDealloc.end()) {
allocationId = it->second.groupId; allocationId = it->second.groupId;
break; break;
} }
@ -187,7 +187,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
temp.arg = atoi(arg); temp.arg = atoi(arg);
else else
temp.arg = 1; temp.arg = 1;
_dealloc[memorynode->GetText()] = temp; mDealloc[memorynode->GetText()] = temp;
} else if (memorynodename == "use") } else if (memorynodename == "use")
functions[memorynode->GetText()].use = true; functions[memorynode->GetText()].use = true;
else else
@ -232,7 +232,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
if (!argString) if (!argString)
return Error(MISSING_ATTRIBUTE, "arg"); return Error(MISSING_ATTRIBUTE, "arg");
_reflection[reflectionnode->GetText()] = atoi(argString); mReflection[reflectionnode->GetText()] = atoi(argString);
} }
} }
@ -240,10 +240,10 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
const char * const extension = node->Attribute("ext"); const char * const extension = node->Attribute("ext");
if (!extension) if (!extension)
return Error(MISSING_ATTRIBUTE, "ext"); return Error(MISSING_ATTRIBUTE, "ext");
_markupExtensions.insert(extension); mMarkupExtensions.insert(extension);
_reporterrors[extension] = (node->Attribute("reporterrors", "true") != nullptr); mReportErrors[extension] = (node->Attribute("reporterrors", "true") != nullptr);
_processAfterCode[extension] = (node->Attribute("aftercode", "true") != nullptr); mProcessAfterCode[extension] = (node->Attribute("aftercode", "true") != nullptr);
for (const tinyxml2::XMLElement *markupnode = node->FirstChildElement(); markupnode; markupnode = markupnode->NextSiblingElement()) { for (const tinyxml2::XMLElement *markupnode = node->FirstChildElement(); markupnode; markupnode = markupnode->NextSiblingElement()) {
const std::string markupnodename = markupnode->Name(); const std::string markupnodename = markupnode->Name();
@ -253,7 +253,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
const char* nodeName = librarynode->Attribute("name"); const char* nodeName = librarynode->Attribute("name");
if (nodeName == nullptr) if (nodeName == nullptr)
return Error(MISSING_ATTRIBUTE, "name"); return Error(MISSING_ATTRIBUTE, "name");
_keywords[extension].insert(nodeName); mKeywords[extension].insert(nodeName);
} else } else
unknown_elements.insert(librarynode->Name()); unknown_elements.insert(librarynode->Name());
} }
@ -273,9 +273,9 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
for (const tinyxml2::XMLElement *e = exporter->FirstChildElement(); e; e = e->NextSiblingElement()) { for (const tinyxml2::XMLElement *e = exporter->FirstChildElement(); e; e = e->NextSiblingElement()) {
const std::string ename = e->Name(); const std::string ename = e->Name();
if (ename == "prefix") if (ename == "prefix")
_exporters[prefix].addPrefix(e->GetText()); mExporters[prefix].addPrefix(e->GetText());
else if (ename == "suffix") else if (ename == "suffix")
_exporters[prefix].addSuffix(e->GetText()); mExporters[prefix].addSuffix(e->GetText());
else else
unknown_elements.insert(ename); unknown_elements.insert(ename);
} }
@ -285,7 +285,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
else if (markupnodename == "imported") { else if (markupnodename == "imported") {
for (const tinyxml2::XMLElement *librarynode = markupnode->FirstChildElement(); librarynode; librarynode = librarynode->NextSiblingElement()) { for (const tinyxml2::XMLElement *librarynode = markupnode->FirstChildElement(); librarynode; librarynode = librarynode->NextSiblingElement()) {
if (strcmp(librarynode->Name(), "importer") == 0) if (strcmp(librarynode->Name(), "importer") == 0)
_importers[extension].insert(librarynode->GetText()); mImporters[extension].insert(librarynode->GetText());
else else
unknown_elements.insert(librarynode->Name()); unknown_elements.insert(librarynode->Name());
} }
@ -297,17 +297,17 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
if (blocknodename == "block") { if (blocknodename == "block") {
const char * blockName = blocknode->Attribute("name"); const char * blockName = blocknode->Attribute("name");
if (blockName) if (blockName)
_executableblocks[extension].addBlock(blockName); mExecutableBlocks[extension].addBlock(blockName);
} else if (blocknodename == "structure") { } else if (blocknodename == "structure") {
const char * start = blocknode->Attribute("start"); const char * start = blocknode->Attribute("start");
if (start) if (start)
_executableblocks[extension].setStart(start); mExecutableBlocks[extension].setStart(start);
const char * end = blocknode->Attribute("end"); const char * end = blocknode->Attribute("end");
if (end) if (end)
_executableblocks[extension].setEnd(end); mExecutableBlocks[extension].setEnd(end);
const char * offset = blocknode->Attribute("offset"); const char * offset = blocknode->Attribute("offset");
if (offset) if (offset)
_executableblocks[extension].setOffset(atoi(offset)); mExecutableBlocks[extension].setOffset(atoi(offset));
} }
else else
@ -537,7 +537,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) { for (const tinyxml2::XMLElement *functionnode = node->FirstChildElement(); functionnode; functionnode = functionnode->NextSiblingElement()) {
const std::string functionnodename = functionnode->Name(); const std::string functionnodename = functionnode->Name();
if (functionnodename == "noreturn") if (functionnodename == "noreturn")
_noreturn[name] = (strcmp(functionnode->GetText(), "true") == 0); mNoReturn[name] = (strcmp(functionnode->GetText(), "true") == 0);
else if (functionnodename == "pure") else if (functionnodename == "pure")
func.ispure = true; func.ispure = true;
else if (functionnodename == "const") { else if (functionnodename == "const") {
@ -549,11 +549,11 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
func.useretval = true; func.useretval = true;
else if (functionnodename == "returnValue") { else if (functionnodename == "returnValue") {
if (const char *expr = functionnode->GetText()) if (const char *expr = functionnode->GetText())
_returnValue[name] = expr; mReturnValue[name] = expr;
if (const char *type = functionnode->Attribute("type")) if (const char *type = functionnode->Attribute("type"))
_returnValueType[name] = type; mReturnValueType[name] = type;
if (const char *container = functionnode->Attribute("container")) if (const char *container = functionnode->Attribute("container"))
_returnValueContainer[name] = std::atoi(container); mReturnValueContainer[name] = std::atoi(container);
} else if (functionnodename == "arg") { } else if (functionnodename == "arg") {
const char* argNrString = functionnode->Attribute("nr"); const char* argNrString = functionnode->Attribute("nr");
if (!argNrString) if (!argNrString)
@ -832,7 +832,7 @@ const Library::AllocFunc* Library::alloc(const Token *tok) const
const Library::AllocFunc* Library::dealloc(const Token *tok) const const Library::AllocFunc* Library::dealloc(const Token *tok) const
{ {
const std::string funcname = getFunctionName(tok); const std::string funcname = getFunctionName(tok);
return isNotLibraryFunction(tok) && functions.find(funcname) != functions.end() ? nullptr : getAllocDealloc(_dealloc, funcname); return isNotLibraryFunction(tok) && functions.find(funcname) != functions.end() ? nullptr : getAllocDealloc(mDealloc, funcname);
} }
/** get allocation id for function */ /** get allocation id for function */
@ -1029,24 +1029,24 @@ const std::string& Library::returnValue(const Token *ftok) const
{ {
if (isNotLibraryFunction(ftok)) if (isNotLibraryFunction(ftok))
return emptyString; return emptyString;
const std::map<std::string, std::string>::const_iterator it = _returnValue.find(getFunctionName(ftok)); const std::map<std::string, std::string>::const_iterator it = mReturnValue.find(getFunctionName(ftok));
return it != _returnValue.end() ? it->second : emptyString; return it != mReturnValue.end() ? it->second : emptyString;
} }
const std::string& Library::returnValueType(const Token *ftok) const const std::string& Library::returnValueType(const Token *ftok) const
{ {
if (isNotLibraryFunction(ftok)) if (isNotLibraryFunction(ftok))
return emptyString; return emptyString;
const std::map<std::string, std::string>::const_iterator it = _returnValueType.find(getFunctionName(ftok)); const std::map<std::string, std::string>::const_iterator it = mReturnValueType.find(getFunctionName(ftok));
return it != _returnValueType.end() ? it->second : emptyString; return it != mReturnValueType.end() ? it->second : emptyString;
} }
int Library::returnValueContainer(const Token *ftok) const int Library::returnValueContainer(const Token *ftok) const
{ {
if (isNotLibraryFunction(ftok)) if (isNotLibraryFunction(ftok))
return -1; return -1;
const std::map<std::string, int>::const_iterator it = _returnValueContainer.find(getFunctionName(ftok)); const std::map<std::string, int>::const_iterator it = mReturnValueContainer.find(getFunctionName(ftok));
return it != _returnValueContainer.end() ? it->second : -1; return it != mReturnValueContainer.end() ? it->second : -1;
} }
bool Library::hasminsize(const std::string &functionName) const bool Library::hasminsize(const std::string &functionName) const
@ -1104,8 +1104,8 @@ bool Library::isnoreturn(const Token *ftok) const
return true; return true;
if (isNotLibraryFunction(ftok)) if (isNotLibraryFunction(ftok))
return false; return false;
const std::map<std::string, bool>::const_iterator it = _noreturn.find(getFunctionName(ftok)); const std::map<std::string, bool>::const_iterator it = mNoReturn.find(getFunctionName(ftok));
return (it != _noreturn.end() && it->second); return (it != mNoReturn.end() && it->second);
} }
bool Library::isnotnoreturn(const Token *ftok) const bool Library::isnotnoreturn(const Token *ftok) const
@ -1114,40 +1114,40 @@ bool Library::isnotnoreturn(const Token *ftok) const
return false; return false;
if (isNotLibraryFunction(ftok)) if (isNotLibraryFunction(ftok))
return false; return false;
const std::map<std::string, bool>::const_iterator it = _noreturn.find(getFunctionName(ftok)); const std::map<std::string, bool>::const_iterator it = mNoReturn.find(getFunctionName(ftok));
return (it != _noreturn.end() && !it->second); return (it != mNoReturn.end() && !it->second);
} }
bool Library::markupFile(const std::string &path) const bool Library::markupFile(const std::string &path) const
{ {
return _markupExtensions.find(Path::getFilenameExtensionInLowerCase(path)) != _markupExtensions.end(); return mMarkupExtensions.find(Path::getFilenameExtensionInLowerCase(path)) != mMarkupExtensions.end();
} }
bool Library::processMarkupAfterCode(const std::string &path) const bool Library::processMarkupAfterCode(const std::string &path) const
{ {
const std::map<std::string, bool>::const_iterator it = _processAfterCode.find(Path::getFilenameExtensionInLowerCase(path)); const std::map<std::string, bool>::const_iterator it = mProcessAfterCode.find(Path::getFilenameExtensionInLowerCase(path));
return (it == _processAfterCode.end() || it->second); return (it == mProcessAfterCode.end() || it->second);
} }
bool Library::reportErrors(const std::string &path) const bool Library::reportErrors(const std::string &path) const
{ {
const std::map<std::string, bool>::const_iterator it = _reporterrors.find(Path::getFilenameExtensionInLowerCase(path)); const std::map<std::string, bool>::const_iterator it = mReportErrors.find(Path::getFilenameExtensionInLowerCase(path));
return (it == _reporterrors.end() || it->second); return (it == mReportErrors.end() || it->second);
} }
bool Library::isexecutableblock(const std::string &file, const std::string &token) const bool Library::isexecutableblock(const std::string &file, const std::string &token) const
{ {
const std::map<std::string, CodeBlock>::const_iterator it = _executableblocks.find(Path::getFilenameExtensionInLowerCase(file)); const std::map<std::string, CodeBlock>::const_iterator it = mExecutableBlocks.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _executableblocks.end() && it->second.isBlock(token)); return (it != mExecutableBlocks.end() && it->second.isBlock(token));
} }
int Library::blockstartoffset(const std::string &file) const int Library::blockstartoffset(const std::string &file) const
{ {
int offset = -1; int offset = -1;
const std::map<std::string, CodeBlock>::const_iterator map_it const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file)); = mExecutableBlocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) { if (map_it != mExecutableBlocks.end()) {
offset = map_it->second.offset(); offset = map_it->second.offset();
} }
return offset; return offset;
@ -1156,9 +1156,9 @@ int Library::blockstartoffset(const std::string &file) const
const std::string& Library::blockstart(const std::string &file) const const std::string& Library::blockstart(const std::string &file) const
{ {
const std::map<std::string, CodeBlock>::const_iterator map_it const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file)); = mExecutableBlocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) { if (map_it != mExecutableBlocks.end()) {
return map_it->second.start(); return map_it->second.start();
} }
return emptyString; return emptyString;
@ -1167,9 +1167,9 @@ const std::string& Library::blockstart(const std::string &file) const
const std::string& Library::blockend(const std::string &file) const const std::string& Library::blockend(const std::string &file) const
{ {
const std::map<std::string, CodeBlock>::const_iterator map_it const std::map<std::string, CodeBlock>::const_iterator map_it
= _executableblocks.find(Path::getFilenameExtensionInLowerCase(file)); = mExecutableBlocks.find(Path::getFilenameExtensionInLowerCase(file));
if (map_it != _executableblocks.end()) { if (map_it != mExecutableBlocks.end()) {
return map_it->second.end(); return map_it->second.end();
} }
return emptyString; return emptyString;
@ -1178,13 +1178,13 @@ const std::string& Library::blockend(const std::string &file) const
bool Library::iskeyword(const std::string &file, const std::string &keyword) const bool Library::iskeyword(const std::string &file, const std::string &keyword) const
{ {
const std::map<std::string, std::set<std::string> >::const_iterator it = const std::map<std::string, std::set<std::string> >::const_iterator it =
_keywords.find(Path::getFilenameExtensionInLowerCase(file)); mKeywords.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _keywords.end() && it->second.count(keyword)); return (it != mKeywords.end() && it->second.count(keyword));
} }
bool Library::isimporter(const std::string& file, const std::string &importer) const bool Library::isimporter(const std::string& file, const std::string &importer) const
{ {
const std::map<std::string, std::set<std::string> >::const_iterator it = const std::map<std::string, std::set<std::string> >::const_iterator it =
_importers.find(Path::getFilenameExtensionInLowerCase(file)); mImporters.find(Path::getFilenameExtensionInLowerCase(file));
return (it != _importers.end() && it->second.count(importer) > 0); return (it != mImporters.end() && it->second.count(importer) > 0);
} }

View File

@ -94,7 +94,7 @@ public:
/** get deallocation info for function by name (deprecated, use other alloc) */ /** get deallocation info for function by name (deprecated, use other alloc) */
const AllocFunc* dealloc(const char name[]) const { const AllocFunc* dealloc(const char name[]) const {
return getAllocDealloc(_dealloc, name); return getAllocDealloc(mDealloc, name);
} }
/** get allocation id for function by name (deprecated, use other alloc) */ /** get allocation id for function by name (deprecated, use other alloc) */
@ -105,7 +105,7 @@ public:
/** get deallocation id for function by name (deprecated, use other alloc) */ /** get deallocation id for function by name (deprecated, use other alloc) */
int deallocId(const char name[]) const { int deallocId(const char name[]) const {
const AllocFunc* af = getAllocDealloc(_dealloc, name); const AllocFunc* af = getAllocDealloc(mDealloc, name);
return af ? af->groupId : 0; return af ? af->groupId : 0;
} }
@ -116,13 +116,13 @@ public:
} }
void setdealloc(const std::string &functionname, int id, int arg) { void setdealloc(const std::string &functionname, int id, int arg) {
_dealloc[functionname].groupId = id; mDealloc[functionname].groupId = id;
_dealloc[functionname].arg = arg; mDealloc[functionname].arg = arg;
} }
/** add noreturn function setting */ /** add noreturn function setting */
void setnoreturn(const std::string& funcname, bool noreturn) { void setnoreturn(const std::string& funcname, bool noreturn) {
_noreturn[funcname] = noreturn; mNoReturn[funcname] = noreturn;
} }
/** is allocation type memory? */ /** is allocation type memory? */
@ -324,7 +324,7 @@ public:
bool processMarkupAfterCode(const std::string &path) const; bool processMarkupAfterCode(const std::string &path) const;
const std::set<std::string> &markupExtensions() const { const std::set<std::string> &markupExtensions() const {
return _markupExtensions; return mMarkupExtensions;
} }
bool reportErrors(const std::string &path) const; bool reportErrors(const std::string &path) const;
@ -341,28 +341,28 @@ public:
bool iskeyword(const std::string &file, const std::string &keyword) const; bool iskeyword(const std::string &file, const std::string &keyword) const;
bool isexporter(const std::string &prefix) const { bool isexporter(const std::string &prefix) const {
return _exporters.find(prefix) != _exporters.end(); return mExporters.find(prefix) != mExporters.end();
} }
bool isexportedprefix(const std::string &prefix, const std::string &token) const { bool isexportedprefix(const std::string &prefix, const std::string &token) const {
const std::map<std::string, ExportedFunctions>::const_iterator it = _exporters.find(prefix); const std::map<std::string, ExportedFunctions>::const_iterator it = mExporters.find(prefix);
return (it != _exporters.end() && it->second.isPrefix(token)); return (it != mExporters.end() && it->second.isPrefix(token));
} }
bool isexportedsuffix(const std::string &prefix, const std::string &token) const { bool isexportedsuffix(const std::string &prefix, const std::string &token) const {
const std::map<std::string, ExportedFunctions>::const_iterator it = _exporters.find(prefix); const std::map<std::string, ExportedFunctions>::const_iterator it = mExporters.find(prefix);
return (it != _exporters.end() && it->second.isSuffix(token)); return (it != mExporters.end() && it->second.isSuffix(token));
} }
bool isimporter(const std::string& file, const std::string &importer) const; bool isimporter(const std::string& file, const std::string &importer) const;
bool isreflection(const std::string &token) const { bool isreflection(const std::string &token) const {
return _reflection.find(token) != _reflection.end(); return mReflection.find(token) != mReflection.end();
} }
int reflectionArgument(const std::string &token) const { int reflectionArgument(const std::string &token) const {
const std::map<std::string, int>::const_iterator it = _reflection.find(token); const std::map<std::string, int>::const_iterator it = mReflection.find(token);
if (it != _reflection.end()) if (it != mReflection.end())
return it->second; return it->second;
return -1; return -1;
} }
@ -497,19 +497,19 @@ private:
int allocid; int allocid;
std::set<std::string> mFiles; std::set<std::string> mFiles;
std::map<std::string, AllocFunc> mAlloc; // allocation functions std::map<std::string, AllocFunc> mAlloc; // allocation functions
std::map<std::string, AllocFunc> _dealloc; // deallocation functions std::map<std::string, AllocFunc> mDealloc; // deallocation functions
std::map<std::string, bool> _noreturn; // is function noreturn? std::map<std::string, bool> mNoReturn; // is function noreturn?
std::map<std::string, std::string> _returnValue; std::map<std::string, std::string> mReturnValue;
std::map<std::string, std::string> _returnValueType; std::map<std::string, std::string> mReturnValueType;
std::map<std::string, int> _returnValueContainer; std::map<std::string, int> mReturnValueContainer;
std::map<std::string, bool> _reporterrors; std::map<std::string, bool> mReportErrors;
std::map<std::string, bool> _processAfterCode; std::map<std::string, bool> mProcessAfterCode;
std::set<std::string> _markupExtensions; // file extensions of markup files std::set<std::string> mMarkupExtensions; // file extensions of markup files
std::map<std::string, std::set<std::string> > _keywords; // keywords for code in the library std::map<std::string, std::set<std::string> > mKeywords; // keywords for code in the library
std::map<std::string, CodeBlock> _executableblocks; // keywords for blocks of executable code std::map<std::string, CodeBlock> mExecutableBlocks; // 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, ExportedFunctions> mExporters; // 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::set<std::string> > mImporters; // keywords that import variables/functions
std::map<std::string, int> _reflection; // invocation of reflection std::map<std::string, int> mReflection; // invocation of reflection
std::map<std::string, struct PodType> podtypes; // pod types std::map<std::string, struct PodType> podtypes; // pod types
std::map<std::string, PlatformType> platform_types; // platform independent typedefs std::map<std::string, PlatformType> platform_types; // platform independent typedefs
std::map<std::string, Platform> platforms; // platform dependent typedefs std::map<std::string, Platform> platforms; // platform dependent typedefs