Пример #1
0
def hash_get(ptr, ikey, skey, key_is_str):
    ht = _cast_ptr_to_ht(ptr)
    zval = zval_utils.make_empty_zval()
    retval_ptr = zval_utils.zppp_stack(global_state.null_zval_ptr_ptr)
    if key_is_str:
        ms = objects.MutableString.from_string_data(skey)
        res = happy_hash.zend_hash_find(ht, ms, 1, retval_ptr)
    else:
        res = happy_hash.zend_hash_index_find(ht, ikey, retval_ptr)
    if res == happy_hash.FAILURE:
        return zval_null
    return _return_retval(retval_ptr)
Пример #2
0
def hash_get(ptr, ikey, skey, key_is_str):
    ht = _cast_ptr_to_ht(ptr)
    zval = zval_utils.make_empty_zval()
    retval_ptr = zval_utils.zppp_stack(global_state.null_zval_ptr_ptr)
    if key_is_str:
        ms = objects.MutableString.from_string_data(skey)
        res = happy_hash.zend_hash_find(ht, ms, 1, retval_ptr)
    else:
        res = happy_hash.zend_hash_index_find(ht, ikey, retval_ptr)
    if res == happy_hash.FAILURE:
        return zval_null
    return _return_retval(retval_ptr)
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