def zend_make_printable_zval(expr, expr_copy):
    if zval_utils.Z_TYPE_P(expr) == IS_STRING:
        return False
    if zval_utils.Z_TYPE_P(expr) == IS_NULL:
        zval_utils.Z_SET_STRVAL_P(expr_copy, objects.MutableString(''))
    elif zval_utils.Z_TYPE_P(expr) == IS_BOOL:
        if zval_utils.Z_LVAL_P(expr):
            zval_utils.Z_SET_STRVAL_P(expr_copy, objects.MutableString('1'))
        else:
            zval_utils.Z_SET_STRVAL_P(expr_copy, objects.MutableString(''))
    elif zval_utils.Z_TYPE_P(expr) == IS_RESOURCE:
        raise Exception('Not implemented yet')
    elif zval_utils.Z_TYPE_P(expr) == IS_ARRAY:
        raise Exception('Not implemented yet')
    elif zval_utils.Z_TYPE_P(expr) == IS_OBJECT:
        raise Exception('Not implemented yet')
    elif zval_utils.Z_TYPE_P(expr) == IS_DOUBLE:
        expr_copy.assign(expr.deref())
        from happy_variables import zval_copy_ctor
        from happy_operators import zend_locale_sprintf_double
        zval_copy_ctor(expr_copy)
        zend_locale_sprintf_double(expr_copy)
    else:
        expr_copy.assign(expr.deref())
        from happy_variables import zval_copy_ctor
        zval_copy_ctor(expr_copy)
        from happy_operators import convert_to_string
        convert_to_string(expr_copy)
    zval_utils.Z_SET_TYPE_P(expr_copy, IS_STRING)
    return True
def zend_make_printable_zval(expr, expr_copy):
    if zval_utils.Z_TYPE_P(expr) == IS_STRING:
        return False
    if zval_utils.Z_TYPE_P(expr) == IS_NULL:
        zval_utils.Z_SET_STRVAL_P(expr_copy, objects.MutableString(''))
    elif zval_utils.Z_TYPE_P(expr) == IS_BOOL:
        if zval_utils.Z_LVAL_P(expr):
            zval_utils.Z_SET_STRVAL_P(expr_copy, objects.MutableString('1'))
        else:
            zval_utils.Z_SET_STRVAL_P(expr_copy, objects.MutableString(''))
    elif zval_utils.Z_TYPE_P(expr) == IS_RESOURCE:
        raise Exception('Not implemented yet')
    elif zval_utils.Z_TYPE_P(expr) == IS_ARRAY:
        raise Exception('Not implemented yet')
    elif zval_utils.Z_TYPE_P(expr) == IS_OBJECT:
        raise Exception('Not implemented yet')
    elif zval_utils.Z_TYPE_P(expr) == IS_DOUBLE:
        expr_copy.assign(expr.deref())
        from happy_variables import zval_copy_ctor
        from happy_operators import zend_locale_sprintf_double
        zval_copy_ctor(expr_copy)
        zend_locale_sprintf_double(expr_copy)
    else:
        expr_copy.assign(expr.deref())
        from happy_variables import zval_copy_ctor
        zval_copy_ctor(expr_copy)
        from happy_operators import convert_to_string
        convert_to_string(expr_copy)
    zval_utils.Z_SET_TYPE_P(expr_copy, IS_STRING)
    return True
Example #3
0
def SEPARATE_ZVAL(ppzv):
    assert isinstance(ppzv, objects.zval_ptr_ptr)
    orig_ptr = ppzv.deref()
    if Z_REFCOUNT_P(orig_ptr) > 1:
        Z_DELREF_P(orig_ptr)
        ppzv.assign(zp_stack(zval_copy(orig_ptr.deref())))
        from happy_variables import zval_copy_ctor
        zval_copy_ctor(ppzv.deref())
        Z_SET_REFCOUNT_PP(ppzv, 1)
        Z_UNSET_ISREF_PP(ppzv)
def SEPARATE_ZVAL(ppzv):
    assert isinstance(ppzv, objects.zval_ptr_ptr)
    orig_ptr = ppzv.deref()
    if Z_REFCOUNT_P(orig_ptr) > 1:
        Z_DELREF_P(orig_ptr)
        ppzv.assign(zp_stack(zval_copy(orig_ptr.deref())))
        from happy_variables import zval_copy_ctor

        zval_copy_ctor(ppzv.deref())
        Z_SET_REFCOUNT_PP(ppzv, 1)
        Z_UNSET_ISREF_PP(ppzv)
def zend_get_constant(name, name_len, result):
    # TODO: make it correct
    assert isinstance(name, MutableString)
    assert isinstance(result, zval_ptr)
    import global_state

    c_ptr = zend_constant_ptr_ptr(const_null_ptr, False)
    retval = True

    if happy_hash.zend_hash_find(global_state.EG.zend_constants, name, name_len + 1, c_ptr) == FAILURE:
        retval = False

    if retval:
        result.assign(c_ptr.deref().deref().value.deref())
        happy_variables.zval_copy_ctor(result)
        zval_utils.Z_SET_REFCOUNT_P(result, 1)
        zval_utils.Z_UNSET_ISREF_P(result)

    return retval
Example #6
0
def i_zval_copy_ctor(zvalue):
    assert isinstance(zvalue, objects.zval_ptr)
    from happy_variables import zval_copy_ctor
    zval_copy_ctor(zvalue)
def i_zval_copy_ctor(zvalue):
    assert isinstance(zvalue, objects.zval_ptr)
    from happy_variables import zval_copy_ctor

    zval_copy_ctor(zvalue)