summaryrefslogtreecommitdiffstats
path: root/kabc/scripts/makeaddressee
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kabc/scripts/makeaddressee
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kabc/scripts/makeaddressee')
-rwxr-xr-xkabc/scripts/makeaddressee215
1 files changed, 215 insertions, 0 deletions
diff --git a/kabc/scripts/makeaddressee b/kabc/scripts/makeaddressee
new file mode 100755
index 000000000..cbc69543a
--- /dev/null
+++ b/kabc/scripts/makeaddressee
@@ -0,0 +1,215 @@
+#!/usr/bin/perl
+
+my $srcdir;
+$srcdir = `dirname $0` || die "Can't determine \$srcdir.";
+chomp $srcdir;
+
+if (!open( ENTRIES, "$srcdir/entrylist" ) ) {
+ print "Can't open $srcdir/entrylist\n";
+ exit 1;
+}
+
+ while(<ENTRIES>) {
+ if (/^#/) { next; }
+ chop;
+ @entries = split /,/;
+ if (!/^.+,(\w+),(\w+)/) { next; }
+ push @entryCtrl, @entries[0];
+ push @entryRealNames, @entries[1];
+ push @entryComments, @entries[2];
+ push @entryTypes, @entries[3];
+ push @entryNames, @entries[4];
+ push @entryCategory, @entries[5];
+ push @entryDebug, @entries[6];
+ }
+
+close ENTRIES;
+
+if (!open( H_IN, "$srcdir/addressee.src.h" ) ) {
+ print "Can't open $srcdir/addressee.src.h\n";
+ exit 1;
+}
+if (!open( H_OUT, ">../addressee.h" ) ) {
+ print "Can't open addressee.h\n";
+ exit 1;
+}
+ print H_OUT "/*** Warning! This file has been generated by the script makeaddressee ***/\n";
+
+ while( <H_IN> ) {
+ if (/--DECLARATIONS--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] =~ /A/ ) {
+ print H_OUT " /**\n";
+ print H_OUT " Set $entryRealNames[$i].\n";
+ print H_OUT " */\n";
+ print H_OUT " void set" . ucfirst($entryNames[$i]);
+ print H_OUT "( const $entryTypes[$i] &$entryNames[$i] );\n";
+
+ print H_OUT " /**\n";
+ print H_OUT " Return $entryRealNames[$i].\n";
+ print H_OUT " */\n";
+ print H_OUT " $entryTypes[$i] $entryNames[$i]() const;\n";
+ }
+
+ if ( $entryCtrl[$i] !~ /L/ ) { next; }
+ print H_OUT " /**\n";
+ print H_OUT " Return translated label for $entryNames[$i] field.\n";
+ print H_OUT " */\n";
+ print H_OUT " static QString $entryNames[$i]Label();\n\n";
+ }
+ } else {
+ print H_OUT;
+ }
+ }
+
+close H_OUT;
+close H_IN;
+
+if (!open( CPP_IN, "$srcdir/addressee.src.cpp" ) ) {
+ print "Can't open $srcdir/addressee.src.cpp\n";
+ exit 1;
+}
+if (!open( CPP_OUT, ">../addressee.cpp" ) ) {
+ print "Can't open addressee.cpp\n";
+ exit 1;
+}
+ print CPP_OUT "/*** Warning! This file has been generated by the script makeaddressee ***/\n";
+
+ while( <CPP_IN> ) {
+ if (/--VARIABLES--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /A/ ) { next; }
+ print CPP_OUT " $entryTypes[$i] $entryNames[$i];\n";
+ }
+ } elsif (/--DEFINITIONS--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] =~ /A/ ) {
+ print CPP_OUT "void Addressee::set" . ucfirst($entryNames[$i]);
+ print CPP_OUT "( const $entryTypes[$i] &$entryNames[$i] )\n{\n";
+ print CPP_OUT " if ( $entryNames[$i] == mData->$entryNames[$i] ) return;\n";
+ print CPP_OUT " detach();\n mData->empty = false;\n";
+ print CPP_OUT " mData->$entryNames[$i] = $entryNames[$i];\n}\n\n";
+
+ print CPP_OUT "$entryTypes[$i] Addressee::$entryNames[$i]() const\n{\n";
+ print CPP_OUT " return mData->$entryNames[$i];\n}\n\n";
+ }
+
+ if ( $entryCtrl[$i] !~ /L/ ) { next; }
+ @labelwords = split ' ', $entryRealNames[$i];
+ for( $j=0; $j < @labelwords; ++$j ) {
+ $labelwords[$j] = ucfirst $labelwords[$j];
+ }
+ $label = join ' ', @labelwords;
+ print CPP_OUT "QString Addressee::$entryNames[$i]Label()\n{\n";
+ if ( $entryComments[$i] ) {
+ print CPP_OUT " return i18n(\"$entryComments[$i]\",\"$label\");\n";
+ } else {
+ print CPP_OUT " return i18n(\"$label\");\n";
+ }
+ print CPP_OUT "}\n\n\n";
+ }
+ } elsif (/--EQUALSTEST--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] =~ /E/ ) {
+ if ( $entryNames[$i] !~ "revision" ) {
+ if ( $entryTypes[$i] =~ "QString" ) {
+ print CPP_OUT " if ( mData->$entryNames[$i] != a.mData->$entryNames[$i] &&\n";
+ print CPP_OUT " !( mData->$entryNames[$i].isEmpty() && a.mData->$entryNames[$i].isEmpty() ) ) {\n";
+ print CPP_OUT " kdDebug(5700) << \"$entryNames[$i] differs\" << endl;\n";
+ print CPP_OUT " return false;\n";
+ print CPP_OUT " }\n";
+ } else {
+ print CPP_OUT " if ( mData->$entryNames[$i] != a.mData->$entryNames[$i] ) {\n";
+ print CPP_OUT " kdDebug(5700) << \"$entryNames[$i] differs\" << endl;\n";
+ print CPP_OUT " return false;\n";
+ print CPP_OUT " }\n";
+ }
+ }
+ }
+ }
+ } elsif (/--STREAMOUT--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] =~ /A/ ) {
+ print CPP_OUT " s << a.mData->$entryNames[$i];\n";
+ }
+ }
+ } elsif (/--STREAMIN--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] =~ /A/ ) {
+ print CPP_OUT " s >> a.mData->$entryNames[$i];\n";
+ }
+ }
+ } elsif (/--DEBUG--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /A/ ) { next; }
+ print CPP_OUT " kdDebug(5700) << \" " . ucfirst($entryNames[$i]);
+ print CPP_OUT ": '\" << $entryNames[$i]()$entryDebug[$i] << \"'\" << endl;\n";
+ }
+ } else {
+ print CPP_OUT;
+ }
+ }
+
+close CPP_OUT;
+close CPP_IN;
+
+if (!open( CPP_IN, "$srcdir/field.src.cpp" ) ) {
+ print "Can't open $srcdir/field.src.cpp\n";
+ exit 1;
+}
+if (!open( CPP_OUT, ">../field.cpp" ) ) {
+ print "Can't open field.cpp\n";
+ exit 1;
+}
+ print CPP_OUT "/*** Warning! This file has been generated by the script makeaddressee ***/\n";
+
+ while( <CPP_IN> ) {
+ if (/--ENUMS--/) {
+ $first = 1;
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /F/ ) { next; }
+ if ( $first ) { $first = 0; }
+ else { print CPP_OUT ",\n"; }
+ print CPP_OUT " " . ucfirst($entryNames[$i]);
+ }
+ print CPP_OUT "\n";
+ } elsif (/--CASELABEL--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /F/ ) { next; }
+ if ( $entryCtrl[$i] !~ /L/ ) { next; }
+ print CPP_OUT " case FieldImpl::" . ucfirst($entryNames[$i]) . ":\n";
+ print CPP_OUT " return Addressee::$entryNames[$i]Label();\n";
+ }
+ } elsif (/--CASEVALUE--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /A/ ) { next; }
+ if ( $entryCtrl[$i] !~ /F/ ) { next; }
+ if ( $entryTypes[$i] ne "QString" ) { next; }
+ print CPP_OUT " case FieldImpl::" . ucfirst($entryNames[$i]) . ":\n";
+ print CPP_OUT " return a.$entryNames[$i]();\n";
+ }
+ } elsif (/--CASESETVALUE--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /A/ ) { next; }
+ if ( $entryCtrl[$i] !~ /F/ ) { next; }
+ if ( $entryTypes[$i] ne "QString" ) { next; }
+ print CPP_OUT " case FieldImpl::" . ucfirst($entryNames[$i]) . ":\n";
+ print CPP_OUT " a.set" . ucfirst($entryNames[$i]) . "( value );\n";
+ print CPP_OUT " return true;\n";
+ }
+ } elsif (/--CREATEFIELDS--/) {
+ for( $i=0; $i<@entryNames; ++$i ) {
+ if ( $entryCtrl[$i] !~ /F/ ) { next; }
+ print CPP_OUT " createField( FieldImpl::" . ucfirst($entryNames[$i]);
+ if ( $entryCategory[$i] ) {
+ print CPP_OUT ", $entryCategory[$i]";
+ }
+ print CPP_OUT " );\n";
+ }
+ } else {
+ print CPP_OUT;
+ }
+ }
+
+close CPP_OUT;
+close CPP_IN;