Changeset 245 for Search-Namazu

Show
Ignore:
Timestamp:
03/28/06 17:55:36 (6 years ago)
Author:
knok
Message:

Added Search::Namazu::ResultXS, pure C result class.

Location:
Search-Namazu/trunk/Search-Namazu
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • Search-Namazu/trunk/Search-Namazu/ChangeLog

    r244 r245  
    22 
    33        * Namazu.{xs,pm}: Added maxget parameter. 
     4          Added a new class: Search::Namazu::ResultXS. 
    45 
    562006-03-27  NOKUBI Takatsugu  <knok@daionet.gr.jp> 
  • Search-Namazu/trunk/Search-Namazu/Namazu.xs

    r244 r245  
    33Namazu.xs 
    44 
    5 # Copyright (C) 1999,2000,2001,2002 NOKUBI Takatsugu All rights reserved. 
     5# Copyright (C) 1999-2006 NOKUBI Takatsugu All rights reserved. 
    66# This is free software with ABSOLUTELY NO WARRANTY. 
    77#  
     
    221221        OUTPUT: 
    222222                RETVAL 
     223 
     224 
     225MODULE = Search::Namazu PACKAGE = Search::Namazu::ResultXS      PREFIX = res_ 
     226 
     227SV * 
     228res_new() 
     229        CODE: 
     230                HV *self; 
     231                HV *stash; 
     232                SV *ref; 
     233 
     234                stash = gv_stashpv("Search::Namazu::ResultXS", 0); 
     235                self = newHV(); 
     236                ref = newRV_inc((SV*) self); 
     237                sv_bless(ref, stash); 
     238                RETVAL = ref; 
     239        OUTPUT: 
     240                RETVAL 
     241 
     242void 
     243res_set(self, key, val) 
     244              SV *self 
     245              SV *key 
     246              SV *val 
     247        CODE: 
     248                HV *hash; 
     249 
     250                hash = (HV *) SvRV(self); 
     251                hv_store(hash, SvPV_nolen(key), SvCUR(key), val, 0); 
     252 
     253SV * 
     254res_get(self, key) 
     255              SV *self 
     256              SV *key 
     257        CODE: 
     258                HV *hash; 
     259                SV **ret; 
     260 
     261                hash = (HV *) SvRV(self); 
     262                ret = hv_fetch(hash, SvPV_nolen(key), SvCUR(key), 0); 
     263                if (ret == NULL) { 
     264                        RETVAL = &PL_sv_undef; 
     265                } else { 
     266                        RETVAL = SvREFCNT_inc(*ret); 
     267                } 
     268        OUTPUT: 
     269                RETVAL 
     270