fix readability-*:
* readability-const-return-type * readability-container-data-pointer * readability-container-size-empty * readability-delete-null-pointer * readability-else-after-return * readability-inconsistent-declaration-parameter-name * readability-redundant-member-init * readability-redundant-smartptr-get * readability-redundant-string-cstr * readability-use-anyofallof * readability-static-definition-in-anonymous-namespace * readability-static-accessed-through-instance * readability-simplify-boolean-expr
This commit is contained in:
@@ -246,10 +246,9 @@ std::string InterpreterSingleton::runString(const char* sCmd)
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
throw SystemExitException();
|
||||
}
|
||||
else {
|
||||
PyException::ThrowException();
|
||||
return {}; // just to quieten code analyzers
|
||||
}
|
||||
|
||||
PyException::ThrowException();
|
||||
return {}; // just to quieten code analyzers
|
||||
}
|
||||
|
||||
PyObject* repr = PyObject_Repr(presult);
|
||||
@@ -259,10 +258,9 @@ std::string InterpreterSingleton::runString(const char* sCmd)
|
||||
Py_DECREF(repr);
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
PyErr_Clear();
|
||||
return {};
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
return {};
|
||||
}
|
||||
|
||||
/** runStringWithKey(psCmd, key, key_initial_value)
|
||||
@@ -292,10 +290,9 @@ std::string InterpreterSingleton::runStringWithKey(const char* psCmd,
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
throw SystemExitException();
|
||||
}
|
||||
else {
|
||||
PyException::ThrowException();
|
||||
return {}; // just to quieten code analyzers
|
||||
}
|
||||
|
||||
PyException::ThrowException();
|
||||
return {}; // just to quieten code analyzers
|
||||
}
|
||||
Py_DECREF(presult);
|
||||
|
||||
@@ -329,9 +326,8 @@ Py::Object InterpreterSingleton::runStringObject(const char* sCmd)
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
throw SystemExitException();
|
||||
}
|
||||
else {
|
||||
throw PyException();
|
||||
}
|
||||
|
||||
throw PyException();
|
||||
}
|
||||
|
||||
return Py::asObject(presult);
|
||||
@@ -417,9 +413,8 @@ void InterpreterSingleton::runInteractiveString(const char* sCmd)
|
||||
}
|
||||
throw exc;
|
||||
}
|
||||
else {
|
||||
Py_DECREF(presult);
|
||||
}
|
||||
|
||||
Py_DECREF(presult);
|
||||
}
|
||||
|
||||
void InterpreterSingleton::runFile(const char* pxFileName, bool local)
|
||||
@@ -466,9 +461,8 @@ void InterpreterSingleton::runFile(const char* pxFileName, bool local)
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
throw SystemExitException();
|
||||
}
|
||||
else {
|
||||
throw PyException();
|
||||
}
|
||||
|
||||
throw PyException();
|
||||
}
|
||||
Py_DECREF(result);
|
||||
}
|
||||
@@ -490,9 +484,8 @@ bool InterpreterSingleton::loadModule(const char* psModName)
|
||||
if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
|
||||
throw SystemExitException();
|
||||
}
|
||||
else {
|
||||
throw PyException();
|
||||
}
|
||||
|
||||
throw PyException();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -825,7 +818,7 @@ void InterpreterSingleton::dbgUnsetBreakPoint(unsigned int /*uiLineNumber*/)
|
||||
void InterpreterSingleton::dbgStep()
|
||||
{}
|
||||
|
||||
const std::string InterpreterSingleton::strToPython(const char* Str)
|
||||
std::string InterpreterSingleton::strToPython(const char* Str)
|
||||
{
|
||||
std::string result;
|
||||
const char* It = Str;
|
||||
@@ -859,40 +852,38 @@ int getSWIGVersionFromModule(const std::string& module)
|
||||
if (it != moduleMap.end()) {
|
||||
return it->second;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
// Get the module and check its __file__ attribute
|
||||
Py::Dict dict(PyImport_GetModuleDict());
|
||||
if (!dict.hasKey(module)) {
|
||||
return 0;
|
||||
}
|
||||
Py::Module mod(module);
|
||||
Py::String file(mod.getAttr("__file__"));
|
||||
std::string filename = (std::string)file;
|
||||
// file can have the extension .py or .pyc
|
||||
filename = filename.substr(0, filename.rfind('.'));
|
||||
filename += ".py";
|
||||
boost::regex rx("^# Version ([1-9])\\.([0-9])\\.([0-9]+)");
|
||||
boost::cmatch what;
|
||||
try {
|
||||
// Get the module and check its __file__ attribute
|
||||
Py::Dict dict(PyImport_GetModuleDict());
|
||||
if (!dict.hasKey(module)) {
|
||||
return 0;
|
||||
}
|
||||
Py::Module mod(module);
|
||||
Py::String file(mod.getAttr("__file__"));
|
||||
std::string filename = (std::string)file;
|
||||
// file can have the extension .py or .pyc
|
||||
filename = filename.substr(0, filename.rfind('.'));
|
||||
filename += ".py";
|
||||
boost::regex rx("^# Version ([1-9])\\.([0-9])\\.([0-9]+)");
|
||||
boost::cmatch what;
|
||||
|
||||
std::string line;
|
||||
Base::FileInfo fi(filename);
|
||||
std::string line;
|
||||
Base::FileInfo fi(filename);
|
||||
|
||||
Base::ifstream str(fi, std::ios::in);
|
||||
while (str && std::getline(str, line)) {
|
||||
if (boost::regex_match(line.c_str(), what, rx)) {
|
||||
int major = std::atoi(what[1].first);
|
||||
int minor = std::atoi(what[2].first);
|
||||
int micro = std::atoi(what[3].first);
|
||||
int version = (major << 16) + (minor << 8) + micro;
|
||||
moduleMap[module] = version;
|
||||
return version;
|
||||
}
|
||||
Base::ifstream str(fi, std::ios::in);
|
||||
while (str && std::getline(str, line)) {
|
||||
if (boost::regex_match(line.c_str(), what, rx)) {
|
||||
int major = std::atoi(what[1].first);
|
||||
int minor = std::atoi(what[2].first);
|
||||
int micro = std::atoi(what[3].first);
|
||||
int version = (major << 16) + (minor << 8) + micro;
|
||||
moduleMap[module] = version;
|
||||
return version;
|
||||
}
|
||||
}
|
||||
catch (Py::Exception& e) {
|
||||
e.clear();
|
||||
}
|
||||
}
|
||||
catch (Py::Exception& e) {
|
||||
e.clear();
|
||||
}
|
||||
|
||||
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
|
||||
|
||||
Reference in New Issue
Block a user