2016-04-28 20:43:44 +03:00
|
|
|
package templater
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/therecipe/qt/internal/binding/parser"
|
2016-10-26 17:44:27 +03:00
|
|
|
"github.com/therecipe/qt/internal/utils"
|
2016-04-28 20:43:44 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func functionIsSupported(_ *parser.Class, f *parser.Function) bool {
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case
|
2016-12-11 23:03:06 +03:00
|
|
|
(f.ClassName() == "QAccessibleObject" || f.ClassName() == "QAccessibleInterface" || f.ClassName() == "QAccessibleWidget" || //QAccessible::State -> quint64
|
|
|
|
f.ClassName() == "QAccessibleStateChangeEvent") && (f.Name == "state" || f.Name == "changedStates" || f.Name == "m_changedStates" || f.Name == "setM_changedStates" || f.Meta == parser.CONSTRUCTOR),
|
2016-04-28 20:43:44 +03:00
|
|
|
|
2016-05-11 16:33:24 +03:00
|
|
|
f.Fullname == "QPixmapCache::find" && f.OverloadNumber == "4", //Qt::Key -> int
|
2016-04-28 20:43:44 +03:00
|
|
|
(f.Fullname == "QPixmapCache::remove" || f.Fullname == "QPixmapCache::insert") && f.OverloadNumber == "2",
|
|
|
|
f.Fullname == "QPixmapCache::replace",
|
|
|
|
|
2016-08-23 23:51:01 +03:00
|
|
|
f.Fullname == "QNdefFilter::appendRecord" && !f.Overload, //QNdefRecord::TypeNameFormat -> uint
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
f.ClassName() == "QSimpleXmlNodeModel" && f.Meta == parser.CONSTRUCTOR,
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
f.Fullname == "QSGMaterialShader::attributeNames",
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
f.ClassName() == "QVariant" && (f.Name == "value" || f.Name == "canConvert"), //needs template
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
f.Fullname == "QNdefRecord::isRecordType", f.Fullname == "QScriptEngine::scriptValueFromQMetaObject", //needs template
|
|
|
|
f.Fullname == "QScriptEngine::fromScriptValue", f.Fullname == "QJSEngine::fromScriptValue",
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
f.ClassName() == "QMetaType" && //needs template
|
2016-04-28 20:43:44 +03:00
|
|
|
(f.Name == "hasRegisteredComparators" || f.Name == "registerComparators" ||
|
|
|
|
f.Name == "hasRegisteredConverterFunction" || f.Name == "registerConverter" ||
|
|
|
|
f.Name == "registerEqualsComparator"),
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
parser.CurrentState.ClassMap[f.ClassName()].Module == parser.MOC && f.Name == "metaObject", //needed for qtmoc
|
2016-04-28 20:43:44 +03:00
|
|
|
|
2016-05-11 16:33:24 +03:00
|
|
|
f.Fullname == "QSignalBlocker::QSignalBlocker" && f.OverloadNumber == "3", //undefined symbol
|
2016-04-28 20:43:44 +03:00
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
(parser.CurrentState.ClassMap[f.ClassName()].IsSubClassOf("QCoreApplication") ||
|
|
|
|
f.ClassName() == "QAudioInput" || f.ClassName() == "QAudioOutput") && f.Name == "notify", //redeclared (name collision with QObject)
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
f.Fullname == "QGraphicsItem::isBlockedByModalPanel", //** problem
|
|
|
|
|
|
|
|
f.Name == "surfaceHandle", //QQuickWindow && QQuickView //unsupported_cppType(QPlatformSurface)
|
|
|
|
|
|
|
|
f.Name == "readData", f.Name == "QNetworkReply", //TODO: char*
|
|
|
|
|
2016-04-30 20:03:25 +03:00
|
|
|
f.Name == "QDesignerFormWindowInterface" || f.Name == "QDesignerFormWindowManagerInterface" || f.Name == "QDesignerWidgetBoxInterface", //unimplemented virtual
|
|
|
|
|
2016-11-16 01:07:05 +03:00
|
|
|
f.Fullname == "QNdefNfcSmartPosterRecord::titleRecords", //T<T> output with unsupported output for *_atList
|
|
|
|
f.Fullname == "QHelpEngineCore::filterAttributeSets", f.Fullname == "QHelpSearchEngine::query", f.Fullname == "QHelpSearchQueryWidget::query",
|
|
|
|
f.Fullname == "QPluginLoader::staticPlugins", f.Fullname == "QSslConfiguration::ellipticCurves", f.Fullname == "QSslConfiguration::supportedEllipticCurves",
|
|
|
|
f.Fullname == "QTextFormat::lengthVectorProperty", f.Fullname == "QTextTableFormat::columnWidthConstraints",
|
2016-04-28 20:43:44 +03:00
|
|
|
|
2016-11-16 01:07:05 +03:00
|
|
|
strings.Contains(f.Access, "unsupported"):
|
2016-04-28 20:43:44 +03:00
|
|
|
{
|
2016-05-21 23:50:57 +03:00
|
|
|
if !strings.Contains(f.Access, "unsupported") {
|
|
|
|
f.Access = "unsupported_isBlockedFunction"
|
|
|
|
}
|
2016-04-28 20:43:44 +03:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 01:07:05 +03:00
|
|
|
if strings.ContainsAny(f.Signature, "<>") {
|
|
|
|
if parser.IsPackedList(f.Output) {
|
|
|
|
for _, p := range f.Parameters {
|
|
|
|
if strings.ContainsAny(p.Value, "<>") {
|
|
|
|
if !strings.Contains(f.Access, "unsupported") {
|
|
|
|
f.Access = "unsupported_isBlockedFunction"
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if !strings.Contains(f.Access, "unsupported") {
|
|
|
|
f.Access = "unsupported_isBlockedFunction"
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-30 20:03:25 +03:00
|
|
|
if f.Default {
|
|
|
|
return functionIsSupportedDefault(f)
|
|
|
|
}
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
if parser.CurrentState.Minimal {
|
2016-08-27 02:22:01 +03:00
|
|
|
return f.Export || f.Meta == parser.DESTRUCTOR || f.Fullname == "QObject::destroyed" || strings.HasPrefix(f.Name, parser.TILDE)
|
2016-05-28 19:18:42 +03:00
|
|
|
}
|
|
|
|
|
2016-04-30 20:03:25 +03:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func functionIsSupportedDefault(f *parser.Function) bool {
|
|
|
|
switch f.Fullname {
|
|
|
|
case
|
|
|
|
"QAnimationGroup::updateCurrentTime", "QAnimationGroup::duration",
|
|
|
|
"QAbstractProxyModel::columnCount", "QAbstractTableModel::columnCount",
|
|
|
|
"QAbstractListModel::data", "QAbstractTableModel::data",
|
|
|
|
"QAbstractProxyModel::index", "QAbstractProxyModel::parent",
|
|
|
|
"QAbstractListModel::rowCount", "QAbstractProxyModel::rowCount", "QAbstractTableModel::rowCount",
|
|
|
|
|
|
|
|
"QPagedPaintDevice::paintEngine", "QAccessibleObject::childCount",
|
|
|
|
"QAccessibleObject::indexOfChild", "QAccessibleObject::role",
|
|
|
|
"QAccessibleObject::text", "QAccessibleObject::child",
|
|
|
|
"QAccessibleObject::parent",
|
|
|
|
|
|
|
|
"QAbstractGraphicsShapeItem::paint", "QGraphicsObject::paint",
|
|
|
|
"QLayout::sizeHint", "QAbstractGraphicsShapeItem::boundingRect",
|
|
|
|
"QGraphicsObject::boundingRect", "QGraphicsLayout::sizeHint",
|
|
|
|
|
|
|
|
"QSimpleXmlNodeModel::typedValue", "QSimpleXmlNodeModel::documentUri",
|
|
|
|
"QSimpleXmlNodeModel::compareOrder", "QSimpleXmlNodeModel::nextFromSimpleAxis",
|
|
|
|
"QSimpleXmlNodeModel::kind", "QSimpleXmlNodeModel::root",
|
|
|
|
|
|
|
|
"QAbstractPlanarVideoBuffer::unmap", "QAbstractPlanarVideoBuffer::mapMode",
|
|
|
|
|
|
|
|
"QSGDynamicTexture::bind", "QSGDynamicTexture::hasMipmaps",
|
|
|
|
"QSGDynamicTexture::textureSize", "QSGDynamicTexture::hasAlphaChannel",
|
2016-06-16 18:49:55 +03:00
|
|
|
"QSGDynamicTexture::textureId",
|
|
|
|
|
2016-11-23 20:08:37 +03:00
|
|
|
"QModbusClient::open", "QModbusClient::close", "QModbusServer::open", "QModbusServer::close",
|
|
|
|
|
|
|
|
"QSimpleXmlNodeModel::name":
|
2016-04-30 20:03:25 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-21 19:55:44 +03:00
|
|
|
//needed for moc
|
2016-12-11 23:03:06 +03:00
|
|
|
if parser.CurrentState.ClassMap[f.ClassName()].IsSubClassOf("QCoreApplication") && (f.Name == "autoMaximizeThreshold" || f.Name == "setAutoMaximizeThreshold") {
|
2016-11-21 19:55:44 +03:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
if parser.CurrentState.Minimal {
|
2016-05-28 19:18:42 +03:00
|
|
|
return f.Export
|
|
|
|
}
|
|
|
|
|
2016-04-28 20:43:44 +03:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func classIsSupported(c *parser.Class) bool {
|
2016-11-23 20:08:37 +03:00
|
|
|
if c == nil {
|
|
|
|
return false
|
|
|
|
}
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
switch c.Name {
|
|
|
|
case
|
2016-11-09 21:31:25 +03:00
|
|
|
"QString", "QStringList", //mapped to primitive
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
"QExplicitlySharedDataPointer", "QFuture", "QDBusPendingReply", "QDBusReply", "QFutureSynchronizer", //needs template
|
|
|
|
"QGlobalStatic", "QMultiHash", "QQueue", "QMultiMap", "QScopedPointer", "QSharedDataPointer",
|
|
|
|
"QScopedArrayPointer", "QSharedPointer", "QThreadStorage", "QScopedValueRollback", "QVarLengthArray",
|
|
|
|
"QWeakPointer", "QWinEventNotifier",
|
|
|
|
|
|
|
|
"QFlags", "QException", "QStandardItemEditorCreator", "QSGSimpleMaterialShader", "QGeoCodeReply", "QFutureWatcher", //other
|
2016-05-21 23:50:57 +03:00
|
|
|
"QItemEditorCreator", "QGeoCodingManager", "QGeoCodingManagerEngine", "QQmlListProperty",
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
"QPlatformGraphicsBuffer", "QPlatformSystemTrayIcon", "QRasterPaintEngine", "QSupportedWritingSystems", "QGeoLocation", //file not found or QPA API
|
2016-05-15 23:07:05 +03:00
|
|
|
"QAbstractOpenGLFunctions",
|
|
|
|
|
|
|
|
"QProcess", "QProcessEnvironment": //TODO: iOS
|
2016-04-28 20:43:44 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
c.Access = "unsupported_isBlockedClass"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case
|
|
|
|
strings.HasPrefix(c.Name, "QOpenGL"), strings.HasPrefix(c.Name, "QPlace"), //file not found or QPA API
|
|
|
|
|
|
|
|
strings.HasPrefix(c.Name, "QAtomic"), //other
|
|
|
|
|
|
|
|
strings.HasSuffix(c.Name, "terator"), strings.Contains(c.Brief, "emplate"): //needs template
|
|
|
|
|
|
|
|
{
|
|
|
|
c.Access = "unsupported_isBlockedClass"
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
if parser.CurrentState.Minimal {
|
2016-05-28 19:18:42 +03:00
|
|
|
return c.Export
|
|
|
|
}
|
|
|
|
|
2016-04-28 20:43:44 +03:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func hasUnimplementedPureVirtualFunctions(className string) bool {
|
2016-12-11 23:03:06 +03:00
|
|
|
for _, f := range parser.CurrentState.ClassMap[className].Functions {
|
2016-04-28 20:43:44 +03:00
|
|
|
var f = *f
|
|
|
|
cppFunction(&f)
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
if f.Virtual == parser.PURE && !functionIsSupported(parser.CurrentState.ClassMap[className], &f) {
|
2016-04-28 20:43:44 +03:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func ShouldBuild(module string) bool {
|
|
|
|
return true //Build[module]
|
|
|
|
}
|
|
|
|
|
|
|
|
var Build = map[string]bool{
|
2016-10-04 19:12:55 +03:00
|
|
|
"Core": false,
|
|
|
|
"AndroidExtras": false,
|
|
|
|
"Gui": false,
|
|
|
|
"Network": false,
|
|
|
|
"Xml": false,
|
|
|
|
"DBus": false,
|
|
|
|
"Nfc": false,
|
|
|
|
"Script": false,
|
|
|
|
"Sensors": false,
|
|
|
|
"Positioning": false,
|
|
|
|
"Widgets": false,
|
|
|
|
"Sql": false,
|
|
|
|
"MacExtras": false,
|
|
|
|
"Qml": false,
|
|
|
|
"WebSockets": false,
|
|
|
|
"XmlPatterns": false,
|
|
|
|
"Bluetooth": false,
|
|
|
|
"WebChannel": false,
|
|
|
|
"Svg": false,
|
|
|
|
"Multimedia": false,
|
|
|
|
"Quick": false,
|
|
|
|
"Help": false,
|
|
|
|
"Location": false,
|
|
|
|
"ScriptTools": false,
|
|
|
|
"UiTools": false,
|
|
|
|
"X11Extras": false,
|
|
|
|
"WinExtras": false,
|
|
|
|
"WebEngine": false,
|
|
|
|
"TestLib": false,
|
|
|
|
"SerialPort": false,
|
|
|
|
"SerialBus": false,
|
|
|
|
"PrintSupport": false,
|
|
|
|
//"PlatformHeaders": false,
|
|
|
|
"Designer": false,
|
|
|
|
"Scxml": false,
|
|
|
|
"Gamepad": false,
|
|
|
|
|
|
|
|
"Purchasing": false,
|
|
|
|
//"DataVisualization": false,
|
|
|
|
//"Charts": false,
|
|
|
|
//"Quick2DRenderer": false,
|
|
|
|
|
|
|
|
"Sailfish": false,
|
2016-04-28 20:43:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func isGeneric(f *parser.Function) bool {
|
|
|
|
|
2016-12-11 23:03:06 +03:00
|
|
|
if f.ClassName() == "QAndroidJniObject" {
|
2016-04-28 20:43:44 +03:00
|
|
|
switch f.Name {
|
|
|
|
case
|
|
|
|
"callMethod",
|
|
|
|
"callStaticMethod",
|
|
|
|
|
|
|
|
"getField",
|
|
|
|
//"setField", -> uses interface{} if not generic
|
|
|
|
|
|
|
|
"getStaticField",
|
|
|
|
//"setStaticField", -> uses interface{} if not generic
|
|
|
|
|
|
|
|
"getObjectField",
|
|
|
|
|
|
|
|
"getStaticObjectField",
|
|
|
|
|
|
|
|
"callObjectMethod",
|
|
|
|
"callStaticObjectMethod":
|
|
|
|
{
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
case "setStaticField":
|
|
|
|
{
|
|
|
|
if f.OverloadNumber == "2" || f.OverloadNumber == "4" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-08-27 02:22:01 +03:00
|
|
|
func classNeedsCallbackFunctions(class *parser.Class) bool {
|
2016-08-28 19:09:35 +03:00
|
|
|
|
2016-04-28 20:43:44 +03:00
|
|
|
for _, function := range class.Functions {
|
2016-08-27 02:22:01 +03:00
|
|
|
if function.Virtual == parser.IMPURE || function.Virtual == parser.PURE || function.Meta == parser.SIGNAL || function.Meta == parser.SLOT {
|
2016-04-28 20:43:44 +03:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func shortModule(module string) string {
|
|
|
|
return strings.ToLower(strings.TrimPrefix(module, "Qt"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func getSortedClassNamesForModule(module string) []string {
|
|
|
|
var output = make([]string, 0)
|
2016-12-11 23:03:06 +03:00
|
|
|
for _, class := range parser.CurrentState.ClassMap {
|
2016-04-28 20:43:44 +03:00
|
|
|
if class.Module == module {
|
|
|
|
output = append(output, class.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sort.Stable(sort.StringSlice(output))
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
|
|
|
func getSortedClassesForModule(module string) []*parser.Class {
|
|
|
|
var (
|
|
|
|
classNames = getSortedClassNamesForModule(module)
|
|
|
|
output = make([]*parser.Class, len(classNames))
|
|
|
|
)
|
|
|
|
for i, name := range classNames {
|
2016-12-11 23:03:06 +03:00
|
|
|
output[i] = parser.CurrentState.ClassMap[name]
|
2016-04-28 20:43:44 +03:00
|
|
|
}
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
2016-08-20 00:20:42 +03:00
|
|
|
func classNeedsDestructor(c *parser.Class) bool {
|
|
|
|
for _, f := range c.Functions {
|
|
|
|
if f.Meta == parser.DESTRUCTOR {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
2016-10-26 17:44:27 +03:00
|
|
|
|
|
|
|
func UseStub() bool {
|
2016-12-11 23:03:06 +03:00
|
|
|
return utils.QT_STUB() && !parser.CurrentState.Minimal && !parser.CurrentState.Moc && !(parser.CurrentState.CurrentModule == "AndroidExtras" || parser.CurrentState.CurrentModule == "Sailfish")
|
2016-10-26 17:44:27 +03:00
|
|
|
}
|