Esempio n. 1
0
def php_array_element_dump(zv, num_args, args, hash_key):
    level = args[0]

    if isinstance(hash_key, happy_hash.HashTableIntKey):
        zend_write(MutableString((level + 1) * ' ' + ('[%d]' % hash_key.intval) + '=>\n'), 0)
    elif isinstance(hash_key, happy_hash.HashTableStringKey):
        zend_write(MutableString((level + 1) * ' ' + ('["%s"]' % hash_key.strval.to_str()) + '=>\n'), 0)
    else:
        assert False
    php_var_dump(zv.deref(), level + 2)
    return 0
Esempio n. 2
0
def php_array_element_dump(zv, num_args, args, hash_key):
    level = args[0]

    if isinstance(hash_key, happy_hash.HashTableIntKey):
        zend_write(
            MutableString((level + 1) * ' ' + ('[%d]' % hash_key.intval) +
                          '=>\n'), 0)
    elif isinstance(hash_key, happy_hash.HashTableStringKey):
        zend_write(
            MutableString((level + 1) * ' ' +
                          ('["%s"]' % hash_key.strval.to_str()) + '=>\n'), 0)
    else:
        assert False
    php_var_dump(zv.deref(), level + 2)
    return 0
Esempio n. 3
0
def php_var_dump(struc, level):
    zval_element_dump_func = None

    if level > 1:
        zend_write(MutableString((level - 1) * ' '), 0)

    if zval_utils.Z_TYPE_P(struc) == IS_LONG:
        zend_write(
            MutableString('%sint(%d)\n' %
                          (COMMON(struc), zval_utils.Z_LVAL_P(struc))), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_BOOL:
        zend_write(
            MutableString('%sbool(%s)\n' %
                          (COMMON(struc),
                           'true' if zval_utils.Z_LVAL_P(struc) else 'false')),
            0)
    elif zval_utils.Z_TYPE_P(struc) == IS_DOUBLE:
        zend_write(
            MutableString('%sfloat(%s)\n' %
                          (COMMON(struc),
                           formatted_as_float(zval_utils.Z_DVAL_P(struc)))), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_STRING:
        zend_write(
            MutableString('%sstring(%d) "%s"\n' %
                          (COMMON(struc), zval_utils.Z_STRLEN_P(struc),
                           zval_utils.Z_STRVAL_P(struc).to_str())), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_ARRAY:
        myht = happy_operators.Z_ARRVAL_P(struc)
        # TODO: check nApplyCount
        zend_write(
            MutableString('%sarray(%d) {\n' %
                          (COMMON(struc),
                           happy_hash.zend_hash_num_elements(
                               happy_operators.Z_ARRVAL_P(struc)))), 0)
        php_element_dump_func = php_array_element_dump
        if myht:
            happy_hash.zend_hash_apply_with_arguments(myht,
                                                      php_element_dump_func, 1,
                                                      level)
            # TODO: dec nApplyCount
        if level > 1:
            zend_write(MutableString((level - 1) * ' '), 0)
        zend_write(MutableString('}\n'), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_NULL:
        zend_write(MutableString('NULL\n'), 0)
    else:
        raise Exception('Not implemented yet')
Esempio n. 4
0
def php_var_dump(struc, level):
    zval_element_dump_func = None

    if level > 1:
        zend_write(MutableString((level - 1) * ' '), 0)

    if zval_utils.Z_TYPE_P(struc) == IS_LONG:
        zend_write(MutableString('%sint(%d)\n' % (COMMON(struc), zval_utils.Z_LVAL_P(struc))), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_BOOL:
        zend_write(MutableString('%sbool(%s)\n' % (COMMON(struc), 'true' if zval_utils.Z_LVAL_P(struc) else 'false')), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_DOUBLE:
        zend_write(MutableString('%sfloat(%s)\n' % (COMMON(struc), formatted_as_float(zval_utils.Z_DVAL_P(struc)))), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_STRING:
        zend_write(MutableString('%sstring(%d) "%s"\n' %
            (COMMON(struc), zval_utils.Z_STRLEN_P(struc), zval_utils.Z_STRVAL_P(struc).to_str())), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_ARRAY:
        myht = happy_operators.Z_ARRVAL_P(struc)
        # TODO: check nApplyCount
        zend_write(MutableString('%sarray(%d) {\n' %
            (COMMON(struc), happy_hash.zend_hash_num_elements(happy_operators.Z_ARRVAL_P(struc)))), 0)
        php_element_dump_func = php_array_element_dump
        if myht:
            happy_hash.zend_hash_apply_with_arguments(myht, php_element_dump_func, 1, level)
            # TODO: dec nApplyCount
        if level > 1:
            zend_write(MutableString((level - 1) * ' '), 0)
        zend_write(MutableString('}\n'), 0)
    elif zval_utils.Z_TYPE_P(struc) == IS_NULL:
        zend_write(MutableString('NULL\n'), 0)
    else:
        raise Exception('Not implemented yet')