Base: remove explicit namespace-name qualifier from *PyImp.cpp
Explicit Base namespace-name is used randomly across PyImp sources. Remove it.
This commit is contained in:
committed by
Benjamin Nauck
parent
24d55dc616
commit
47c1565edf
@@ -87,20 +87,20 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
PyObject* object {};
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::QuantityPy::Type), &object)) {
|
||||
*self = *(static_cast<Base::QuantityPy*>(object)->getQuantityPtr());
|
||||
if (PyArg_ParseTuple(args, "O!", &(QuantityPy::Type), &object)) {
|
||||
*self = *(static_cast<QuantityPy*>(object)->getQuantityPtr());
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
double f = std::numeric_limits<double>::max();
|
||||
if (PyArg_ParseTuple(args, "dO!", &f, &(Base::UnitPy::Type), &object)) {
|
||||
*self = Quantity(f, *(static_cast<Base::UnitPy*>(object)->getUnitPtr()));
|
||||
if (PyArg_ParseTuple(args, "dO!", &f, &(UnitPy::Type), &object)) {
|
||||
*self = Quantity(f, *(static_cast<UnitPy*>(object)->getUnitPtr()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
if (PyArg_ParseTuple(args, "dO!", &f, &(Base::QuantityPy::Type), &object)) {
|
||||
if (PyArg_ParseTuple(args, "dO!", &f, &(QuantityPy::Type), &object)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Second argument must be a Unit not a Quantity");
|
||||
return -1;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
try {
|
||||
*self = Quantity::parse(str);
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
catch (const ParserError& e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return -1;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
try {
|
||||
*self = Quantity(f, unit);
|
||||
}
|
||||
catch (const Base::ParserError& e) {
|
||||
catch (const ParserError& e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return -1;
|
||||
}
|
||||
@@ -187,16 +187,16 @@ PyObject* QuantityPy::getValueAs(PyObject* args) const
|
||||
// first try Quantity
|
||||
if (!quant.isValid()) {
|
||||
PyObject* object {};
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::QuantityPy::Type), &object)) {
|
||||
quant = *static_cast<Base::QuantityPy*>(object)->getQuantityPtr();
|
||||
if (PyArg_ParseTuple(args, "O!", &(QuantityPy::Type), &object)) {
|
||||
quant = *static_cast<QuantityPy*>(object)->getQuantityPtr();
|
||||
}
|
||||
}
|
||||
|
||||
if (!quant.isValid()) {
|
||||
PyObject* object {};
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "O!", &(Base::UnitPy::Type), &object)) {
|
||||
quant.setUnit(*static_cast<Base::UnitPy*>(object)->getUnitPtr());
|
||||
if (PyArg_ParseTuple(args, "O!", &(UnitPy::Type), &object)) {
|
||||
quant.setUnit(*static_cast<UnitPy*>(object)->getUnitPtr());
|
||||
quant.setValue(1.0);
|
||||
}
|
||||
}
|
||||
@@ -205,8 +205,8 @@ PyObject* QuantityPy::getValueAs(PyObject* args) const
|
||||
PyObject* object {};
|
||||
double value {};
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "dO!", &value, &(Base::UnitPy::Type), &object)) {
|
||||
quant.setUnit(*static_cast<Base::UnitPy*>(object)->getUnitPtr());
|
||||
if (PyArg_ParseTuple(args, "dO!", &value, &(UnitPy::Type), &object)) {
|
||||
quant.setUnit(*static_cast<UnitPy*>(object)->getUnitPtr());
|
||||
quant.setValue(value);
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ PyObject* QuantityPy::number_negative_handler(PyObject* self)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
double b = -1;
|
||||
return new QuantityPy(new Quantity(*a * b));
|
||||
}
|
||||
@@ -313,7 +313,7 @@ PyObject* QuantityPy::number_positive_handler(PyObject* self)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
return new QuantityPy(new Quantity(*a));
|
||||
}
|
||||
|
||||
@@ -324,14 +324,14 @@ PyObject* QuantityPy::number_absolute_handler(PyObject* self)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
return new QuantityPy(new Quantity(fabs(a->getValue()), a->getUnit()));
|
||||
}
|
||||
|
||||
static Quantity& pyToQuantity(Quantity& q, PyObject* pyobj)
|
||||
{
|
||||
if (PyObject_TypeCheck(pyobj, &Base::QuantityPy::Type)) {
|
||||
q = *static_cast<Base::QuantityPy*>(pyobj)->getQuantityPtr();
|
||||
if (PyObject_TypeCheck(pyobj, &QuantityPy::Type)) {
|
||||
q = *static_cast<QuantityPy*>(pyobj)->getQuantityPtr();
|
||||
}
|
||||
else if (PyFloat_Check(pyobj)) {
|
||||
q = Quantity(PyFloat_AsDouble(pyobj));
|
||||
@@ -459,11 +459,11 @@ PyObject* QuantityPy::number_remainder_handler(PyObject* self, PyObject* other)
|
||||
|
||||
double d1 {};
|
||||
double d2 {};
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
d1 = a->getValue();
|
||||
|
||||
if (PyObject_TypeCheck(other, &(QuantityPy::Type))) {
|
||||
Base::Quantity* b = static_cast<QuantityPy*>(other)->getQuantityPtr();
|
||||
Quantity* b = static_cast<QuantityPy*>(other)->getQuantityPtr();
|
||||
d2 = b->getValue();
|
||||
}
|
||||
else if (PyFloat_Check(other)) {
|
||||
@@ -507,19 +507,19 @@ PyObject* QuantityPy::number_power_handler(PyObject* self, PyObject* other, PyOb
|
||||
PY_TRY
|
||||
{
|
||||
if (PyObject_TypeCheck(other, &(QuantityPy::Type))) {
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Base::Quantity* b = static_cast<QuantityPy*>(other)->getQuantityPtr();
|
||||
Base::Quantity q(a->pow(*b)); // to prevent memory leak in case of exception
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* b = static_cast<QuantityPy*>(other)->getQuantityPtr();
|
||||
Quantity q(a->pow(*b)); // to prevent memory leak in case of exception
|
||||
|
||||
return new QuantityPy(new Quantity(q));
|
||||
}
|
||||
if (PyFloat_Check(other)) {
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
double b = PyFloat_AsDouble(other);
|
||||
return new QuantityPy(new Quantity(a->pow(b)));
|
||||
}
|
||||
if (PyLong_Check(other)) {
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
double b = (double)PyLong_AsLong(other);
|
||||
return new QuantityPy(new Quantity(a->pow(b)));
|
||||
}
|
||||
@@ -535,7 +535,7 @@ int QuantityPy::number_nonzero_handler(PyObject* self)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Base::Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
Quantity* a = static_cast<QuantityPy*>(self)->getQuantityPtr();
|
||||
return a->getValue() != 0.0;
|
||||
}
|
||||
|
||||
@@ -628,12 +628,12 @@ Py::Object QuantityPy::getUnit() const
|
||||
|
||||
void QuantityPy::setUnit(Py::Object arg)
|
||||
{
|
||||
Py::Type UnitType(Base::getTypeAsObject(&Base::UnitPy::Type));
|
||||
Py::Type UnitType(getTypeAsObject(&UnitPy::Type));
|
||||
if (!arg.isType(UnitType)) {
|
||||
throw Py::AttributeError("Not yet implemented");
|
||||
}
|
||||
|
||||
getQuantityPtr()->setUnit(*static_cast<Base::UnitPy*>((*arg))->getUnitPtr());
|
||||
getQuantityPtr()->setUnit(*static_cast<UnitPy*>((*arg))->getUnitPtr());
|
||||
}
|
||||
|
||||
Py::String QuantityPy::getUserString() const
|
||||
@@ -678,7 +678,7 @@ void QuantityPy::setFormat(Py::Dict arg)
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
fmt.format = Base::QuantityFormat::toFormat(fmtstr[0], &ok);
|
||||
fmt.format = QuantityFormat::toFormat(fmtstr[0], &ok);
|
||||
if (!ok) {
|
||||
throw Py::ValueError("Invalid format character");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user