diff options
author | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-04-12 13:50:25 +0300 |
---|---|---|
committer | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-04-12 13:52:31 +0300 |
commit | da73676c8a5af66b55523a9cdfbfbea2baa88a2a (patch) | |
tree | 0a3b8933a1817c152116da5fa8a7b5cdd8102e60 /mmoc | |
parent | 8832674482d3b9a7fcf77b0cfdcb8e6fe4960b4d (diff) |
Changes: Renamed dui to meegotouch
By: Holger, Daniel, Janne
RevBy: Tomas, Holger
Diffstat (limited to 'mmoc')
-rw-r--r-- | mmoc/.gitignore | 1 | ||||
-rwxr-xr-x | mmoc/mmoc | 193 | ||||
-rw-r--r-- | mmoc/mmoc.pro | 20 |
3 files changed, 214 insertions, 0 deletions
diff --git a/mmoc/.gitignore b/mmoc/.gitignore new file mode 100644 index 00000000..9ebe64e4 --- /dev/null +++ b/mmoc/.gitignore @@ -0,0 +1 @@ +.dummy diff --git a/mmoc/mmoc b/mmoc/mmoc new file mode 100755 index 00000000..2f0c0a8d --- /dev/null +++ b/mmoc/mmoc @@ -0,0 +1,193 @@ +#! /usr/bin/perl + +use English; + +if ($ENV{"QTDIR"}) +{ + $::QT_MOC_PATH = "$ENV{\"QTDIR\"}/bin/moc"; +} +else +{ + $::QT_MOC_PATH = "moc"; + # here we need to do things differently for windows + if ( "MSWin32" != "$OSNAME" ) + { + $::QT_MOC_PATH = `which moc`; + } +} + +chomp( $::QT_MOC_PATH ); + +exit main( @ARGV ); + +sub main +{ + my @argv = @_; + + my @commandLineParameters = ( $::QT_MOC_PATH ); + + my $filename = ""; + my $type = ""; + + for ( my $i=0; $i<@argv; ++$i ) { + if ( $argv[$i] =~ /style.h$/ ) { + $type = "Style"; + $filename = $argv[$i]; + } elsif ( $argv[$i] =~ /model.h$/ ) { + $type = "Model"; + $filename = $argv[$i]; + } else { + push @commandLineParameters, $argv[$i]; + } + } + + if ( $filename eq "" ) { + system( @commandLineParameters ); + } else { + push @commandLineParameters, "-f".$filename; + + if ( $type eq "Model" ) { + runModelMoc( $filename, @commandLineParameters ); + } elsif ( $type eq "Style" ) { + runStyleMoc( $filename, @commandLineParameters ); + } + } + + return 0; +} + +# common regular expressions +$::spaces = "\s*"; +$::comma = ","; +$::colon = ":"; +$::parenO = "\("; +$::parenC = "\)"; +$::emptyParen = "\(\)"; +$::angleO = "<"; +$::angleC = ">"; +$::braceO = "\{"; +$::nameSpace = "(?:\w+::)"; +$::typeName = "\w+"; +$::pointer = "\*"; +$::templateName = "\w+"; +$::plainParam = "(\w+)"; +$::boolParam = "(true|false)"; +$::anyParam = "(.+)"; + +sub runStyleMoc +{ + my ($header, @arguments) = @_; + + my $commandLine = join( " ", @arguments ); + + open( INF, "<$header" ) || die( "Could not open $header for reading : $!" ); + + open( MOC, "|$commandLine" ) || die( "Could not run command $commandLine : $!" ); + + while ( <INF> ) { + chomp; + my $line = $_; + + $line =~ s/\s*M_STYLE_ATTRIBUTE\s*\(\s*(\w+\:*\w*)\s*,\s*(\w+)\s*,\s*(\w+)\s*\)\s*/ Q_PROPERTY($1 $2 READ $2 WRITE set$3)/; + $line =~ s/\s*M_STYLE_PTR_ATTRIBUTE\s*\(\s*(\w+\:*\w*\s*\*+)\s*,\s*(\w+)\s*,\s*(\w+)\s*\)\s*/ Q_PROPERTY(const $1 $2 READ $2 WRITE set$3)/; + + print MOC "$line\n"; + } + + close( MOC ); + + close( INF ); +} + +sub runModelMoc +{ + my ($header, @arguments) = @_; + + my $commandLine = join( " ", @arguments ); + + my @pattern = ( + $::spaces. + "M_MODEL_PROPERTY". + $::spaces.$::parenO.$::spaces. + "(". + "(?:". + $::nameSpace."{,1}". + $::typeName. + $::spaces. + $::pointer."{,1}". + ")". + "|". + "(?:". + $::templateName. + $::angleO. + $::spaces. + $::typeName. + $::spaces. + $::pointer."{,1}". + $::spaces. + $::angleC. + ")". + ")". + $::spaces.$::comma.$::spaces. + $::plainParam. + $::spaces.$::comma.$::spaces. + $::plainParam. + $::spaces.$::comma.$::spaces. + $::plainParam. + $::spaces.$::comma.$::spaces. + $::anyParam. + $::spaces.$::parenC.$::spaces, + + $::spaces. + "M_MODEL_PTR_PROPERTY". + $::spaces.$::parenO.$::spaces. + "(". + "(?:". + $::nameSpace."{,1}". + $::typeName. + $::spaces. + $::pointer."{,1}". + $::spaces. + ")". + "|". + "(?:". + $::templateName. + $::angleO. + $::spaces. + $::typeName. + $::spaces. + $::pointer."{,1}". + $::spaces. + $::angleC. + ")". + ")". + $::spaces.$::comma.$::spaces. + $::plainParam. + $::spaces.$::comma.$::spaces. + $::plainParam. + $::spaces.$::comma.$::spaces. + $::boolParam. + $::spaces.$::comma.$::spaces. + $::anyParam. + $::spaces.$::parenC.$::spaces, + + ); + + open( INF, "<$header" ) || die( "Could not open header file for reading : $!" ); + + open( MOC, "|$commandLine" ) || die( "Could not run command $commandLine : $!" ); + + while ( <INF> ) { + chomp; + my $line = $_; + + $line =~ s/$pattern[0]/ Q_PROPERTY($1 $2 READ $2 WRITE set$3)/; + $line =~ s/$pattern[1]/ Q_PROPERTY($1 $2 READ $2 WRITE set$3)/; + + print MOC "$line\n"; + } + + close( MOC ); + + close( INF ); +} diff --git a/mmoc/mmoc.pro b/mmoc/mmoc.pro new file mode 100644 index 00000000..4541841d --- /dev/null +++ b/mmoc/mmoc.pro @@ -0,0 +1,20 @@ +include(../mkspecs/common.pri) + +TEMPLATE = subdirs +SUBDIRS = + +QMAKE_EXTRA_TARGETS += check +check.depends = +check.commands = $$system(true) + +QMAKE_EXTRA_TARGETS += check-xml +check-xml.depends = +check-xml.commands = $$system(true) + +mmoc.target = .dummy +mmoc.commands = touch $$mmoc.target +mmoc.path = $$M_INSTALL_BIN +mmoc.files = mmoc + +INSTALLS += \ + mmoc\ |