Browse Source

Style: Dont use namespace std, it has no future considering templates (dont 'use' any namespace, use ns aliases)

master
heck 1 week ago
parent
commit
983164e42a
7 changed files with 51 additions and 56 deletions
  1. +0
    -1
      setup.py
  2. +1
    -2
      src/pEp/_pEp/basic_api.cc
  3. +2
    -1
      src/pEp/_pEp/basic_api.hh
  4. +12
    -13
      src/pEp/_pEp/identity.cc
  5. +20
    -21
      src/pEp/_pEp/message.cc
  6. +8
    -9
      src/pEp/_pEp/pEpmodule.cc
  7. +8
    -9
      src/pEp/_pEp/str_attr.cc

+ 0
- 1
setup.py View File

@ -204,7 +204,6 @@ module_pEp = Extension(
'src/pEp/_pEp/message.cc',
'src/pEp/_pEp/message_api.cc',
'src/pEp/_pEp/str_attr.cc',
# 'src/pEp/_pEp/user_interface.cc',
],
)


+ 1
- 2
src/pEp/_pEp/basic_api.cc View File

@ -14,7 +14,6 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
void update_identity(Identity &ident)
{
@ -127,7 +126,7 @@ namespace pEp {
::pEp_identity *ident = ::identity_dup(il->ident);
if (!ident) {
free_identity_list(private_keys);
throw bad_alloc();
throw std::bad_alloc();
}
result.append(Identity(ident));
}


+ 2
- 1
src/pEp/_pEp/basic_api.hh View File

@ -31,7 +31,8 @@ namespace pEp {
void set_own_key(Identity &ident, string fpr);
void set_comm_partner_key(Identity &ident, string fpr);
} /* namespace PythonAdapter */
} /* namespace pEp */
#endif /* BASIC_API_HH */
#endif /* BASIC_API_HH */

+ 12
- 13
src/pEp/_pEp/identity.cc View File

@ -18,7 +18,6 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
Identity::Identity(
@ -34,7 +33,7 @@ namespace pEp {
&::free_identity)
{
if (!_ident) {
throw bad_alloc();
throw std::bad_alloc();
}
_ident->comm_type = (PEP_comm_type)comm_type;
_ident->flags = (identity_flags_t)flags;
@ -59,7 +58,7 @@ namespace pEp {
string Identity::_repr()
{
stringstream build;
std::stringstream build;
build << "Identity(";
string address;
if (_ident->address)
@ -97,7 +96,7 @@ namespace pEp {
void Identity::username(string value)
{
if (value.length() && value.length() < 5) {
throw length_error("username must be at least 5 characters");
throw std::length_error("username must be at least 5 characters");
}
str_attr(_ident->username, value);
@ -108,7 +107,7 @@ namespace pEp {
if (value == "") {
memset(_ident->lang, 0, 3);
} else if (value.length() != 2) {
throw length_error("length of lang must be 2");
throw std::length_error("length of lang must be 2");
} else {
memcpy(_ident->lang, value.c_str(), 3);
}
@ -141,7 +140,7 @@ namespace pEp {
{
pEp_identity *dup = ::identity_dup(*this);
if (!dup) {
throw bad_alloc();
throw std::bad_alloc();
}
return Identity(dup);
@ -195,12 +194,12 @@ namespace pEp {
Identity identity_attr(pEp_identity *&ident)
{
if (!ident) {
throw out_of_range("no identity assigned");
throw std::out_of_range("no identity assigned");
}
pEp_identity *_dup = ::identity_dup(ident);
if (!_dup) {
throw bad_alloc();
throw std::bad_alloc();
}
Identity _ident(_dup);
@ -212,7 +211,7 @@ namespace pEp {
Identity &_ident = extract<Identity &>(value);
pEp_identity *_dup = ::identity_dup(_ident);
if (!_dup) {
throw bad_alloc();
throw std::bad_alloc();
}
PEP_STATUS status = ::update_identity(Adapter::session(), _dup);
_throw_status(status);
@ -227,7 +226,7 @@ namespace pEp {
for (identity_list *_il = il; _il && _il->ident; _il = _il->next) {
pEp_identity *ident = ::identity_dup(_il->ident);
if (!ident) {
throw bad_alloc();
throw std::bad_alloc();
}
result.append(object(Identity(ident)));
}
@ -239,7 +238,7 @@ namespace pEp {
{
identity_list *_il = ::new_identity_list(NULL);
if (!_il) {
throw bad_alloc();
throw std::bad_alloc();
}
identity_list *_i = _il;
@ -252,7 +251,7 @@ namespace pEp {
pEp_identity *_dup = ::identity_dup(_ident);
if (!_dup) {
::free_identity_list(_il);
throw bad_alloc();
throw std::bad_alloc();
}
PEP_STATUS status = ::update_identity(Adapter::session(), _dup);
if (status != PEP_STATUS_OK) {
@ -262,7 +261,7 @@ namespace pEp {
_i = ::identity_list_add(_i, _dup);
if (!_i) {
::free_identity_list(_il);
throw bad_alloc();
throw std::bad_alloc();
}
}


+ 20
- 21
src/pEp/_pEp/message.cc View File

@ -20,13 +20,12 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
Message::Blob::Blob(bloblist_t *bl, bool chained) : _bl(bl), part_of_chain(chained)
{
if (!_bl) {
throw bad_alloc();
throw std::bad_alloc();
}
}
@ -35,7 +34,7 @@ namespace pEp {
part_of_chain(false)
{
if (!_bl) {
throw bad_alloc();
throw std::bad_alloc();
}
Py_buffer src;
@ -47,7 +46,7 @@ namespace pEp {
char *mem = (char *)malloc(src.len);
if (!mem) {
PyBuffer_Release(&src);
throw bad_alloc();
throw std::bad_alloc();
}
memcpy(mem, src.buf, src.len);
@ -73,7 +72,7 @@ namespace pEp {
string Message::Blob::_repr()
{
stringstream build;
std::stringstream build;
build << "Blob(";
if (!_bl) {
build << "b'', '', ''";
@ -99,7 +98,7 @@ namespace pEp {
try {
Message::Blob &blob = extract<Message::Blob &>(self);
bl = blob._bl;
} catch (exception &e) {
} catch (std::exception &e) {
PyErr_SetString(PyExc_RuntimeError, "extract not possible");
view->obj = NULL;
return -1;
@ -139,13 +138,13 @@ namespace pEp {
_msg(new_message((PEP_msg_direction)dir), &free_message)
{
if (!_msg) {
throw bad_alloc();
throw std::bad_alloc();
}
if (from) {
_msg->from = ::identity_dup(*from);
if (!_msg->from) {
throw bad_alloc();
throw std::bad_alloc();
}
_msg->dir = (PEP_msg_direction)dir;
}
@ -164,7 +163,7 @@ namespace pEp {
}
if (!_cpy) {
throw bad_alloc();
throw std::bad_alloc();
}
_msg = shared_ptr<message>(_cpy);
@ -177,10 +176,10 @@ namespace pEp {
throw runtime_error("mime_decode_message: cannot create temp file");
case PEP_OUT_OF_MEMORY:
throw bad_alloc();
throw std::bad_alloc();
default:
stringstream build;
std::stringstream build;
build << "mime_decode_message: unknown error (" << (int)status << ")";
throw runtime_error(build.str());
}
@ -189,7 +188,7 @@ namespace pEp {
Message::Message(const Message &second) : _msg(second._msg)
{
if (!_msg.get()) {
throw bad_alloc();
throw std::bad_alloc();
}
}
@ -210,7 +209,7 @@ namespace pEp {
string Message::_str()
{
if (!(_msg->from && _msg->from->address && _msg->from->address[0])) {
throw out_of_range(".from_.address missing");
throw std::out_of_range(".from_.address missing");
}
char *mimetext;
@ -230,10 +229,10 @@ namespace pEp {
throw runtime_error("mime_encode_message: cannot create temp file");
case PEP_OUT_OF_MEMORY:
throw bad_alloc();
throw std::bad_alloc();
default:
stringstream build;
std::stringstream build;
build << "mime_encode_message: unknown error (" << (int)status << ")";
throw runtime_error(build.str());
}
@ -243,7 +242,7 @@ namespace pEp {
string Message::_repr()
{
stringstream build;
std::stringstream build;
build << "Message(" << repr(_str()) << ")";
return build.str();
}
@ -263,7 +262,7 @@ namespace pEp {
{
bloblist_t *bl = new_bloblist(NULL, 0, NULL, NULL);
if (!bl) {
throw bad_alloc();
throw std::bad_alloc();
}
bloblist_t *_l = bl;
@ -283,7 +282,7 @@ namespace pEp {
_l = _l->next;
free(_ll);
}
throw bad_alloc();
throw std::bad_alloc();
}
}
@ -356,7 +355,7 @@ namespace pEp {
{
message *dup = message_dup(*this);
if (!dup) {
throw bad_alloc();
throw std::bad_alloc();
}
return Message(dup);
}
@ -402,12 +401,12 @@ namespace pEp {
try {
m.from(update(m.from()));
} catch (out_of_range &) {
} catch (std::out_of_range &) {
}
try {
m.recv_by(update(m.recv_by()));
} catch (out_of_range &) {
} catch (std::out_of_range &) {
}
m.to(update(m.to()));


+ 8
- 9
src/pEp/_pEp/pEpmodule.cc View File

@ -28,7 +28,6 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
static const char *version_string = "p≡p Python adapter version 0.3";
@ -93,14 +92,14 @@ namespace pEp {
return;
}
if (status == PEP_OUT_OF_MEMORY) {
throw bad_alloc();
throw std::bad_alloc();
}
if (status == PEP_ILLEGAL_VALUE) {
throw invalid_argument("illegal value");
}
if (string(pEp_status_to_string(status)) == "unknown status code") {
stringstream build;
build << setfill('0') << "p≡p 0x" << setw(4) << hex << status;
std::stringstream build;
build << std::setfill('0') << "p≡p 0x" << std::setw(4) << std::hex << status;
throw runtime_error(build.str());
} else {
throw runtime_error(pEp_status_to_string(status));
@ -119,7 +118,7 @@ namespace pEp {
call<void>(funcref.ptr(), Message(msg));
PyGILState_Release(gil);
pEpLog("GIL released");
} catch (exception &e) {
} catch (std::exception &e) {
}
return PEP_STATUS_OK;
@ -137,7 +136,7 @@ namespace pEp {
call<void>(funcref.ptr(), Identity(me), Identity(partner), signal);
PyGILState_Release(gil);
pEpLog("GIL released");
} catch (exception &e) {
} catch (std::exception &e) {
}
return PEP_STATUS_OK;
@ -197,7 +196,7 @@ namespace pEp {
if (identities != boost::python::api::object() && boost::python::len(identities)) {
shared_identities = new_identity_list(nullptr);
if (!shared_identities) {
throw bad_alloc();
throw std::bad_alloc();
}
try {
@ -206,9 +205,9 @@ namespace pEp {
Identity ident = extract<Identity>(identities[i]);
si = identity_list_add(si, ident);
if (!si)
throw bad_alloc();
throw std::bad_alloc();
}
} catch (exception &ex) {
} catch (std::exception &ex) {
free_identity_list(shared_identities);
throw ex;
}


+ 8
- 9
src/pEp/_pEp/str_attr.cc View File

@ -11,7 +11,6 @@
namespace pEp {
namespace PythonAdapter {
using namespace std;
using namespace boost::python;
using namespace boost::locale;
@ -42,7 +41,7 @@ namespace pEp {
free(str);
str = strdup(normalized.c_str());
if (!str) {
throw bad_alloc();
throw std::bad_alloc();
}
}
@ -77,7 +76,7 @@ namespace pEp {
{
stringlist_t *_sl = new_stringlist(NULL);
if (!_sl) {
throw bad_alloc();
throw std::bad_alloc();
}
stringlist_t *_s = _sl;
@ -91,7 +90,7 @@ namespace pEp {
_s = stringlist_add(_s, s.c_str());
if (!_s) {
free_stringlist(_sl);
throw bad_alloc();
throw std::bad_alloc();
}
}
@ -120,7 +119,7 @@ namespace pEp {
{
stringpair_list_t *_spl = new_stringpair_list(NULL);
if (!_spl) {
throw bad_alloc();
throw std::bad_alloc();
}
stringpair_list_t *_s = _spl;
@ -139,12 +138,12 @@ namespace pEp {
stringpair_t *pair = new_stringpair(key.c_str(), _value.c_str());
if (!pair) {
free_stringpair_list(_spl);
throw bad_alloc();
throw std::bad_alloc();
}
_s = stringpair_list_add(_s, pair);
if (!_s) {
free_stringpair_list(_spl);
throw bad_alloc();
throw std::bad_alloc();
}
}
@ -156,7 +155,7 @@ namespace pEp {
{
stringlist_t *result = new_stringlist(NULL);
if (!result) {
throw bad_alloc();
throw std::bad_alloc();
}
stringlist_t *_s = result;
@ -169,7 +168,7 @@ namespace pEp {
_s = stringlist_add(_s, s.c_str());
if (!_s) {
free_stringlist(result);
throw bad_alloc();
throw std::bad_alloc();
}
}


Loading…
Cancel
Save