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 hash_add(ptr, ikey, skey, key_is_str, ptr2): ht = _cast_ptr_to_ht(ptr) zval = _cast_ptr_to_zval(ptr2) if not zval: zval = zval_utils.make_empty_zval() zval_ptr = zval_utils.zp_stack(zval) zval_ptr_ptr = zval_utils.zpp_stack(zval_ptr) retval_ptr = zval_utils.zppp_stack(global_state.null_zval_ptr_ptr) # TODO: ADDREF on zval??? if key_is_str: ms = objects.MutableString.from_string_data(skey) res = happy_hash.zend_hash_add(ht, ms, 1, zval_ptr_ptr, 0, retval_ptr) else: res = happy_hash.zend_hash_index_update(ht, ikey, zval_ptr_ptr, 0, retval_ptr) if res == happy_hash.FAILURE: return zval_null return _return_retval(retval_ptr)