summaryrefslogtreecommitdiffstats
path: root/scripts/xmi2qt.pl
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-08-22 22:09:42 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-08-23 03:14:27 +0200
commitcac2d532793a8ea2c871fdfca0c122fa4e605d1f (patch)
treebd76c6555f7f8de8630acf78e39aa45eca3f487c /scripts/xmi2qt.pl
parent2d02ef07339a9e004af82c7775acc40d506a954e (diff)
Add improved generation of model classes
- No more xmi2qt.xq, classes are generated directly from normative xmi - Still takes long time to generate because of multiple passes in input xmi model Change-Id: I561f452ac89007400c93dfc48b5dcfe23593de3c Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'scripts/xmi2qt.pl')
-rwxr-xr-xscripts/xmi2qt.pl32
1 files changed, 30 insertions, 2 deletions
diff --git a/scripts/xmi2qt.pl b/scripts/xmi2qt.pl
index eea5f150..4a648b32 100755
--- a/scripts/xmi2qt.pl
+++ b/scripts/xmi2qt.pl
@@ -49,7 +49,7 @@ use XML::XPath;
use Template;
my %options=();
-getopt("oi",\%options);
+getopt("oip",\%options);
my $tt = Template->new(INTERPOLATE => 1, INCLUDE_PATH => 'templates/');
@@ -66,6 +66,20 @@ if ($tt->process('global.h', {
}) ne 1) { print $tt->error(); }
close STDOUT;
+open STDOUT, '>', $options{o}."/".$namespace."/qt".lc($namespace)."namespace.h";
+if ($tt->process('modulenamespace.h', {
+ xmi => $options{i},
+ namespace => $namespace,
+}) ne 1) { print $tt->error(); }
+close STDOUT;
+
+open STDOUT, '>', $options{o}."/".$namespace."/qt".lc($namespace)."namespace.cpp";
+if ($tt->process('modulenamespace.cpp', {
+ xmi => $options{i},
+ namespace => $namespace,
+}) ne 1) { print $tt->error(); }
+close STDOUT;
+
open STDOUT, '>', $options{o}."/".$namespace."/".lc($namespace).".pri";
if ($tt->process('module.pri', {
xmi => $options{i},
@@ -80,8 +94,22 @@ if ($tt->process('module.pro', {
close STDOUT;
my $classset = $xmi->find('//packagedElement[@xmi:type=\'uml:Class\']');
+my $count = 0;
+my @pids;
foreach my $class ($classset->get_nodelist) {
my $className = $class->findvalue('@name');
- system("./generate-class.pl -i " . $options{i} . " -o " . $options{o} . " -c " . $className);
+ die "could not fork" unless defined(my $pid = fork);
+ unless ($pid) { #child execs
+ exec "./generate-class.pl", "-i", $options{i}, "-o", $options{o}, "-c", $className;
+ die "exec of generate-class.pl failed";
+ }
+ push @pids, $pid;
+ $count = $count + 1;
+ if ($count % $options{p} == 0) {
+ for my $pid (@pids) {
+ waitpid $pid, 0;
+ }
+ @pids=();
+ }
}