SLTupleType ToTuple(SLImportModules modules, SwiftTupleType st)
        {
            List <SLNameTypePair> contents = st.Contents.Select(
                (swiftType, i) => new SLNameTypePair(
                    (swiftType.Name == null ? SLIdentifier.Anonymous : new SLIdentifier(swiftType.Name.Name)),
                    MapType(modules, swiftType))).ToList();

            return(new SLTupleType(contents));
        }
        public SLTupleType ToParameters(SLImportModules modules, SwiftTupleType st)
        {
            List <SLNameTypePair> contents = st.Contents.Select(
                (swiftType, i) => new SLNameTypePair(
                    swiftType.IsReference || MustBeInOut(swiftType) ? SLParameterKind.InOut : SLParameterKind.None,
                    ConjureIdentifier(swiftType.Name, i),
                    MapType(modules, swiftType))).ToList();

            return(new SLTupleType(contents));
        }
Esempio n. 3
0
        public SwiftType SingleTypeFromMaybeTuple(SwiftType t)
        {
            SwiftTupleType tuple = t as SwiftTupleType;

            if (tuple != null)
            {
                Assert.AreEqual(1, tuple.Contents.Count, $"Item expected to be a single tuple element but as {tuple.Contents.Count}.");
                return(tuple.Contents [0]);
            }
            else
            {
                return(t);
            }
        }