summaryrefslogtreecommitdiff
path: root/swift/src/Ice/SlicedData.swift
blob: c3eccc4c805b773f956415eb181d6a3a0a5d207b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

/// SlicedData holds the slices of unknown class or exception types.
public final class SlicedData {
    /// The details of each slice, in order of most-derived to least-derived.
    public private(set) var slices: [SliceInfo]

    init(slices: [SliceInfo]) {
        self.slices = slices
    }

    /// Clears the slices to break potential cyclic references.
    public func clear() {
        let copy = slices
        slices = [] // need to clear the slices before the loop to avoid recursive calls
        for slice in copy {
            for value in slice.instances {
                value.ice_getSlicedData()?.clear()
            }
        }
    }
}