source: NonGTP/Boost/boost/signals/detail/gen_signal_N.pl @ 857

Revision 857, 4.1 KB checked in by igarcia, 19 years ago (diff)
Line 
1#!/usr/bin/perl -w
2#
3# Boost.Signals library
4
5# Copyright Douglas Gregor 2001-2003. Use, modification and
6# distribution is subject to the Boost Software License, Version
7# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8# http://www.boost.org/LICENSE_1_0.txt)
9
10# For more information, see http://www.boost.org
11use English;
12
13if ($#ARGV < 0) {
14  print "Usage: perl gen_signal_N <number of arguments>\n";
15  exit;
16}
17
18
19$totalNumArgs = $ARGV[0];
20for ($numArgs = 0; $numArgs <= $totalNumArgs; ++$numArgs) {
21  open OUT, ">signal$numArgs.hpp";
22  print OUT "// Boost.Signals library\n";
23  print OUT "//\n";
24  print OUT "// Copyright (C) 2001 Doug Gregor (gregod\@cs.rpi.edu)\n";
25  print OUT "//\n";
26  print OUT "// Permission to copy, use, sell and distribute this software is granted\n";
27  print OUT "// provided this copyright notice appears in all copies.\n";
28  print OUT "// Permission to modify the code and to distribute modified code is granted\n";
29  print OUT "// provided this copyright notice appears in all copies, and a notice\n";
30  print OUT "// that the code was modified is included with the copyright notice.\n";
31  print OUT "//\n";
32  print OUT "// This software is provided \"as is\" without express or implied warranty,\n";
33  print OUT "// and with no claim as to its suitability for any purpose.\n";
34  print OUT " \n";
35  print OUT "// For more information, see http://www.boost.org\n";
36  print OUT "\n";
37  print OUT "#ifndef BOOST_SIGNALS_SIGNAL" . $numArgs . "_HEADER\n";
38  print OUT "#define BOOST_SIGNALS_SIGNAL" , $numArgs . "_HEADER\n";
39  print OUT "\n";
40  print OUT "#define BOOST_SIGNALS_NUM_ARGS $numArgs\n";
41
42  $templateParms = "";
43  for ($i = 1; $i <= $numArgs; ++$i) {
44    if ($i > 1) {
45      $templateParms .= ", ";
46    }
47    $templateParms .= "typename T$i";
48  }
49  print OUT "#define BOOST_SIGNALS_TEMPLATE_PARMS $templateParms\n";
50
51  $_ = $templateParms;
52  s/typename //g;
53  $templateArgs = $_;
54  print OUT "#define BOOST_SIGNALS_TEMPLATE_ARGS $templateArgs\n";
55
56  $parms = "";
57  for ($i = 1; $i <= $numArgs; ++$i) {
58    if ($i > 1) {
59      $parms .= ", ";
60    }
61    $parms .= "T$i a$i";
62  }
63  print OUT "#define BOOST_SIGNALS_PARMS $parms\n";
64
65  $args = "";
66  for ($i = 1; $i <= $numArgs; ++$i) {
67    if ($i > 1) {
68      $args .= ", ";
69    }
70    $args .= "a$i";
71  }
72  print OUT "#define BOOST_SIGNALS_ARGS $args\n";
73
74  $boundArgs = "";
75  for ($i = 1; $i <= $numArgs; ++$i) {
76    if ($i > 1) {
77      $boundArgs .= ", ";
78    }
79    $boundArgs .= "args->a$i";
80  }
81  print OUT "#define BOOST_SIGNALS_BOUND_ARGS $boundArgs\n";
82
83  $argsAsMembers = "";
84  for ($i = 1; $i <= $numArgs; ++$i) {
85    $argsAsMembers .= "T$i a$i;";
86  }
87  print OUT "#define BOOST_SIGNALS_ARGS_AS_MEMBERS $argsAsMembers\n";
88
89  $copyParms = "";
90  for ($i = 1; $i <= $numArgs; ++$i) {
91    if ($i > 1) {
92      $copyParms .= ", ";
93    }
94    $copyParms .= "T$i ia$i";
95  }
96  print OUT "#define BOOST_SIGNALS_COPY_PARMS $copyParms\n";
97
98  $initArgs = "";
99  if ($numArgs > 0) {
100      $initArgs = ":";
101  }
102  for ($i = 1; $i <= $numArgs; ++$i) {
103    if ($i > 1) {
104      $initArgs .= ", ";
105    }
106    $initArgs .= "a$i(ia$i)";
107  }
108  print OUT "#define BOOST_SIGNALS_INIT_ARGS $initArgs\n";
109
110  $argTypes = "";
111  for ($i = 1; $i <= $numArgs; ++$i) {
112    $argTypes .= "typedef T$i arg". ($i+1) . "_type; ";
113  }
114
115  print OUT "#define BOOST_SIGNALS_ARG_TYPES $argTypes\n";
116  print OUT "\n";
117  print OUT "#include <boost/signals/signal_template.hpp>\n";
118  print OUT "\n";
119  print OUT "#undef BOOST_SIGNALS_ARG_TYPES\n";
120  print OUT "#undef BOOST_SIGNALS_INIT_ARGS\n";
121  print OUT "#undef BOOST_SIGNALS_COPY_PARMS\n";
122  print OUT "#undef BOOST_SIGNALS_ARGS_AS_MEMBERS\n";
123  print OUT "#undef BOOST_SIGNALS_BOUND_ARGS\n";
124  print OUT "#undef BOOST_SIGNALS_ARGS\n";
125  print OUT "#undef BOOST_SIGNALS_PARMS\n";
126  print OUT "#undef BOOST_SIGNALS_TEMPLATE_ARGS\n";
127  print OUT "#undef BOOST_SIGNALS_TEMPLATE_PARMS\n";
128  print OUT "#undef BOOST_SIGNALS_NUM_ARGS\n";
129  print OUT "\n";
130  print OUT "#endif // BOOST_SIGNALS_SIGNAL" . $numArgs . "_HEADER\n";
131  close OUT;
132}
Note: See TracBrowser for help on using the repository browser.