Commit 55b0295d authored by Julien Wintz's avatar Julien Wintz
Browse files

Updating wrappers management

parent a4c64295
......@@ -34,6 +34,7 @@ set(DTK_HAVE_PLOT "@DTK_HAVE_PLOT@")
set(DTK_HAVE_VRPN "@DTK_HAVE_VRPN@")
set(DTK_HAVE_NITE "@DTK_HAVE_NITE@")
set(DTK_HAVE_PYTHON "@DTK_HAVE_PYTHON@")
set(DTK_BUILD_WRAPPERS "@DTK_BUILD_WRAPPERS@")
set(DTK_HAVE_TCL "@DTK_HAVE_TCL@")
set(DTK_BUILD_VR "@DTK_BUILD_VR@")
......
......@@ -77,6 +77,10 @@ if(SWIG_FOUND)
"-c++"
"-module" ${name}
"-I${PROJECT_SOURCE_DIR}/.."
"-I${PROJECT_SOURCE_DIR}/"
"-I${dtk_SOURCE_DIR}/"
"-I${dtk_SOURCE_DIR}/src"
"-I${dtk_SOURCE_DIR}/src/dtkCore"
"-outdir" ${CMAKE_CURRENT_BINARY_DIR}
"-o" ${wrap_output}
${input}
......
......@@ -28,24 +28,23 @@
#include <QtDebug>
#include <QtCore>
#include "dtkAbstractData.h"
#include "dtkAbstractDataFactory.h"
#include "dtkAbstractDataReader.h"
#include "dtkAbstractDataWriter.h"
#include "dtkAbstractDataConverter.h"
#include "dtkAbstractDataSerializer.h"
#include "dtkAbstractDataDeserializer.h"
#include "dtkAbstractObject.h"
#include "dtkAbstractProcess.h"
#include "dtkAbstractProcessFactory.h"
#include "dtkAbstractView.h"
#include "dtkAbstractViewAnimator.h"
#include "dtkAbstractViewFactory.h"
#include "dtkAbstractViewInteractor.h"
#include "dtkAbstractViewNavigator.h"
#include "dtkPlugin.h"
#include "dtkPluginManager.h"
#include "dtkSmartPointer.h"
#include <dtkCore/dtkAbstractData.h>
#include <dtkCore/dtkAbstractDataFactory.h>
#include <dtkCore/dtkAbstractDataReader.h>
#include <dtkCore/dtkAbstractDataWriter.h>
#include <dtkCore/dtkAbstractDataConverter.h>
#include <dtkCore/dtkAbstractDataSerializer.h>
#include <dtkCore/dtkAbstractObject.h>
#include <dtkCore/dtkAbstractProcess.h>
#include <dtkCore/dtkAbstractProcessFactory.h>
#include <dtkCore/dtkAbstractView.h>
#include <dtkCore/dtkAbstractViewAnimator.h>
#include <dtkCore/dtkAbstractViewFactory.h>
#include <dtkCore/dtkAbstractViewInteractor.h>
#include <dtkCore/dtkAbstractViewNavigator.h>
#include <dtkCore/dtkPlugin.h>
#include <dtkCore/dtkPluginManager.h>
#include <dtkCore/dtkSmartPointer.h>
#include <string>
%}
......@@ -214,6 +213,7 @@
}
}
// C++ -> Python
%typemap(out) QString {
......@@ -468,7 +468,6 @@ public:
// /////////////////////////////////////////////////////////////////
%include "dtkAbstractObject.h"
%include "dtkAbstractData.h"
%include "dtkAbstractDataFactory.h"
%include "dtkAbstractDataReader.h"
......
......@@ -102,7 +102,7 @@ void dtkPluginManager::initializeApplication(void)
int argc = 1;
char *argv[] = {"dtk-embedded"};
(void) new QCoreApplication(argc, argv);
(void) new QApplication(argc, argv);
}
void dtkPluginManager::initialize(void)
......
......@@ -233,16 +233,9 @@ void dtkInterpreter::onKeyEnterPressed(void)
d->history.push_front(line);
d->history_index = 0;
d->history_dirty = false;
int stat;
this->output(d->interpreter->interpret(line, &stat));
} else {
this->appendPlainText(d->prompt);
}
this->output(d->interpreter->interpret(line, &stat));
}
void dtkInterpreter::output(const QString& result)
......
......@@ -51,6 +51,7 @@ static const QString dtkScriptInterpreterPythonRedirector_define =
class dtkScriptInterpreterPythonPrivate
{
public:
QString buffer;
};
// /////////////////////////////////////////////////////////////////
......@@ -74,11 +75,40 @@ dtkScriptInterpreterPython::~dtkScriptInterpreterPython(void)
QString dtkScriptInterpreterPython::interpret(const QString& command, int *stat)
{
QString statement = command;
if(command.endsWith(":")) {
if(!d->buffer.isEmpty())
d->buffer.append("\n");
d->buffer.append(command);
qDebug() << command << d->buffer;
return "";
}
if(!command.isEmpty() && command.startsWith(" ")) {
if(!d->buffer.isEmpty())
d->buffer.append("\n");
d->buffer.append(command);
qDebug() << command << d->buffer;
return "";
}
if(command.isEmpty() && !d->buffer.isEmpty()) {
if(!d->buffer.isEmpty())
d->buffer.append("\n");
statement = d->buffer;
d->buffer.clear();
qDebug() << command << d->buffer << statement;
}
if(statement.isEmpty())
return "";
PyObject *module = PyImport_AddModule("__main__");
PyRun_SimpleString(dtkScriptInterpreterPythonRedirector_define.toAscii().constData());
switch(PyRun_SimpleString(command.toAscii().constData())) {
switch(PyRun_SimpleString(statement.toAscii().constData())) {
case 0: *stat = Status_Ok; break;
case -1: *stat = Status_Error; break;
default: break;
......
Supports Markdown
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