summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsJavaParserHelper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmDependsJavaParserHelper.cxx')
-rw-r--r--Source/cmDependsJavaParserHelper.cxx49
1 files changed, 21 insertions, 28 deletions
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index bd3ee4d..79c4669 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -35,7 +35,7 @@ cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
}
void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
- std::vector<std::string>* files, const char* prefix, const char* sep)
+ std::vector<std::string>* files, const char* prefix, const char* sep) const
{
std::string rname = "";
if (prefix) {
@@ -44,8 +44,8 @@ void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
}
rname += this->Name;
files->push_back(rname);
- std::vector<CurrentClass>::iterator it;
- for (it = this->NestedClasses->begin(); it != this->NestedClasses->end();
+ std::vector<CurrentClass>::const_iterator it;
+ for (it = this->NestedClasses.begin(); it != this->NestedClasses.end();
++it) {
it->AddFileNamesForPrinting(files, rname.c_str(), sep);
}
@@ -59,7 +59,7 @@ void cmDependsJavaParserHelper::DeallocateParserType(char** pt)
if (!*pt) {
return;
}
- *pt = 0;
+ *pt = CM_NULLPTR;
this->UnionsAvailable--;
}
@@ -160,13 +160,13 @@ void cmDependsJavaParserHelper::PrepareElement(
cmDependsJavaParserHelper::ParserType* me)
{
// Inititalize self
- me->str = 0;
+ me->str = CM_NULLPTR;
}
void cmDependsJavaParserHelper::AllocateParserType(
cmDependsJavaParserHelper::ParserType* pt, const char* str, int len)
{
- pt->str = 0;
+ pt->str = CM_NULLPTR;
if (len == 0) {
len = (int)strlen(str);
}
@@ -191,25 +191,19 @@ void cmDependsJavaParserHelper::StartClass(const char* cls)
void cmDependsJavaParserHelper::EndClass()
{
- CurrentClass* parent = 0;
- CurrentClass* current = 0;
- if (!this->ClassStack.empty()) {
- current = &(*(this->ClassStack.end() - 1));
- if (this->ClassStack.size() > 1) {
- parent = &(*(this->ClassStack.end() - 2));
- }
- }
- if (current == 0) {
+ if (this->ClassStack.empty()) {
std::cerr << "Error when parsing. Current class is null" << std::endl;
abort();
}
- if (parent == 0) {
+ if (this->ClassStack.size() <= 1) {
std::cerr << "Error when parsing. Parent class is null" << std::endl;
abort();
}
+ CurrentClass& current = this->ClassStack.back();
+ CurrentClass& parent = this->ClassStack[this->ClassStack.size() - 2];
this->CurrentDepth--;
- parent->NestedClasses->push_back(*current);
- this->ClassStack.erase(this->ClassStack.end() - 1, this->ClassStack.end());
+ parent.NestedClasses.push_back(current);
+ this->ClassStack.pop_back();
}
void cmDependsJavaParserHelper::PrintClasses()
@@ -228,11 +222,11 @@ void cmDependsJavaParserHelper::PrintClasses()
std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
{
std::vector<std::string> files;
- CurrentClass* toplevel = &(*(this->ClassStack.begin()));
- std::vector<CurrentClass>::iterator it;
- for (it = toplevel->NestedClasses->begin();
- it != toplevel->NestedClasses->end(); ++it) {
- it->AddFileNamesForPrinting(&files, 0, "$");
+ CurrentClass const& toplevel = this->ClassStack.front();
+ std::vector<CurrentClass>::const_iterator it;
+ for (it = toplevel.NestedClasses.begin(); it != toplevel.NestedClasses.end();
+ ++it) {
+ it->AddFileNamesForPrinting(&files, CM_NULLPTR, "$");
}
return files;
}
@@ -309,11 +303,10 @@ int cmDependsJavaParserHelper::LexInput(char* buf, int maxlen)
if (buf[0] == '\n') {
this->CurrentLine++;
}
- return (1);
- } else {
- buf[0] = '\n';
- return (0);
+ return 1;
}
+ buf[0] = '\n';
+ return 0;
}
void cmDependsJavaParserHelper::Error(const char* str)
{
@@ -333,7 +326,7 @@ void cmDependsJavaParserHelper::Error(const char* str)
void cmDependsJavaParserHelper::UpdateCombine(const char* str1,
const char* str2)
{
- if (this->CurrentCombine == "" && str1 != 0) {
+ if (this->CurrentCombine == "" && str1 != CM_NULLPTR) {
this->CurrentCombine = str1;
}
this->CurrentCombine += ".";