- Mode debug info

This commit is contained in:
Marcus Boerger 2007-01-20 16:19:20 +00:00
parent 512f5dafb8
commit ab2c4ffe54
7 changed files with 146 additions and 52 deletions

View File

@ -629,8 +629,9 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /*
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(obj TSRMLS_CC);
HashTable *rv;
zval *tmp, *storage;
int name_len, class_len, prop_len;
zstr zname, zclass, zprop;
int name_len;
zstr zname;
zend_class_entry *base;
if (HASH_OF(intern->array) == intern->std.properties) {
*is_temp = 0;
@ -646,28 +647,10 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /*
storage = intern->array;
zval_add_ref(&storage);
if (Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator) {
zclass.s = "ArrayIterator";
class_len = sizeof("ArrayIterator") - 1;
} else {
zclass.s = "ArrayObject";
class_len = sizeof("ArrayObject") - 1;
}
zprop.s = "storage";
prop_len = sizeof("storage") - 1;
if (UG(unicode)) {
zclass.u = zend_ascii_to_unicode(zclass.s, class_len + 1 ZEND_FILE_LINE_CC);
zprop.u = zend_ascii_to_unicode(zprop.s, prop_len + 1 ZEND_FILE_LINE_CC);
zend_u_mangle_property_name(&zname, &name_len, IS_UNICODE, zclass, class_len, zprop, prop_len, 0);
zend_u_symtable_update(rv, IS_UNICODE, zname, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname.v);
efree(zclass.v);
efree(zprop.v);
} else {
zend_mangle_property_name(&zname.s, &name_len, zclass.s, class_len, zprop.s, prop_len, 0);
zend_symtable_update(rv, zname.s, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname.v);
}
base = (Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator) ? spl_ce_ArrayIterator : spl_ce_ArrayObject;
zname = spl_gen_private_prop_name(base, "storage", sizeof("storage")-1, &name_len TSRMLS_CC);
zend_u_symtable_update(rv, ZEND_STR_TYPE, zname, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname.v);
return rv;
}

View File

@ -456,6 +456,57 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil
return NULL;
} /* }}} */
static HashTable* spl_filesystem_object_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{{ */
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(obj TSRMLS_CC);
HashTable *rv;
zval *tmp, zrv;
zstr pnstr;
int pnlen;
char stmp[2];
*is_temp = 1;
ALLOC_HASHTABLE(rv);
ZEND_INIT_SYMTABLE_EX(rv, zend_hash_num_elements(intern->std.properties) + 3, 0);
INIT_PZVAL(&zrv);
Z_ARRVAL(zrv) = rv;
zend_hash_copy(rv, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, "pathName", sizeof("pathName")-1, &pnlen TSRMLS_CC);
add_u_assoc_zstrl_ex(&zrv, ZEND_STR_TYPE, pnstr, pnlen+1, intern->path_type, intern->path, intern->path_len, 1);
efree(pnstr.v);
if (intern->file_name.v) {
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, "fileName", sizeof("fileName")-1, &pnlen TSRMLS_CC);
add_u_assoc_zstrl_ex(&zrv, ZEND_STR_TYPE, pnstr, pnlen+1, intern->file_name_type, intern->file_name, intern->file_name_len, 1);
efree(pnstr.v);
}
if (intern->type == SPL_FS_DIR && intern->u.dir.sub_path.v) {
pnstr = spl_gen_private_prop_name(spl_ce_RecursiveDirectoryIterator, "subPathName", sizeof("subPathName")-1, &pnlen TSRMLS_CC);
add_u_assoc_zstrl_ex(&zrv, ZEND_STR_TYPE, pnstr, pnlen+1, intern->u.dir.sub_path_type, intern->u.dir.sub_path, intern->u.dir.sub_path_len, 1);
efree(pnstr.v);
}
if (intern->type == SPL_FS_FILE) {
pnstr = spl_gen_private_prop_name(spl_ce_SplFileObject, "openMode", sizeof("openMode")-1, &pnlen TSRMLS_CC);
add_u_assoc_stringl_ex(&zrv, ZEND_STR_TYPE, pnstr, pnlen+1, intern->u.file.open_mode, intern->u.file.open_mode_len, 1);
efree(pnstr.v);
stmp[1] = '\0';
stmp[0] = intern->u.file.delimiter;
pnstr = spl_gen_private_prop_name(spl_ce_SplFileObject, "delimiter", sizeof("delimiter")-1, &pnlen TSRMLS_CC);
add_u_assoc_stringl_ex(&zrv, ZEND_STR_TYPE, pnstr, pnlen+1, stmp, 1, 1);
efree(pnstr.v);
stmp[0] = intern->u.file.enclosure;
pnstr = spl_gen_private_prop_name(spl_ce_SplFileObject, "enclosure", sizeof("enclosure")-1, &pnlen TSRMLS_CC);
add_u_assoc_stringl_ex(&zrv, ZEND_STR_TYPE, pnstr, pnlen+1, stmp, 1, 1);
efree(pnstr.v);
}
return rv;
}
/* }}}} */
/* {{{ proto void DirectoryIterator::__construct(string path) U
Cronstructs a new dir iterator from a path. */
SPL_METHOD(DirectoryIterator, __construct)
@ -2233,6 +2284,7 @@ PHP_MINIT_FUNCTION(spl_directory)
memcpy(&spl_filesystem_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
spl_filesystem_object_handlers.cast_object = spl_filesystem_object_cast;
spl_filesystem_object_handlers.get_debug_info = spl_filesystem_object_get_debug_info;
REGISTER_SPL_SUB_CLASS_EX(DirectoryIterator, SplFileInfo, spl_filesystem_object_new, spl_DirectoryIterator_functions);
zend_class_implements(spl_ce_DirectoryIterator TSRMLS_CC, 1, zend_ce_iterator);

View File

@ -144,6 +144,22 @@ int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int c
}
/* }}} */
zstr spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, int prop_len, int *name_len TSRMLS_DC) /* {{{ */
{
zstr rv;
zstr zprop;
if (UG(unicode)) {
zprop.u = zend_ascii_to_unicode(prop_name, prop_len + 1 ZEND_FILE_LINE_CC);
zend_u_mangle_property_name(&rv, name_len, IS_UNICODE, ce->name, ce->name_length, zprop, prop_len, 0);
efree(zprop.v);
} else {
zend_mangle_property_name(&rv.s, name_len, ce->name.s, ce->name_length, prop_name, prop_len, 0);
}
return rv;
}
/* }}} */
/*
* Local variables:
* tab-width: 4

View File

@ -88,6 +88,9 @@ int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int c
PHP_MALIAS(spl_ ## alias_class, function_name, alias_function, arg_info, flags)
#endif /* PHP_FUNCTIONS_H */
/* caller must efree(return.v) */
zstr spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, int prop_len, int *name_len TSRMLS_DC);
/*
* Local Variables:
* c-basic-offset: 4

View File

@ -122,9 +122,9 @@ static HashTable* spl_object_storage_debug_infos(zval *obj, int *is_temp TSRMLS_
HashTable *rv, *props;
HashPosition pos;
zval *tmp, *storage, **entry;
char md5str[33], *name;
char md5str[33];
int name_len;
zstr zname, zclass, zprop;
zstr zname;
*is_temp = 1;
@ -145,19 +145,9 @@ static HashTable* spl_object_storage_debug_infos(zval *obj, int *is_temp TSRMLS_
zend_hash_move_forward_ex(&intern->storage, &pos);
}
if (UG(unicode)) {
zclass.u = USTR_MAKE("SplObjectStorage");
zprop.u = USTR_MAKE("storage");
zend_u_mangle_property_name(&zname, &name_len, IS_UNICODE, zclass, sizeof("SplObjectStorage")-1, zprop, sizeof("storage")-1, 0);
zend_u_symtable_update(rv, IS_UNICODE, zname, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname.v);
efree(zclass.v);
efree(zprop.v);
} else {
zend_mangle_property_name(&name, &name_len, "SplObjectStorage", sizeof("SplObjectStorage")-1, "storage", sizeof("storage")-1, 0);
zend_symtable_update(rv, name, name_len+1, &storage, sizeof(zval *), NULL);
efree(name);
}
zname = spl_gen_private_prop_name(spl_ce_SplObjectStorage, "storage", sizeof("storage")-1, &name_len TSRMLS_CC);
zend_u_symtable_update(rv, ZEND_STR_TYPE, zname, name_len+1, &storage, sizeof(zval *), NULL);
efree(zname.v);
return rv;
}

View File

@ -12,7 +12,9 @@ var_dump(is_string($d));
?>
===DONE===
--EXPECTF--
object(DirectoryIterator)#%d (0) {
object(DirectoryIterator)#%d (1) {
%s"pathName"%s"SplFileInfo":private]=>
%s(1) "."
}
bool(false)
bool(false)

View File

@ -45,9 +45,17 @@ test(dirname(__FILE__), substr(dirname(__FILE__),-1), 'l');
<?php exit(0); ?>
--EXPECTF--
===0===
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
string(%d) "%s"
["fileName":"SplFileInfo":private]=>
string(%d) "%sfileobject_001a.txt"
}
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
string(%d) "%s"
["fileName":"SplFileInfo":private]=>
string(%d) "%sfileobject_001a.txt"
}
bool(false)
bool(true)
@ -63,9 +71,17 @@ string(%d) "%sfileobject_001a.txt"
string(19) "fileobject_001a.txt"
string(%d) "%stests"
===1===
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
string(%d) "%s"
["fileName":"SplFileInfo":private]=>
string(%d) "%s"
}
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
string(%d) "%s"
["fileName":"SplFileInfo":private]=>
string(%d) "%s"
}
bool(false)
bool(true)
@ -81,9 +97,17 @@ string(%d) "%stests"
string(%d) "%stests"
string(%d) "%stests"
===2===
object(SplFileInfo)#1 (0) {
object(SplFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
string(%d) "%s"
["fileName":"SplFileInfo":private]=>
string(%d) "%s"
}
object(SplFileInfo)#2 (0) {
object(SplFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
string(%d) "%s"
["fileName":"SplFileInfo":private]=>
string(%d) "%s"
}
bool(false)
bool(true)
@ -101,9 +125,17 @@ string(%d) "%sspl"
===DONE===
--UEXPECTF--
===0===
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
[u"pathName":u"SplFileInfo":private]=>
unicode(%d) "%s"
[u"fileName":u"SplFileInfo":private]=>
unicode(%d) "%sfileobject_001a.txt"
}
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
[u"pathName":u"SplFileInfo":private]=>
unicode(%d) "%s"
[u"fileName":u"SplFileInfo":private]=>
unicode(%d) "%sfileobject_001a.txt"
}
bool(false)
bool(true)
@ -119,9 +151,17 @@ unicode(%d) "%sfileobject_001a.txt"
unicode(19) "fileobject_001a.txt"
unicode(%d) "%stests"
===1===
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
[u"pathName":u"SplFileInfo":private]=>
unicode(%d) "%s"
[u"fileName":u"SplFileInfo":private]=>
unicode(%d) "%s"
}
object(SplFileInfo)#%d (0) {
object(SplFileInfo)#%d (2) {
[u"pathName":u"SplFileInfo":private]=>
unicode(%d) "%s"
[u"fileName":u"SplFileInfo":private]=>
unicode(%d) "%s"
}
bool(false)
bool(true)
@ -137,9 +177,17 @@ unicode(%d) "%stests"
unicode(%d) "%stests"
unicode(%d) "%stests"
===2===
object(SplFileInfo)#1 (0) {
object(SplFileInfo)#%d (2) {
[u"pathName":u"SplFileInfo":private]=>
unicode(%d) "%s"
[u"fileName":u"SplFileInfo":private]=>
unicode(%d) "%s"
}
object(SplFileInfo)#2 (0) {
object(SplFileInfo)#%d (2) {
[u"pathName":u"SplFileInfo":private]=>
unicode(%d) "%s"
[u"fileName":u"SplFileInfo":private]=>
unicode(%d) "%s"
}
bool(false)
bool(true)