~ubuntu-branches/ubuntu/oneiric/mpqc/oneiric

« back to all changes in this revision

Viewing changes to bin/tmpl2mac.pl

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2005-11-27 11:41:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051127114149-zgz9r3gk50w8ww2q
Tags: 2.3.0-1
* New upstream release.
* debian/rules (SONAME): Activate awk snippet for automatic so-name
  detection again, resulting in a bump to `7' and making a `c2a' for
  the C++ allocator change unnecessary; closes: #339232.
* debian/patches/00list (08_gcc-4.0_fixes): Removed, no longer needed.
* debian/rules (test): Remove workarounds, do not abort build if tests
  fail.
* debian/ref: Removed.
* debian/control.in (libsc): Added Conflict against libsc6c2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# This perl script takes a template class definition and converts it to
3
 
# a cpp macro.
4
 
#
5
 
 
6
 
$type = 'notype';
7
 
$class = 'noclass';
8
 
$macroize = 0;
9
 
while (<>) {
10
 
    # skip whole line comment and blank lines
11
 
    next if (/^\s*(\/\/.*)?$/);
12
 
    # strip comments
13
 
    s/\/\/.*//;
14
 
    if (/^template *< *class +([_A-Za-z][_A-Za-z0-9]*) *>/) { #the template dec
15
 
        $type = $1;
16
 
    } elsif (/^class +([_A-Za-z][_A-Za-z0-9]*)/) { # the class dec
17
 
        $class = $1;
18
 
        print "\#define $1_declare($type) \\\n";
19
 
        s/^(class +)$class/$1$class \#\# $type/;
20
 
        s/\n//;
21
 
        # change the names of inherited template classes to macro version
22
 
        s/< *$type *>/ \#\# $type/g;
23
 
        print "$_ \\\n";
24
 
        $macroize = 1;
25
 
    } elsif (/^} *; *$/) {      # the end of the class definition
26
 
                                # (don't end members like this)
27
 
        print "};\n";
28
 
        $macroize = 0;
29
 
    } elsif (/^ *$/) {          # in case the above misses the definition end
30
 
        print "\n";
31
 
        $macroize = 0;
32
 
    } elsif ($macroize) {       # a line in the body of the class definition
33
 
        s/$class *< *$type *>/$class \#\# $type/g;
34
 
        s/^( *~? *)$class( *\()/$1$class \#\# $type$2/; # fixes the CTOR's
35
 
                                                        # and DTOR's
36
 
        # change the names of inherited template classes initializers
37
 
        # that appear in CTOR to the macro version
38
 
        s/< *$type *>/ \#\# $type/g;
39
 
        s/\n//;
40
 
        print "$_ \\\n";
41
 
    } else {                    # a line outside the class definition
42
 
        print "$_";
43
 
    }
44
 
    
45
 
}