Commit c18c6165 authored by Jan Möbius's avatar Jan Möbius

Fixed some conversions, output cleanup

parent 01b8d449
......@@ -194,7 +194,7 @@ bool PythonInterpreter::runScript(QString _script) {
std::cerr << "Now executing script:" << std::endl;
std::cerr << _script.toStdString() << std::endl;
py::exec((const char*)_script.toLatin1(), py::globals(), locals);
py::exec(_script.toStdString(), py::globals(), locals);
std::cerr << "Finished successfully" << std::endl;
}
......@@ -232,7 +232,7 @@ QString PythonInterpreter::runScriptOutput(QString _script) {
void PythonInterpreter::pyOutput(const char* w)
{
if (externalLogging_) {
std::cerr << "Python output:\n " << w << std::endl;
std::cerr << "Python output: " << w << std::endl;
Q_EMIT log(LOGOUT, QString(w));
} else {
LogOut += QString::fromUtf8(w);
......@@ -242,7 +242,7 @@ void PythonInterpreter::pyOutput(const char* w)
void PythonInterpreter::pyError(const char* w)
{
if (externalLogging_) {
std::cerr << "Python error:\n " << w << std::endl;
std::cerr << "Python error: " << w << std::endl;
Q_EMIT log(LOGERR, QString(w));
} else {
LogErr += QString::fromUtf8(w);
......@@ -263,8 +263,6 @@ PYBIND11_EMBEDDED_MODULE(openflipper, m) {
// to work on the existing one.
core.def(py::init([]() { return core_; }));
core.def("updateView", &Core::updateView, QCoreApplication::translate("PythonDocCore","Redraw the contents of the viewer.").toLatin1().data() );
core.def("blockScenegraphUpdates", &Core::blockScenegraphUpdates, QCoreApplication::translate("PythonDocCore","Disable Scenegraph Updates (e.g. before loading or adding a large number of files)").toLatin1().data() );
core.def("updateUI", &Core::updateUI, QCoreApplication::translate("PythonDocCore","Process events during script execution to keep the ui alive").toLatin1().data() );
......
......@@ -57,11 +57,12 @@ namespace pybind11 { namespace detail {
PYBIND11_TYPE_CASTER(QString, _("str"));
/**
* Conversion part 1 (Python->C++): convert a PyObject into a inty
* Conversion part 1 (Python->C++): convert a PyObject into a QString
* instance or return false upon failure. The second argument
* indicates whether implicit conversions should be applied.
*/
bool load(handle src, bool ) {
/* Extract PyObject from handle */
PyObject *source = src.ptr();
......@@ -84,7 +85,7 @@ namespace pybind11 { namespace detail {
}
/**
* Conversion part 2 (C++ -> Python): convert an QVariant instance into
* Conversion part 2 (C++ -> Python): convert an QString instance into
* a Python object. The second and third arguments are used to
* indicate the return value policy and parent object (for
* ``return_value_policy::reference_internal``) and are generally
......@@ -108,7 +109,7 @@ namespace pybind11 { namespace detail {
PYBIND11_TYPE_CASTER(Vector, _("Vector"));
/**
* Conversion part 1 (Python->C++): convert a PyObject into a inty
* Conversion part 1 (Python->C++): convert a PyObject into a Vector
* instance or return false upon failure. The second argument
* indicates whether implicit conversions should be applied.
*/
......@@ -149,17 +150,14 @@ namespace pybind11 { namespace detail {
}
/**
* Conversion part 2 (C++ -> Python): convert an QVariant instance into
* Conversion part 2 (C++ -> Python): convert an Vector instance into
* a Python object. The second and third arguments are used to
* indicate the return value policy and parent object (for
* ``return_value_policy::reference_internal``) and are generally
* ignored by implicit casters.
*/
static handle cast(Vector src, return_value_policy /* policy */, handle /* parent */) {
return py::array_t<double>({src[0],src[1],src[2]});
// return (PyUnicode_FromString( src.toUtf8().data()) );
return PyTuple_Pack(3, PyFloat_FromDouble(src[0]),PyFloat_FromDouble(src[1]),PyFloat_FromDouble(src[2]));
}
};
}} // namespace pybind11::detail
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment