Merge pull request #15343 from xpol/fixes-porject-config-waring

Use pre-processor condition rather than runtime check.
This commit is contained in:
minggo 2016-04-06 11:25:24 +08:00
commit aa8cf8dfd4
1 changed files with 26 additions and 26 deletions

View File

@ -247,7 +247,7 @@ void ProjectConfig::setDebugLogFilePath(const std::string &logFile)
string ProjectConfig::getDebugLogFilePath() const
{
if (isAbsolutePath(_debugLogFile)) return _debugLogFile;
auto path(getProjectDir());
path.append(_debugLogFile);
return path;
@ -435,7 +435,7 @@ string ProjectConfig::makeCommandLine(unsigned int mask /* = kProjectConfigAll *
{
buff << " " << cmd;
}
string result = buff.str();
while (result.at(0) == ' ')
{
@ -448,9 +448,9 @@ string ProjectConfig::makeCommandLine(unsigned int mask /* = kProjectConfigAll *
vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProjectConfigAll */) const
{
vector<string> ret;
stringstream buff;
if (mask & kProjectConfigProjectDir)
{
auto path = getProjectDir();
@ -460,7 +460,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back(dealWithSpaceWithPath(path));
}
}
if (mask & kProjectConfigScriptFile)
{
auto path = getScriptFileRealPath();
@ -470,7 +470,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back(dealWithSpaceWithPath(path));
}
}
if (mask & kProjectConfigWritablePath)
{
auto path = getWritableRealPath();
@ -480,18 +480,18 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back(dealWithSpaceWithPath(path));
}
}
if (mask & kProjectConfigFrameSize)
{
buff.str("");
buff << (int)getFrameSize().width;
buff << "x";
buff << (int)getFrameSize().height;
ret.push_back("-resolution");
ret.push_back(buff.str());
}
if (mask & kProjectConfigFrameScale)
{
if (getFrameScale() < 1.0f)
@ -499,12 +499,12 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
buff.str("");
buff.precision(2);
buff << getFrameScale();
ret.push_back("-scale");
ret.push_back(buff.str());
}
}
if (mask & kProjectConfigWriteDebugLogToFile)
{
if (isWriteDebugLogToFile())
@ -513,7 +513,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back(getDebugLogFilePath());
}
}
if (mask & kProjectConfigShowConsole)
{
if (isShowConsole())
@ -527,7 +527,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back("disable");
}
}
if (mask & kProjectConfigWindowOffset)
{
if (_windowOffset.x != 0 && _windowOffset.y != 0)
@ -537,12 +537,12 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
buff << ",";
buff << (int)_windowOffset.y;
buff << "";
ret.push_back("-position");
ret.push_back(buff.str());
}
}
if (mask & kProjectConfigDebugger)
{
switch (getDebuggerType())
@ -557,7 +557,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
break;
}
}
if (mask & kProjectConfigListen)
{
if (!_bindAddress.empty())
@ -566,7 +566,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
ret.push_back(_bindAddress);
}
}
if (mask & kProjectConfigSearchPath)
{
if (_searchPath.size() > 0)
@ -578,7 +578,7 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
}
string pathArgs = pathbuff.str();
pathArgs[pathArgs.length()-1] = '\0';
ret.push_back("-search-path");
ret.push_back(pathArgs);
}
@ -658,7 +658,7 @@ void ProjectConfig::setLanguageDataPath(const std::string &filePath)
bool isBinary = true;
string jsonExtension = ".json";
int exLength = jsonExtension.length();
if (filePath.length() >= exLength &&
if (filePath.length() >= exLength &&
(0 == filePath.compare(filePath.length() - exLength, exLength, jsonExtension)))
{
isBinary = false;
@ -709,7 +709,7 @@ void ProjectConfig::dump()
CCLOG(" write debug log: %s (%s)", _writeDebugLogToFile ? getDebugLogFilePath().c_str() : "NO",
_writeDebugLogToFile ? getDebugLogFilePath().c_str() : "");
CCLOG(" listen: %s", _bindAddress.c_str());
if (_debuggerType == kCCRuntimeDebuggerLDT)
{
CCLOG(" debugger: Eclipse LDT");
@ -726,13 +726,13 @@ void ProjectConfig::dump()
{
CCLOG(" debugger: none");
}
CCLOG(" add searching path:");
for (auto &path : _searchPath)
{
CCLOG(" %s", path.c_str());
}
CCLOG("\n\n");
}
@ -825,11 +825,11 @@ string ProjectConfig::replaceProjectDirToFullPath(const string &path) const
bool ProjectConfig::isAbsolutePath(const string &path) const
{
if (DIRECTORY_SEPARATOR_CHAR == '/')
{
return path.length() > 0 && path[0] == '/';
}
#if defined(_WINDOWS)
return path.length() > 2 && path[1] == ':';
#else
return path.length() > 0 && path[0] == '/';
#endif
}
string ProjectConfig::dealWithSpaceWithPath(const string &path) const