Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 57f48840 authored by Julien Wintz's avatar Julien Wintz

Fixed wrapping input for C# notably.

parent 43437735
......@@ -76,8 +76,7 @@ set(DTK_HAVE_NITE @DTK_HAVE_NITE@)
set(DTK_HAVE_ZLIB @DTK_HAVE_ZLIB@)
if(DTK_BUILD_COMPOSER)
set(dtk_INCLUDE_DIRS ${dtk_INCLUDE_DIRS}
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkComposer")
set(dtk_INCLUDE_DIRS ${dtk_INCLUDE_DIRS} "@CMAKE_CURRENT_SOURCE_DIR@/src/dtkComposer")
endif(DTK_BUILD_COMPOSER)
######################################################################
......
......@@ -12,7 +12,6 @@
// Code:
#pragma once
#include "dtkCorePluginManager"
......@@ -24,7 +23,7 @@
// DTK_DECLARE_OBJECT
// ///////////////////////////////////////////////////////////////////
#define DTK_DECLARE_OBJECT(type) \
#define DTK_DECLARE_OBJECT(type) \
Q_DECLARE_METATYPE(type)
// ///////////////////////////////////////////////////////////////////
......@@ -69,15 +68,15 @@ public:
// DTK_DECLARE_PLUGIN_MANAGER
// ///////////////////////////////////////////////////////////////////
#define DTK_DECLARE_PLUGIN_MANAGER(type,Export) \
#define DTK_DECLARE_PLUGIN_MANAGER(type,Export) \
class Export type##PluginManager : public dtkCorePluginManager<type##Plugin> {};
// ///////////////////////////////////////////////////////////////////
// DTK_DECLARE_WIDGET_FACTORY
// ///////////////////////////////////////////////////////////////////
#define DTK_DECLARE_WIDGET_FACTORY(type,Export) \
class Export type##WidgetFactory : public dtkCoreWidgetFactory{}; \
#define DTK_DECLARE_WIDGET_FACTORY(type,Export) \
class Export type##WidgetFactory : public dtkCoreWidgetFactory{}; \
template <typename T> QWidget *type##WidgetCreator() { return new T; };
// ///////////////////////////////////////////////////////////////////
......
### CMakeLists.txt ---
##
## Author: Julien Wintz
## Copyright (C) 2008 - Julien Wintz, Inria.
## Created: Mon Jul 20 18:39:20 2009 (+0200)
## Version: $Id$
## Last-Updated: mer. sept. 17 14:55:40 2014 (+0200)
## By: Thibaud Kloczko
## Update #: 411
##
######################################################################
##
### Commentary:
##
######################################################################
##
### Change log:
### Change Log:
##
######################################################################
##
### Code:
project(dtkCoreSupport)
......@@ -55,8 +50,6 @@ set(${PROJECT_NAME}_HEADERS
dtkAbstractViewInteractor_p.h
dtkAbstractViewNavigator.h
dtkAbstractViewNavigator_p.h
# dtkArray.h
# dtkArray.tpp
dtkCpuid.h
dtkGlobal.h
dtkPlugin.h
......@@ -68,8 +61,7 @@ set(${PROJECT_NAME}_HEADERS
dtkSingleton.h
dtkSingletonDeclare.h
dtkSmartPointer.h
dtkTest.h
)
dtkTest.h)
set(${PROJECT_NAME}_SOURCES
dtkAbstractDataFactory.cpp
......@@ -90,7 +82,6 @@ set(${PROJECT_NAME}_SOURCES
dtkAbstractViewAnimator.cpp
dtkAbstractViewInteractor.cpp
dtkAbstractViewNavigator.cpp
# dtkArray.cpp
dtkCpuid.cpp
dtkPlugin.cpp
dtkPluginManager.cpp
......@@ -98,8 +89,7 @@ set(${PROJECT_NAME}_SOURCES
dtkSingleton.cpp
dtkSingletonDeclare.cpp
dtkSmartPointer.cpp
dtkUpdater.cpp
)
dtkUpdater.cpp)
## #################################################################
## Wrapping
......@@ -131,8 +121,7 @@ endif()
add_library(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_SOURCES_WRAP}
${${PROJECT_NAME}_HEADERS}
)
${${PROJECT_NAME}_HEADERS})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
......@@ -176,7 +165,6 @@ add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}Export.h" "${CMAKE_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}Export.h" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export")
## #################################################################
## Handling of generated script modules
## #################################################################
......@@ -194,12 +182,13 @@ if(DTK_BUILD_WRAPPERS AND SWIG_FOUND)
COMMENT "-- Moving python modules to ${CMAKE_BINARY_DIR}/modules")
set(${PROJECT_NAME}_MODULES ${CMAKE_BINARY_DIR}/modules/dtkcoresupport.py)
if(APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCoreSupport.i
COMMAND ln -sf ../lib/libdtkCoreSupport.dylib _dtkcoresupport.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules
)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtkcoresupport.so)
endif(APPLE)
......@@ -207,8 +196,8 @@ if(DTK_BUILD_WRAPPERS AND SWIG_FOUND)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
DEPENDS ${PROJECT_SOURCE_DIR}/dtkCoreSupport.i
COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkCoreSupport.so _dtkcoresupport.so
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules
)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtkcoresupport.so)
endif(UNIX AND NOT APPLE)
......@@ -246,3 +235,6 @@ install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT coresupport
EXPORT dtkDepends)
######################################################################
### CMakeLists.txt ends here
/* dtkCoreSupport.i --- Core layer swig interface definition
/* Version: $Id$
*
* Author: Julien Wintz
* Copyright (C) 2008 - Julien Wintz, Inria.
* Created: Tue Jan 6 21:45:15 2009 (+0100)
* Version: $Id$
* Last-Updated: ven. janv. 31 15:41:41 2014 (+0100)
* By: Nicolas Niclausse
* Update #: 493
*/
/* Commentary:
*
*/
/* Change log:
/* Change Log:
*
*/
#ifndef DTKCORESUPPORT_I
#define DTKCORESUPPORT_I
/* Code: */
#pragma once
%module coresupport
%include "carrays.i"
%array_class(double, doubleArray);
%{
#include <QtDebug>
......@@ -149,7 +146,7 @@
// /////////////////////////////////////////////////////////////////
%ignore created(dtkAbstractData *data, const QString& type);
%ignore created(dtkAbstractProcess *process,const QString& type);
%ignore created(dtkAbstractProcess *process, const QString& type);
%ignore created(dtkAbstractView *view, const QString& type);
// /////////////////////////////////////////////////////////////////
......@@ -158,7 +155,7 @@
%ignore loaded(const QString& path);
%ignore unloaded(const QString& path);
%ignore loadError(const QString& path);
%ignore loadError(const QString& path);
// /////////////////////////////////////////////////////////////////
// Typemaps
......@@ -167,7 +164,7 @@
#ifdef SWIGPYTHON
%typecheck(SWIG_TYPECHECK_STRING) char * {
$1 = PyString_Check($input) ? 1 : 0;
$1 = PyString_Check($input) ? 1 : 0;
}
%typemap(typecheck) QString = char *;
......@@ -177,19 +174,19 @@
%typemap(in) QString {
if (PyString_Check($input)) {
$1 = QString(PyString_AsString($input));
} else {
qDebug("QString expected");
}
$1 = QString(PyString_AsString($input));
} else {
qDebug("QString expected");
}
}
%typemap(in) const QString& {
if (PyString_Check($input)) {
char *t = PyString_AsString($input);
$1 = new QString(t);
} else {
qDebug("QString expected");
}
char *t = PyString_AsString($input);
$1 = new QString(t);
} else {
qDebug("QString expected");
}
}
%typemap(in) QStringList {
......@@ -198,9 +195,8 @@
int end = PyList_Size($input);
for(i;i!=end; ++i) {
$1 << QString(PyString_AsString(PyList_GET_ITEM($input, i)));
}
}
else {
} else {
qDebug("QStringList expected");
}
}
......@@ -213,14 +209,12 @@
for(i;i!=end; ++i) {
char *t = PyString_AsString(PyList_GET_ITEM($input, i));
(*$1) << QString(t);
}
}
else {
} else {
qDebug("QStringList expected");
}
}
// C++ -> Python
%typemap(out) QString {
......@@ -234,14 +228,14 @@
%define %QList_typemapsPtr(DATA_TYPE)
%typemap(out) QList<DATA_TYPE> {
$result = PyList_New($1.size());
int i = 0;
QList<DATA_TYPE>::iterator it = $1.begin();
QList<DATA_TYPE>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
PyObject* obj = SWIG_NewPointerObj((*it), $descriptor(DATA_TYPE), 0|0);
PyList_SET_ITEM($result, i, obj);
}
$result = PyList_New($1.size());
int i = 0;
QList<DATA_TYPE>::iterator it = $1.begin();
QList<DATA_TYPE>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
PyObject* obj = SWIG_NewPointerObj((*it), $descriptor(DATA_TYPE), 0|0);
PyList_SET_ITEM($result, i, obj);
}
}
%enddef // %QList_typemapsPtr()
......@@ -251,15 +245,15 @@
%define %QList_typemaps(DATA_TYPE)
%typemap(out) QList<DATA_TYPE> {
$result = PyList_New($1.size());
int i = 0;
QList<DATA_TYPE>::iterator it = $1.begin();
QList<DATA_TYPE>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
DATA_TYPE *newItem = new DATA_TYPE(*it);
PyObject* obj = SWIG_NewPointerObj(newItem, $descriptor(DATA_TYPE*), 0|0);
PyList_SET_ITEM($result, i, obj);
}
$result = PyList_New($1.size());
int i = 0;
QList<DATA_TYPE>::iterator it = $1.begin();
QList<DATA_TYPE>::iterator end = $1.end();
for(;it!=end; ++it, ++i) {
DATA_TYPE *newItem = new DATA_TYPE(*it);
PyObject* obj = SWIG_NewPointerObj(newItem, $descriptor(DATA_TYPE*), 0|0);
PyList_SET_ITEM($result, i, obj);
}
}
%enddef // %QList_typemaps()
......@@ -272,7 +266,7 @@
for(;it!=end; ++it, ++i) {
PyObject* st = PyString_FromString((*it).toUtf8().constData());
PyList_SET_ITEM($result, i, st);
}
}
}
%typemap(out) QList<QString> {
......@@ -283,11 +277,10 @@
for(;it!=end; ++it, ++i) {
PyObject* st = PyString_FromString((*it).toUtf8().constData());
PyList_SET_ITEM($result, i, st);
}
}
}
template <class T1, class T2>
class QPair
template <class T1, class T2> class QPair
{
public:
T1 first;
......@@ -297,11 +290,11 @@ public:
%define %QPair_typemaps(DATA_TYPE_1, DATA_TYPE_2)
%typemap(out) QPair<DATA_TYPE_1, DATA_TYPE_2> {
$result = PyTuple_New(2);
PyObject* obj1 = SWIG_NewPointerObj(*$1.first, $descriptor(DATA_TYPE_1), 0|0);
PyObject* obj2 = SWIG_NewPointerObj(*$1.second, $descriptor(DATA_TYPE_2), 0|0);
PyTuple_SET_ITEM($result, 0, obj1);
PyTuple_SET_ITEM($result, 1, obj2);
$result = PyTuple_New(2);
PyObject* obj1 = SWIG_NewPointerObj(*$1.first, $descriptor(DATA_TYPE_1), 0|0);
PyObject* obj2 = SWIG_NewPointerObj(*$1.second, $descriptor(DATA_TYPE_2), 0|0);
PyTuple_SET_ITEM($result, 0, obj1);
PyTuple_SET_ITEM($result, 1, obj2);
}
%enddef // %QPair_typemaps()
......@@ -338,86 +331,67 @@ public:
#elif SWIGCSHARP
// /////////////////////////////////////////////////////////////////
//
// C#
// /////////////////////////////////////////////////////////////////
// %typemap(typecheck) QString = char *;
// %typemap(typecheck) const QString& = char *;
// // C# -> C++
// %typemap(in) QString {
// QString $1_str((char *)$input);
// $1 = &$1_str;
// }
// %typemap(in) const QString& {
// QString $1_str((char *)$input);
// $1 = &$1_str;
// }
// // C++ -> C#
// %typemap(out) QString {
// $result = SWIG_csharp_string_callback($1.toUtf8().constData());
// }
// %typemap(out) const QString & {
// $result = SWIG_csharp_string_callback($1.toUtf8().constData());
// }
%typemap(ctype) QString "char *"
%typemap(imtype) QString "string"
%typemap(cstype) QString "string"
%typemap(csdirectorin) QString "$iminput"
%typemap(csdirectorout) QString "$cscall"
%typemap(in, canthrow=1) QString
%{
%typemap(in, canthrow=1) QString {
if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
}
$1 = QString($input);
%}
}
%typemap(out) QString
%{
%typemap(out) QString {
$result = SWIG_csharp_string_callback($1.toUtf8().constData());
%}
}
%typemap(directorout, canthrow=1) QString
%{ if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
}
$result = string($input); %}
%typemap(directorout, canthrow=1) QString {
if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
}
$result = string($input);
}
%typemap(directorin) QString %{ $input = SWIG_csharp_string_callback($1.toUtf8().constData()); %}
%typemap(directorin) QString {
$input = SWIG_csharp_string_callback($1.toUtf8().constData());
}
%typemap(csin) QString "$csinput"
%typemap(csout, excode=SWIGEXCODE) QString {
string ret = $imcall;$excode
string ret = $imcall;$excode;
return ret;
}
}
%typemap(csvarin, excode=SWIGEXCODE2) QString %{
%typemap(csvarin, excode=SWIGEXCODE2) QString {
set {
$imcall;$excode
} %}
%typemap(csvarout, excode=SWIGEXCODE2) QString %{
}
}
%typemap(csvarout, excode=SWIGEXCODE2) QString {
get {
string ret = $imcall;$excode
return ret;
} %}
}
}
%typemap(typecheck) QString = char *;
%typemap(throws, canthrow=1) QString
%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
return $null; %}
%typemap(throws, canthrow=1) QString {
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
return $null;
}
%typemap(ctype) const QString & "char *"
%typemap(imtype) const QString & "string"
......@@ -425,48 +399,59 @@ public:
%typemap(csdirectorin) const QString & "$iminput"
%typemap(csdirectorout) const QString & "$cscall"
%typemap(in, canthrow=1) const QString &
%{ if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
}
QString $1_str($input);
$1 = &$1_str; %}
%typemap(out) const QString & %{ $result = SWIG_csharp_string_callback($1->toUtf8().constData()); %}
%typemap(in, canthrow=1) const QString & {
if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
}
QString $1_str($input);
$1 = &$1_str;
}
%typemap(out) const QString & {
$result = SWIG_csharp_string_callback($1->toUtf8().constData());
}
%typemap(csin) const QString & "$csinput"
%typemap(csout, excode=SWIGEXCODE) const QString & {
string ret = $imcall;$excode
return ret;
}
}
%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const QString &
%{ if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const QString & {
if (!$input) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
return $null;
}
/* possible thread/reentrant code problem */
static string $1_str;
$1_str = $input;
$result = &$1_str; %}
$result = &$1_str;
}
%typemap(directorin) const QString & %{ $input = SWIG_csharp_string_callback($1.toUtf8().constData()); %}
%typemap(directorin) const QString & {
$input = SWIG_csharp_string_callback($1.toUtf8().constData());
}
%typemap(csvarin, excode=SWIGEXCODE2) const QString & %{
%typemap(csvarin, excode=SWIGEXCODE2) const QString & {
set {
$imcall;$excode
} %}
%typemap(csvarout, excode=SWIGEXCODE2) const QString & %{
}
}
%typemap(csvarout, excode=SWIGEXCODE2) const QString & {
get {
string ret = $imcall;$excode
return ret;
} %}
string ret = $imcall;$excode;
return ret;
}
}
%typemap(typecheck) const QString & = char *;
%typemap(throws, canthrow=1) const QString &
%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
return $null; %}
%typemap(throws, canthrow=1) const QString & {
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
return $null;
}
#endif
......@@ -490,4 +475,4 @@ public:
%include "dtkPlugin.h"
%include "dtkPluginManager.h"
#endif
/* dtkCoreSupport.i ends here */
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