3 # +------------------------------------+
4 # | Inspire Internet Relay Chat Daemon |
5 # +------------------------------------+
7 # InspIRCd: (C) 2002-2007 InspIRCd Development Team
8 # See: http://www.inspircd.org/wiki/index.php/Credits
10 # This program is free but copyrighted software; see
11 # the file COPYING for details.
13 # ---------------------------------------------------
18 my $maxparams = shift;
20 die "You must supply a number of parameters to generate headers allowing for!" unless(defined $maxparams);
21 die "You must request a non-negative parameter limit!" unless($maxparams >= 0);
23 print STDERR "Generating headerfile for a maximium of $maxparams parameters\n";
25 # First generate the HanderBase family
27 my @templatetypes = ('ReturnType');
28 for(my $i = 0; $i <= $maxparams; $i++)
30 push @templatetypes, "Param" . $i if($i > 0);
31 print "template <typename " . join(', typename ', @templatetypes) . "> class CoreExport HandlerBase" . $i . "\n";
34 print " virtual ReturnType Call(" . join(', ', @templatetypes[1..$#templatetypes]) . ") = 0;\n";
35 print " virtual ~HandlerBase" . $i . "() { }\n";
39 # And now the caller family
41 print "template <typename HandlerType> class CoreExport caller\n";
44 print " HandlerType* target;\n\n";
45 print " caller(HandlerType* initial)\n";
46 print " : target(initial)\n";
48 print " virtual ~caller() { }\n\n";
49 print " caller& operator=(HandlerType* newtarget)\n";
51 print " target = newtarget;\n";
52 print " return *this;\n";
59 @templatetypes = ('ReturnType');
60 for(my $i = 0; $i <= $maxparams; $i++)
62 push @templatetypes, "Param" . $i if($i > 0);
64 my $handlertype = "HandlerBase" . $i . "<" . join(', ', @templatetypes) . ">";
65 my @templatetypepairs = map { $_ . " " . lc($_) } @templatetypes;
66 my @lctemplatetypes = map(lc, @templatetypes);
68 print "template <typename " . join(', typename ', @templatetypes) . "> class CoreExport caller" . $i . " : public caller< " . $handlertype . " >\n";
71 print " caller" . $i . "(" . $handlertype . "* initial)\n";
72 print " : caller< " . $handlertype. " >::caller(initial)\n";
74 print " virtual ReturnType operator() (" . join(', ', @templatetypepairs[1..$#templatetypepairs]) . ")\n";
76 print " return this->target->Call(" . join(', ', @lctemplatetypes[1..$#lctemplatetypes]) . ");\n";