Changeset 4262 for src/perl5

Show
Ignore:
Timestamp:
06/01/05 13:28:02 (4 years ago)
Author:
clkao
svk:copy_cache_prev:
5801
Message:

Misc reference from p5 access fixes and tests.

Location:
src/perl5
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/perl5/README

    r4092 r4262  
    1515them to actual caller P6 namespace. 
    1616 
    17 =item Reference args 
     17=item Reference access from perl5 
    1818 
    19 Make C<Getopt::Long> work. 
     19=over  
     20 
     21=item scalar 
     22 
     23Make C<Getopt::Long> work.  C<MkValRef> gets dereferenced value, pending the fix to this. 
     24 
     25=item array 
     26 
     27C<STORE> / C<PUSH> fails, the array is correct in the accessor applied 
     28in perl5 tie, but not properly propogate back.  perhaps because args 
     29not marked as rw at the beginning. 
     30 
     31=item hash 
     32 
     33Requires C<eval_apply> to return multiple value so we can store the 
     34list for key iterator. 
     35 
     36=back 
    2037 
    2138=back 
  • src/perl5/perl5.c

    r4241 r4262  
    44#include "pugsembed.c" 
    55 
    6 /* undefine to enable pugsembed debug messages */ 
     6/* define to enable pugsembed debug messages */ 
     7#define PERL5_EMBED_DEBUG 0 
     8 
     9#if PERL5_EMBED_DEBUG 
     10#define oRZ "" 
     11#define hate Perl_croak(aTHX_ "hate software") 
     12#else 
    713#define oRZ "#" 
    8 #define hate Perl_croak(aTHX_ "hate software") 
     14#define hate 
     15#endif 
    916 
    1017/* Workaround for mapstart: the only op which needs a different ppaddr */ 
     
    3744"            return $array; }\n\n" 
    3845 
     46"sub Hash { my ($class, $val) = @_;\n" 
     47"           my $hash; tie %$hash, 'pugs::hash', $val;\n" 
     48oRZ"   warn 'returning '.$hash;\n" 
     49"            return $hash; }\n\n" 
     50 
    3951"our $AUTOLOAD;\n" 
    4052"sub AUTOLOAD { my $type = $AUTOLOAD; $type =~ s/.*:://;\n" 
     
    4355 
    4456"package pugs::array;\n" 
     57 
     58"our $AUTOLOAD;\n" 
     59"sub AUTOLOAD { my $type = $AUTOLOAD; $type =~ s/.*:://;\n" 
     60"               warn 'unhandled supported: '.$type } \n" 
     61 
    4562"sub TIEARRAY {\n" 
    4663"       my ($class, $val) = @_;\n" 
     
    5067"       my ($self, $index, $elem) = @_;\n" 
    5168oRZ"    warn 'store! '.$elem;\n" 
    52 "       pugs::guts::eval_apply('{ $^x[$^y] = $^z }', $$self, $index, $elem) }\n\n" 
     69"       pugs::guts::eval_apply('sub ($x is rw, $y, $z) { $x[$y] = $z;\n" 
     70oRZ"                                                     warn $x\n" 
     71"                               }', $$self, $index, $elem) }\n\n" 
     72 
     73"sub PUSH {\n" 
     74"       my ($self, $elem) = @_;\n" 
     75"       pugs::guts::eval_apply('sub ($x is rw, $z) { $x.push($z);\n" 
     76oRZ"                                                 warn $x\n" 
     77"                               }', $$self, $elem) }\n\n" 
    5378 
    5479"sub FETCHSIZE {\n" 
    5580"       my ($self) = @_;\n" 
    5681"       my $ret = pugs::guts::invoke('elems', $$self); \n" 
    57 oRZ"    warn 'FETCHSIZE: '.$ret; $ret; }\n\n" 
     82oRZ"    warn 'FETCHSIZE: '.$ret;\n" 
     83"       $ret; }\n\n" 
     84 
     85"sub EXISTS {\n" 
     86"       my ($self, $index) = @_;\n" 
     87"       pugs::guts::eval_apply('sub ($x, $y) { $x.exists($y) }', $$self, $index) }\n" 
    5888 
    5989"sub FETCH {\n" 
    6090"       my ($self, $index) = @_;\n" 
    61 "       pugs::guts::eval_apply('{ $^x[$^y] }', $$self, $index) }\n" 
     91oRZ"    warn 'FETCH: '.$index;\n" 
     92"       pugs::guts::eval_apply('sub ($x, $y) { $x.[$y] }', $$self, $index) }\n" 
     93 
     94"package pugs::hash;\n" 
     95 
     96"our $AUTOLOAD;\n" 
     97"sub AUTOLOAD { my $type = $AUTOLOAD; $type =~ s/.*:://;\n" 
     98"               warn 'unhandled supported: '.$type } \n" 
     99 
     100"sub TIEHASH {\n" 
     101"       my ($class, $val) = @_;\n" 
     102"       bless [$val,0], $class; }\n\n" 
     103 
     104"sub FIRSTKEY {\n" 
     105"       my ($self) = @_;\n" 
     106"       my $ret = pugs::guts::invoke('keys', $self->[0]); \n" 
     107oRZ"       warn $ret;\n" 
     108"       $self->[1] = 0; $self->[2] = $ret;" 
     109"       $self->NEXTKEY; }\n" 
     110 
     111"sub NEXTKEY {\n" 
     112"       my ($self) = @_;\n" 
     113"       return undef if $self->[1] > $#{$self->[2]};" 
     114"       $self->[2]->[$self->[1]++]; }" 
     115 
     116 
    62117oRZ"warn 'compiled';\n" 
    63118"1;\n"; 
     
    68123    int i; 
    69124    dXSARGS; 
    70     if (items < 1) 
     125    if (items < 1) { 
    71126      hate; 
     127    } 
    72128 
    73129    sv = ST(0); 
     
    102158    int i; 
    103159    dXSARGS; 
    104     if (items < 1) 
     160    if (items < 1) { 
    105161        hate; 
     162    } 
    106163 
    107164    val = pugs_Eval(SvPV_nolen(ST(0))); 
     
    109166    stack = (Val **)malloc(sizeof(Val*)*items-1); 
    110167    for (i = 1; i < items; ++i) { 
     168#if PERL5_EMBED_DEBUG 
    111169        fprintf(stderr, "put into stack: %s\n", SvPV_nolen(ST(i))); 
     170#endif 
    112171        stack[i-1] = pugs_SvToVal(ST(i)); 
    113172    } 
     
    213272    newXS((char*) "pugs::guts::eval_apply", _pugs_guts_eval_apply, (char*)__FILE__); 
    214273 
    215 #ifndef oRZ 
     274#if PERL5_EMBED_DEBUG 
    216275    fprintf(stderr, "(%s)", pugs_guts_code); 
    217276#endif 
     
    219278 
    220279    if (SvTRUE(ERRSV)) { 
    221         fprintf(stderr, "Hate!\n"); 
    222280        STRLEN n_a; 
    223281        printf("Error init perl: %s\n", SvPV(ERRSV,n_a)); 
     
    308366    SPAGAIN; 
    309367 
    310     /* fprintf(stderr, "%d is count\n", count); */ 
    311368    Newz(42, out, count+1, SV*); 
    312369 
  • src/perl5/pugsembed.c

    r4231 r4262  
    2828 
    2929    type = pugs_Apply(pugs_PvToVal("&ref"), val, isa, G_SCALAR); 
     30#if PERL5_EMBED_DEBUG 
    3031    fprintf(stderr, "query the type: got %s\n", SvPV_nolen(type)); 
     32#endif 
    3133    if (SvTRUE( type )) { 
    3234        SV **rv; 
     
    4042        } 
    4143        else { 
     44            /* for scalar ref, should still turn into tied one */ 
     45#if PERL5_EMBED_DEBUG 
    4246            fprintf(stderr, "unknown type\n"); 
     47#endif 
    4348        } 
    4449    }