Skip to content

Commit a4e2582

Browse files
author
Fraser J. Gordon
committed
Merge branch 'modular' of https://github.com/runrev/livecode-widgets into modular
2 parents d835dce + fd69b28 commit a4e2582

1 file changed

Lines changed: 56 additions & 1 deletion

File tree

engine/src/mcio.cpp

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ enum
836836
IO_VALUEREF_ARRAY_EMPTY,
837837
IO_VALUEREF_ARRAY_SEQUENCE,
838838
IO_VALUEREF_ARRAY_MAP,
839+
IO_VALUEREF_LIST_EMPTY,
840+
IO_VALUEREF_LIST_ANY,
839841
};
840842

841843
IO_stat IO_write_valueref_new(MCValueRef p_value, IO_handle p_stream)
@@ -933,6 +935,23 @@ IO_stat IO_write_valueref_new(MCValueRef p_value, IO_handle p_stream)
933935
}
934936
}
935937
break;
938+
case kMCValueTypeCodeList:
939+
{
940+
if (MCProperListIsEmpty((MCProperListRef)p_value))
941+
t_stat = IO_write_uint1(IO_VALUEREF_LIST_EMPTY, p_stream);
942+
else
943+
{
944+
t_stat = IO_write_uint1(IO_VALUEREF_LIST_ANY, p_stream);
945+
if (t_stat == IO_NORMAL)
946+
t_stat = IO_write_uint4(MCProperListGetLength((MCProperListRef)p_value), p_stream);
947+
for(uindex_t i = 0; t_stat == IO_NORMAL && i < MCProperListGetLength((MCProperListRef)p_value); i++)
948+
{
949+
if (t_stat == IO_NORMAL)
950+
t_stat = IO_write_valueref_new(MCProperListFetchElementAtIndex((MCProperListRef)p_value, i), p_stream);
951+
}
952+
}
953+
}
954+
break;
936955
default:
937956
MCAssert(false);
938957
return IO_ERROR;
@@ -1090,7 +1109,43 @@ IO_stat IO_read_valueref_new(MCValueRef& r_value, IO_handle p_stream)
10901109
t_mutable_array != nil)
10911110
MCValueRelease(t_mutable_array);
10921111
}
1093-
break;
1112+
break;
1113+
case IO_VALUEREF_LIST_EMPTY:
1114+
r_value = MCValueRetain(kMCEmptyList);
1115+
break;
1116+
case IO_VALUEREF_LIST_ANY:
1117+
{
1118+
MCProperListRef t_mutable_list;
1119+
t_mutable_list = nil;
1120+
if (!MCProperListCreateMutable(t_mutable_list))
1121+
t_stat = IO_ERROR;
1122+
1123+
uint4 t_length;
1124+
if (t_stat == IO_NORMAL)
1125+
t_stat = IO_read_uint4(&t_length, p_stream);
1126+
for(uindex_t i = 0; t_stat == IO_NORMAL && i < t_length; i++)
1127+
{
1128+
MCValueRef t_element;
1129+
t_element = nil;
1130+
1131+
t_stat = IO_read_valueref_new(t_element, p_stream);
1132+
if (t_stat == IO_NORMAL &&
1133+
!MCProperListPushElementOntoBack(t_mutable_list, t_element))
1134+
t_stat = IO_ERROR;
1135+
1136+
if (t_element != nil)
1137+
MCValueRelease(t_element);
1138+
}
1139+
1140+
if (t_stat == IO_NORMAL &&
1141+
!MCProperListCopyAndRelease(t_mutable_list, (MCProperListRef&)r_value))
1142+
t_stat = IO_ERROR;
1143+
1144+
if (t_stat == IO_ERROR &&
1145+
t_mutable_list != nil)
1146+
MCValueRelease(t_mutable_list);
1147+
}
1148+
break;
10941149
// AL-2014-08-04: [[ Bug 13056 ]] Return IO_ERROR if we don't read a valid type
10951150
default:
10961151
return IO_ERROR;

0 commit comments

Comments
 (0)