WIP: usable constructors for QApplication and related.

This commit is contained in:
Matthias Koefferlein 2018-06-02 22:21:59 +02:00
parent ea31e5bcde
commit 40b2e9a1a5
5 changed files with 171 additions and 85 deletions

View File

@ -203,6 +203,10 @@ if [ $update != 0 ]; then
# classes first
for d in $qt_mods; do
echo "--------------------------------------------------------"
echo "Production on $d ..."
echo ""
cd $d
mkdir -p generated

View File

@ -1,8 +1,56 @@
# Run the script with Qt >=4.6.2
# QTINCLUDE=/usr/include/qt4 ./mkqtdecl.rb
# mv Makefile.qtdecl.new Makefile.qtdecl
# mv gsiDeclQtTypeTraits.h.new gsiDeclQtTypeTraits.h
# --------------------------------------------------------------
# Some definitions
def add_native_qapp_ctor_impl(cls)
qapplication_ctor_code = <<'CODE'
static %CLS% *ctor_%CLS%_Adaptor_args(const std::vector<std::string> &args)
{
// %CLS% needs static sources, so we give it some.
static char **argv = 0;
static std::vector<std::string> args_copy;
static int argc = 0;
if (argv != 0) {
throw tl::Exception(tl::to_string(QObject::tr("%CLS% cannot be instantiated twice")));
}
argv = new char *[args.size ()];
args_copy = args;
argc = int (args.size ());
for (std::vector<std::string>::const_iterator a = args_copy.begin (); a != args_copy.end (); ++a) {
argv[a - args_copy.begin ()] = (char *) a->c_str ();
}
return new %CLS%_Adaptor (argc, argv);
}
%CLS%_Adaptor (int &argc, char **argv) : %CLS% (argc, argv) { }
CODE
qapplication_ctor_decl = <<'DECL'
gsi::constructor("new", &%CLS%_Adaptor::ctor_%CLS%_Adaptor_args, gsi::arg ("argv"), "@brief Creates a new %CLS% object\n\n@param argv The command line arguments to pass to Qt")
DECL
add_native_impl(cls + "_Adaptor", qapplication_ctor_code.gsub("%CLS%", cls), qapplication_ctor_decl.gsub("%CLS%", cls))
end
# --------------------------------------------------------------
# all modules
drop_method :all_classes, /::qt_check_for_QOBJECT_macro/ # don't include in API!
drop_method :all_classes, /::metaObject/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /::qt_/ # internal use only
drop_method :all_classes, /::d_func/ # internal use only
drop_method :all_classes, /::connectNotify/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /::devType\(/ # not required
drop_method :all_classes, /::x11/ # no X11 stuff
drop_method :all_classes, /::data_ptr/ # no private data
rename :all_classes, /::create\(/, "qt_create" # clashes with GSI/Ruby
rename :all_classes, /::destroy\(/, "qt_destroy" # clashes with GSI/Ruby
rename :all_classes, /::raise\(/, "qt_raise" # clashes with Ruby "raise" keyword
# --------------------------------------------------------------
# Qt
@ -153,10 +201,6 @@ drop_class "QVectorIterator"
drop_class "QVectorTypedData"
drop_enum_const "QEvent", /CocoaRequestModal/ # not available on WIN
drop_method :all_classes, /::metaObject/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /::qt_/ # internal use only
drop_method :all_classes, /::d_func/ # internal use only
drop_method :all_classes, /::connectNotify/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method "QFont", /QFont::initialize/ # Must not hide Ruby's initialize and is not public
drop_method "QColormap", /QColormap::initialize/ # Must not hide Ruby's initialize and is not public
drop_method "QAccessible", /QAccessible::initialize/ # Must not hide Ruby's initialize and is not public
@ -179,10 +223,11 @@ drop_method "QMatrix4x4", /QMatrix4x4::QMatrix4x4.*GenericMatrix/ # GenericMatri
drop_method "QMatrix4x4", /QMatrix4x4::normalMatrix/ # return value GenericMatrix is a template
drop_method "QMatrix4x4", /QMatrix4x4::toGenericMatrix/ # return value GenericMatrix is a template
drop_method "QCoreApplication", /QCoreApplication::setEventFilter/ # requires callbacks
drop_method "QCoreApplication", /QCoreApplication::QCoreApplication/ # not required (use instance), required char **
drop_method "QCoreApplication", /QCoreApplication::argv/ # requires char **
drop_method "QCoreApplication", /QCoreApplication::argc/ # does not make sense without argv ..
drop_method "QCoreApplication", /QCoreApplication::compressEvent/ # QPostEventList is missing
drop_method "QCoreApplication", /QCoreApplication::watchUnixSignal/ # not available on WIN
keep_arg "QCoreApplication", /::postEvent/, 1 # will take ownership of event
drop_method "", /::operator\s*>>\(QDataStream\s*&/ # implemented through "read" below
drop_method "", /::operator\s*<<\(QDataStream\s*&/ # implemented through "put" below
drop_method "QDataStream", /::operator\s*>>/ # implemented through read
@ -201,14 +246,12 @@ drop_method "QFile", /QFile::open.*IO_FILE/ # uses internal struct
drop_method "QPrinter", /QPrinter::printerSelectionOption/ # not available on WIN
drop_method "QPrinter", /QPrinter::setPrinterSelectionOption/ # not available on WIN
drop_method "QSessionManager", /QSessionManager::handle/ # not available on WIN
drop_method "QCoreApplication", /QCoreApplication::watchUnixSignal/ # not available on WIN
drop_method "QPersistentModelIndex", /QPersistentModelIndex::operator\s+const\s+class\s+QModelIndex/ # implemented specially
drop_method "QSettings", /QSettings::registerFormat/ # uses callbacks
drop_method "QSettings", /QSettings::iniCodec/ # requires QTextCodec
drop_method "QSettings", /QSettings::setIniCodec/ # requires QTextCodec
drop_method "QAbstractFileEngine", /QAbstractFileEngine::supportsExtension/ # missing classes ExtensionOption etc.
drop_method "QAbstractFileEngine", /QAbstractFileEngine::extension/ # missing classes ExtensionOption etc.
drop_method :all_classes, /::qt_check_for_QOBJECT_macro/ # don't include in API!
drop_method "QUrl", /QUrl::data_ptr/ # QUrlPrivate not available
drop_method "QFile", /QFile::fileEngine\(\)/ # requires AbstractFileEngine
drop_method "QTemporaryFile", /QTemporaryFile::fileEngine\(\)/ # requires AbstractFileEngine
@ -268,6 +311,10 @@ rename "QResource", /QResource::unregisterResource\(const QString/, "unregisterR
rename "QProcess", /QProcess::error\(QProcess::ProcessError/, "error_sig" # disambiguator
rename "QProcess", /QProcess::finished\(int[\s\w]*\)/, "finished_int" # disambiguator finished(int) vs. finished(int, QProcess::ExitStatus)
# alternative implementation for QCoreApplication::QCoreApplication
drop_method "QCoreApplication", /QCoreApplication::QCoreApplication/
add_native_qapp_ctor_impl("QCoreApplication")
# alternative implementation for QObject::findChild using QObject for T
add_native_impl("QObject", <<'CODE', <<'DECL')
QObject *find_child_impl (QObject *object, const QString &name) { return object->findChild<QObject *> (name); }
@ -1133,10 +1180,6 @@ drop_class "QWSScreenSaver"
drop_class "QWSServer"
drop_class "QWSWindow"
rename :all_classes, /::create\(/, "qt_create" # clashes with GSI/Ruby
rename :all_classes, /::destroy\(/, "qt_destroy" # clashes with GSI/Ruby
rename :all_classes, /::raise\(/, "qt_raise" # clashes with Ruby "raise" keyword
# depedencies from operators are not derived automatically currently:
include "QPoint", [ "<QPoint>", "<QMatrix>", "<QMatrix4x4>" ]
include "QPointF", [ "<QPointF>", "<QMatrix>", "<QMatrix4x4>" ]
@ -1146,14 +1189,12 @@ include "QAction", [ "<QAction>", "<QGraphicsWidget>", "<QMenu>" ]
include "QCursor", [ "<QCursor>", "<QScreen>", "<QBitmap>" ]
include "QGraphicsItem", [ "<QGraphicsItem>", "<QGraphicsTransform>", "<QGraphicsScene>", "<QStyleOptionGraphicsItem>", "<QGraphicsEffect>", "<QGraphicsWidget>", "<QGraphicsSceneContextMenuEvent>", "<QGraphicsSceneDragDropEvent>", "<QGraphicsSceneHoverEvent>", "<QGraphicsSceneMouseEvent>", "<QGraphicsSceneWheelEvent>", "<QPainter>" ]
include "QGraphicsScene", [ "<QGraphicsScene>", "<QGraphicsView>", "<QGraphicsItem>", "<QGraphicsWidget>", "<QGraphicsEllipseItem>", "<QGraphicsLineItem>", "<QGraphicsPathItem>", "<QGraphicsPixmapItem>", "<QGraphicsPolygonItem>", "<QGraphicsRectItem>", "<QGraphicsSimpleTextItem>", "<QGraphicsTextItem>", "<QGraphicsProxyWidget>", "<QGraphicsItemGroup>", "<QStyle>", "<QGraphicsSceneContextMenuEvent>", "<QGraphicsSceneDragDropEvent>", "<QGraphicsSceneHelpEvent>", "<QGraphicsSceneMouseEvent>", "<QGraphicsSceneWheelEvent>" ]
include "QGuiApplication", [ "<QGuiApplication>", "<QScreen>", "<QSessionManager>", "<QClipboard>", "<QWindow>", "<QStyleHints>" ]
include "QApplication", [ "<QApplication>", "<QSessionManager>", "<QDesktopWidget>", "<QStyle>", "<QScreen>", "<QLocale>", "<QClipboard>", "<QInputContext>" ]
include "QTextStream", [ "<QTextStream>", "<QIODevice>", "<QLocale>", "<QTextCodec>", "<QDomNode>", "<QSplitter>" ]
include "QWindow", [ "<QWindow>", "<QScreen>" ]
include "QOffscreenSurface", [ "<QOffscreenSurface>", "<QScreen>" ]
include "QScreenOrientationChangeEvent", [ "<QScreenOrientationChangeEvent>", "<QScreen>" ]
drop_method :all_classes, /::devType\(/ # not required
drop_method "QAbstractPageSetupDialog", /QAbstractPageSetupDialog::QAbstractPageSetupDialog\(QAbstractPageSetupDialogPrivate/
drop_method "QClipboardEvent", /QClipboardEvent::data/
drop_method "QClipboardEvent", /QClipboardEvent::QClipboardEvent\(QEventPrivate/
@ -1165,7 +1206,6 @@ drop_method "QPixmap", /QPixmap::handle/ # not available on WIN
drop_method "QPixmap", /QPixmap::fromX11Pixmap/ # not available on WIN
drop_method "QTabletEvent", /QTabletEvent::QTabletEvent/ # TODO: too many arguments
drop_method "QGraphicsProxyWidget", /QGraphicsProxyWidget::setGeometry\(double/ # not available as override (private or protected inheritance?)
drop_method :all_classes, /::x11/ # no X11 stuff
drop_method "QPixmap", /QPixmap::QPixmap\(const\s+char\s+\*\s*const\s*\w*\s*\[\s*\]/ # no const char *[] - TODO: provide differen implementation?
drop_method "QImage", /QImage::QImage\(const\s+char\s+\*\s*const\s*xpm\s*\[\s*\]/ # no const char *[] - TODO: provide differen implementation?
drop_method "QImage", /QImage::QImage\(const\s+char\s+\*\s*fileName/ # not available for QT_NO_CAST_TO_ASCII
@ -1184,7 +1224,6 @@ drop_method "QGraphicsEffect", /QGraphicsEffect::source\s*\(\s*\)/ # requires Q
drop_method "QGraphicsScene", /QGraphicsScene::drawItems/ # requires QGraphicsItem *[], TODO: provide an alternative!
drop_method "QGraphicsView", /QGraphicsView::drawItems/ # requires QGraphicsItem *[], TODO: provide an alternative!
# drop_method "QGtkStyle", /QGtkStyle::QGtkStyle\s*\(\s*QGtkStylePrivate/ # requires QGtkStylePrivate
drop_method :all_classes, /::data_ptr/ # no private data
drop_method "QTextList", /QTextList::setFormat\(const\s+QTextFormat\s+/ # got mixed in somehow(?). Not part of API
drop_method "QTextTable", /QTextTable::setFormat\(const\s+QTextFormat\s+/ # got mixed in somehow(?). Not part of API
drop_method "QTextTableCell", /QTextTableCell::begin/ # requires template type return value (TODO: provide alternative?)
@ -1274,7 +1313,6 @@ drop_method "Qimage", /Qimage::text\(const\s+QString/ # clashes with const char
rename "QDialogButtonBox", /QDialogButtonBox::QDialogButtonBox\(QFlags/, "new_buttons"
rename "QIcon", /QIcon::pixmap\(int\s+extent/, "pixmap_ext"
rename "QKeySequence", /QKeySequence::QKeySequence\(QKeySequence::StandardKey/, "new_std"
keep_arg "QCoreApplication", /::postEvent/, 1 # will take ownership of event
keep_arg "QBoxLayout", /::addLayout/, 0 # will take ownership of layout
keep_arg "QGridLayout", /::addLayout/, 0 # will take ownership of layout
keep_arg "QLayout", /::addChildLayout/, 0 # will take ownership of layout
@ -1319,18 +1357,7 @@ rename "QPrintDialog", /QPrintDialog::accepted\(QPrinter/, "accepted_sig"
# special implementations:
drop_method "QApplication", /QApplication::QApplication/ # uses char **
# provide a dummy application for the constructor for test purposes
add_native_impl("QApplication", <<'CODE', <<'DECL')
static QApplication *ctor_QApplication()
{
static char *(dummy_argv[]) = { (char *)"undefined_application" };
static int argc = 1;
return new QApplication (argc, dummy_argv);
}
CODE
gsi::constructor("new_app", &ctor_QApplication, "@brief Creates a new QApplication object\n\nThis implementation is provided for test purposes only. It is not required usually to create a QApplication object. Use the object provided by QApplication::instance instead.")
DECL
add_native_qapp_ctor_impl("QApplication")
no_imports "QItemSelection" # base class is a template. TODO: provide a solution (i.e. additional manual declarations)
no_imports "QPageSetupDialog" # base class is a QAbstractPageSetupDialog which is not readily available

View File

@ -1,8 +1,58 @@
# Run the script with Qt >=4.6.2
# QTINCLUDE=/usr/include/qt4 ./mkqtdecl.rb
# mv Makefile.qtdecl.new Makefile.qtdecl
# mv gsiDeclQtTypeTraits.h.new gsiDeclQtTypeTraits.h
# --------------------------------------------------------------
# Some definitions
def add_native_qapp_ctor_impl(cls)
qapplication_ctor_code = <<'CODE'
static %CLS% *ctor_%CLS%_Adaptor_args(const std::vector<std::string> &args)
{
// %CLS% needs static sources, so we give it some.
static char **argv = 0;
static std::vector<std::string> args_copy;
static int argc = 0;
if (argv != 0) {
throw tl::Exception(tl::to_string(QObject::tr("%CLS% cannot be instantiated twice")));
}
argv = new char *[args.size ()];
args_copy = args;
argc = int (args.size ());
for (std::vector<std::string>::const_iterator a = args_copy.begin (); a != args_copy.end (); ++a) {
argv[a - args_copy.begin ()] = (char *) a->c_str ();
}
return new %CLS%_Adaptor (argc, argv);
}
%CLS%_Adaptor (int &argc, char **argv) : %CLS% (argc, argv) { }
CODE
qapplication_ctor_decl = <<'DECL'
gsi::constructor("new", &%CLS%_Adaptor::ctor_%CLS%_Adaptor_args, gsi::arg ("argv"), "@brief Creates a new %CLS% object\n\n@param argv The command line arguments to pass to Qt")
DECL
add_native_impl(cls + "_Adaptor", qapplication_ctor_code.gsub("%CLS%", cls), qapplication_ctor_decl.gsub("%CLS%", cls))
end
# --------------------------------------------------------------
# all modules
drop_method :all_classes, /QPrivateSignal/ # private signals cannot be exposed as methods
drop_method :all_classes, /::metaObject/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /::qt_/ # internal use only
drop_method :all_classes, /::d_func/ # internal use only
drop_method :all_classes, /::connectNotify/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /\(\s*Qt::Initialization/ # special constructors
drop_method :all_classes, /::qt_check_for_QOBJECT_macro/ # don't include in API!
drop_method :all_classes, /::devType\(/ # not required
drop_method :all_classes, /::data_ptr/ # no private data
drop_method :all_classes, /::x11/ # no X11 stuff
rename :all_classes, /::create\(/, "qt_create" # clashes with GSI/Ruby
rename :all_classes, /::destroy\(/, "qt_destroy" # clashes with GSI/Ruby
rename :all_classes, /::raise\(/, "qt_raise" # clashes with Ruby "raise" keyword
# --------------------------------------------------------------
# Qt
@ -192,12 +242,6 @@ drop_class "QVectorIterator"
drop_class "QVectorTypedData"
drop_enum_const "QEvent", /CocoaRequestModal/ # not available on WIN
drop_method :all_classes, /QPrivateSignal/ # private signals cannot be exposed as methods
drop_method :all_classes, /::metaObject/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /::qt_/ # internal use only
drop_method :all_classes, /::d_func/ # internal use only
drop_method :all_classes, /::connectNotify/ # messes up the overload scheme since it can be overloaded but is required internally before overloading is effective (on attach). Use staticMetaObject instead.
drop_method :all_classes, /\(\s*Qt::Initialization/ # special constructors
drop_method "QQuaternion", /QQuaternion::toRotationMatrix\(/ # GenericMatrix not available
drop_method "QQuaternion", /QQuaternion::fromRotationMatrix\(/ # GenericMatrix not available
drop_method "QJsonValue", /QJsonValue::QJsonValue\(\s*QLatin1String/ # QLatin1String not available
@ -239,10 +283,11 @@ drop_method "QMatrix4x4", /QMatrix4x4::normalMatrix/ # return value GenericMatri
drop_method "QMatrix4x4", /QMatrix4x4::toGenericMatrix/ # return value GenericMatrix is a template
drop_method "QMimeType", /QMimeType::QMimeType\(const\s+QMimeTypePrivate\s+/ # no access to internal struct
drop_method "QCoreApplication", /QCoreApplication::setEventFilter/ # requires callbacks
drop_method "QCoreApplication", /QCoreApplication::QCoreApplication/ # not required (use instance), required char **
drop_method "QCoreApplication", /QCoreApplication::argv/ # requires char **
drop_method "QCoreApplication", /QCoreApplication::argc/ # does not make sense without argv ..
drop_method "QCoreApplication", /QCoreApplication::compressEvent/ # QPostEventList is missing
drop_method "QCoreApplication", /QCoreApplication::watchUnixSignal/ # not available on WIN
keep_arg "QCoreApplication", /::postEvent/, 1 # will take ownership of event
drop_method "", /::operator\s*>>\(QDataStream\s*&/ # implemented through "read" below
drop_method "", /::operator\s*<<\(QDataStream\s*&/ # implemented through "put" below
drop_method "QDataStream", /::operator\s*>>/ # implemented through read
@ -261,14 +306,12 @@ drop_method "QFileInfo", /QFileInfo::QFileInfo\(QFileInfoPrivate\s+\*/ # uses in
drop_method "QPrinter", /QPrinter::printerSelectionOption/ # not available on WIN
drop_method "QPrinter", /QPrinter::setPrinterSelectionOption/ # not available on WIN
drop_method "QSessionManager", /QSessionManager::handle/ # not available on WIN
drop_method "QCoreApplication", /QCoreApplication::watchUnixSignal/ # not available on WIN
drop_method "QPersistentModelIndex", /QPersistentModelIndex::operator\s+const\s+class\s+QModelIndex/ # implemented specially
drop_method "QSettings", /QSettings::registerFormat/ # uses callbacks
drop_method "QSettings", /QSettings::iniCodec/ # requires QTextCodec
drop_method "QSettings", /QSettings::setIniCodec/ # requires QTextCodec
drop_method "QAbstractFileEngine", /QAbstractFileEngine::supportsExtension/ # missing classes ExtensionOption etc.
drop_method "QAbstractFileEngine", /QAbstractFileEngine::extension/ # missing classes ExtensionOption etc.
drop_method :all_classes, /::qt_check_for_QOBJECT_macro/ # don't include in API!
drop_method "QUrl", /QUrl::data_ptr/ # QUrlPrivate not available
drop_method "QFile", /QFile::fileEngine\(\)/ # requires AbstractFileEngine
drop_method "QTemporaryFile", /QTemporaryFile::fileEngine\(\)/ # requires AbstractFileEngine
@ -340,6 +383,10 @@ rename "QResource", /QResource::unregisterResource\(const QString/, "unregisterR
rename "QProcess", /QProcess::error\(QProcess::ProcessError/, "error_sig" # disambiguator
rename "QProcess", /QProcess::finished\(int[\s\w]*\)/, "finished_int" # disambiguator finished(int) vs. finished(int, QProcess::ExitStatus)
# alternative implementation for QCoreApplication::QCoreApplication
drop_method "QCoreApplication", /QCoreApplication::QCoreApplication/
add_native_qapp_ctor_impl("QCoreApplication")
# alternative implementation for QObject::findChild using QObject for T
add_native_impl("QObject", <<'CODE', <<'DECL')
QObject *find_child_impl (QObject *object, const QString &name) { return object->findChild<QObject *> (name); }
@ -1236,10 +1283,6 @@ drop_class "QOpenGLVertexArrayObject" # OpenGL native types not supported
drop_class "QOpenGLWidget" # OpenGL native types not supported
drop_class "QOpenGLWindow" # OpenGL native types not supported
rename :all_classes, /::create\(/, "qt_create" # clashes with GSI/Ruby
rename :all_classes, /::destroy\(/, "qt_destroy" # clashes with GSI/Ruby
rename :all_classes, /::raise\(/, "qt_raise" # clashes with Ruby "raise" keyword
# depedencies from operators are not derived automatically currently:
include "QPoint", [ "<QPoint>", "<QMatrix>", "<QMatrix4x4>" ]
include "QPointF", [ "<QPointF>", "<QMatrix>", "<QMatrix4x4>" ]
@ -1255,7 +1298,6 @@ include "QWindow", [ "<QWindow>", "<QScreen>" ]
include "QOffscreenSurface", [ "<QOffscreenSurface>", "<QScreen>" ]
include "QScreenOrientationChangeEvent", [ "<QScreenOrientationChangeEvent>", "<QScreen>" ]
drop_method :all_classes, /::devType\(/ # not required
drop_method "QWindow", /QWindow::handle/ # QPlatformWindow not available
drop_method "QScreen", /QScreen::handle/ # QPlatformScreen not available
drop_method "QSurface", /QSurface::surfaceHandle/ # QPlatformSurface not available
@ -1277,7 +1319,6 @@ drop_method "QPixmap", /QPixmap::handle/ # not available on WIN
drop_method "QPixmap", /QPixmap::fromX11Pixmap/ # not available on WIN
drop_method "QTabletEvent", /QTabletEvent::QTabletEvent/ # TODO: too many arguments
drop_method "QGraphicsProxyWidget", /QGraphicsProxyWidget::setGeometry\(double/ # not available as override (private or protected inheritance?)
drop_method :all_classes, /::x11/ # no X11 stuff
drop_method "QPixmap", /QPixmap::QPixmap\(const\s+char\s+\*\s*const\s*\w*\s*\[\s*\]/ # no const char *[] - TODO: provide differen implementation?
drop_method "QImage", /QImage::QImage\(const\s+char\s+\*\s*const\s*xpm\s*\[\s*\]/ # no const char *[] - TODO: provide differen implementation?
drop_method "QImage", /QImage::QImage\(const\s+char\s+\*\s*fileName/ # not available for QT_NO_CAST_TO_ASCII
@ -1296,7 +1337,6 @@ drop_method "QGraphicsEffect", /QGraphicsEffect::source\s*\(\s*\)/ # requires Q
drop_method "QGraphicsScene", /QGraphicsScene::drawItems/ # requires QGraphicsItem *[], TODO: provide an alternative!
drop_method "QGraphicsView", /QGraphicsView::drawItems/ # requires QGraphicsItem *[], TODO: provide an alternative!
# drop_method "QGtkStyle", /QGtkStyle::QGtkStyle\s*\(\s*QGtkStylePrivate/ # requires QGtkStylePrivate
drop_method :all_classes, /::data_ptr/ # no private data
drop_method "QTextList", /QTextList::setFormat\(const\s+QTextFormat\s+/ # got mixed in somehow(?). Not part of API
drop_method "QTextTable", /QTextTable::setFormat\(const\s+QTextFormat\s+/ # got mixed in somehow(?). Not part of API
drop_method "QTextTableCell", /QTextTableCell::begin/ # requires template type return value (TODO: provide alternative?)
@ -1389,7 +1429,6 @@ drop_method "Qimage", /Qimage::text\(const\s+QString/ # clashes with const char
rename "QDialogButtonBox", /QDialogButtonBox::QDialogButtonBox\(QFlags/, "new_buttons"
rename "QIcon", /QIcon::pixmap\(int\s+extent/, "pixmap_ext"
rename "QKeySequence", /QKeySequence::QKeySequence\(QKeySequence::StandardKey/, "new_std"
keep_arg "QCoreApplication", /::postEvent/, 1 # will take ownership of event
keep_arg "QBoxLayout", /::addLayout/, 0 # will take ownership of layout
keep_arg "QGridLayout", /::addLayout/, 0 # will take ownership of layout
keep_arg "QLayout", /::addChildLayout/, 0 # will take ownership of layout
@ -1437,32 +1476,10 @@ rename "QButtonGroup", /QButtonGroup::buttonToggled\(int/, "buttonToggled_int" #
# special implementations:
drop_method "QApplication", /QApplication::QApplication/ # does not work because of char** and isn't because of singleton
# provide a dummy application for the constructor for test purposes
add_native_impl("QApplication", <<'CODE', <<'DECL')
static QApplication *ctor_QApplication()
{
static char *(dummy_argv[]) = { (char *)"undefined_application" };
static int argc = 1;
return new QApplication (argc, dummy_argv);
}
CODE
gsi::constructor("new_app", &ctor_QApplication, "@brief Creates a new QApplication object\n\nThis implementation is provided for test purposes only. It is not required usually to create a QApplication object. Use the object provided by QApplication::instance instead.")
DECL
add_native_qapp_ctor_impl("QApplication")
drop_method "QGuiApplication", /QGuiApplication::QGuiApplication/ # does not work because of char** and isn't because of singleton
# provide a dummy application for the constructor for test purposes
add_native_impl("QGuiApplication", <<'CODE', <<'DECL')
static QGuiApplication *ctor_QGuiApplication()
{
static char *(dummy_argv[]) = { (char *)"undefined_application" };
int argc = 1;
return new QGuiApplication (argc, dummy_argv);
}
CODE
gsi::constructor("new_app", &ctor_QGuiApplication, "@brief Creates a new QGuiApplication object\n\nThis implementation is provided for test purposes only. It is not required usually to create a QGuiApplication object. Use the object provided by QGuiApplication::instance instead.")
DECL
add_native_qapp_ctor_impl("QGuiApplication")
no_imports "QItemSelection" # base class is a template. TODO: provide a solution (i.e. additional manual declarations)
no_imports "QPageSetupDialog" # base class is a QAbstractPageSetupDialog which is not readily available

View File

@ -1005,6 +1005,27 @@ GSI_QTCORE_PUBLIC gsi::Class<QCoreApplication> &qtdecl_QCoreApplication () { ret
class QCoreApplication_Adaptor : public QCoreApplication, public qt_gsi::QtObjectBase
{
public:
static QCoreApplication *ctor_QCoreApplication_Adaptor_args(const std::vector<std::string> &args)
{
// QCoreApplication needs static sources, so we give it some.
static char **argv = 0;
static std::vector<std::string> args_copy;
static int argc = 0;
if (argv != 0) {
throw tl::Exception(tl::to_string(QObject::tr("QCoreApplication cannot be instantiated twice")));
}
argv = new char *[args.size ()];
args_copy = args;
argc = int (args.size ());
for (std::vector<std::string>::const_iterator a = args_copy.begin (); a != args_copy.end (); ++a) {
argv[a - args_copy.begin ()] = (char *) a->c_str ();
}
return new QCoreApplication_Adaptor (argc, argv);
}
QCoreApplication_Adaptor (int &argc, char **argv) : QCoreApplication (argc, argv) { }
virtual ~QCoreApplication_Adaptor();
@ -1435,6 +1456,8 @@ static gsi::Methods methods_QCoreApplication_Adaptor () {
}
gsi::Class<QCoreApplication_Adaptor> decl_QCoreApplication_Adaptor (qtdecl_QCoreApplication (), "QtCore", "QCoreApplication",
gsi::constructor("new", &QCoreApplication_Adaptor::ctor_QCoreApplication_Adaptor_args, gsi::arg ("argv"), "@brief Creates a new QCoreApplication object\n\n@param argv The command line arguments to pass to Qt")
+
methods_QCoreApplication_Adaptor (),
"@qt\n@brief Binding of QCoreApplication");

View File

@ -55,12 +55,6 @@ static void _call_smo (const qt_gsi::GenericStaticMethod *, gsi::SerialArgs &, g
ret.write<const QMetaObject &> (QApplication::staticMetaObject);
}
static QApplication *ctor_QApplication()
{
static char *(dummy_argv[]) = { (char *)"undefined_application" };
static int argc = 1;
return new QApplication (argc, dummy_argv);
}
// bool QApplication::autoSipEnabled()
@ -1584,8 +1578,6 @@ static gsi::Methods methods_QApplication () {
gsi::Class<QCoreApplication> &qtdecl_QCoreApplication ();
qt_gsi::QtNativeClass<QApplication> decl_QApplication (qtdecl_QCoreApplication (), "QtGui", "QApplication_Native",
gsi::constructor("new_app", &ctor_QApplication, "@brief Creates a new QApplication object\n\nThis implementation is provided for test purposes only. It is not required usually to create a QApplication object. Use the object provided by QApplication::instance instead.")
+
methods_QApplication (),
"@hide\n@alias QApplication");
@ -1597,6 +1589,27 @@ GSI_QTGUI_PUBLIC gsi::Class<QApplication> &qtdecl_QApplication () { return decl_
class QApplication_Adaptor : public QApplication, public qt_gsi::QtObjectBase
{
public:
static QApplication *ctor_QApplication_Adaptor_args(const std::vector<std::string> &args)
{
// QApplication needs static sources, so we give it some.
static char **argv = 0;
static std::vector<std::string> args_copy;
static int argc = 0;
if (argv != 0) {
throw tl::Exception(tl::to_string(QObject::tr("QApplication cannot be instantiated twice")));
}
argv = new char *[args.size ()];
args_copy = args;
argc = int (args.size ());
for (std::vector<std::string>::const_iterator a = args_copy.begin (); a != args_copy.end (); ++a) {
argv[a - args_copy.begin ()] = (char *) a->c_str ();
}
return new QApplication_Adaptor (argc, argv);
}
QApplication_Adaptor (int &argc, char **argv) : QApplication (argc, argv) { }
virtual ~QApplication_Adaptor();
@ -2097,6 +2110,8 @@ static gsi::Methods methods_QApplication_Adaptor () {
}
gsi::Class<QApplication_Adaptor> decl_QApplication_Adaptor (qtdecl_QApplication (), "QtGui", "QApplication",
gsi::constructor("new", &QApplication_Adaptor::ctor_QApplication_Adaptor_args, gsi::arg ("argv"), "@brief Creates a new QApplication object\n\n@param argv The command line arguments to pass to Qt")
+
methods_QApplication_Adaptor (),
"@qt\n@brief Binding of QApplication");