3 # Regenerate (overwriting only if changed):
7 # lib/overload/numbers.pm
9 # from information stored in the DATA section of this file.
11 # This allows the order of overloading constants to be changed.
13 # Accepts the standard regen_lib -q and -v args.
15 # This script is normally invoked from regen.pl.
18 # Get function prototypes
19 require 'regen_lib.pl';
28 my ($enum, $name) = /^(\S+)\s+(\S+)/ or die "Can't parse $_";
33 safer_unlink ('lib/overload/numbers.pm');
34 my $c = safer_open("overload.c-new");
35 my $h = safer_open("overload.h-new");
36 mkdir("lib/overload", 0777) unless -d 'lib/overload';
37 my $p = safer_open('lib/overload/numbers.pm');
45 # -*- buffer-read-only: t -*-
47 # lib/overload/numbers.pm
49 # Copyright (C) 2008 by Larry Wall and others
51 # You may distribute under the terms of either the GNU General Public
52 # License or the Artistic License, as specified in the README file.
54 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
55 # This file is built by overload.pl
58 package overload::numbers;
68 { my \$i = 0; our %names = map { \$_ => \$i++ } \@names }
70 { my \$i = 0; our %enums = map { \$_ => \$i++ } \@enums }
79 /* -*- buffer-read-only: t -*-
83 * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall
86 * You may distribute under the terms of either the GNU General Public
87 * License or the Artistic License, as specified in the README file.
89 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
90 * This file is built by overload.pl
96 print_header('overload.c');
99 print_header('overload.h');
105 print map " ${_}_amg,\n", @enums;
109 /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
112 #define NofAMmeth max_amg_code
118 #define AMG_id2name(id) (PL_AMG_names[id]+1)
119 #define AMG_id2namelen(id) (PL_AMG_namelens[id]-1)
121 static const U8 PL_AMG_namelens[NofAMmeth] = {
124 my $last = pop @names;
126 print $c map { " " . (length $_) . ",\n" } @names;
128 my $lastlen = length $last;
133 static const char * const PL_AMG_names[NofAMmeth] = {
134 /* Names kept in the symbol table. fallback => "()", the rest has
135 "(" prepended. The only other place in perl which knows about
136 this convention is AMG_id2name (used for debugging output and
137 'nomethod' only), the only other place which has it hardwired is
141 print $c map { s/(["\\"])/\\$1/g; " \"$_\",\n" } @names;
151 rename_if_different("overload.c-new", "overload.c");
152 rename_if_different("overload.h-new","overload.h");
155 # Fallback should be the first
158 # These 5 are the most common in the fallback switch statement in amagic_call
165 # These have non-default cases in that switch statement
178 # These 12 feature in the next switch statement
231 # Note: Perl_Gv_AMupdate() assumes that DESTROY is the last entry