Changeset 196 in svn for trunk


Ignore:
Timestamp:
2006-09-24T08:02:43Z (9 years ago)
Author:
Xuefer
Message:

fix #36, wrong inheriting static class variables

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/processor/hashtable.m4

    r58 r196  
    1 dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname])
     1dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname] [, 4:check_function])
    22define(`DEF_HASH_TABLE_FUNC', `
    33    DEF_STRUCT_P_FUNC(`HashTable', `$1', `
     
    9494
    9595        for (b = src->pListHead; b != NULL; b = b->pListNext) {
     96            ifelse(`$4', `', `', `
     97                pushdef(`BUCKET', `b')
     98                if ($4 == ZEND_HASH_APPLY_REMOVE) {
     99                    IFCOPY(`dst->nNumOfElements --;')
     100                    continue;
     101                }
     102                popdef(`BUCKET')
     103          ')
     104         
    96105            IFCALCCOPY(`bucketsize = BUCKET_SIZE(b);')
    97106            ALLOC(pnew, char, bucketsize, , Bucket)
  • trunk/processor/head.m4

    r195 r196  
    247247}
    248248/* }}} */
     249static int xc_hash_static_member_check(xc_processor_t *processor, Bucket *b TSRMLS_DC) /* {{{ */
     250{
     251    zend_class_entry *src = processor->active_class_entry_src;
     252    if (src->parent) {
     253        zval **srczv;
     254        if (zend_hash_quick_find(CE_STATIC_MEMBERS(src), b->arKey, b->nKeyLength, b->h, (void **) &srczv) == SUCCESS) {
     255            zval **zv = (zval **) b->pData;
     256            if (*srczv == *zv) {
     257                return ZEND_HASH_APPLY_REMOVE;
     258            }
     259        }
     260    }
     261    return ZEND_HASH_APPLY_KEEP;
     262}
     263/* }}} */
     264/* fix static members on restore */
     265static void inherit_static_prop(zval **p) /* {{{ */
     266{
     267    (*p)->refcount++;
     268    (*p)->is_ref = 1;
     269}
     270/* }}} */
     271static void xc_fix_static_members(xc_processor_t *processor, zend_class_entry *dst TSRMLS_DC) /* {{{ */
     272{
     273    zend_class_entry *parent_ce = dst->parent;
     274    if (parent_ce->type != dst->type) {
     275        /* User class extends internal class */
     276        zend_update_class_constants(parent_ce  TSRMLS_CC);
     277        zend_hash_merge(&dst->default_static_members, CE_STATIC_MEMBERS(parent_ce), (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
     278    }
     279    else {
     280        zend_hash_merge(&dst->default_static_members, &parent_ce->default_static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
     281    }
     282
     283    /*
     284    HashPosition pos;
     285    HashTable *pmembers = CE_STATIC_MEMBERS(dst->parent);
     286    zval **zv;
     287    for (zend_hash_internal_pointer_reset_ex(pmembers, &pos);
     288            zend_hash_get_current_data_ex(pmembers, (void **) &zv, &pos) == SUCCESS;
     289            zend_hash_move_forward_ex(pmembers, &pos)) {
     290            if (zend_hash_quick_find(parent->static_members, p->arKey, p->nKeyLength, p->h, &pprop.ptr) == SUCCESS) {
     291            }
     292    }
     293    */
     294}
     295/* }}} */
    249296#endif
    250297/* {{{ call op_array ctor handler */
  • trunk/processor/processor.m4

    r194 r196  
    6565dnl }}}
    6666DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr')
     67DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr_static_member_check',  `zval_ptr', , `xc_hash_static_member_check(processor, BUCKET TSRMLS_CC)')
    6768#ifdef HAVE_XCACHE_CONSTANT
    6869DEF_HASH_TABLE_FUNC(`HashTable_zend_constant',      `zend_constant')
     
    297298    STRUCT(HashTable, properties_info, HashTable_zend_property_info)
    298299#   ifdef ZEND_ENGINE_2_1
    299     STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
     300    STRUCT(HashTable, default_static_members, IFSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr))
    300301    IFCOPY(`dst->static_members = &dst->default_static_members;')
     302    IFRESTORE(`if (dst->parent) xc_fix_static_members(processor, dst TSRMLS_CC);')
    301303    DONE(static_members)
    302304#   else
    303     STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
     305    STRUCT_P(HashTable, static_members, IFSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr))
    304306#   endif
    305307    STRUCT(HashTable, constants_table, HashTable_zval_ptr)
  • trunk/xcache.c

    r190 r196  
    24622462static startup_func_t xc_last_ext_startup;
    24632463static zend_llist_element *xc_llist_element;
    2464 static xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
     2464static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
    24652465{
    24662466    return p1 == p2;
Note: See TracChangeset for help on using the changeset viewer.