|
836 | 836 | IO_VALUEREF_ARRAY_EMPTY, |
837 | 837 | IO_VALUEREF_ARRAY_SEQUENCE, |
838 | 838 | IO_VALUEREF_ARRAY_MAP, |
| 839 | + IO_VALUEREF_LIST_EMPTY, |
| 840 | + IO_VALUEREF_LIST_ANY, |
839 | 841 | }; |
840 | 842 |
|
841 | 843 | 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) |
933 | 935 | } |
934 | 936 | } |
935 | 937 | 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; |
936 | 955 | default: |
937 | 956 | MCAssert(false); |
938 | 957 | return IO_ERROR; |
@@ -1090,7 +1109,43 @@ IO_stat IO_read_valueref_new(MCValueRef& r_value, IO_handle p_stream) |
1090 | 1109 | t_mutable_array != nil) |
1091 | 1110 | MCValueRelease(t_mutable_array); |
1092 | 1111 | } |
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; |
1094 | 1149 | // AL-2014-08-04: [[ Bug 13056 ]] Return IO_ERROR if we don't read a valid type |
1095 | 1150 | default: |
1096 | 1151 | return IO_ERROR; |
|
0 commit comments