| 148 | } |
| 149 | |
| 150 | static Object::Ptr SerializeObject(const Object::Ptr& input, int attributeTypes, SerializeStack& stack, bool dryRun) |
| 151 | { |
| 152 | Type::Ptr type = input->GetReflectionType(); |
| 153 | |
| 154 | if (!type) |
| 155 | return nullptr; |
| 156 | |
| 157 | DictionaryData fields; |
| 158 | |
| 159 | if (!dryRun) { |
| 160 | fields.reserve(type->GetFieldCount() + 1); |
| 161 | } |
| 162 | |
| 163 | ObjectLock olock(input); |
| 164 | |
| 165 | for (int i = 0; i < type->GetFieldCount(); i++) { |
| 166 | Field field = type->GetFieldInfo(i); |
| 167 | |
| 168 | if (attributeTypes != 0 && (field.Attributes & attributeTypes) == 0) |
| 169 | continue; |
| 170 | |
| 171 | if (strcmp(field.Name, "type") == 0) |
| 172 | continue; |
| 173 | |
| 174 | Value value = input->GetField(i); |
| 175 | stack.Push(field.Name, value); |
| 176 | |
| 177 | auto serialized (SerializeInternal(value, attributeTypes, stack, dryRun)); |
| 178 | |
| 179 | if (!dryRun) { |
| 180 | fields.emplace_back(field.Name, std::move(serialized)); |
| 181 | } |
| 182 | |
| 183 | stack.Pop(); |
| 184 | } |
| 185 | |
| 186 | if (!dryRun) { |
| 187 | fields.emplace_back("type", type->GetName()); |
| 188 | } |
| 189 | |
| 190 | return dryRun ? nullptr : new Dictionary(std::move(fields)); |
| 191 | } |
| 192 | |
| 193 | static Array::Ptr DeserializeArray(const Array::Ptr& input, bool safe_mode, int attributeTypes) |
| 194 | { |
no test coverage detected