diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-02-11 09:07:04 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-02-11 09:07:04 +0000 |
commit | b90c9a30a3bfe863d14ed5fb1c105f55b9616222 (patch) | |
tree | e62897235519d3f4adb1140fd549a5869deee18e /ext | |
parent | 3de3d21f074d2625e0cbc46fd7d33fabf6fd811e (diff) | |
download | perl-b90c9a30a3bfe863d14ed5fb1c105f55b9616222.tar.gz |
Split Japanese encodings - part 2
- build separate .c files with separate 'compile' steps
- overall Japanese.xs / Japanese.pm which loads them
p4raw-id: //depot/perlio@14637
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Encode/EUC_JP/Japanese.pm | 4 | ||||
-rw-r--r-- | ext/Encode/EUC_JP/Makefile.PL | 61 |
2 files changed, 51 insertions, 14 deletions
diff --git a/ext/Encode/EUC_JP/Japanese.pm b/ext/Encode/EUC_JP/Japanese.pm index b63cb617aa..2e81a3eb1d 100644 --- a/ext/Encode/EUC_JP/Japanese.pm +++ b/ext/Encode/EUC_JP/Japanese.pm @@ -1,8 +1,8 @@ -package Encode::EUC_JP; +package Encode::Japanese; use Encode; our $VERSION = '0.01'; use XSLoader; -XSLoader::load('Encode::EUC_JP',$VERSION); +XSLoader::load('Encode::Japanese',$VERSION); 1; __END__ diff --git a/ext/Encode/EUC_JP/Makefile.PL b/ext/Encode/EUC_JP/Makefile.PL index fac7d208db..0a7d536eb3 100644 --- a/ext/Encode/EUC_JP/Makefile.PL +++ b/ext/Encode/EUC_JP/Makefile.PL @@ -37,17 +37,58 @@ sub post_initialize { $o{$e.$x} = 1; } + $o{"Japanese$x"} = 1; $self->{'O_FILES'} = [sort keys %o]; - my @files; + my @files = ('Japanese.xs'); my %xs; foreach my $table (keys %tables) { - $xs{"$table.xs"} = "$table.c"; - foreach my $ext (qw($(OBJ_EXT) .xs .c .h _def.h .fnm)) { + foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) { push (@files,$table.$ext); } } - $self->{'XS_FILES'} = {%xs}; + $self->{'XS_FILES'} = { 'Japanese.xs' => 'Japanese.c' }; $self->{'clean'}{'FILES'} .= join(' ',@files); + open(XS,">Japanese.xs") || die "Cannot open Japanese.xs:$!"; + print XS <<'END'; +#include <EXTERN.h> +#include <perl.h> +#include <XSUB.h> +#define U8 U8 +#include "../encode.h" +END + foreach my $table (keys %tables) { + print XS qq[#include "${table}.h"\n]; + } + print XS <<'END'; + +static void +Encode_XSEncoding(pTHX_ encode_t *enc) +{ + dSP; + HV *stash = gv_stashpv("Encode::XS", TRUE); + SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash); + int i = 0; + PUSHMARK(sp); + XPUSHs(sv); + while (enc->name[i]) + { + const char *name = enc->name[i++]; + XPUSHs(sv_2mortal(newSVpvn(name,strlen(name)))); + } + PUTBACK; + call_pv("Encode::define_encoding",G_DISCARD); + SvREFCNT_dec(sv); +} + +MODULE = Encode::Japanese PACKAGE = Encode::Japanese +BOOT: +{ +END + foreach my $table (keys %tables) { + print XS qq[#include "${table}_def.h"\n]; + } + print XS "}\n"; + close(XS); return ''; } @@ -55,25 +96,21 @@ sub postamble { my $self = shift; my $dir = $self->catdir($self->updir,'Encode'); - my $str = "# Encode\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n"; - $str .= 'Encode$(OBJ_EXT) :'; + my $str = "# Japanese\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n"; + $str .= 'Japanese$(OBJ_EXT) :'; + $str .= ' Japanese.xs'; foreach my $table (keys %tables) { $str .= " $table.c"; } $str .= "\n\n"; - foreach my $table (keys %tables) - { - $str .= "$table.c : $table.xs\n"; - } - $str .= "\n"; my $compile = $self->catfile($self->updir,'compile'); foreach my $table (keys %tables) { my $numlines = 1; my $lengthsofar = length($str); my $continuator = ''; - $str .= "$table.xs : $compile Makefile.PL"; + $str .= "$table.c : $compile Makefile.PL"; foreach my $file (@{$tables{$table}}) { $str .= $continuator.' '.$self->catfile($dir,$file); |