[英]Eiffel: are the convert methods working in case of agent call arguments?
[英]eiffel type conformance and attachement check not working
尝试使用make_from_separate
解决 SCOOP 后果之一我遇到了一个问题,即在运行时类型似乎相同并且不会通过attached
的语句。
non_separate_from_any, any_from_separate (v: separate ANY): ANY
local
l_array: ARRAY[detachable ANY]
l_res_ll_arr_det_any: LINKED_LIST[ARRAY[detachable ANY]]
l_arr_det_str: ARRAY[detachable STRING]
do
if
attached {REAL} v as l_v
then
Result := l_v
elseif attached {separate INTEGER_32_REF} v as l_v then
Result := l_v.as_integer_32
elseif attached {INTEGER} v as l_v then
Result := l_v
elseif attached {separate STRING} v as l_v then
create {STRING} Result.make_from_separate (l_v)
elseif attached {separate STRING_32} v as l_v then
create {STRING_32} Result.make_from_separate (l_v)
elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
create l_res_ll_arr_det_any.make
across
l_v is l_list_item_sep
loop
create l_array.make_empty
separate l_list_item_sep as l_list_item_sep_tmp do
across
l_list_item_sep_tmp as l_array_item_non_sep
loop
if attached l_array_item_non_sep as l_any_sep then
l_array.put (non_separate_from_any (l_any_sep), l_array_item_non_sep.cursor_index)
else
l_array.put (Void, l_array_item_non_sep.cursor_index)
end
end
end
l_res_ll_arr_det_any.extend (l_array)
end
Result := l_res_ll_arr_det_any
elseif attached {separate ARRAY[detachable STRING]} v as l_v then
create l_arr_det_str.make_empty
across
l_v as l_s_sep
loop
if attached l_s_sep.item as l_s_sep_att then
l_arr_det_str.put (create {STRING}.make_from_separate (l_s_sep_att), l_s_sep.cursor_index)
else
l_arr_det_str.put (Void, l_s_sep.cursor_index)
end
end
Result := l_arr_det_str
else
check
implement_me: False
then
do_nothing
end
end
ensure
instance_free: Class
end
声明如下:
DB_TUPLE_COL_NAMES -> items: ARRAY[STRING]
DEFAULT_DB_ACTION -> column_names: separate like {DB_TUPLE_COL_NAMES}.items
DEFAULT_DB_ACTION -> make_from_separate (other: separate like Current)
在运行时我得到了other.column_names -> at runtime: ARRAY[detachable STRING]
看起来 object 的实际类型是ARRAY [detachable STRING]
而不是ARRAY [STRING]
。
改变
elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
create ll_arr_det_any.make -- l_arr_det_str: ARRAY[detachable STRING]
和
elseif attached {separate LINKED_LIST[separate ARRAY[detachable ANY]]} v as l_v then
create l_arr_str.make -- l_arr_det_str: ARRAY[STRING]
我的错误是{SCOOP_UTIL}.any_from_separate
。
作为
{separate LINKED_LIST[separate ARRAY[ANY]]}
符合
{separate LINKED_LIST[separate ARRAY[detachable ANY]]}
它正在走这条路,我解释说我必须创建一个
ARRAY[detachable ANY]
但它是一个ARRAY[ANY]
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.