Changeset 2029

Show
Ignore:
Timestamp:
02/25/08 21:15:06 (3 months ago)
Author:
karpet
Message:

refactor stash into its own class for easier debugging

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/bindings/perl/3.xs

    r2028 r2029  
    2323 
    2424    PREINIT: 
    25         HV* stash; 
    26         HV* analyzer_stash; 
    2725        swish_3* s3; 
    2826 
    2927    CODE: 
    30         stash   = newHV(); 
    31         s3      = swish_init_swish3( &sp_handler, newRV_inc((SV*)stash) ); 
     28        s3 = swish_init_swish3( &sp_handler, NULL ); 
    3229        s3->ref_cnt++; 
    33          
    34         sp_hv_store(stash, DATA_CLASS_KEY,      newSVpv(DATA_CLASS, 0)); 
    35         sp_hv_store(stash, CONFIG_CLASS_KEY,    newSVpv(CONFIG_CLASS, 0)); 
    36         sp_hv_store(stash, ANALYZER_CLASS_KEY,  newSVpv(ANALYZER_CLASS, 0)); 
    37         sp_hv_store(stash, PARSER_CLASS_KEY,    newSVpv(PARSER_CLASS, 0)); 
    38  
    39         //sp_describe_object(s3->stash); 
    40         //sp_describe_object(newRV_noinc((SV*)s3->stash)); 
     30        s3->stash = sp_Stash_new(); 
     31         
     32        sp_Stash_set_char( s3->stash, DATA_CLASS_KEY,     DATA_CLASS ); 
     33        sp_Stash_set_char( s3->stash, CONFIG_CLASS_KEY,   CONFIG_CLASS ); 
     34        sp_Stash_set_char( s3->stash, ANALYZER_CLASS_KEY, ANALYZER_CLASS ); 
     35        sp_Stash_set_char( s3->stash, PARSER_CLASS_KEY,   PARSER_CLASS ); 
     36        sp_Stash_set_char( s3->stash, SELF_CLASS_KEY,     CLASS ); 
     37         
     38        //warn("new() stash refcnt = %d\n", SvREFCNT((SV*)SvRV((SV*)s3->stash))); 
     39         
     40        //sp_describe_object( (SV*)s3->stash ); 
    4141 
    4242        s3->analyzer->tokenizer = &sp_tokenize; 
    43         analyzer_stash  = newHV(); 
    44         s3->analyzer->stash = newRV_inc((SV*)analyzer_stash); 
     43        s3->analyzer->stash  = sp_Stash_new(); 
     44        sp_Stash_set_char( s3->analyzer->stash, SELF_CLASS_KEY, ANALYZER_CLASS ); 
     45        s3->config->stash    = sp_Stash_new(); 
     46        sp_Stash_set_char( s3->config->stash, SELF_CLASS_KEY, CONFIG_CLASS ); 
    4547                 
    4648        RETVAL = s3; 
     
    148150    set_analyzer_class  = 15 
    149151    get_analyzer_class  = 16 
    150     set_stash           = 17 
    151     get_stash           = 18 
    152     set_regex           = 19 
    153     get_regex           = 20 
     152    set_regex           = 17 
     153    get_regex           = 18 
    154154PREINIT: 
    155     SV*             stash; 
    156     SV*             RETVAL; 
    157     SV*             tmp; 
     155    SV  *RETVAL; 
     156    char *class; 
    158157PPCODE: 
    159158{ 
    160  
    161     stash = self->stash; 
    162     // TODO need this? 
    163     SvREFCNT_inc(stash); 
    164159     
    165160    //warn("number of items %d for ix %d", items, ix); 
     
    174169                    warn("freeing config on set_config"); 
    175170                } 
     171                sp_Stash_destroy(self->config->stash); 
     172                if (self->config->stash != NULL) { 
     173                    //SWISH_WARN("set config stash to NULL"); 
     174                    self->config->stash = NULL; 
     175                } 
    176176                swish_free_config(self->config); 
    177177             } 
     
    183183    // get_config    
    184184    case 2:  self->config->ref_cnt++; 
    185              RETVAL = sp_bless_ptr(sp_hvref_fetch_as_char(stash, CONFIG_CLASS_KEY), (IV)self->config); 
     185             class = sp_Stash_get_char(self->stash, CONFIG_CLASS_KEY); 
     186             sp_Stash_set_char( self->config->stash, SELF_CLASS_KEY, class ); 
     187             RETVAL = sp_bless_ptr(class, (IV)self->config); 
    186188             break; 
    187189 
     
    193195                    warn("freeing analyzer on set_analyzer"); 
    194196                } 
     197                sp_Stash_destroy(self->analyzer->stash); 
    195198                swish_free_analyzer(self->analyzer); 
    196199             } 
     
    202205    // get_analyzer 
    203206    case 4:  self->analyzer->ref_cnt++; 
    204              RETVAL = sp_bless_ptr(sp_hvref_fetch_as_char(stash, ANALYZER_CLASS_KEY), (IV)self->analyzer); 
     207             class = sp_Stash_get_char(self->stash, ANALYZER_CLASS_KEY); 
     208             sp_Stash_set_char( self->analyzer->stash, SELF_CLASS_KEY, class ); 
     209             RETVAL = sp_bless_ptr(class, (IV)self->analyzer); 
    205210             break; 
    206211 
     
    219224    // get_parser   
    220225    case 6:  self->parser->ref_cnt++; 
    221              RETVAL = sp_bless_ptr(sp_hvref_fetch_as_char(stash, PARSER_CLASS_KEY), (IV)self->parser); 
     226             class = sp_Stash_get_char(self->stash, PARSER_CLASS_KEY); 
     227             RETVAL = sp_bless_ptr(class, (IV)self->parser); 
    222228             break; 
    223229 
    224230    // set_handler 
    225     case 7:  sp_hvref_replace(stash, HANDLER_KEY, ST(1)); 
     231    case 7:  sp_Stash_replace(self->stash, HANDLER_KEY, ST(1)); 
    226232             break; 
    227233 
    228234    // get_handler 
    229     case 8:  RETVAL = sp_hvref_fetch(stash, HANDLER_KEY); 
     235    case 8:  RETVAL = sp_Stash_get(self->stash, HANDLER_KEY); 
    230236             break; 
    231237     
    232238    // set_data_class 
    233     case 9:  sp_hvref_replace(stash, DATA_CLASS_KEY, ST(1)); 
     239    case 9:  sp_Stash_replace(self->stash, DATA_CLASS_KEY, ST(1)); 
    234240             break; 
    235241              
    236242    // get_data_class 
    237     case 10: RETVAL = sp_hvref_fetch(stash, DATA_CLASS_KEY); 
     243    case 10: RETVAL = sp_Stash_get(self->stash, DATA_CLASS_KEY); 
    238244             break; 
    239245 
    240246    // set_parser_class 
    241     case 11: sp_hvref_replace(stash, PARSER_CLASS_KEY, ST(1)); 
     247    case 11: sp_Stash_replace(self->stash, PARSER_CLASS_KEY, ST(1)); 
    242248             break; 
    243249     
    244250    // get_parser_class 
    245     case 12: RETVAL = sp_hvref_fetch(stash, PARSER_CLASS_KEY); 
     251    case 12: RETVAL = sp_Stash_get(self->stash, PARSER_CLASS_KEY); 
    246252             break; 
    247253     
    248254    // set_config_class 
    249     case 13: sp_hvref_replace(stash, CONFIG_CLASS_KEY, ST(1)); 
     255    case 13: sp_Stash_replace(self->stash, CONFIG_CLASS_KEY, ST(1)); 
    250256             break; 
    251257     
    252258    // get_config_class 
    253     case 14: RETVAL = sp_hvref_fetch(stash, CONFIG_CLASS_KEY); 
     259    case 14: RETVAL = sp_Stash_get(self->stash, CONFIG_CLASS_KEY); 
    254260             break; 
    255261 
    256262    // set_analyzer_class 
    257     case 15: sp_hvref_replace(stash, ANALYZER_CLASS_KEY, ST(1)); 
     263    case 15: sp_Stash_replace(self->stash, ANALYZER_CLASS_KEY, ST(1)); 
    258264             break; 
    259265     
    260266    // get_analyzer_class 
    261     case 16: RETVAL = sp_hvref_fetch(stash, ANALYZER_CLASS_KEY); 
    262              break; 
    263  
    264     // set_stash 
    265     case 17: self->stash = ST(1); 
    266              break; 
    267  
    268     // get_stash 
    269     case 18: RETVAL = stash; 
    270              SvREFCNT_inc( self->stash ); 
     267    case 16: RETVAL = sp_Stash_get(self->stash, ANALYZER_CLASS_KEY); 
    271268             break; 
    272269 
    273270    // set_regex 
    274     case 19: sp_SV_is_qr( ST(1) );              
     271    case 17: sp_SV_is_qr( ST(1) );              
    275272             self->analyzer->regex = SvREFCNT_inc( ST(1) ); 
    276273             break; 
    277274              
    278275    // get_regex 
    279     case 20: RETVAL  = self->analyzer->regex; 
     276    case 18: RETVAL  = self->analyzer->regex; 
    280277             break;     
    281278         
     
    293290        s3 = (swish_3*)sp_extract_ptr(self); 
    294291        s3->ref_cnt--; 
     292 
     293        if ( SWISH_DEBUG ) { 
     294          warn("s3->stash refcnt = %d\n",  
     295            sp_Stash_inner_refcnt(s3->stash) ); 
     296          warn("s3->config->stash refcnt = %d\n",  
     297            sp_Stash_inner_refcnt( s3->config->stash) ); 
     298          warn("s3->analyzer->stash refcnt = %d\n",  
     299            sp_Stash_inner_refcnt( s3->analyzer->stash) ); 
     300             
     301        }             
    295302         
    296303        if (SWISH_DEBUG) { 
    297304            warn("DESTROYing swish_3 object %s  [%d] [ref_cnt = %d]",  
    298                 SvPV(ST(0), PL_na), self, s3->ref_cnt); 
     305                SvPV(ST(0), PL_na), s3, s3->ref_cnt); 
    299306        } 
    300307         
    301308        if (s3->ref_cnt < 1) { 
     309            sp_Stash_destroy( s3->stash ); 
     310            if ( s3->config->ref_cnt == 1 ) { 
     311                sp_Stash_destroy( s3->config->stash ); 
     312                //SWISH_WARN("set config stash to NULL"); 
     313                s3->config->stash = NULL; 
     314            } 
     315            if ( s3->analyzer->ref_cnt == 1 ) { 
     316                sp_Stash_destroy( s3->analyzer->stash ); 
     317            } 
     318             
    302319            swish_free_swish3( s3 ); 
    303320        } 
     
    324341INCLUDE: XS/Doc.xs 
    325342INCLUDE: XS/Data.xs 
    326  
     343INCLUDE: XS/Stash.xs 
     344 
  • libswish3/trunk/bindings/perl/XS/Analyzer.xs

    r2028 r2029  
    6363    CODE: 
    6464        self->ref_cnt--; 
    65          
     65                 
    6666        if (SWISH_DEBUG) { 
    6767            warn("DESTROYing swish_Analyzer object %s  [%d] [ref_cnt = %d]",  
     
    7070         
    7171        if (self->ref_cnt < 1) { 
     72            sp_Stash_destroy( self->stash ); 
    7273            swish_free_analyzer(self); 
    7374        } 
  • libswish3/trunk/bindings/perl/XS/Config.xs

    r2028 r2029  
    109109void 
    110110DESTROY(self) 
    111     swish_Config* self 
     111    swish_Config* self; 
    112112     
    113113    CODE: 
    114114        self->ref_cnt--; 
    115          
    116         if (self->stash != NULL) { 
    117             SvREFCNT_dec(self->stash); 
    118         } 
    119          
     115                
    120116        if (SWISH_DEBUG) { 
    121117            warn("DESTROYing swish_Config object %s  [%d] [ref_cnt = %d]",  
     
    125121        if (self->ref_cnt < 1) { 
    126122             
    127           if (self->stash != NULL) { 
    128             if (SWISH_DEBUG) { 
    129                 warn("decreasing refcnt on config->stash [currently %d]", 
    130                 SvREFCNT((SV*)SvRV((SV*)self->stash)) 
    131                 ); 
    132             } 
    133             while ( SvREFCNT((SV*)SvRV((SV*)self->stash)) > 0 ) { 
    134                 SvREFCNT_dec(self->stash); 
    135             } 
    136             self->stash = NULL; 
    137           } 
    138            
     123          sp_Stash_destroy( self->stash ); 
     124          //SWISH_WARN("set config stash to NULL"); 
     125          self->stash = NULL; 
    139126          swish_free_config( self ); 
    140127           
  • libswish3/trunk/bindings/perl/XS/Data.xs

    r2028 r2029  
    1414    CODE: 
    1515        self->s3->ref_cnt++; 
    16         class  = sp_hvref_fetch_as_char((SV*)self->s3->stash, SWISH3_CLASS_KEY); 
     16        class  = sp_hvref_fetch_as_char((SV*)self->s3->stash, SELF_CLASS_KEY); 
    1717        warn("s3 class = %s\n", class); 
    1818        RETVAL = sp_bless_ptr( class, (IV)self->s3 ); 
  • libswish3/trunk/bindings/perl/lib/SWISH/3.pm

    r2028 r2029  
    5656    } 
    5757 
    58     #defaults 
     58    # override defaults 
    5959    for my $param (qw( data_class parser_class config_class analyzer_class )) 
    6060    { 
    6161        my $method = 'set_' . $param; 
    6262 
    63         #warn "$method"; 
    64         $self->$method( $arg{$param} ) if exists $arg{param}; 
     63        if ( exists $arg{$param} ) { 
     64 
     65            #warn "$method"; 
     66            $self->$method( $arg{$param} ); 
     67        } 
    6568    } 
    6669 
     
    105108sub default_handler { 
    106109    my $data = shift; 
     110    unless ( $ENV{SWISH_DEBUG} ) { 
     111        warn "default handler called\n"; 
     112        return; 
     113    } 
    107114 
    108115    select(STDERR); 
  • libswish3/trunk/bindings/perl/macros.h

    r2028 r2029  
    2121#define PARSER_KEY          "sp_parser" 
    2222#define TOKEN_HANDLER_KEY   "sp_token_handler" 
    23 #define SWISH3_CLASS_KEY    "sp_self_class" 
     23#define SELF_CLASS_KEY      "sp_self_class" 
    2424 
    2525 
  • libswish3/trunk/bindings/perl/t/07-refcnt.t

    r2028 r2029  
    2121# avoid spurious mem error from libswish3 
    2222# just because of order of Perl ref cleanup 
    23 undef $analyzer; 
     23#undef $analyzer; 
    2424 
  • libswish3/trunk/bindings/perl/t/08-handler.t

    r2028 r2029  
    33use_ok('SWISH::3'); 
    44 
    5 ok( my $s3 = SWISH::3->new( handler => sub { diag("got data: $_[0] ") } ), 
    6 #ok( my $s3 = SWISH::3->new(  ), 
     5#ok( my $s3 = SWISH::3->new( handler => sub { diag("got data: $_[0] ") } ), 
     6ok( my $s3 = SWISH::3->new(  ), 
    77    "new parser" ); 
    88ok( $s3->parse("t/test.html"), "parse HTML" ); 
  • libswish3/trunk/bindings/perl/t/10tokenize.t

    r2028 r2029  
    3636} 
    3737 
    38 undef $analyzer; 
    39 undef $wlist; 
    40 undef $s3; 
     38#undef $analyzer; 
     39#undef $wlist; 
     40#undef $s3; 
  • libswish3/trunk/bindings/perl/t/11get_set_parser.t

    r2028 r2029  
    3838# avoid spurious libswish3 mem error due to "random" order of Perl 
    3939# SV cleanup 
    40 undef $analyzer; 
    41 undef $ana2; 
    42 undef $ana1; 
    43 undef $conf2; 
    44 undef $conf1; 
    45 undef $config; 
    46 undef $s3; 
     40#undef $analyzer; 
     41#undef $ana2; 
     42#undef $ana1; 
     43#undef $conf2; 
     44#undef $conf1; 
     45#undef $config; 
     46#undef $s3; 
    4747 
  • libswish3/trunk/bindings/perl/xs_helpers.c

    r2028 r2029  
    66/* C code to make writing XS easier */ 
    77 
    8 /* sp_Obj is a struct that makes refcounting easier */ 
    9  
    10 typedef struct sp_Obj sp_Obj; 
    11 struct sp_Obj  
    12 
    13     void    *c_ptr; 
    14     SV      *perl_obj; 
    15 }; 
    16  
    17 static SV*      sp_hv_store( HV* h, const char* key, SV* val); 
    18 static SV*      sp_hvref_store( SV* h, const char* key, SV* val); 
     8static SV*      sp_hv_store( HV* h, const char* key, SV* val ); 
     9static SV*      sp_hv_store_char( HV* h, const char* key, char *val ); 
     10static SV*      sp_hvref_store( SV* h, const char* key, SV* val ); 
     11static SV*      sp_hvref_store_char( SV* h, const char* key, char *val ); 
    1912static SV*      sp_hv_fetch( HV* h, const char* key ); 
    2013static SV*      sp_hvref_fetch( SV* h, const char* key ); 
     
    2518static SV*      sp_hv_delete( HV* h, const char* key ); 
    2619static SV*      sp_hvref_delete( SV* h, const char* key ); 
     20static void     sp_hv_replace( HV *h, char* key, SV* value ); 
    2721static void     sp_hvref_replace( SV * hashref, char* key, SV* value ); 
    2822static SV*      sp_bless_ptr( char* CLASS, IV c_ptr ); 
    2923static char*    sp_get_objects_class( SV* object ); 
    30 static HV*      sp_extract_hash_from_object( SV* object ); 
     24static HV*      sp_extract_hash( SV* object ); 
    3125static void     sp_dump_hash( SV* hash_ref ); 
    3226static void     sp_describe_object( SV* object ); 
     
    4943static swish_Analyzer*  sp_new_analyzer(); 
    5044 
    51 static sp_Obj*  sp_new_Obj( char* class, void* c_ptr); 
    52 static SV*      sp_Obj_to_perl(sp_Obj* self); 
    53 static void     sp_Obj_inc_refcount(sp_Obj *self); 
    54 static void     sp_Obj_dec_refcount(sp_Obj *self); 
    55 static int      sp_Obj_get_refcount(sp_Obj *self); 
     45/* implements nearly all methods for SWISH::3::Stash, a private class */ 
     46 
     47static SV*      sp_Stash_new(); 
     48static void     sp_Stash_set( SV *object, const char *key, SV *value ); 
     49static void     sp_Stash_set_char( SV *object, const char *key, char *value ); 
     50static SV*      sp_Stash_get( SV *object, const char *key ); 
     51static char*    sp_Stash_get_char( SV *object, const char *key ); 
     52static void     sp_Stash_replace( SV *object, const char *key, SV *value ); 
     53static int      sp_Stash_inner_refcnt( SV *object ); 
     54static void     sp_Stash_destroy( SV *object ); 
     55 
     56static SV* 
     57sp_Stash_new() 
     58
     59    HV *hash; 
     60    SV *object; 
     61    hash    = newHV(); 
     62    object  = sv_bless( newRV((SV*)hash), gv_stashpv("SWISH::3::Stash",0) ); 
     63    //SvREFCNT_dec( hash ); 
     64    return object; 
     65
     66 
     67static void 
     68sp_Stash_set( SV *object, const char *key, SV *value ) 
     69
     70    HV *hash; 
     71    hash = sp_extract_hash( object ); 
     72    sp_hv_store( hash, key, value ); 
     73
     74 
     75static void 
     76sp_Stash_set_char( SV *object, const char *key, char *value ) 
     77
     78    HV *hash; 
     79    hash = sp_extract_hash( object ); 
     80    sp_hv_store_char( hash, key, value ); 
     81
     82 
     83static SV* 
     84sp_Stash_get( SV *object, const char *key ) 
     85
     86    HV *hash; 
     87    hash = sp_extract_hash( object ); 
     88    //return SvREFCNT_inc( sp_hv_fetch( hash, key ) ); 
     89    return sp_hv_fetch( hash, key ); 
     90
     91 
     92static char* 
     93sp_Stash_get_char( SV *object, const char *key ) 
     94
     95    HV *hash; 
     96    hash = sp_extract_hash( object ); 
     97    return sp_hv_fetch_as_char( hash, key ); 
     98
     99 
     100static void 
     101sp_Stash_replace( SV *object, const char *key, SV *value ) 
     102
     103    HV *hash; 
     104    hash = sp_extract_hash( object ); 
     105    return sp_hv_replace( hash, (char*)key, value ); 
     106
    56107 
    57108static int 
    58 sp_Obj_get_refcount(sp_Obj *self) 
    59 
    60     return SvREFCNT(self->perl_obj); 
    61 
    62  
    63 static void 
    64 sp_Obj_inc_refcount(sp_Obj *self) 
    65 
    66     SvREFCNT_inc(self->perl_obj); 
    67 
    68  
    69 static void 
    70 sp_Obj_dec_refcount(sp_Obj *self) 
    71 
    72     /* If the SV's refcount falls to 0, DESTROY will be invoked from 
    73      * Perl-space. 
    74      */ 
    75     SvREFCNT_dec(self->perl_obj); 
    76 
    77  
    78  
    79 static sp_Obj*   
    80 sp_new_Obj( char *class, void *c_ptr ) 
    81 
    82     sp_Obj* self; 
    83     SV*     perl_obj; 
    84      
    85     self        = swish_xmalloc(sizeof(sp_Obj*)); 
    86     self->c_ptr = c_ptr; 
    87      
    88     /* init a new perl object wrapping the sp_Obj ptr */ 
    89     perl_obj = newSV(0); 
    90     sv_setref_pv(perl_obj, class, self); 
    91      
    92     /* make a reference to the object and save the reference */ 
    93     self->perl_obj = SvRV(perl_obj); 
    94      
    95     /* increment ref count of the inner object (perl_obj) */ 
    96     sp_Obj_inc_refcount(self); 
    97      
    98     /* decrement the outer object (RV) so that it is DESTROYed 
    99        by Perl when we return self 
    100     */ 
    101     SvREFCNT_dec(perl_obj); 
    102      
    103     /* self contains the original c_ptr and a perl SV 
    104        which is a wrapper around self. This means we use Perl's 
    105        reference counting feature to control when our sp_Obj ptr 
    106        is DESTROYed. 
    107     */ 
    108      
    109     return self; 
    110 
    111  
    112 static SV* 
    113 sp_Obj_to_perl( sp_Obj* self ) 
    114 
    115     return newRV_inc(self->perl_obj); 
    116 
     109sp_Stash_inner_refcnt( SV *object ) 
     110
     111    return SvREFCNT((SV*)SvRV((SV*)object)); 
     112
     113 
     114static void 
     115sp_Stash_destroy( SV *object ) 
     116
     117    HV *hash; 
     118    hash = sp_extract_hash( object ); 
     119    if ( SWISH_DEBUG ) { 
     120        warn("Stash_destroy Stash object %s for class %s [%d]",  
     121            SvPV(object, PL_na), sp_hv_fetch_as_char(hash, SELF_CLASS_KEY), object); 
     122        warn("Stash object refcnt = %d", SvREFCNT(object)); 
     123        warn("Stash hash   refcnt = %d", SvREFCNT(hash)); 
     124    } 
     125    hv_undef(hash); 
     126    //sp_describe_object( object ); 
     127    if (SvREFCNT( hash )) { 
     128        SvREFCNT_dec( hash ); 
     129    } 
     130    if (SvREFCNT( object ) ) { 
     131        SvREFCNT_dec( object ); 
     132    } 
     133
     134 
    117135 
    118136static void 
     
    149167    return *ok; 
    150168} 
     169 
     170static SV* 
     171sp_hv_store_char( HV* h, const char *key, char *val) 
     172{ 
     173    dTHX; 
     174    SV *value; 
     175    value = newSVpv(val, 0); 
     176    sp_hv_store( h, key, value ); 
     177    SvREFCNT_dec(value); 
     178    return value; 
     179} 
     180 
    151181static SV* 
    152182sp_hvref_store( SV* h, const char* key, SV* val) 
    153183{ 
    154184    return sp_hv_store( (HV*)SvRV(h), key, val ); 
     185} 
     186 
     187static SV* 
     188sp_hvref_store_char( SV* h, const char* key, char *val) 
     189{ 
     190    return sp_hv_store_char( (HV*)SvRV(h), key, val ); 
    155191} 
    156192 
     
    258294    dTHX; 
    259295    char* class = sv_reftype(SvRV(object), 1); 
    260     warn("object belongs to %s\n", class); 
     296    //warn("object belongs to %s\n", class); 
    261297    return class; 
    262298} 
    263299 
    264300static HV*  
    265 sp_extract_hash_from_object( SV* object ) 
    266 
    267     dTHX; 
    268     HV* hash = NULL; 
    269     char* class = sp_get_objects_class( object ); 
     301sp_extract_hash( SV* object ) 
     302
     303    dTHX; 
     304    HV* hash; 
     305    char* class; 
     306     
     307    class = sp_get_objects_class( object ); 
    270308    if (SvROK(object) && SvTYPE(SvRV(object))==SVt_PVHV) 
    271309        hash = (HV*)SvRV(object); 
     
    355393    char* class = sp_get_objects_class( object ); 
    356394    //warn("looking for %s in %s\n", name, class); 
    357     HV* hash = sp_extract_hash_from_object( object ); 
     395    HV* hash = sp_extract_hash( object ); 
    358396    SV* sv   = sp_hv_fetch( hash, (const char*)name ); 
    359397     
     
    362400         
    363401    return sv; 
     402} 
     403 
     404static void 
     405sp_hv_replace( HV *hash, char *key, SV *value ) 
     406{ 
     407    if (sp_hv_exists(hash, key)) { 
     408        sp_hv_delete(hash, key); 
     409    } 
     410    sp_hv_store( hash, key, value ); 
    364411} 
    365412 
     
    720767    config = swish_init_config(); 
    721768    config->ref_cnt++; 
    722     //config->stash = newRV_inc((SV*)stash); 
    723     //sp_hvref_store( config->stash, SELF_KEY, sp_bless_ptr(CONFIG_CLASS, (IV)config) ); 
     769    config->stash = sp_Stash_new(); 
    724770     
    725771    return config;