Exemple #1
0
        /// <summary>
        /// Retrieve a type from a typemap.
        /// </summary>
        /// <param name="maps">The map to use.</param>
        /// <param name="og">The type to map.</param>
        /// <returns>The mapped type.</returns>
        public static Type MapOne(IEnumerable <Dictionary <string, string> > maps, Type og)
        {
            var type = og;

            foreach (var map in maps)
            {
                type = MapOne(map, type);
            }

            return(type);
        }
Exemple #2
0
        private bool TryCreateEnumVariant(Function function, out Function variant, Project core)
        {
            var  varied        = false;
            var  newParameters = new List <Parameter>();
            var  paramsMod     = false;
            Type newReturnType = function.ReturnType;

            foreach (var functionParameter in function.Parameters)
            {
                if (functionParameter.Type.OriginalGroup is null || core.Enums.All
                        (x => x.Name != functionParameter.Type.OriginalGroup))
                {
                    newParameters.Add(functionParameter);
                    continue;
                }

                paramsMod = true;
                varied    = true;
                var t =
                    new TypeSignatureBuilder(functionParameter.Type).WithName
                        (functionParameter.Type.OriginalGroup)
                    .Build();
                t.OriginalName = t.Name; // stop GLenum mapping
                newParameters.Add
                (
                    new ParameterSignatureBuilder(functionParameter).WithType
                    (
                        t
                    ).Build()
                );
            }

            if (!(function.ReturnType.OriginalGroup is null || core.Enums.All
                      (x => x.Name != function.ReturnType.OriginalGroup)))
            {
                varied        = true;
                newReturnType = new TypeSignatureBuilder(function.ReturnType).WithName
                                    (function.ReturnType.OriginalGroup)
                                .Build();
                newReturnType.OriginalName = newReturnType.Name;
            }

            variant = new FunctionSignatureBuilder(function).WithParameters(newParameters)
                      .WithName(paramsMod ? function.Name : function.Name + "G")
                      .WithReturnType(newReturnType)
                      .Build();
            return(varied);
        }
Exemple #3
0
        public static Type MapOne(List <Dictionary <string, string> > maps, Type og)
        {
            var type = og;

            foreach (var map in maps)
            {
                if (map.ContainsKey(type.ToString()))
                {
                    type = ParseTypeSignature
                           (
                        map[type.ToString()], type.OriginalName
                           );
                }
                else if (map.ContainsKey(type.Name))
                {
                    type.Name = map[type.Name];
                }
            }

            return(type);
        }
Exemple #4
0
        /// <summary>
        /// Retrieve a type from a typemap.
        /// </summary>
        /// <param name="map">The map to use.</param>
        /// <param name="og">The type to map.</param>
        /// <returns>The mapped type.</returns>
        public static Type MapOne(Dictionary <string, string> map, Type og)
        {
            var type = og;

            if (map.ContainsKey(type.ToString()))
            {
                type = ParseTypeSignature
                       (
                    map[type.ToString()], type.OriginalName, type.OriginalGroup
                       );
            }
            else if (map.ContainsKey(type.Name))
            {
                type.Name = map[type.Name];
            }

            if (og.FunctionPointerSignature is not null)
            {
                type.FunctionPointerSignature = og.FunctionPointerSignature;
                Map(map, type.FunctionPointerSignature);
            }

            return(type);
        }
Exemple #5
0
 static bool IsChar(Type type) => type.Name == "char" || type.GenericTypes.Any(IsChar);
 public bool TryCreateVariant(Type returnType, out Type variant, Project core)
 {
     variant = null;
     return(false);
 }