Changeset 551

Show
Ignore:
Timestamp:
03/18/02 16:38:20
Author:
miyagawa
Message:

0.05

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PHP-Session/trunk/Changes

    r550 r551  
    11Revision history for Perl extension PHP::Session 
     2 
     30.05  Mon Mar 18 16:36:27 JST 2002 
     4        * added Boolean type (ext/var.h in PHP source code) 
    25 
    360.04  Fri Mar 15 16:14:32 JST 2002 
  • PHP-Session/trunk/lib/PHP/Session.pm

    r550 r551  
    33use strict; 
    44use vars qw($VERSION); 
    5 $VERSION = 0.04
     5$VERSION = 0.05
    66 
    77use vars qw(%SerialImpl); 
     
    149149 
    150150  # check if data is registered 
    151   $session->is_registerd('bar'); 
     151  $session->is_registered('bar'); 
    152152 
    153153  # save session data 
     
    172172=item * 
    173173 
    174 Objects in PHP are deserialized as hash reference, blessed into 
     174Objects in PHP are restrored as objects blessed into 
    175175PHP::Session::Object (Null class). 
    176176 
    177177=item * 
    178178 
    179 Locking when save()ing data is acquired via exclusive flock, same as 
     179Locking when save()ing data is acquired via exclusive C<flock>, same as 
    180180PHP implementation. 
    181181 
  • PHP-Session/trunk/lib/PHP/Session/Serializer/PHP.pm

    r550 r551  
    55 
    66use vars qw($VERSION); 
    7 $VERSION = 0.04
     7$VERSION = 0.05
    88 
    99sub _croak { require Carp; Carp::croak(@_) } 
     
    1515 
    1616my $var_re = '(\w+)\|'; 
    17 my $str_re = 's:\d+:"(.*?)"\;'; 
     17my $str_re = 's:\d+:"(.*?)";'; 
    1818my $int_re = 'i:(\d+);'; 
    19 my $dig_re = 'd:([\-\d\.]+);'; 
     19my $dbl_re = 'd:([\-\d\.]+);'; 
    2020my $arr_re = 'a:(\d+):'; 
    2121my $obj_re = 'O:\d+:"(.*?)":\d+:'; 
    2222my $nul_re = '(N);'; 
     23my $bool_re = 'b:([01]);'; 
    2324 
    2425use constant VARNAME   => 0; 
    2526use constant STRING    => 1; 
    2627use constant INTEGER   => 2; 
    27 use constant DIGIT     => 3; 
     28use constant DOUBLE    => 3; 
    2829use constant ARRAY     => 4; 
    2930use constant CLASSNAME => 5; 
    3031use constant NULL      => 6; 
     32use constant BOOLEAN   => 7; 
    3133 
    3234sub decode { 
    3335    my($self, $data) = @_; 
    34     while ($data =~ s/^$var_re(?:$str_re|$int_re|$dig_re|$arr_re|$obj_re|$nul_re)//) { 
    35         my @match = ($1, $2, $3, $4, $5, $6, $7); 
    36         my @literal = grep defined, @match[STRING, INTEGER, DIGIT]; 
     36    while ($data =~ s/^$var_re(?:$str_re|$int_re|$dbl_re|$arr_re|$obj_re|$nul_re|$bool_re)//) { 
     37        my @match = ($1, $2, $3, $4, $5, $6, $7, $8); 
     38        my @literal = grep defined, @match[STRING, INTEGER, DOUBLE, BOOLEAN]; 
    3739        @literal and $self->{_data}->{$match[VARNAME]} = $literal[0], next; 
    3840 
     
    6163    $data =~ s/^{(.*)}$/$1/; 
    6264    my @data; 
    63     while ($data =~ s/^($str_re|$int_re|$dig_re|$arr_re|$obj_re)//) { 
    64         my @match = ($1, $2, $3, $4, $5, $6, $7); 
    65         my @literal = grep defined, @match[STRING, INTEGER, DIGIT]; 
     65    while ($data =~ s/^($str_re|$int_re|$dbl_re|$arr_re|$obj_re|$nul_re|$bool_re)//) { 
     66        my @match = ($1, $2, $3, $4, $5, $6, $7, $8); 
     67        my @literal = grep defined, @match[STRING, INTEGER, DOUBLE, BOOLEAN]; 
    6668        @literal and push @data, $literal[0] and next; 
    6769 
     
    98100    my($self, $value) = @_; 
    99101    if (! defined $value) { 
    100         return $self->encode_undef($value); 
     102        return $self->encode_null($value); 
    101103    } 
    102104    elsif (! ref $value) { 
     
    105107        } 
    106108        elsif ($value =~ /^[\d\-\.]+$/) { 
    107             return $self->encode_digit($value); 
     109            return $self->encode_double($value); 
    108110        } 
    109111        else { 
     
    112114    } 
    113115    elsif (ref $value eq 'HASH') { 
    114         return $self->encode_hash($value); 
     116        return $self->encode_array($value); 
    115117    } 
    116118    elsif (ref $value eq 'PHP::Session::Object') { 
     
    122124} 
    123125 
    124 sub encode_undef
     126sub encode_null
    125127    my($self, $value) = @_; 
    126128    return 'N;'; 
     
    132134} 
    133135 
    134 sub encode_digit
     136sub encode_double
    135137    my($self, $value) = @_; 
    136138    return sprintf "d:%d;", $value; 
     
    142144} 
    143145 
    144 sub encode_hash
     146sub encode_array
    145147    my($self, $value) = @_; 
    146148    return sprintf 'a:%d:{%s}', 2 * (keys %$value), join('', map $self->do_encode($_), %$value);