summaryrefslogtreecommitdiffstats
path: root/ksvg/scripts/add_static.pl
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
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /ksvg/scripts/add_static.pl
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.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/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksvg/scripts/add_static.pl')
-rw-r--r--ksvg/scripts/add_static.pl42
1 files changed, 42 insertions, 0 deletions
diff --git a/ksvg/scripts/add_static.pl b/ksvg/scripts/add_static.pl
new file mode 100644
index 00000000..9a88c00f
--- /dev/null
+++ b/ksvg/scripts/add_static.pl
@@ -0,0 +1,42 @@
+# Add #include "ksvg_lookup.h", GENERATEDDATA and ELEMENTDATA to all headers passed as argument
+# Usage: perl -w -i.bak add_static.pl *.h
+my $added_ksvg_lookup = 0;
+#my $added_staticdata = 0;
+my $inclass=0;
+my $bracelevel=0;
+my $class_bracelevel;
+my $has_staticdata=0;
+while (<>) {
+ $added_ksvg_lookup=0 if (/\#ifndef/); # this while loop runs over multiple files...
+ $added_ksvg_lookup=1 if (/\#include \"ksvg_lookup.h\"/); # already there
+ if (!$added_ksvg_lookup) {
+ if (/^\s*\#\s*include/ || /^namespace/ || /^class/) {
+ $added_ksvg_lookup = 1;
+ print '#include "ksvg_lookup.h"' . "\n";
+ }
+ }
+ if ( /^class/ && !/;/ ) {
+ die if $inclass;
+ $inclass=1;
+ $class_bracelevel=$bracelevel;
+ $has_staticdata=0;
+ }
+ if ( /{/ ) {
+ $bracelevel++;
+ die if /{.*{/; # not handled currently
+ }
+ if ( /}/ ) {
+ $bracelevel--;
+ die if /}.*}/; # not handled currently
+ }
+ $has_staticdata = 1 if ( $inclass && /GENERATEDDATA/ );
+ if ( $inclass && ($class_bracelevel == $bracelevel) && /};/ ) {
+ print "public:\n\tGENERATEDDATA\n" if ( !$has_staticdata );
+ $inclass=0;
+ # $added_staticdata=1;
+ }
+ print;
+}
+die "still in class!" if ($inclass);
+die "bracelevel != 0!" if ($bracelevel);
+#die "found no class where to add GENERATEDDATA!" if (!$added_staticdata);