def hash_update(ptr, ikey, skey, key_is_str, ptr2): ht = _cast_ptr_to_ht(ptr) zval = _cast_ptr_to_zval(ptr2) zval_ptr = zval_utils.zp_stack(zval) zval_ptr_ptr = zval_utils.zpp_stack(zval) # TODO: ADDREF on zval??? if key_is_str: ms = objects.MutableString.from_string_data(skey) res = happy_hash.zend_hash_update(ht, ms, 1, zval_ptr_ptr, 0, global_state.null_zval_ptr_ptr_ptr) else: res = happy_hash.zend_hash_index_update( ht, ikey, zval_ptr_ptr, 0, global_state.null_zval_ptr_ptr_ptr) return res == happy_hash.SUCCESS
def hash_update(ptr, ikey, skey, key_is_str, ptr2): ht = _cast_ptr_to_ht(ptr) zval = _cast_ptr_to_zval(ptr2) zval_ptr = zval_utils.zp_stack(zval) zval_ptr_ptr = zval_utils.zpp_stack(zval) # TODO: ADDREF on zval??? if key_is_str: ms = objects.MutableString.from_string_data(skey) res = happy_hash.zend_hash_update(ht, ms, 1, zval_ptr_ptr, 0, global_state.null_zval_ptr_ptr_ptr) else: res = happy_hash.zend_hash_index_update(ht, ikey, zval_ptr_ptr, 0, global_state.null_zval_ptr_ptr_ptr) return res == happy_hash.SUCCESS
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)