예제 #1
0
        private IEnumerable <string> GetParameters(IList <Parameter> parameters)
        {
            var bldr = new StringBuilder( );

            for (int i = 0; i < parameters.Count; ++i)
            {
                var arg     = parameters[i];
                var argType = arg.Type;
                foreach (var attr in arg.Attributes)
                {
                    bldr.Append(attr.AsString( ));
                }

                if (arg.IsOut)
                {
                    bldr.Append("out ");
                    if (!argType.IsConstCharString() && argType is PointerType pt)
                    {
                        argType = pt.Pointee;
                    }
                }

                if (arg.IsInOut)
                {
                    bldr.Append("ref ");
                    if (argType.IsConstCharString( ) && argType is PointerType pt)
                    {
                        argType = pt.Pointee;
                    }
                }

                bldr.Append(TypePrinter.GetName(argType, TypeNameKind.Managed))
                .Append(' ')
                .Append(CreateEscapedIdentifier(arg));

                if (i < parameters.Count - 1)
                {
                    bldr.Append(", ");
                }

                yield return(bldr.ToString( ));

                bldr.Clear( );
            }
        }
예제 #2
0
 public string GetManagedName(Type t)
 {
     return(TypePrinter.GetName(t, TypeNameKind.Managed));
 }