From: Nick Ing-Simmons Date: Mon, 11 Feb 2002 09:07:04 +0000 (+0000) Subject: Split Japanese encodings - part 2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b90c9a30a3bfe863d14ed5fb1c105f55b9616222;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/ext/Encode/EUC_JP/Japanese.pm b/ext/Encode/EUC_JP/Japanese.pm index b63cb61..2e81a3e 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 fac7d20..0a7d536 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 +#include +#include +#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);