コード例 #1
0
        void ProcessPotentialNameOverride(ProcessedMethod processedMethod)
        {
            MethodInfo method = processedMethod.Method;

            if (IsOperatorOrFriendlyVersion(method))
            {
                string nameOverride = OperatorOverloads.GetObjCName(processedMethod.Method.Name, processedMethod.Method.GetParameters().Length);
                if (nameOverride != null)
                {
                    processedMethod.NameOverride = nameOverride;
                }
            }
        }
コード例 #2
0
        protected IEnumerable <ProcessedMethod> PostProcessMethods(IEnumerable <ProcessedMethod> methods)
        {
            var equals = new HashSet <MethodInfo> ();

            foreach (var m in methods)
            {
                if (m.MethodType == MethodType.NSObjectProcotolIsEqual)
                {
                    equals.Add(m.Method);
                }
            }
            HashSet <MethodInfo> operatorToIgnore = new HashSet <MethodInfo> (OperatorOverloads.FindOperatorPairToIgnore(methods, equals));

            foreach (var processedMethod in methods)
            {
                var method = processedMethod.Method;
                if (operatorToIgnore.Contains(method))
                {
                    Delayed.Add(ErrorHelper.CreateWarning(1033, $"Method {method.Name} is not generated because another method exposes the operator with a friendly name"));
                    continue;
                }

                if (IsOperatorOrFriendlyVersion(method))
                {
                    processedMethod.IsOperator = true;
                }

                ProcessPotentialName(processedMethod);

                if (Mapper.CheckForDuplicateSelectors(processedMethod) == DuplicationStatus.Unresolvable)
                {
                    Delayed.Add(ErrorHelper.CreateWarning(1052, $"Element {method.Name} is not generated as its name conflicts with other elements on the same class."));
                    continue;
                }

                Mapper.Register(processedMethod);

                processedMethod.Freeze();
                yield return(processedMethod);
            }
        }
コード例 #3
0
        protected IEnumerable <ProcessedMethod> PostProcessMethods(IEnumerable <ProcessedMethod> methods)
        {
            HashSet <string> duplicateNames = FindDuplicateNames(methods);

            var equals = new HashSet <MethodInfo> ();

            foreach (var m in methods)
            {
                if (m.MethodType == MethodType.NSObjectProcotolIsEqual)
                {
                    equals.Add(m.Method);
                }
            }
            HashSet <MethodInfo> operatorToIgnore = new HashSet <MethodInfo> (OperatorOverloads.FindOperatorPairToIgnore(methods, equals));

            foreach (var processedMethod in methods)
            {
                var method = processedMethod.Method;
                if (operatorToIgnore.Contains(method))
                {
                    Delayed.Add(ErrorHelper.CreateWarning(1033, $"Method {method.Name} is not generated because another method exposes the operator with a friendly name"));
                    continue;
                }

                if (duplicateNames.Contains(CreateStringRep(method)) && method.Name != "CompareTo")                   // HACK
                {
                    processedMethod.FallBackToTypeName = true;
                }

                if (IsOperatorOrFriendlyVersion(method))
                {
                    processedMethod.IsOperator = true;
                }

                ProcessPotentialNameOverride(processedMethod);

                yield return(processedMethod);
            }
        }
コード例 #4
0
        void ProcessPotentialName(ProcessedMethod processedMethod)
        {
            MethodInfo method = processedMethod.Method;

            if (IsOperatorOrFriendlyVersion(method))
            {
                string nameOverride = OperatorOverloads.GetObjCName(processedMethod.Method.Name, processedMethod.Method.GetParameters().Length);
                if (nameOverride != null)
                {
                    processedMethod.NameOverride = nameOverride;
                }
            }

            string objCSignature = processedMethod.ObjCSignature;

            if (RestrictedObjSelectors.IsImportantSelector(objCSignature))
            {
                string newName = "managed" + method.Name.PascalCase();
                processedMethod.NameOverride = newName;
                Delayed.Add(ErrorHelper.CreateWarning(1051, $"Element {method.Name} is generated instead as {newName} because its name conflicts with an important objective-c selector."));
            }
        }
コード例 #5
0
 public bool IsOperatorOrFriendlyVersion(MethodInfo method)
 {
     return(method.IsOperatorMethod() || OperatorOverloads.MatchesOperatorFriendlyName(method));
 }