{
$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 '';
}
{
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);