From a7ad7cbd6ef77129bf67539c77a421d57b9c7786 Mon Sep 17 00:00:00 2001 From: Xuefer Date: Thu, 22 Mar 2012 18:18:05 +0000 Subject: [PATCH] PHP_5_4: improve handling traits yet still need review. values of default_properties_table is nullable git-svn-id: svn://svn.lighttpd.net/xcache/trunk@825 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- processor/head.m4 | 3 +++ processor/processor.m4 | 36 ++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/processor/head.m4 b/processor/head.m4 index fcf3340..6974250 100644 --- a/processor/head.m4 +++ b/processor/head.m4 @@ -28,6 +28,8 @@ define(`SIZEOF_zend_function', `sizeof(zend_function)') define(`COUNTOF_zend_function', `1') define(`SIZEOF_zval_ptr', `sizeof(zval_ptr)') define(`COUNTOF_zval_ptr', `1') +define(`SIZEOF_zval_ptr_nullable', `sizeof(zval_ptr_nullable)') +define(`COUNTOF_zval_ptr_nullable', `1') define(`SIZEOF_xc_entry_name_t', `sizeof(xc_entry_name_t)') define(`COUNTOF_xc_entry_name_t', `1') @@ -48,6 +50,7 @@ sinclude(builddir`/structinfo.m4') #endif typedef zval *zval_ptr; +typedef zval *zval_ptr_nullable; typedef zend_uchar zval_data_type; #ifdef IS_UNICODE typedef UChar zstr_uchar; diff --git a/processor/processor.m4 b/processor/processor.m4 index 64a8894..da40e31 100644 --- a/processor/processor.m4 +++ b/processor/processor.m4 @@ -2,6 +2,7 @@ dnl ================ /* {{{ Pre-declare */ DECL_STRUCT_P_FUNC(`zval') DECL_STRUCT_P_FUNC(`zval_ptr') +DECL_STRUCT_P_FUNC(`zval_ptr_nullable') DECL_STRUCT_P_FUNC(`zend_op_array') DECL_STRUCT_P_FUNC(`zend_class_entry') #ifdef HAVE_XCACHE_CONSTANT @@ -64,6 +65,7 @@ DEF_STRUCT_P_FUNC(`zend_brk_cont_element', , ` ') dnl }}} DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr', `zval_ptr') +DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr_nullable', `zval_ptr_nullable') DEF_HASH_TABLE_FUNC(`HashTable_zend_function', `zend_function') #ifdef ZEND_ENGINE_2 DEF_HASH_TABLE_FUNC(`HashTable_zend_property_info', `zend_property_info') @@ -214,6 +216,16 @@ DEF_STRUCT_P_FUNC(`zval_ptr', , `dnl {{{ DONE_SIZE(sizeof(zval_ptr)) ') dnl }}} +DEF_STRUCT_P_FUNC(`zval_ptr_nullable', , `dnl {{{ + if (src[0]) { + STRUCT_P_EX(zval_ptr, dst, src, `', `', ` ') + } + else { + IFCOPY(`COPYNULL_EX(src[0], src)') + } + DONE_SIZE(sizeof(zval_ptr_nullable)) +') +dnl }}} dnl {{{ zend_arg_info #ifdef ZEND_ENGINE_2 DEF_STRUCT_P_FUNC(`zend_arg_info', , ` @@ -327,9 +339,9 @@ DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{ #ifdef ZEND_ENGINE_2_4 DISPATCH(int, default_properties_count) - STRUCT_ARRAY(default_properties_count, zval_ptr, default_properties_table) + STRUCT_ARRAY(default_properties_count, zval_ptr_nullable, default_properties_table) DISPATCH(int, default_static_members_count) - STRUCT_ARRAY(default_static_members_count, zval_ptr, default_static_members_table) + STRUCT_ARRAY(default_static_members_count, zval_ptr_nullable, default_static_members_table) IFCOPY(`dst->static_members_table = dst->default_static_members_table;') DONE(static_members_table) #else @@ -354,21 +366,23 @@ DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{ if (src->num_interfaces) { CALLOC(dst->interfaces, zend_class_entry*, src->num_interfaces) DONE(`interfaces') + } + else { + COPYNULL(`interfaces') + } # ifdef ZEND_ENGINE_2_4 + if (src->num_traits) { CALLOC(dst->traits, zend_class_entry*, src->num_traits) DONE(`traits') DONE(`trait_aliases') DONE(`trait_precedences') -# endif } else { - COPYNULL(`interfaces') -# ifdef ZEND_ENGINE_2_4 COPYNULL(`traits') COPYNULL(`trait_aliases') COPYNULL(`trait_precedences') -# endif } +# endif ') IFDASM(` if (src->num_interfaces) { @@ -385,20 +399,22 @@ DEF_STRUCT_P_FUNC(`zend_class_entry', , `dnl {{{ add_assoc_zval_ex(dst, ZEND_STRS("interfaces"), arr); */ DONE(`interfaces') + } + else { + COPYNULL(`interfaces') + } # ifdef ZEND_ENGINE_2_4 + if (src->num_traits) { DONE(`traits') DONE(`trait_aliases') DONE(`trait_precedences') -# endif } else { - COPYNULL(`interfaces') -# ifdef ZEND_ENGINE_2_4 COPYNULL(`traits') COPYNULL(`trait_aliases') COPYNULL(`trait_precedences') -# endif } +# endif ') IFRESTORE(`', ` IFDASM(`', `