Skip to content

Commit

Permalink
Create regen/feature.pl
Browse files Browse the repository at this point in the history
This script generates lib/feature.pm.  Soon it will be made to gener-
ate other files, too.
  • Loading branch information
Father Chrysostomos committed Dec 24, 2011
1 parent ebd7756 commit 69bcf1d
Show file tree
Hide file tree
Showing 6 changed files with 488 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Cross/Makefile-cross-SH
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ CHMOD_W = chmod +w
# opcode.pl: opcode.h opnames.h pp_proto.h
# regcomp.pl: regnodes.h
# warnings.pl: warnings.h lib/warnings.pm
# feature.pl: lib/feature.pl
# The correct versions should be already supplied with the perl kit,
# in case you don't have perl available.
# To force them to be regenerated, run
Expand All @@ -856,7 +857,8 @@ CHMOD_W = chmod +w
# (make regen_headers is kept for backwards compatibility)
AUTOGEN_FILES = opcode.h opnames.h pp_proto.h proto.h embed.h embedvar.h \
perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm
perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm \
lib/feature.pm
.PHONY: regen_headers regen_all
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4822,6 +4822,7 @@ regcomp.h Private declarations for above
regcomp.sym Data for regnodes.h
regen/embed_lib.pl Reads embed.fnc and regen/opcodes
regen/embed.pl Produces {embed,embedvar,proto}.h
regen/feature.pl Generates feature.pm
regen/keywords.pl Program to write keywords.h
regen/mg_vtable.pl generate mg_vtable.h
regen/mk_PL_charclass.pl Populate the PL_charclass table
Expand Down
4 changes: 3 additions & 1 deletion Makefile.SH
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ CHMOD_W = chmod +w
# opcode.pl: opcode.h opnames.h pp_proto.h
# regcomp.pl: regnodes.h
# warnings.pl: warnings.h lib/warnings.pm
# feature.pl: lib/feature.pm
# The correct versions should be already supplied with the perl kit,
# in case you don't have perl available.
# To force them to be regenerated, run
Expand All @@ -1161,7 +1162,8 @@ CHMOD_W = chmod +w
# (make regen_headers is kept for backwards compatibility)
AUTOGEN_FILES = opcode.h opnames.h pp_proto.h proto.h embed.h embedvar.h \
perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm
perlapi.h perlapi.c regnodes.h warnings.h lib/warnings.pm \
lib/feature.pm
.PHONY: regen_headers regen_all
Expand Down
38 changes: 19 additions & 19 deletions lib/feature.pm
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# -*- buffer-read-only: t -*-
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is built by regen/feature.pl.
# Any changes made here will be lost!

package feature;

our $VERSION = '1.25';

# (feature name) => (internal name, used in %^H)
my %feature = (
say => 'feature_say',
state => 'feature_state',
Expand All @@ -13,33 +17,27 @@ my %feature = (
unicode_strings => 'feature_unicode',
);

# These work backwards--the presence of the hint elem disables the feature:
my %default_feature = (
array_base => 'feature_no$[',
array_base => 'feature_no$[',
);

# This gets set (for now) in $^H as well as in %^H,
# for runtime speed of the uc/lc/ucfirst/lcfirst functions.
# See HINT_UNI_8_BIT in perl.h.
our $hint_uni8bit = 0x00000800;

# NB. the latest bundle must be loaded by the -E switch (see toke.c)

our %feature_bundle = (
"default" => [keys %default_feature],
"5.10" => [qw(say state switch array_base)],
"5.11" => [qw(say state switch unicode_strings array_base)],
"5.15" => [qw(say state switch unicode_strings unicode_eval
evalbytes current_sub)],
"5.10" => [qw(array_base say state switch)],
"5.11" => [qw(array_base say state switch unicode_strings)],
"5.15" => [qw(current_sub evalbytes say state switch unicode_eval unicode_strings)],
"5.9.5" => [qw(array_base say state switch)],
"default" => [qw(array_base)],
);


# Each of these is the same as the previous bundle
for(12...14, 16) {
for (12,13,14,16) {
$feature_bundle{"5.$_"} = $feature_bundle{"5.".($_-1)}
}

# special case
$feature_bundle{"5.9.5"} = $feature_bundle{"5.10"};
# This gets set (for now) in $^H as well as in %^H,
# for runtime speed of the uc/lc/ucfirst/lcfirst functions.
# See HINT_UNI_8_BIT in perl.h.
our $hint_uni8bit = 0x00000800;

# TODO:
# - think about versioned features (use feature switch => 2)
Expand Down Expand Up @@ -372,3 +370,5 @@ sub croak {
}

1;

# ex: set ro:
1 change: 1 addition & 0 deletions regen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
regcomp.pl
warnings.pl
embed.pl
feature.pl
);

my $tap = $ARGV[0] && $ARGV[0] eq '--tap' ? '# ' : '';
Expand Down
Loading

0 comments on commit 69bcf1d

Please sign in to comment.