Changeset 4102 for src/Pugs/Types

Show
Ignore:
Timestamp:
05/29/05 18:05:01 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
5515
Message:

* Perl5Embed: .kv, .keys, .values, .pairs etc now works on Perl hashrefs.

Location:
src/Pugs/Types
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Types/Array.hs

    r3961 r4102  
    264264        idxSV   <- fromVal $ castV idx 
    265265        evalPerl5Sub "sub { $_[0]->[$_[1]] }" [sv, idxSV] 
     266    array_clear sv = do 
     267        evalPerl5Sub "sub { undef @{$_[0]} }" [sv] 
     268        return () 
    266269    array_storeVal sv idx val = do 
    267270        idxSV   <- fromVal $ castV idx 
     
    269272        evalPerl5Sub "sub { $_[0]->[$_[1]] = $_[2] }" [sv, idxSV, valSV] 
    270273        return () 
    271     array_storeElem _ _ _  = retConstError undef 
    272     array_deleteElem _ _   = retConstError undef 
     274    array_deleteElem sv idx = do 
     275        idxSV   <- fromVal $ castV idx 
     276        evalPerl5Sub "sub { delete $_[0]->[$_[1]] }" [sv, idxSV] 
     277        return () 
  • src/Pugs/Types/Hash.hs

    r4084 r4102  
    123123        keySV   <- fromVal $ castV key 
    124124        evalPerl5Sub "sub { $_[0]->{$_[1]} }" [sv, keySV] 
    125     hash_clear _ = retConstError undef 
    126     hash_store _ _ = retConstError undef 
     125    hash_clear sv = do 
     126        evalPerl5Sub "sub { undef %{$_[0]} }" [sv] 
     127        return () 
    127128    hash_storeVal sv key val = do 
    128129        keySV   <- fromVal $ castV key 
     
    134135        keysStr <- fromVal keysSV 
    135136        return $ lines keysStr 
    136     hash_storeElem _ _ _ = retConstError undef 
    137     hash_deleteElem _ _ = retConstError undef 
     137    hash_deleteElem sv key = do 
     138        keySV   <- fromVal $ castV key 
     139        evalPerl5Sub "sub { delete $_[0]->{$_[1]} }" [sv, keySV] 
     140        return () 
     141    hash_isEmpty sv = do 
     142        fromVal =<< evalPerl5Sub "sub { !!%{$_[0]} }" [sv]