// Start is called before the first frame update void Start() { methodOverload = new MethodOverload(); addedNumbersText.text = "0 + 0 = 0"; addedStringsText.text = "Lorem + Ipsum = Lorem Ipsum"; }
private static string GetOverloadInfo(MethodOverload overload) { StringBuilder result = new StringBuilder(); foreach (var inParameter in overload.InParameters) { if (inParameter.IsOptional) { result.Append("["); } result.Append("–> "); AppendParameterInfo(result, inParameter); if (inParameter.IsOptional) { result.Append("]"); } result.AppendLine(); } foreach (var outParameter in overload.OutParameters) { result.Append("<– "); AppendParameterInfo(result, outParameter); result.AppendLine(); } return(result.ToString()); }
private XElement CreateOverloadElement(MethodOverload overload) { return(new XElement("overload", new XAttribute("static", overload.IsStatic), new XElement("inParams", overload.InParameters.Select(CreateInParamElement)), new XElement("outParams", overload.OutParameters.Select(CreateOutParamElement)) )); }
public static int test() { var obj = new MethodOverload(); return(obj.method()); }
public static int test() { var obj = new MethodOverload(); return obj.method(); }
private static Method CreateMethod(MoaiClass moaiClass, Annotation[] annotations, MethodPosition methodPosition, TypeCollection types, WarningList warnings) { // Get @lua annotation var luaNameAnnotation = GetNameAnnotation(moaiClass, annotations, methodPosition, warnings); if (luaNameAnnotation == null) { return(null); } // Check that there is a single @text annotation CheckTextAnnotation(annotations, methodPosition, warnings); // Parse annotations var method = new Method { MethodPosition = methodPosition, Name = luaNameAnnotation.Value, OwningClass = moaiClass, }; moaiClass.Members.Add(method); MethodOverload currentOverload = null; foreach (var annotation in annotations) { if (annotation is LuaNameAnnotation) { // Nothing to do - name has already been set. } else if (annotation is TextAnnotation) { // Set method description method.Description = ((TextAnnotation)annotation).Value; } else if (annotation is ParameterAnnotation) { if (currentOverload == null) { currentOverload = new MethodOverload { OwningMethod = method }; method.Overloads.Add(currentOverload); } var parameterAnnotation = (ParameterAnnotation)annotation; string paramName = parameterAnnotation.Name; if (annotation is InParameterAnnotation | annotation is OptionalInParameterAnnotation) { // Add input parameter if (currentOverload.InParameters.Any(param => param.Name == paramName)) { warnings.Add(methodPosition, WarningType.UnexpectedValue, "Found multiple params with name '{0}' for single overload.", paramName); } var inParameter = new InParameter { Name = paramName, Description = parameterAnnotation.Description, Type = types.GetOrCreate(parameterAnnotation.Type, methodPosition), IsOptional = annotation is OptionalInParameterAnnotation }; currentOverload.InParameters.Add(inParameter); } else { // Add output parameter var outParameter = new OutParameter { Name = paramName, Type = types.GetOrCreate(parameterAnnotation.Type, methodPosition), Description = parameterAnnotation.Description }; currentOverload.OutParameters.Add(outParameter); } } else if (annotation is OverloadAnnotation) { // Let the next parameter annotation start a new override currentOverload = null; } else { warnings.Add(methodPosition, WarningType.UnexpectedAnnotation, "Unexpected {0} annotation.", annotation.Command); } } return(method); }