5 # This allows the order of overloading constants to be changed.
9 # Get function prototypes
10 require 'regen_lib.pl';
15 use File::Spec::Functions qw(catdir catfile);;
21 my ($enum, $name) = /^(\S+)\s+(\S+)/ or die "Can't parse $_";
26 safer_unlink ('overload.h', 'overload.c', catfile(qw(lib overload numbers.pm)));
27 my $c = safer_open("overload.c");
28 my $h = safer_open("overload.h");
29 mkdir("lib/overload") unless -d catdir(qw(lib overload));
30 my $p = safer_open(catfile(qw(lib overload numbers.pm)));
38 # -*- buffer-read-only: t -*-
40 # lib/overload/numbers.pm
42 # Copyright (C) 2008 by Larry Wall and others
44 # You may distribute under the terms of either the GNU General Public
45 # License or the Artistic License, as specified in the README file.
47 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
48 # This file is built by overload.pl
51 package overload::numbers;
61 { my \$i = 0; our %names = map { \$_ => \$i++ } \@names }
63 { my \$i = 0; our %enums = map { \$_ => \$i++ } \@enums }
72 /* -*- buffer-read-only: t -*-
76 * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall
79 * You may distribute under the terms of either the GNU General Public
80 * License or the Artistic License, as specified in the README file.
82 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
83 * This file is built by overload.pl
89 print_header('overload.c');
92 print_header('overload.h');
98 print " ${_}_amg,\n", foreach @enums;
102 /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
105 #define NofAMmeth max_amg_code
111 #define AMG_id2name(id) (PL_AMG_names[id]+1)
112 #define AMG_id2namelen(id) (PL_AMG_namelens[id]-1)
114 static const U8 PL_AMG_namelens[NofAMmeth] = {
117 my $last = pop @names;
119 print $c " $_,\n" foreach map { length $_ } @names;
121 my $lastlen = length $last;
126 static const char * const PL_AMG_names[NofAMmeth] = {
127 /* Names kept in the symbol table. fallback => "()", the rest has
128 "(" prepended. The only other place in perl which knows about
129 this convention is AMG_id2name (used for debugging output and
130 'nomethod' only), the only other place which has it hardwired is
134 print $c " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names;
146 # Fallback should be the first
149 # These 5 are the most common in the fallback switch statement in amagic_call
156 # These have non-default cases in that switch statement
169 # These 12 feature in the next switch statement
221 # Note: Perl_Gv_AMupdate() assumes that DESTROY is the last entry