Silence a gcc warning, spotted by Tels
[p5sagit/p5-mst-13.2.git] / overload.pl
CommitLineData
bab3dc31 1#!/usr/bin/perl -w
2
3#
4# Generate overload.h
8c798f87 5# This allows the order of overloading constants to be changed.
bab3dc31 6#
7
8BEGIN {
9 # Get function prototypes
10 require 'regen_lib.pl';
11}
12
13use strict;
14
15my (@enums, @names);
16while (<DATA>) {
17 next if /^#/;
18 next if /^$/;
19 my ($enum, $name) = /^(\S+)\s+(\S+)/ or die "Can't parse $_";
20 push @enums, $enum;
21 push @names, $name;
22}
23
24safer_unlink 'overload.h';
25die "overload.h: $!" unless open(H, ">overload.h");
26binmode H;
27select H;
28print <<'EOF';
29/* -*- buffer-read-only: t -*-
30 *
31 * overload.h
32 *
33 * Copyright (C) 1997, 1998, 2000, 2001, 2005 and 2006 by Larry Wall and
34 * others
35 *
36 * You may distribute under the terms of either the GNU General Public
37 * License or the Artistic License, as specified in the README file.
38 *
39 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
40 * This file is built by overload.pl
41 */
42
43enum {
44EOF
45
46print " ${_}_amg,\n", foreach @enums;
47
48print <<'EOF';
49 max_amg_code
50 /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
51};
52
53
54#define NofAMmeth max_amg_code
55#define AMG_id2name(id) (PL_AMG_names[id]+1)
56
57#ifdef DOINIT
58EXTCONST char * const PL_AMG_names[NofAMmeth] = {
59 /* Names kept in the symbol table. fallback => "()", the rest has
60 "(" prepended. The only other place in perl which knows about
61 this convention is AMG_id2name (used for debugging output and
62 'nomethod' only), the only other place which has it hardwired is
63 overload.pm. */
64EOF
65
66my $last = pop @names;
67print " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names;
68
69print <<"EOT";
70 "$last"
71};
72#else
73EXTCONST char * PL_AMG_names[NofAMmeth];
74#endif /* def INITAMAGIC */
75EOT
76
8c798f87 77close H or die $!;
78
bab3dc31 79__DATA__
80# Fallback should be the first
81fallback ()
82
83# These 5 are the most common in the fallback switch statement in amagic_call
84to_sv (${}
85to_av (@{}
86to_hv (%{}
87to_gv (*{}
88to_cv (&{}
89
90# These have non-default cases in that switch statement
91inc (++
92dec (--
93bool_ (bool
94numer (0+
95string (""
96not (!
97copy (=
98abs (abs
99neg (neg
100iter (<>
101int (int
102
103# These 12 feature in the next switch statement
104lt (<
105le (<=
106gt (>
107ge (>=
108eq (==
109ne (!=
110slt (lt
111sle (le
112sgt (gt
113sge (ge
114seq (eq
115sne (ne
116
117nomethod (nomethod
118add (+
119add_ass (+=
120subtr (-
121subtr_ass (-=
122mult (*
123mult_ass (*=
124div (/
125div_ass (/=
126modulo (%
127modulo_ass (%=
128pow (**
129pow_ass (**=
130lshift (<<
131lshift_ass (<<=
132rshift (>>
133rshift_ass (>>=
134band (&
135band_ass (&=
136bor (|
137bor_ass (|=
138bxor (^
139bxor_ass (^=
140ncmp (<=>
141scmp (cmp
142compl (~
143atan2 (atan2
144cos (cos
145sin (sin
146exp (exp
147log (log
148sqrt (sqrt
149repeat (x
150repeat_ass (x=
151concat (.
152concat_ass (.=
153smart (~~
154# Note: Perl_Gv_AMupdate() assumes that DESTROY is the last entry
155DESTROY DESTROY