mirror of https://github.com/KLayout/klayout.git
Fixed new implementation of Qt bindings for Qt5
This commit is contained in:
parent
0c89999705
commit
d66291af5b
|
|
@ -1,177 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "gsiQt.h"
|
||||
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QPoint>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Generic declarations for a pair
|
||||
|
||||
namespace qt_gsi
|
||||
{
|
||||
|
||||
template <class A, class B>
|
||||
struct pair_decl
|
||||
{
|
||||
static typename qt_gsi::Converter<A>::target_type pair_first(const QPair<A, B> *pair)
|
||||
{
|
||||
return qt_gsi::Converter<A>::toc (pair->first);
|
||||
}
|
||||
|
||||
static typename qt_gsi::Converter<B>::target_type pair_second(const QPair<A, B> *pair)
|
||||
{
|
||||
return qt_gsi::Converter<B>::toc (pair->second);
|
||||
}
|
||||
|
||||
static void pair_set_first(QPair<A, B> *pair, const typename qt_gsi::Converter<A>::target_type &s)
|
||||
{
|
||||
pair->first = qt_gsi::Converter<A>::toq (s);
|
||||
}
|
||||
|
||||
static void pair_set_second(QPair<A, B> *pair, const typename qt_gsi::Converter<B>::target_type &s)
|
||||
{
|
||||
pair->second = qt_gsi::Converter<B>::toq (s);
|
||||
}
|
||||
|
||||
static bool pair_equal(const QPair<A, B> *pair, const QPair<A, B> &other)
|
||||
{
|
||||
return *pair == other;
|
||||
}
|
||||
|
||||
/* Not available for all types:
|
||||
static bool pair_less(const QPair<A, B> *pair, const QPair<A, B> &other)
|
||||
{
|
||||
return *pair < other;
|
||||
}
|
||||
*/
|
||||
|
||||
static QPair<A, B> *pair_default_ctor()
|
||||
{
|
||||
return new QPair<A, B>();
|
||||
}
|
||||
|
||||
static QPair<A, B> *pair_ctor(const typename qt_gsi::Converter<A>::target_type &first, const typename qt_gsi::Converter<B>::target_type &second)
|
||||
{
|
||||
return new QPair<A, B>(qt_gsi::Converter<A>::toq (first), qt_gsi::Converter<B>::toq (second));
|
||||
}
|
||||
|
||||
static gsi::Methods methods ()
|
||||
{
|
||||
return
|
||||
gsi::constructor("new", &pair_default_ctor, "@brief Creates a new pair") +
|
||||
gsi::constructor("new", &pair_ctor, "@brief Creates a new pair from the given arguments\n@args first, second") +
|
||||
gsi::method_ext("first", &pair_first, "@brief Returns the first element of the pair\n") +
|
||||
gsi::method_ext("first=", &pair_set_first, "@brief Sets the first element of the pair\n@args first") +
|
||||
gsi::method_ext("second", &pair_second, "@brief Returns the second element of the pair\n") +
|
||||
gsi::method_ext("second=", &pair_set_second, "@brief Sets the second element of the pair\n@args second") +
|
||||
gsi::method_ext("==", &pair_equal, "@brief Returns true if self is equal to the other pair\n@args other")
|
||||
// not available for all types:
|
||||
// gsi::method_ext("<", &pair_less, "@brief Returns true if self is less than the other pair\n@args other")
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Declarations for QPair<QString, QString>
|
||||
|
||||
gsi::Class<QPair<QString, QString> > decl_QString_QPair ("QStringPair",
|
||||
qt_gsi::pair_decl<QString, QString>::methods (),
|
||||
"@qt\\n@brief Represents a QPair<QString, QString>"
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Declarations for QPair<QByteArray, QByteArray>
|
||||
|
||||
gsi::Class<QPair<QByteArray, QByteArray> > decl_QByteArray_QPair ("QByteArrayPair",
|
||||
qt_gsi::pair_decl<QByteArray, QByteArray>::methods (),
|
||||
"@qt\\n@brief Represents a QPair<QString, QString>"
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Declarations for QPair<double, double>
|
||||
|
||||
gsi::Class<QPair<double, double> > decl_double_QPair ("QDoublePair",
|
||||
qt_gsi::pair_decl<double, double>::methods (),
|
||||
"@qt\\n@brief Represents a QPair<double, double>"
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Declarations for QPair<double, QPointf>
|
||||
|
||||
gsi::Class<QPair<double, QPointF> > decl_double_QPointF_QPair ("QDoublePointFPair",
|
||||
qt_gsi::pair_decl<double, QPointF>::methods (),
|
||||
"@qt\\n@brief Represents a QPair<double, QPointF>"
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Declarations for QPair<double, QColor>
|
||||
|
||||
gsi::Class<QPair<double, QColor> > decl_double_QColor_QPair ("QDoubleColorPair",
|
||||
qt_gsi::pair_decl<double, QColor>::methods (),
|
||||
"@qt\\n@brief Represents a QPair<double, QColor>"
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Declarations for QPair<QHostAddress, int>
|
||||
|
||||
gsi::Class<QPair<QHostAddress, int> > decl_QHostAddress_int_QPair ("QHostAddressIntPair",
|
||||
qt_gsi::pair_decl<QHostAddress, int>::methods (),
|
||||
"@qt\\n@brief Represents a QPair<QHostAddress, int>"
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Some helper functions
|
||||
|
||||
namespace qt_gsi
|
||||
{
|
||||
|
||||
std::vector<std::string>
|
||||
to_string_vector (const QStringList &sl)
|
||||
{
|
||||
std::vector<std::string> sv;
|
||||
sv.reserve (sl.size ());
|
||||
for (QStringList::const_iterator s = sl.begin (); s != sl.end (); ++s) {
|
||||
sv.push_back (tl::to_string (*s));
|
||||
}
|
||||
return sv;
|
||||
}
|
||||
|
||||
QStringList
|
||||
to_string_list (const std::vector<std::string> &sv)
|
||||
{
|
||||
QStringList sl;
|
||||
for (std::vector<std::string>::const_iterator s = sv.begin (); s != sv.end (); ++s) {
|
||||
sl.push_back (tl::to_qstring (*s));
|
||||
}
|
||||
return sl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "gsiQt.h"
|
||||
|
||||
#include <QtGui/QGraphicsItem>
|
||||
#include <QtGui/QGraphicsObject>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
namespace qt_gsi
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// QVariant::Type implementation
|
||||
// (this type is not created automatically since QVariant is implemented implicitly)
|
||||
|
||||
class QVariant_Namespace { };
|
||||
|
||||
// A dummy namespace "QVariant"
|
||||
gsi::Class<QVariant_Namespace> decl_QVariant_Namespace ("QVariant",
|
||||
gsi::Methods(),
|
||||
"@qt\n@brief This class represents the QVariant namespace");
|
||||
|
||||
static gsi::Enum<QVariant::Type> decl_QVariant_Type_Enum ("QVariant_Type",
|
||||
gsi::enum_const ("Invalid", QVariant::Invalid, "@brief Enum constant QVariant::Invalid") +
|
||||
gsi::enum_const ("Bool", QVariant::Bool, "@brief Enum constant QVariant::Bool") +
|
||||
gsi::enum_const ("Int", QVariant::Int, "@brief Enum constant QVariant::Int") +
|
||||
gsi::enum_const ("UInt", QVariant::UInt, "@brief Enum constant QVariant::UInt") +
|
||||
gsi::enum_const ("LongLong", QVariant::LongLong, "@brief Enum constant QVariant::LongLong") +
|
||||
gsi::enum_const ("ULongLong", QVariant::ULongLong, "@brief Enum constant QVariant::ULongLong") +
|
||||
gsi::enum_const ("Double", QVariant::Double, "@brief Enum constant QVariant::Double") +
|
||||
gsi::enum_const ("Char", QVariant::Char, "@brief Enum constant QVariant::Char") +
|
||||
gsi::enum_const ("Map", QVariant::Map, "@brief Enum constant QVariant::Map") +
|
||||
gsi::enum_const ("List", QVariant::List, "@brief Enum constant QVariant::List") +
|
||||
gsi::enum_const ("String", QVariant::String, "@brief Enum constant QVariant::String") +
|
||||
gsi::enum_const ("StringList", QVariant::StringList, "@brief Enum constant QVariant::StringList") +
|
||||
gsi::enum_const ("ByteArray", QVariant::ByteArray, "@brief Enum constant QVariant::ByteArray") +
|
||||
gsi::enum_const ("BitArray", QVariant::BitArray, "@brief Enum constant QVariant::BitArray") +
|
||||
gsi::enum_const ("Date", QVariant::Date, "@brief Enum constant QVariant::Date") +
|
||||
gsi::enum_const ("Time", QVariant::Time, "@brief Enum constant QVariant::Time") +
|
||||
gsi::enum_const ("DateTime", QVariant::DateTime, "@brief Enum constant QVariant::DateTime") +
|
||||
gsi::enum_const ("Url", QVariant::Url, "@brief Enum constant QVariant::Url") +
|
||||
gsi::enum_const ("Locale", QVariant::Locale, "@brief Enum constant QVariant::Locale") +
|
||||
gsi::enum_const ("Rect", QVariant::Rect, "@brief Enum constant QVariant::Rect") +
|
||||
gsi::enum_const ("RectF", QVariant::RectF, "@brief Enum constant QVariant::RectF") +
|
||||
gsi::enum_const ("Size", QVariant::Size, "@brief Enum constant QVariant::Size") +
|
||||
gsi::enum_const ("SizeF", QVariant::SizeF, "@brief Enum constant QVariant::SizeF") +
|
||||
gsi::enum_const ("Line", QVariant::Line, "@brief Enum constant QVariant::Line") +
|
||||
gsi::enum_const ("LineF", QVariant::LineF, "@brief Enum constant QVariant::LineF") +
|
||||
gsi::enum_const ("Point", QVariant::Point, "@brief Enum constant QVariant::Point") +
|
||||
gsi::enum_const ("PointF", QVariant::PointF, "@brief Enum constant QVariant::PointF") +
|
||||
gsi::enum_const ("RegExp", QVariant::RegExp, "@brief Enum constant QVariant::RegExp") +
|
||||
gsi::enum_const ("Hash", QVariant::Hash, "@brief Enum constant QVariant::Hash") +
|
||||
gsi::enum_const ("LastCoreType", QVariant::LastCoreType, "@brief Enum constant QVariant::LastCoreType") +
|
||||
gsi::enum_const ("Font", QVariant::Font, "@brief Enum constant QVariant::Font") +
|
||||
gsi::enum_const ("Pixmap", QVariant::Pixmap, "@brief Enum constant QVariant::Pixmap") +
|
||||
gsi::enum_const ("Brush", QVariant::Brush, "@brief Enum constant QVariant::Brush") +
|
||||
gsi::enum_const ("Color", QVariant::Color, "@brief Enum constant QVariant::Color") +
|
||||
gsi::enum_const ("Palette", QVariant::Palette, "@brief Enum constant QVariant::Palette") +
|
||||
gsi::enum_const ("Icon", QVariant::Icon, "@brief Enum constant QVariant::Icon") +
|
||||
gsi::enum_const ("Image", QVariant::Image, "@brief Enum constant QVariant::Image") +
|
||||
gsi::enum_const ("Polygon", QVariant::Polygon, "@brief Enum constant QVariant::Polygon") +
|
||||
gsi::enum_const ("Region", QVariant::Region, "@brief Enum constant QVariant::Region") +
|
||||
gsi::enum_const ("Bitmap", QVariant::Bitmap, "@brief Enum constant QVariant::Bitmap") +
|
||||
gsi::enum_const ("Cursor", QVariant::Cursor, "@brief Enum constant QVariant::Cursor") +
|
||||
gsi::enum_const ("SizePolicy", QVariant::SizePolicy, "@brief Enum constant QVariant::SizePolicy") +
|
||||
gsi::enum_const ("KeySequence", QVariant::KeySequence, "@brief Enum constant QVariant::KeySequence") +
|
||||
gsi::enum_const ("Pen", QVariant::Pen, "@brief Enum constant QVariant::Pen") +
|
||||
gsi::enum_const ("TextLength", QVariant::TextLength, "@brief Enum constant QVariant::TextLength") +
|
||||
gsi::enum_const ("TextFormat", QVariant::TextFormat, "@brief Enum constant QVariant::TextFormat") +
|
||||
gsi::enum_const ("Matrix", QVariant::Matrix, "@brief Enum constant QVariant::Matrix") +
|
||||
gsi::enum_const ("Transform", QVariant::Transform, "@brief Enum constant QVariant::Transform") +
|
||||
gsi::enum_const ("Matrix4x4", QVariant::Matrix4x4, "@brief Enum constant QVariant::Matrix4x4") +
|
||||
gsi::enum_const ("Vector2D", QVariant::Vector2D, "@brief Enum constant QVariant::Vector2D") +
|
||||
gsi::enum_const ("Vector3D", QVariant::Vector3D, "@brief Enum constant QVariant::Vector3D") +
|
||||
gsi::enum_const ("Vector4D", QVariant::Vector4D, "@brief Enum constant QVariant::Vector4D") +
|
||||
gsi::enum_const ("Quaternion", QVariant::Quaternion, "@brief Enum constant QVariant::Quaternion") +
|
||||
gsi::enum_const ("LastGuiType", QVariant::LastGuiType, "@brief Enum constant QVariant::LastGuiType") +
|
||||
gsi::enum_const ("UserType", QVariant::UserType, "@brief Enum constant QVariant::UserType") +
|
||||
gsi::enum_const ("LastType", QVariant::LastType, "@brief Enum constant QVariant::LastType"),
|
||||
"@qt\n@brief This class represents the QVariant::Type enum");
|
||||
|
||||
static gsi::QFlagsClass<QVariant::Type> decl_QVariant_Type_Enums ("QVariant_QFlags_Type",
|
||||
"@qt\n@brief This class represents the QFlags<QVariant::Type> flag set");
|
||||
|
||||
// Inject the declarations into the parent
|
||||
static gsi::ClassExt<QVariant_Namespace> inject_QVariant_Type_Enum_in_parent (decl_QVariant_Type_Enum.defs ());
|
||||
static gsi::ClassExt<QVariant_Namespace> decl_QVariant_Type_Enum_as_child (decl_QVariant_Type_Enum, "Type");
|
||||
static gsi::ClassExt<QVariant_Namespace> decl_QVariant_Type_Enums_as_child (decl_QVariant_Type_Enums, "QFlags_Type");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// AbstractMethodCalledException implementation
|
||||
|
||||
AbstractMethodCalledException::AbstractMethodCalledException (const char *method_name)
|
||||
: tl::Exception (tl::to_string (QObject::tr ("Abstract method called (%s)")).c_str (), method_name)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// QtObjectBase implementation
|
||||
|
||||
void QtObjectBase::init(QObject *object)
|
||||
{
|
||||
// This method is called whenever a QtObjectBase object is created as a GSI
|
||||
// interface for a QObject. If there is a parent, we can make C++ hold the reference to that
|
||||
// object, thus moving the ownership to the C++ parent.
|
||||
if (object->parent ()) {
|
||||
keep ();
|
||||
}
|
||||
}
|
||||
|
||||
void QtObjectBase::init(QGraphicsItem *object)
|
||||
{
|
||||
// This method is called whenever a QtObjectBase object is created as a GSI
|
||||
// interface for a QGraphicsItem. If there is a parent, we can make C++ hold the reference to that
|
||||
// object, thus moving the ownership to the C++ parent.
|
||||
if (object->parentItem ()) {
|
||||
keep ();
|
||||
}
|
||||
}
|
||||
|
||||
void QtObjectBase::init(QGraphicsObject *object)
|
||||
{
|
||||
// This method is called whenever a QtObjectBase object is created as a GSI
|
||||
// interface for a QGraphicsObject. If there is a parent, we can make C++ hold the reference to that
|
||||
// object, thus moving the ownership to the C++ parent.
|
||||
if (object->parentItem () || object->parent ()) {
|
||||
keep ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -3,24 +3,15 @@ DESTDIR=$$OUT_PWD/..
|
|||
|
||||
include($$PWD/../klayout.pri)
|
||||
include(qtdecl.pro)
|
||||
include($$PWD/../gsiqt_common/gsiqt_common.pri)
|
||||
|
||||
DEFINES += MAKE_GSIQT_LIBRARY
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
SOURCES += \
|
||||
gsiQt.cc \
|
||||
gsiDeclQtBasic.cc \
|
||||
gsiQtHelper.cc
|
||||
|
||||
HEADERS += \
|
||||
gsiQt.h \
|
||||
gsiQtCommon.h \
|
||||
gsiQtHelper.h
|
||||
|
||||
# NOTE: db is required since some bridges to db are provided (i.e db::Polygon)
|
||||
INCLUDEPATH += ../tl ../gsi ../db
|
||||
DEPENDPATH += ../tl ../gsi ../db
|
||||
INCLUDEPATH += ../tl ../gsi ../db ../gsiqt_common
|
||||
DEPENDPATH += ../tl ../gsi ../db ../gsiqt_common
|
||||
|
||||
LIBS += -L$$DESTDIR -ltl -lgsi -ldb
|
||||
|
||||
|
|
|
|||
|
|
@ -1,453 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _HDR_gsiQt
|
||||
#define _HDR_gsiQt
|
||||
|
||||
#include "gsiDecl.h"
|
||||
#include "gsiSignals.h"
|
||||
#include "gsiEnums.h"
|
||||
#include "tlString.h"
|
||||
#include "tlException.h"
|
||||
#include "tlTypeTraits.h"
|
||||
#include "tlHeap.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
// contributes the WIN specific typedefs
|
||||
#include <QWindow>
|
||||
|
||||
class QGraphicsItem;
|
||||
class QGraphicsObject;
|
||||
|
||||
namespace qt_gsi
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A generic way to implement a method binding
|
||||
*
|
||||
* Using that way saves compile time and memory
|
||||
*/
|
||||
class GenericMethod : public gsi::MethodBase
|
||||
{
|
||||
public:
|
||||
GenericMethod (const char *name, const char *doc, bool is_const, void (*init_func)(GenericMethod *), void (*call_func)(const GenericMethod *, void *, gsi::SerialArgs &args, gsi::SerialArgs &ret))
|
||||
: gsi::MethodBase (name, doc, is_const, false), mp_init_func (init_func), mp_call_func (call_func), mp_set_callback_func (0)
|
||||
{
|
||||
}
|
||||
|
||||
GenericMethod (const char *name, const char *doc, bool is_const, void (*init_func)(GenericMethod *), void (*call_func)(const GenericMethod *, void *, gsi::SerialArgs &args, gsi::SerialArgs &ret), void (*set_callback_func) (void *v, const gsi::Callback &cb))
|
||||
: gsi::MethodBase (name, doc, is_const, false), mp_init_func (init_func), mp_call_func (call_func), mp_set_callback_func (set_callback_func)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void initialize ()
|
||||
{
|
||||
clear ();
|
||||
(*mp_init_func) (this);
|
||||
}
|
||||
|
||||
virtual gsi::MethodBase *clone () const
|
||||
{
|
||||
return new GenericMethod (*this);
|
||||
}
|
||||
|
||||
virtual void call (void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret) const
|
||||
{
|
||||
(*mp_call_func) (this, cls, args, ret);
|
||||
}
|
||||
|
||||
virtual bool is_callback () const
|
||||
{
|
||||
return mp_set_callback_func != 0;
|
||||
}
|
||||
|
||||
virtual void set_callback (void *v, const gsi::Callback &cb) const
|
||||
{
|
||||
if (mp_set_callback_func) {
|
||||
(*mp_set_callback_func) (v, cb);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void (*mp_init_func) (GenericMethod *self);
|
||||
void (*mp_call_func) (const GenericMethod *self, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret);
|
||||
void (*mp_set_callback_func) (void *cls, const gsi::Callback &cb);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A generic way to implement a static method binding
|
||||
*
|
||||
* Using that way saves compile time and memory
|
||||
*/
|
||||
class GenericStaticMethod : public gsi::StaticMethodBase
|
||||
{
|
||||
public:
|
||||
GenericStaticMethod (const char *name, const char *doc, void (*init_func)(GenericStaticMethod *), void (*call_func)(const GenericStaticMethod *self, gsi::SerialArgs &args, gsi::SerialArgs &ret))
|
||||
: gsi::StaticMethodBase (name, doc), mp_init_func (init_func), mp_call_func (call_func)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void initialize ()
|
||||
{
|
||||
clear ();
|
||||
(*mp_init_func) (this);
|
||||
}
|
||||
|
||||
virtual gsi::MethodBase *clone () const
|
||||
{
|
||||
return new GenericStaticMethod (*this);
|
||||
}
|
||||
|
||||
virtual void call (void *, gsi::SerialArgs &args, gsi::SerialArgs &ret) const
|
||||
{
|
||||
(*mp_call_func) (this, args, ret);
|
||||
}
|
||||
|
||||
private:
|
||||
void (*mp_init_func) (GenericStaticMethod *self);
|
||||
void (*mp_call_func) (const GenericStaticMethod *self, gsi::SerialArgs &args, gsi::SerialArgs &ret);
|
||||
};
|
||||
|
||||
template <class QT> struct Converter;
|
||||
|
||||
template <class QT>
|
||||
class QtToCppAdaptor
|
||||
{
|
||||
public:
|
||||
typedef Converter<QT> converter_type;
|
||||
typedef typename converter_type::target_type target_type;
|
||||
typedef typename converter_type::source_type source_type;
|
||||
|
||||
QtToCppAdaptor ()
|
||||
: mp_ref (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
QtToCppAdaptor (const QtToCppAdaptor<QT> &d)
|
||||
: m_qt (d.m_qt), mp_ref (d.mp_ref)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
QtToCppAdaptor (const target_type &t)
|
||||
: m_qt (converter_type::toq (t)), mp_ref (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
QtToCppAdaptor (const target_type *t)
|
||||
: m_qt (converter_type::toq (*t)), mp_ref (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
QtToCppAdaptor (target_type &t)
|
||||
: m_qt (converter_type::toq (t)), mp_ref (&t)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
QtToCppAdaptor (target_type *t)
|
||||
: m_qt (converter_type::toq (*t)), mp_ref (t)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
~QtToCppAdaptor ()
|
||||
{
|
||||
if (mp_ref) {
|
||||
*mp_ref = converter_type::toc (m_qt);
|
||||
}
|
||||
}
|
||||
|
||||
source_type *ptr ()
|
||||
{
|
||||
return &m_qt;
|
||||
}
|
||||
|
||||
source_type &ref ()
|
||||
{
|
||||
return m_qt;
|
||||
}
|
||||
|
||||
const source_type *cptr () const
|
||||
{
|
||||
return &m_qt;
|
||||
}
|
||||
|
||||
const source_type &cref () const
|
||||
{
|
||||
return m_qt;
|
||||
}
|
||||
|
||||
private:
|
||||
source_type m_qt;
|
||||
target_type *mp_ref;
|
||||
};
|
||||
|
||||
template <class QT>
|
||||
class CppToQtReadAdaptor
|
||||
{
|
||||
public:
|
||||
typedef Converter<QT> converter_type;
|
||||
typedef typename converter_type::target_type target_type;
|
||||
typedef typename converter_type::source_type source_type;
|
||||
|
||||
CppToQtReadAdaptor ()
|
||||
: mp_ref (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
CppToQtReadAdaptor (tl::Heap &heap, const source_type &qt)
|
||||
{
|
||||
mp_ref = new target_type (converter_type::toc (qt));
|
||||
heap.push (mp_ref);
|
||||
}
|
||||
|
||||
operator const target_type *() const
|
||||
{
|
||||
return mp_ref;
|
||||
}
|
||||
|
||||
operator const target_type &() const
|
||||
{
|
||||
return *mp_ref;
|
||||
}
|
||||
|
||||
private:
|
||||
const target_type *mp_ref;
|
||||
|
||||
CppToQtReadAdaptor (const CppToQtReadAdaptor<QT> &d);
|
||||
CppToQtReadAdaptor &operator= (const CppToQtReadAdaptor<QT> &d);
|
||||
};
|
||||
|
||||
template <class QT>
|
||||
class CppToQtAdaptor
|
||||
{
|
||||
public:
|
||||
typedef Converter<QT> converter_type;
|
||||
typedef typename converter_type::target_type target_type;
|
||||
typedef typename converter_type::source_type source_type;
|
||||
|
||||
CppToQtAdaptor ()
|
||||
: mp_ref (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
CppToQtAdaptor (const CppToQtAdaptor<QT> &d)
|
||||
: m_t (d.m_t), mp_ref (d.mp_ref)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
CppToQtAdaptor (const source_type &qt)
|
||||
: m_t (converter_type::toc (qt)), mp_ref (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
CppToQtAdaptor (source_type &qt)
|
||||
: m_t (converter_type::toc (qt)), mp_ref (&qt)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
~CppToQtAdaptor ()
|
||||
{
|
||||
if (mp_ref) {
|
||||
*mp_ref = converter_type::toq (m_t);
|
||||
}
|
||||
}
|
||||
|
||||
operator target_type *()
|
||||
{
|
||||
return &m_t;
|
||||
}
|
||||
|
||||
operator target_type &()
|
||||
{
|
||||
return m_t;
|
||||
}
|
||||
|
||||
operator const target_type *() const
|
||||
{
|
||||
return &m_t;
|
||||
}
|
||||
|
||||
operator const target_type &() const
|
||||
{
|
||||
return m_t;
|
||||
}
|
||||
|
||||
private:
|
||||
target_type m_t;
|
||||
source_type *mp_ref;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Converter
|
||||
{
|
||||
typedef T source_type;
|
||||
typedef T target_type;
|
||||
static const T &toq (const T &v) { return v; }
|
||||
static const T &toc (const T &v) { return v; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<Qt::HANDLE>
|
||||
{
|
||||
public:
|
||||
typedef Qt::HANDLE source_type;
|
||||
typedef size_t target_type;
|
||||
static source_type toq (target_type c) { return source_type (c); }
|
||||
static target_type toc (source_type qc) { return target_type (qc); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<Q_PID>
|
||||
{
|
||||
public:
|
||||
typedef Q_PID source_type;
|
||||
typedef size_t target_type;
|
||||
static source_type toq (target_type c) { return source_type (c); }
|
||||
static target_type toc (source_type qc) { return target_type (qc); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<QChar>
|
||||
{
|
||||
public:
|
||||
typedef QChar source_type;
|
||||
typedef unsigned int target_type;
|
||||
static QChar toq (unsigned int c) { return QChar (c); }
|
||||
static unsigned int toc (QChar qc) { return qc.unicode (); }
|
||||
};
|
||||
|
||||
std::vector<std::string> to_string_vector (const QStringList &sl);
|
||||
QStringList to_string_list (const std::vector<std::string> &sv);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
template <>
|
||||
struct Converter<WId>
|
||||
{
|
||||
public:
|
||||
typedef WId source_type;
|
||||
typedef size_t target_type;
|
||||
static source_type toq (target_type c) { return source_type (c); }
|
||||
static target_type toc (source_type qc) { return target_type (qc); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<HCURSOR>
|
||||
{
|
||||
public:
|
||||
typedef HCURSOR source_type;
|
||||
typedef size_t target_type;
|
||||
static source_type toq (target_type c) { return source_type (c); }
|
||||
static target_type toc (source_type qc) { return target_type (qc); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<HFONT>
|
||||
{
|
||||
public:
|
||||
typedef HFONT source_type;
|
||||
typedef size_t target_type;
|
||||
static source_type toq (target_type c) { return source_type (c); }
|
||||
static target_type toc (source_type qc) { return target_type (qc); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class AbstractMethodCalledException
|
||||
: public tl::Exception
|
||||
{
|
||||
public:
|
||||
AbstractMethodCalledException (const char *method_name);
|
||||
};
|
||||
|
||||
class QtObjectBase
|
||||
: public gsi::ObjectBase
|
||||
{
|
||||
public:
|
||||
void init (void *)
|
||||
{
|
||||
// fallback case: no particular initialization
|
||||
}
|
||||
|
||||
void init (QObject *object);
|
||||
void init (QGraphicsItem *object);
|
||||
void init (QGraphicsObject *object);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An implementation helper for the "keep arg" feature
|
||||
* This helper will call keep on the object or objects, hence passing
|
||||
* ownership to the callee.
|
||||
*/
|
||||
template <class T>
|
||||
inline void qt_keep (T *obj)
|
||||
{
|
||||
QtObjectBase *qt_obj = dynamic_cast<QtObjectBase *>(obj);
|
||||
if (qt_obj) {
|
||||
qt_obj->keep ();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void qt_keep (const QList<T *> &list)
|
||||
{
|
||||
for (typename QList<T *>::const_iterator l = list.begin (); l != list.end (); ++l) {
|
||||
qt_keep (*l);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void qt_keep (const std::vector<T *> &list)
|
||||
{
|
||||
for (typename std::vector<T *>::const_iterator l = list.begin (); l != list.end (); ++l) {
|
||||
qt_keep (*l);
|
||||
}
|
||||
}
|
||||
|
||||
// Using this macro on a variable will supress the "unused variable" or "unused argument"
|
||||
// warning:
|
||||
#define __SUPPRESS_UNUSED_WARNING(x) (void)(x)
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(HDR_gsiQtCommon_h)
|
||||
# define HDR_gsiQtCommon_h
|
||||
|
||||
# if defined _WIN32 || defined __CYGWIN__
|
||||
|
||||
# ifdef MAKE_GSIQT_LIBRARY
|
||||
# define GSIQT_PUBLIC __declspec(dllexport)
|
||||
# else
|
||||
# define GSIQT_PUBLIC __declspec(dllimport)
|
||||
# endif
|
||||
# define GSIQT_LOCAL
|
||||
|
||||
# else
|
||||
|
||||
# if __GNUC__ >= 4
|
||||
# define GSIQT_PUBLIC __attribute__ ((visibility ("default")))
|
||||
# define GSIQT_LOCAL __attribute__ ((visibility ("hidden")))
|
||||
# else
|
||||
# define GSIQT_PUBLIC
|
||||
# define GSIQT_LOCAL
|
||||
# endif
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
|
@ -3,22 +3,14 @@ DESTDIR=$$OUT_PWD/..
|
|||
|
||||
include($$PWD/../klayout.pri)
|
||||
include(qtdecl.pro)
|
||||
include($$PWD/../gsiqt_common/gsiqt_common.pri)
|
||||
|
||||
DEFINES += MAKE_GSIQT_LIBRARY
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
SOURCES += \
|
||||
gsiQt.cc \
|
||||
gsiQtBasic.cc \
|
||||
gsiQtAdditional.cc \
|
||||
|
||||
HEADERS += \
|
||||
gsiQt.h \
|
||||
gsiQtCommon.h
|
||||
|
||||
# NOTE: db is required since some bridges to db are provided (i.e db::Polygon)
|
||||
INCLUDEPATH += ../tl ../gsi ../db
|
||||
DEPENDPATH += ../tl ../gsi ../db
|
||||
INCLUDEPATH += ../tl ../gsi ../db ../gsiqt_common
|
||||
DEPENDPATH += ../tl ../gsi ../db ../gsiqt_common
|
||||
LIBS += -L$$DESTDIR -ltl -lgsi -ldb
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
#include "gsiQt.h"
|
||||
|
||||
|
|
@ -88,11 +89,7 @@ class QUrlTwoFlagsClass
|
|||
: public gsi::Class<QUrlTwoFlagsAdaptor<A, B>, QUrlTwoFlags<A, B> >
|
||||
{
|
||||
public:
|
||||
#if QT_VERSION >= 0x050000
|
||||
typedef typename QFlags<A>::Int int_repr;
|
||||
#else
|
||||
typedef int int_repr;
|
||||
#endif
|
||||
|
||||
QUrlTwoFlagsClass (const std::string &name, const std::string &doc = std::string ())
|
||||
: gsi::Class<QUrlTwoFlagsAdaptor<A, B>, QUrlTwoFlags<A, B> > (name, methods (), doc)
|
||||
|
|
@ -324,3 +321,4 @@ static gsi::ClassExt<QUrl> decl_QUrlTwoFlags_as_child (decl_QUrlTwoFlags, "Forma
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -42,6 +42,11 @@
|
|||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
// contributes the WIN specific typedefs
|
||||
# include <QWindow>
|
||||
#endif
|
||||
|
||||
class QGraphicsItem;
|
||||
class QGraphicsObject;
|
||||
|
||||
|
|
@ -401,6 +406,7 @@ public:
|
|||
static unsigned int toc (QChar qc) { return qc.unicode (); }
|
||||
};
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
template <>
|
||||
struct Converter<QBool>
|
||||
{
|
||||
|
|
@ -410,6 +416,7 @@ public:
|
|||
static QBool toq (bool b) { return QBool (b); }
|
||||
static bool toc (QBool qb) { return qb; }
|
||||
};
|
||||
#endif
|
||||
|
||||
std::vector<std::string> to_string_vector (const QStringList &sl);
|
||||
QStringList to_string_list (const std::vector<std::string> &sv);
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/gsiQt.cc \
|
||||
$$PWD/gsiDeclQtBasic.cc \
|
||||
$$PWD/gsiDeclQt5Basic.cc \
|
||||
$$PWD/gsiQtHelper.cc
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/gsiQt.h \
|
||||
$$PWD/gsiQtCommon.h \
|
||||
$$PWD/gsiQtHelper.h
|
||||
|
||||
|
|
@ -157,19 +157,23 @@ win32 {
|
|||
INCLUDEPATH += $$DESTDIR/laybasic
|
||||
DEPENDPATH += $$DESTDIR/laybasic
|
||||
|
||||
equals(HAVE_QTBINDINGS, "1") {
|
||||
equals(HAVE_QT5, "1") {
|
||||
INCLUDEPATH += ../gsiqt5
|
||||
DEPENDPATH += ../gsiqt5
|
||||
LIBS += -lgsiqt5
|
||||
} else {
|
||||
INCLUDEPATH += ../gsiqt
|
||||
DEPENDPATH += ../gsiqt
|
||||
LIBS += -lgsiqt
|
||||
}
|
||||
# for gsiQtExternals.h:
|
||||
equals(HAVE_QT5, "1") {
|
||||
INCLUDEPATH += ../gsiqt5
|
||||
DEPENDPATH += ../gsiqt5
|
||||
} else {
|
||||
INCLUDEPATH += ../gsiqtstub
|
||||
DEPENDPATH += ../gsiqtstub
|
||||
INCLUDEPATH += ../gsiqt
|
||||
DEPENDPATH += ../gsiqt
|
||||
}
|
||||
|
||||
equals(HAVE_QTBINDINGS, "1") {
|
||||
INCLUDEPATH += ../gsiqt_common
|
||||
DEPENDPATH += ../gsiqt_common
|
||||
equals(HAVE_QT5, "1") {
|
||||
LIBS += -lgsiqt5
|
||||
} else {
|
||||
LIBS += -lgsiqt
|
||||
}
|
||||
}
|
||||
|
||||
equals(HAVE_RUBY, "1") {
|
||||
|
|
|
|||
|
|
@ -276,18 +276,22 @@ INCLUDEPATH += ../tl ../gsi ../db ../rdb
|
|||
DEPENDPATH += ../tl ../gsi ../db ../rdb
|
||||
LIBS += -L$$DESTDIR -ltl -lgsi -ldb -lrdb
|
||||
|
||||
equals(HAVE_QTBINDINGS, "1") {
|
||||
equals(HAVE_QT5, "1") {
|
||||
INCLUDEPATH += ../gsiqt5
|
||||
DEPENDPATH += ../gsiqt5
|
||||
LIBS += -lgsiqt5
|
||||
} else {
|
||||
INCLUDEPATH += ../gsiqt
|
||||
DEPENDPATH += ../gsiqt
|
||||
LIBS += -lgsiqt
|
||||
}
|
||||
# for gsiQtExternals.h:
|
||||
equals(HAVE_QT5, "1") {
|
||||
INCLUDEPATH += ../gsiqt5
|
||||
DEPENDPATH += ../gsiqt5
|
||||
} else {
|
||||
INCLUDEPATH += ../gsiqtstub
|
||||
DEPENDPATH += ../gsiqtstub
|
||||
INCLUDEPATH += ../gsiqt
|
||||
DEPENDPATH += ../gsiqt
|
||||
}
|
||||
|
||||
equals(HAVE_QTBINDINGS, "1") {
|
||||
INCLUDEPATH += ../gsiqt_common
|
||||
DEPENDPATH += ../gsiqt_common
|
||||
equals(HAVE_QT5, "1") {
|
||||
LIBS += -lgsiqt5
|
||||
} else {
|
||||
LIBS += -lgsiqt
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue