[Kde-bindings] KDE/kdebindings/kalyptus
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Jan 22 16:18:39 UTC 2007
SVN commit 626256 by rdale:
* Convert to generic types for marshalling QLists, QVectors and QMaps,
and use C# List<>s and Dictionary<>s.
CCMAIL: kde-bindings at kde.org
M +97 -83 kalyptusCxxToKimono.pm
--- trunk/KDE/kdebindings/kalyptus/kalyptusCxxToKimono.pm #626255:626256
@@ -35,7 +35,7 @@
use vars qw/
$libname $rootnode $outputdir $opt $debug
$methodNumber
- %builtins %typeunion %allMethods %allTypes %enumValueToType %typedeflist %arraytypeslist %mungedTypeMap %csharpImports
+ %builtins %typeunion %allMethods %allTypes %enumValueToType %typedeflist %maptypeslist %arraytypeslist %mungedTypeMap %csharpImports
%skippedClasses %partial_classes %operatorNames /;
BEGIN
@@ -303,78 +303,88 @@
'operator++' => 'op_incr',
);
+%maptypeslist =
+(
+ 'QMap<int, QVariant>' => 'Dictionary<int, QVariant>',
+ 'QMap<int, QVariant>&' => 'Dictionary<int, QVariant>',
+ 'QMap<QDate, QTextCharFormat>' => 'Dictionary<QDate, QTextCharFormat>',
+ 'QMap<QDate, QTextCharFormat>&' => 'Dictionary<QDate, QTextCharFormat>',
+ 'QMap<QString, QVariant>' => 'Dictionary<string, QVariant>',
+ 'QMap<QString, QVariant>&' => 'Dictionary<string, QVariant>',
+);
+
%arraytypeslist =
(
- 'QStringList' => 1,
- 'QStringList&' => 1,
- 'QStringList*' => 1,
- 'QList<QByteArray>' => 1,
- 'QList<QByteArray>&' => 1,
- 'QList<QByteArray>*' => 1,
- 'QList<qreal>' => 1,
- 'QList<int>' => 1,
- 'QList<int>&' => 1,
- 'QList<QTableWidgetSelectionRange>' => 1,
- 'QList<QTextLayout::FormatRange>' => 1,
- 'QList<QTextLayout::FormatRange>&' => 1,
- 'QList<QTextBlock>' => 1,
- 'QList<QPolygonF>' => 1,
- 'QList<QHostAddress>' => 1,
- 'QList<QHostAddress>&' => 1,
- 'QVariantList&' => 1,
- 'QList<QVariant>' => 1,
- 'QList<QVariant>&' => 1,
- 'QList<QPixmap>' => 1,
- 'QList<QModelIndex>' => 1,
- 'QList<QModelIndex>&' => 1,
- 'QModelIndexList&' => 1,
- 'QModelIndexList' => 1,
- 'QList<QImageTextKeyLang>' => 1,
- 'QList<QUrl>' => 1,
- 'QList<QUrl>&' => 1,
- 'QVector<QPointF>' => 1,
- 'QVector<QPointF>&' => 1,
- 'QVector<QPoint>' => 1,
- 'QVector<QPoint>&' => 1,
- 'QVector<QLine>' => 1,
- 'QVector<QLine>&' => 1,
- 'QVector<QLineF>' => 1,
- 'QVector<QLineF>&' => 1,
- 'QVector<QRect>' => 1,
- 'QVector<QRect>&' => 1,
- 'QVector<QRectF>' => 1,
- 'QVector<QRectF>&' => 1,
- 'QVector<QColor>' => 1,
- 'QVector<QColor>&' => 1,
- 'QVector<QRgb>' => 1,
- 'QVector<QRgb>&' => 1,
- 'QVector<QVariant>' => 1,
- 'QVector<QVariant>&' => 1,
- 'QVector<QTextFormat>' => 1,
- 'QVector<QTextFormat>&' => 1,
- 'QVector<QTextLength>&' => 1,
- 'QList<QTextFrame*>' => 1,
- 'QList<QAction*>' => 1,
- 'QList<QTreeWidgetItem*>' => 1,
- 'QList<QTreeWidgetItem*>&' => 1,
- 'QList<QAbstractButton*>' => 1,
- 'QList<QListWidgetItem*>' => 1,
- 'QList<QListWidgetItem*>&' => 1,
- 'QList<QTableWidgetItem*>' => 1,
- 'QList<QTableWidgetItem*>&' => 1,
- 'QList<QStandardItem*>&' => 1,
- 'QList<QStandardItem*>' => 1,
- 'QList<QGraphicsItem*>' => 1,
- 'QList<QGraphicsItem*>&' => 1,
- 'QList<QUndoStack*>' => 1,
- 'QList<QUndoStack*>&' => 1,
- 'QList<QRectF>&' => 1,
- 'QList<QRectF>' => 1,
- 'QWidgetList' => 1,
- 'QWidgetList&' => 1,
- 'QObjectList' => 1,
- 'QObjectList&' => 1,
- 'QFileInfoList' => 1,
+ 'QStringList' => 'List<string>',
+ 'QStringList&' => 'List<string>',
+ 'QStringList*' => 'List<string>',
+ 'QList<QByteArray>' => 'List<QByteArray>',
+ 'QList<QByteArray>&' => 'List<QByteArray>',
+ 'QList<QByteArray>*' => 'List<QByteArray>',
+ 'QList<qreal>' => 'List<double>',
+ 'QList<int>' => 'List<int>',
+ 'QList<int>&' => 'List<int>',
+ 'QList<QTableWidgetSelectionRange>' => 'List<QTableWidgetSelectionRange>',
+# 'QList<QTextLayout::FormatRange>' => 'List<QTextLayout.FormatRange>',
+# 'QList<QTextLayout::FormatRange>&' => 'List<QTextLayout.FormatRange>',
+ 'QList<QTextBlock>' => 'List<QTextBlock>',
+ 'QList<QPolygonF>' => 'List<QPolygonF>',
+ 'QList<QHostAddress>' => 'List<QHostAddress>',
+ 'QList<QHostAddress>&' => 'List<QHostAddress>',
+ 'QVariantList&' => 'List<QVariant>',
+ 'QList<QVariant>' => 'List<QVariant>',
+ 'QList<QVariant>&' => 'List<QVariant>',
+ 'QList<QPixmap>' => 'List<QPixmap>',
+ 'QList<QModelIndex>' => 'List<QModelIndex>',
+ 'QList<QModelIndex>&' => 'List<QModelIndex>',
+ 'QModelIndexList&' => 'List<QModelIndex>',
+ 'QModelIndexList' => 'List<QModelIndex>',
+# 'QList<QImageTextKeyLang>' => 'List<QImageTextKeyLang>',
+ 'QList<QUrl>' => 'List<QUrl>',
+ 'QList<QUrl>&' => 'List<QUrl>',
+ 'QVector<QPointF>' => 'List<QPointF>',
+ 'QVector<QPointF>&' => 'List<QPointF>',
+ 'QVector<QPoint>' => 'List<QPoint>',
+ 'QVector<QPoint>&' => 'List<QPoint>',
+ 'QVector<QLine>' => 'List<QLine>',
+ 'QVector<QLine>&' => 'List<QLine>',
+ 'QVector<QLineF>' => 'List<QLineF>',
+ 'QVector<QLineF>&' => 'List<QLineF>',
+ 'QVector<QRect>' => 'List<QRect>',
+ 'QVector<QRect>&' => 'List<QRect>',
+ 'QVector<QRectF>' => 'List<QRectF>',
+ 'QVector<QRectF>&' => 'List<QRectF>',
+ 'QVector<QColor>' => 'List<QColor>',
+ 'QVector<QColor>&' => 'List<QColor>',
+# 'QVector<QRgb>' => 'List<QRgb>',
+# 'QVector<QRgb>&' => 'List<QRgb>',
+ 'QVector<QVariant>' => 'List<QVariant>',
+ 'QVector<QVariant>&' => 'List<QVariant>',
+ 'QVector<QTextFormat>' => 'List<QTextFormat>',
+ 'QVector<QTextFormat>&' => 'List<QTextFormat>',
+ 'QVector<QTextLength>&' => 'List<QTextFormat>',
+ 'QList<QTextFrame*>' => 'List<QTextFrame>',
+ 'QList<QAction*>' => 'List<QAction>',
+ 'QList<QTreeWidgetItem*>' => 'List<QTreeWidgetItem>',
+ 'QList<QTreeWidgetItem*>&' => 'List<QTreeWidgetItem>',
+ 'QList<QAbstractButton*>' => 'List<QAbstractButton>',
+ 'QList<QListWidgetItem*>' => 'List<QListWidgetItem>',
+ 'QList<QListWidgetItem*>&' => 'List<QListWidgetItem>',
+ 'QList<QTableWidgetItem*>' => 'List<QTableWidgetItem>',
+ 'QList<QTableWidgetItem*>&' => 'List<QTableWidgetItem>',
+ 'QList<QStandardItem*>&' => 'List<QStandardItem>',
+ 'QList<QStandardItem*>' => 'List<QStandardItem>',
+ 'QList<QGraphicsItem*>' => 'List<QGraphicsItem>',
+ 'QList<QGraphicsItem*>&' => 'List<QGraphicsItem>',
+ 'QList<QUndoStack*>' => 'List<QUndoStack>',
+ 'QList<QUndoStack*>&' => 'List<QUndoStack>',
+ 'QList<QRectF>&' => 'List<QRectF>',
+ 'QList<QRectF>' => 'List<QRectF>',
+ 'QWidgetList' => 'List<QWidget>',
+ 'QWidgetList&' => 'List<QWidget>',
+ 'QObjectList' => 'List<QObject>',
+ 'QObjectList&' => 'List<QObject>',
+ 'QFileInfoList' => 'List<QFileInfo>',
);
}
@@ -395,8 +405,8 @@
return "";
} elsif ( cplusplusToCSharp($classname_ptr) eq "string[][]" ) {
return "";
- } elsif ( cplusplusToCSharp($classname_ptr) eq "string[]" ) {
- return "";
+# } elsif ( cplusplusToCSharp($classname_ptr) eq "string[]" ) {
+# return "";
} elsif ( cplusplusToCSharp($classname_ptr) =~ /^[a-z]/ ) {
return "";
}
@@ -412,7 +422,7 @@
my $className = $cplusplusType;
$className =~ s/[*&]//;
- if ( $cplusplusType =~ /void\*|KHTMLPart::PageSecurity|QFileInfoList|QValueList<QIconDragItem>|QValueList<QCString>|QValueList<QVariant>|QValueList<QPixmap>|QValueListConstIterator<QString>|QMap|EditMode|QPtrList<QPixmap>|QPtrList<QPoint>|QTextFormat|QTextCursor|QTextDocument|QNetworkProtocolFactoryBase|QDomNodePrivate|QSqlDriverCreatorBase|QSqlFieldInfoList|QObjectUserData|QUObject|QTextParag|QWidgetMapper|QMemArray<int>|QBitArray|QLayoutIterator|QAuBucket|QUnknownInterface|QConnectionList/ ) {
+ if ( $cplusplusType =~ /void\*|KHTMLPart::PageSecurity|QFileInfoList|QValueList<QIconDragItem>|QValueList<QCString>|QValueList<QVariant>|QValueList<QPixmap>|QValueListConstIterator<QString>|EditMode|QPtrList<QPixmap>|QPtrList<QPoint>|QTextFormat|QTextCursor|QTextDocument|QNetworkProtocolFactoryBase|QDomNodePrivate|QSqlDriverCreatorBase|QSqlFieldInfoList|QObjectUserData|QUObject|QTextParag|QWidgetMapper|QMemArray<int>|QBitArray|QLayoutIterator|QAuBucket|QUnknownInterface|QConnectionList/ ) {
return ""; # Unsupported type
} elsif ( $cplusplusType =~ /bool/ && kalyptusDataDict::ctypemap($cplusplusType) eq "int" ) {
return "bool";
@@ -433,10 +443,12 @@
return "out short";
} elsif ( $cplusplusType =~ /KCmdLineOptions/ ) {
return "string[][]";
- } elsif ( $cplusplusType =~ /char\s*\*\*/ || $cplusplusType =~ /^[^<]*QStringList/|| $cplusplusType =~ /QStrList/) {
- return "string[]";
+# } elsif ( $cplusplusType =~ /char\s*\*\*/ || $cplusplusType =~ /^[^<]*QStringList/|| $cplusplusType =~ /QStrList/) {
+# return "string[]";
+ } elsif ( $maptypeslist{$cplusplusType} ) {
+ return $maptypeslist{$cplusplusType};
} elsif ( $arraytypeslist{$cplusplusType} ) {
- return "ArrayList"
+ return $arraytypeslist{$cplusplusType};
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QUrlInfoValueList\s*\*/
|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QVariantValueList\s*\*/
|| kalyptusDataDict::ctypemap($cplusplusType) =~ /qt_QIconDragItemValueList\s*\*/
@@ -1247,6 +1259,7 @@
if ( $csharpClassName eq 'QObject' ) {
$classdec .= "\tpublic class QObject : Qt, IDisposable {\n";
$classdec .= " \n\t\tprivate IntPtr _smokeObject;\n";
+ $classdec .= "\t\tprotected Object Q_EMIT = null;\n";
$classdec .= "\t\tprotected $csharpClassName(Type dummy) {\n";
$classdec .= "\t\t\ttry {\n";
$classdec .= "\t\t\t\tType proxyInterface = Qyoto.GetSignalsInterface(GetType());\n";
@@ -1346,9 +1359,8 @@
print CLASS "\t\t\t_interceptor = ($csharpClassName) realProxy.GetTransparentProxy();\n\t\t}\n";
print CLASS $methodCode;
-
+
if ( is_kindof($node, "QObject") ) {
- print CLASS "\t\tprotected Object Q_EMIT = null;\n";
print CLASS "\t\tprotected new I" . $csharpClassName . "Signals Emit() {\n";
print CLASS "\t\t\treturn (I" . $csharpClassName . "Signals) Q_EMIT;\n";
print CLASS "\t\t}\n";
@@ -1591,6 +1603,8 @@
$addImport->{"System.Collections"} = 1;
} elsif ( cplusplusToCSharp($it) =~ /^List</ ) {
$addImport->{"System.Collections.Generic"} = 1;
+ } elsif ( cplusplusToCSharp($it) =~ /^Dictionary</ ) {
+ $addImport->{"System.Collections.Generic"} = 1;
} else {
print " No import found for $type\n" if ($debugCI);
}
@@ -3549,11 +3563,11 @@
$line =~ s/argc, ?argv/args/g;
$line =~ s/int argc, ?char ?\* ?argv(\[\])?/string[] args/g;
$line =~ s/int argc, ?char ?\*\* ?argv/string[] args/g;
- if ($node->{NodeType} eq "Param") {
- $line =~ s/(const )?QC?StringList(\s*&)?/string[]/g;
- } else {
+# if ($node->{NodeType} eq "Param") {
+# $line =~ s/(const )?QC?StringList(\s*&)?/string[]/g;
+# } else {
$line =~ s/(const )?QC?StringList(\s*&)?/List<string>/g;
- }
+# }
$line =~ s/NodeList/ArrayList/g;
$line =~ s/KTrader::OfferList/ArrayList/g;
$line =~ s/QString::null/null/g;
More information about the Kde-bindings
mailing list