void ThrowOnExistingProperty(SwiftPropertyType prop, string propType)
 {
     if (prop != null)
     {
         throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 6, $"Already have a {propType} entry for property {Name} in {Class.ClassName.ToFullyQualifiedName ()}");
     }
 }
Exemple #2
0
        public override void Add(TLDefinition tld, Stream srcStm)
        {
            TLFunction tlf = tld as TLFunction;

            if (tlf == null)
            {
                throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 7, $"Expected a TLFunction for a property but got a {tld.GetType ().Name}.");
            }

            SwiftPropertyType prop = tlf.Signature as SwiftPropertyType;

            if (prop == null)
            {
                throw ErrorHelper.CreateError(ReflectorError.kInventoryBase + 8, $"Expected a function of property type but got a {tlf.Signature.GetType ().Name}.");
            }

            PropertyContents contents  = null;
            SwiftName        nameToUse = prop.PrivateName ?? prop.Name;

            if (!values.TryGetValue(nameToUse, out contents))
            {
                contents = new PropertyContents(tlf.Class, nameToUse, sizeofMachinePointer);
                values.Add(nameToUse, contents);
            }
            contents.Add(tlf, prop);
        }
        public void Add(TLFunction tlf, SwiftPropertyType prop)
        {
            var method = tlf as TLMethodDescriptor;

            if (method != null)
            {
                switch (prop.PropertyType)
                {
                case PropertyType.Getter:
                    TLFGetterDescriptor = method;
                    break;

                case PropertyType.Setter:
                    TLFSetterDescriptor = method;
                    break;

                case PropertyType.Materializer:
                    TLFMaterializerDescriptor = method;
                    break;

                case PropertyType.DidSet:
                    TLFDidSetDescriptor = method;
                    break;

                case PropertyType.WillSet:
                    TLFWillSetDescriptor = method;
                    break;

                case PropertyType.ModifyAccessor:
                    TLFModifyDescriptor = method;
                    break;

                default:
                    throw ErrorHelper.CreateError(ReflectorError.kCantHappenBase + 68, $"Unexpected property descriptor {prop.PropertyType.ToString ()}");
                }
            }
            else
            {
                switch (prop.PropertyType)
                {
                case PropertyType.Getter:
                    Getter    = prop;
                    TLFGetter = tlf;
                    break;

                case PropertyType.Setter:
                    Setter    = prop;
                    TLFSetter = tlf;
                    break;

                case PropertyType.Materializer:
                    Materializer    = prop;
                    TLFMaterializer = tlf;
                    break;

                case PropertyType.DidSet:
                    DidSet    = prop;
                    TLFDidSet = tlf;
                    break;

                case PropertyType.WillSet:
                    WillSet    = prop;
                    TLFWillSet = tlf;
                    break;

                case PropertyType.ModifyAccessor:
                    ModifyAccessor    = prop;
                    TLFModifyAccessor = tlf;
                    break;

                default:
                    throw ErrorHelper.CreateError(ReflectorError.kCantHappenBase + 2, $"Unexpected property element {prop.PropertyType.ToString ()}");
                }
            }
        }
Exemple #4
0
        static bool IsStaticProperty(SwiftType signature, SwiftClassType classType)
        {
            SwiftPropertyType pt = signature as SwiftPropertyType;

            return(pt != null && pt.IsStatic);
        }
Exemple #5
0
        static bool IsPrivateProperty(SwiftType signature, SwiftClassType cl)
        {
            SwiftPropertyType pt = signature as SwiftPropertyType;

            return(pt != null && pt.IsPrivate);
        }
Exemple #6
0
        static bool IsSubscript(SwiftType signature, SwiftClassType cl)
        {
            SwiftPropertyType prop = signature as SwiftPropertyType;

            return(prop != null && prop.IsSubscript);
        }