[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-patches
Subject:    [Mono-patches] [mono/mono] [5 commits] ff691ffb: coding style fix
From:       "Lucas Meijer (lucas () unity3d ! com)" <mono-patches () lists ! ximian ! com>
Date:       2011-03-31 18:54:03
Message-ID: 20110331185403.395C82212B () mono ! ximian ! com
[Download RAW message or body]


   Branch: refs/heads/master
     Home: https://github.com/mono/mono

   Commit: ff691ffb4be0a1bc84306b26a6c810caadd84777
   Author: Lucas Meijer <lucas@unity3d.com>
Committer: Sebastien Pouliot <sebastien@ximian.com>
     Date: 03/31/2011 10:37:47
      URL: https://github.com/mono/mono/commit/ff691ffb4be0a1bc84306b26a6c810caadd84777


coding style fix

Changed paths:
 M mono/metadata/security-core-clr.c

Modified: mono/metadata/security-core-clr.c
===================================================================
--- a/mono/metadata/security-core-clr.c
+++ b/mono/metadata/security-core-clr.c
@@ -691,7 +691,7 @@ mono_security_core_clr_ensure_delegate_creation (MonoMethod \
*method, gboolean th  caller, method));
 	}
 
-	if (mono_security_core_clr_get_options() & \
MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE) { +	if \
(mono_security_core_clr_get_options () & \
MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE) {  if \
(!mono_security_core_clr_is_platform_image (method->klass->image))  return TRUE;
 	}


   Commit: e045ceaf34217e48da3f08afba7fd064c153c681
   Author: Lucas Meijer <lucas@unity3d.com>
Committer: Sebastien Pouliot <sebastien@ximian.com>
     Date: 03/31/2011 10:37:47
      URL: https://github.com/mono/mono/commit/e045ceaf34217e48da3f08afba7fd064c153c681


change documentation to be in the right format for public api, and document the \
meaning of the different enum values.

Changed paths:
 M mono/metadata/security-core-clr.c
 M mono/metadata/security-core-clr.h

Modified: mono/metadata/security-core-clr.c
===================================================================
--- a/mono/metadata/security-core-clr.c
+++ b/mono/metadata/security-core-clr.c
@@ -411,13 +411,23 @@ mono_security_core_clr_require_elevated_permissions (void)
 
 static MonoSecurityCoreCLROptions security_core_clr_options = \
MONO_SECURITY_CORE_CLR_OPTIONS_DEFAULT;  
-/*
- * mono_security_core_clr_set_options
+/**
+ * mono_security_core_clr_set_options:
+ * @options: the new options for the coreclr system to use
+ *
+ * By default, the CoreCLRs security model forbids execution trough reflection of \
methods not visible from the calling code. + * Even if the method being called is not \
in a platform assembly. For non moonlight CoreCLR users this restriction does not + * \
make a lot of sense, since the author could have just changed the non platform \
assembly to allow the method to be called. + * This function allows specific \
relaxations from the default behaviour to be set. + *
+ * Use MONO_SECURITY_CORE_CLR_OPTIONS_DEFAULT for the default coreclr coreclr \
behaviour as used in Moonlight. + *
+ * Use MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION to allow transparent code to \
execute methods and access  + * fields that are not in platformcode, even if those \
methods and fields are private or otherwise not visible to the calling code. + *
+ * Use MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE to allow delegates to be \
created that point at methods that are not in + * platformcode even if those methods \
                and fields are private or otherwise not visible to the calling code.
  *
- *      By default, the CoreCLRs security model forbids execution trough reflection \
                of methods not visible from the calling code.
- *      Even if the method being called is not in a platform assembly. For non \
                moonlight CoreCLR users this restriction does not
- *      make a lot of sense, since the author could have just changed the non \
                platform assembly to allow the method to be called.
- *	this function allows specific relaxations from the default behaviour to be set. 
  */
 
 void 
@@ -425,6 +435,12 @@ mono_security_core_clr_set_options (MonoSecurityCoreCLROptions \
options) {  security_core_clr_options = options;
 }
 
+/**
+ * mono_security_core_clr_get_options:
+ *
+ * Retrieves the current options used by the coreclr system.
+ */
+
 MonoSecurityCoreCLROptions
 mono_security_core_clr_get_options ()
 {
Modified: mono/metadata/security-core-clr.h
===================================================================
--- a/mono/metadata/security-core-clr.h
+++ b/mono/metadata/security-core-clr.h
@@ -21,9 +21,18 @@ typedef enum {
 } MonoSecurityCoreCLRLevel;
 
 typedef enum {
+	//The following flags can be used in combination, and control specific behaviour of \
the CoreCLR securit system. +
+	//Default coreclr behaviour, as used in moonlight.
 	MONO_SECURITY_CORE_CLR_OPTIONS_DEFAULT = 0,
+
+	//Allow transparent code to execute methods and access fields that are not in \
platformcode, +	//even if those methods and fields are private or otherwise not \
visible to the calling code.  MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_REFLECTION = 1,
-	MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE = 2,
+
+	//Allow delegates to be created that point at methods that are not in platformcode,
+	//even if those methods and fields are private or otherwise not visible to the \
calling code. +	MONO_SECURITY_CORE_CLR_OPTIONS_RELAX_DELEGATE = 2
 } MonoSecurityCoreCLROptions;
 
 extern gboolean mono_security_core_clr_test;


   Commit: fb2a62048a9cc5e1018a474d62901c4bb1beceaa
   Author: Marek Safar <marek.safar@gmail.com>
     Date: 03/31/2011 13:41:46
      URL: https://github.com/mono/mono/commit/fb2a62048a9cc5e1018a474d62901c4bb1beceaa


[566531] Fix error message for missing parameter name

Changed paths:
 M mcs/mcs/cs-parser.jay
 M mcs/mcs/statement.cs
Added paths:
 A mcs/errors/cs1001-6.cs

Modified: mcs/mcs/cs-parser.jay
===================================================================
--- a/mcs/mcs/cs-parser.jay
+++ b/mcs/mcs/cs-parser.jay
@@ -1490,7 +1490,7 @@ fixed_parameter
 	  {
 		Error_SyntaxError (yyToken);	  
 	  	Location l = GetLocation ($4);
-		$$ = new Parameter ((FullNamedExpression) $3, "NeedSomeGeneratorHere", \
(Parameter.Modifier) $2, (Attributes) $1, l); +		$$ = new Parameter \
((FullNamedExpression) $3, null, (Parameter.Modifier) $2, (Attributes) $1, l);  }
 	| opt_attributes
 	  opt_parameter_modifier
Modified: mcs/mcs/statement.cs
===================================================================
--- a/mcs/mcs/statement.cs
+++ b/mcs/mcs/statement.cs
@@ -2501,7 +2501,8 @@ namespace Mono.CSharp {
 
 				// TODO: Should use Parameter only and more block there
 				parameter_info[i] = new ParameterInfo (this, i);
-				AddLocalName (p.Name, parameter_info[i]);
+				if (p.Name != null)
+					AddLocalName (p.Name, parameter_info[i]);
 			}
 		}
 

Added: mcs/errors/cs1001-6.cs
===================================================================
--- /dev/null
+++ b/mcs/errors/cs1001-6.cs
@@ -0,0 +1,10 @@
+// CS1001: Unexpected symbol `,', expecting identifier
+// Line: 6
+
+public class MonoRuntime
+{
+	public static void Main (A, B)
+	{
+	}
+}
+



   Commit: 9ea0d7f3c379855982159b6a4fa2fbdb497a88a1
   Author: Marek Safar <marek.safar@gmail.com>
     Date: 03/31/2011 13:41:47
      URL: https://github.com/mono/mono/commit/9ea0d7f3c379855982159b6a4fa2fbdb497a88a1


Add more checks for invalid attribute arguments

Changed paths:
 M mcs/errors/cs0307-6.cs
 M mcs/errors/cs1542.cs
 M mcs/errors/known-issues-net_4_0
 M mcs/mcs/constant.cs
 M mcs/mcs/ecore.cs
 M mcs/mcs/expression.cs
 M mcs/mcs/ikvm.cs
 M mcs/mcs/namespace.cs
 M mcs/tests/ver-il-net_4_0.xml
Added paths:
 A mcs/errors/cs0182-13.cs
 A mcs/errors/cs0307-7.cs
 A mcs/errors/cs1540-18.cs
 A mcs/errors/cs1540-19.cs
 A mcs/tests/test-819.cs
Removed paths:
 D mcs/errors/cs0122-8.cs

Modified: mcs/errors/cs0307-6.cs
===================================================================
--- a/mcs/errors/cs0307-6.cs
+++ b/mcs/errors/cs0307-6.cs
@@ -1,4 +1,4 @@
-// CS0307: The variable `a' cannot be used with type arguments
+// CS0307: The type parameter `a' cannot be used with type arguments
 // Line: 9
 
 public class Tests
Modified: mcs/errors/cs1542.cs
===================================================================
--- a/mcs/errors/cs1542.cs
+++ b/mcs/errors/cs1542.cs
@@ -1,3 +1,3 @@
 // CS1542: Added module file `CS1542-lib.dll' is an assembly. Consider using `-r' \
option to reference the file  // Line: 0
-// Compiler options: -r:CS1542-lib.dll
\ No newline at end of file
+// Compiler options: -addmodule:CS1542-lib.dll
\ No newline at end of file
Modified: mcs/errors/known-issues-net_4_0
===================================================================
--- a/mcs/errors/known-issues-net_4_0
+++ b/mcs/errors/known-issues-net_4_0
@@ -17,8 +17,6 @@ cs0162-7.cs NO ERROR
 cs0457-2.cs
 cs0457.cs
 
-cs1540-6.cs NO ERROR
-
 dcs0165.cs NO ERROR # Bug 593369
 
 # all the following are from bug #628673
@@ -29,13 +27,10 @@ cs0023-11.cs
 cs0111-3.cs
 cs0122-19.cs
 cs0122-28.cs
-cs0122-8.cs
 cs0168-2.cs
 cs0177-8.cs NO ERROR
-cs0307-6.cs
 cs0308-7.cs
 cs0519.cs
 cs0647-14.cs NO ERROR
-cs1542.cs NO ERROR
 cs1612-6.cs NO ERROR
 cs3006-7.cs NO ERROR
Modified: mcs/mcs/constant.cs
===================================================================
--- a/mcs/mcs/constant.cs
+++ b/mcs/mcs/constant.cs
@@ -2020,19 +2020,26 @@ namespace Mono.CSharp {
 
 		public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder \
enc, TypeSpec targetType)  {
-			// Type it as string cast
-			if (targetType.BuiltinType == BuiltinTypeSpec.Type.Object)
+			switch (targetType.BuiltinType) {
+			case BuiltinTypeSpec.Type.Object:
+				// Type it as string cast
 				enc.Encode (rc.Module.Compiler.BuiltinTypes.String);
-
-			var ac = targetType as ArrayContainer;
-			if (ac != null) {
-				if (ac.Rank != 1 || ac.Element.IsArray)
-					base.EncodeAttributeValue (rc, enc, targetType);
-				else
-					enc.Encode (uint.MaxValue);
-			} else {
+				goto case BuiltinTypeSpec.Type.String;
+			case BuiltinTypeSpec.Type.String:
+			case BuiltinTypeSpec.Type.Type:
 				enc.Encode (byte.MaxValue);
+				return;
+			default:
+				var ac = targetType as ArrayContainer;
+				if (ac != null && ac.Rank == 1 && !ac.Element.IsArray) {
+					enc.Encode (uint.MaxValue);
+					return;
+				}
+
+				break;
 			}
+
+			base.EncodeAttributeValue (rc, enc, targetType);
 		}
 
 		public override void Emit (EmitContext ec)
Modified: mcs/mcs/ecore.cs
===================================================================
--- a/mcs/mcs/ecore.cs
+++ b/mcs/mcs/ecore.cs
@@ -313,10 +313,11 @@ namespace Mono.CSharp {
 			}
 		}
 
-		public void Error_TypeArgumentsCannotBeUsed (Report report, Location loc, \
MemberSpec member, int arity) +		public void Error_TypeArgumentsCannotBeUsed \
(IMemberContext context, MemberSpec member, int arity, Location loc)  {
 			// Better message for possible generic expressions
 			if (member != null && (member.Kind & MemberKind.GenericMask) != 0) {
+				var report = context.Module.Compiler.Report;
 				report.SymbolRelatedToPreviousError (member);
 				if (member is TypeSpec)
 					member = ((TypeSpec) member).GetDefinition ();
@@ -332,13 +333,13 @@ namespace Mono.CSharp {
 						name, member.GetSignatureForError ());
 				}
 			} else {
-				Error_TypeArgumentsCannotBeUsed (report, ExprClassName, GetSignatureForError (), \
loc); +				Error_TypeArgumentsCannotBeUsed (context, ExprClassName, \
GetSignatureForError (), loc);  }
 		}
 
-		public void Error_TypeArgumentsCannotBeUsed (Report report, string exprType, \
string name, Location loc) +		public void Error_TypeArgumentsCannotBeUsed \
(IMemberContext context, string exprType, string name, Location loc)  {
-			report.Error (307, loc, "The {0} `{1}' cannot be used with type arguments",
+			context.Module.Compiler.Report.Error (307, loc, "The {0} `{1}' cannot be used \
with type arguments",  exprType, name);
 		}
 
@@ -561,7 +562,15 @@ namespace Mono.CSharp {
 			}
 
 			var r = new OverloadResolver (ctors, OverloadResolver.Restrictions.NoBaseMembers, \
                loc);
-			return r.ResolveMember<MethodSpec> (rc, ref args);
+			var ctor = r.ResolveMember<MethodSpec> (rc, ref args);
+			if (ctor == null)
+				return null;
+
+			if ((ctor.Modifiers & Modifiers.PROTECTED) != 0 && !rc.HasSet \
(ResolveContext.Options.BaseInitializer)) { \
+				MemberExpr.CheckProtectedMemberAccess (rc, ctor, ctor.DeclaringType, loc); +			}
+
+			return ctor;
 		}
 
 		[Flags]
@@ -2135,7 +2144,7 @@ namespace Mono.CSharp {
 
 			FullNamedExpression retval = ec.LookupNamespaceOrType (Name, -System.Math.Max (1, \
Arity), loc, true);  if (retval != null) {
-				Error_TypeArgumentsCannotBeUsed (ec.Module.Compiler.Report, loc, retval.Type, \
Arity); +				Error_TypeArgumentsCannotBeUsed (ec, retval.Type, Arity, loc);
 /*
 				var te = retval as TypeExpr;
 				if (HasTypeArguments && te != null && !te.Type.IsGeneric)
@@ -2227,7 +2236,7 @@ namespace Mono.CSharp {
 							e = variable.CreateReferenceExpression (rc, loc);
 							if (e != null) {
 								if (Arity > 0)
-									Error_TypeArgumentsCannotBeUsed (rc.Report, "variable", Name, loc);
+									Error_TypeArgumentsCannotBeUsed (rc, "variable", Name, loc);
 
 								return e;
 							}
@@ -2327,6 +2336,32 @@ namespace Mono.CSharp {
 					if (variable_found) {
 						rc.Report.Error (841, loc, "A local variable `{0}' cannot be used before it is \
declared", Name);  } else {
+						if (Arity > 0) {
+							TypeParameter[] tparams = rc.CurrentTypeParameters;
+							if (tparams != null) {
+								foreach (var ctp in tparams) {
+									if (ctp.Name == Name) {
+										Error_TypeArgumentsCannotBeUsed (rc, "type parameter", Name, loc);
+										return null;
+									}
+								}
+							}
+
+							var ct = rc.CurrentType;
+							do {
+								if (ct.MemberDefinition.TypeParametersCount > 0) {
+									foreach (var ctp in ct.MemberDefinition.TypeParameters) {
+										if (ctp.Name == Name) {
+											Error_TypeArgumentsCannotBeUsed (rc, "type parameter", Name, loc);
+											return null;
+										}
+									}
+								}
+
+								ct = ct.DeclaringType;
+							} while (ct != null);
+						}
+
 						rc.Report.Error (103, loc, "The name `{0}' does not exist in the current \
context", Name);  }
 
@@ -2570,21 +2605,25 @@ namespace Mono.CSharp {
 				return;
 
 			if ((member.Modifiers & Modifiers.PROTECTED) != 0 && !(InstanceExpression is \
                This)) {
-				var ct = rc.CurrentType;
-				var expr_type = InstanceExpression.Type;
-				if (ct == expr_type)
-					return;
+				CheckProtectedMemberAccess (rc, member, InstanceExpression.Type, loc);
+			}
+		}
 
-				if ((member.Modifiers & Modifiers.INTERNAL) != 0 && \
member.DeclaringType.MemberDefinition.IsInternalAsPublic \
                (ct.MemberDefinition.DeclaringAssembly))
-					return;
+		public static void CheckProtectedMemberAccess<T> (ResolveContext rc, T member, \
TypeSpec qualifier, Location loc) where T : MemberSpec +		{
+			var ct = rc.CurrentType;
+			if (ct == qualifier)
+				return;
 
-				expr_type = expr_type.GetDefinition ();
-				if (ct != expr_type && !IsSameOrBaseQualifier (ct, expr_type)) {
-					rc.Report.SymbolRelatedToPreviousError (member);
-					rc.Report.Error (1540, loc,
-						"Cannot access protected member `{0}' via a qualifier of type `{1}'. The \
                qualifier must be of type `{2}' or derived from it",
-						member.GetSignatureForError (), expr_type.GetSignatureForError (), \
                ct.GetSignatureForError ());
-				}
+			if ((member.Modifiers & Modifiers.INTERNAL) != 0 && \
member.DeclaringType.MemberDefinition.IsInternalAsPublic \
(ct.MemberDefinition.DeclaringAssembly)) +				return;
+
+			qualifier = qualifier.GetDefinition ();
+			if (ct != qualifier && !IsSameOrBaseQualifier (ct, qualifier)) {
+				rc.Report.SymbolRelatedToPreviousError (member);
+				rc.Report.Error (1540, loc,
+					"Cannot access protected member `{0}' via a qualifier of type `{1}'. The \
qualifier must be of type `{2}' or derived from it", \
+					member.GetSignatureForError (), qualifier.GetSignatureForError (), \
ct.GetSignatureForError ());  }
 		}
 
@@ -4411,7 +4450,7 @@ namespace Mono.CSharp {
 
 			if (ta_count != best_candidate.Arity && (ta_count > 0 || ((IParametersMember) \
                best_candidate).Parameters.IsEmpty)) {
 				var mg = new MethodGroupExpr (new [] { best_candidate }, \
                best_candidate.DeclaringType, loc);
-				mg.Error_TypeArgumentsCannotBeUsed (rc.Report, loc, best_candidate, ta_count);
+				mg.Error_TypeArgumentsCannotBeUsed (rc, best_candidate, ta_count, loc);
 				return;
 			}
 
@@ -4690,7 +4729,7 @@ namespace Mono.CSharp {
 
 		public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
 		{
-			Error_TypeArgumentsCannotBeUsed (ec.Report, "constant", GetSignatureForError (), \
loc); +			Error_TypeArgumentsCannotBeUsed (ec, "constant", GetSignatureForError (), \
loc);  }
 	}
 
@@ -5152,7 +5191,7 @@ namespace Mono.CSharp {
 
 		public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
 		{
-			Error_TypeArgumentsCannotBeUsed (ec.Report, "field", GetSignatureForError (), \
loc); +			Error_TypeArgumentsCannotBeUsed (ec, "field", GetSignatureForError (), \
loc);  }
 	}
 
@@ -5354,7 +5393,7 @@ namespace Mono.CSharp {
 
 		public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
 		{
-			Error_TypeArgumentsCannotBeUsed (ec.Report, "property", GetSignatureForError (), \
loc); +			Error_TypeArgumentsCannotBeUsed (ec, "property", GetSignatureForError (), \
loc);  }
 	}
 
@@ -5682,7 +5721,7 @@ namespace Mono.CSharp {
 
 		public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
 		{
-			Error_TypeArgumentsCannotBeUsed (ec.Report, "event", GetSignatureForError (), \
loc); +			Error_TypeArgumentsCannotBeUsed (ec, "event", GetSignatureForError (), \
loc);  }
 	}
 
Modified: mcs/mcs/expression.cs
===================================================================
--- a/mcs/mcs/expression.cs
+++ b/mcs/mcs/expression.cs
@@ -7770,7 +7770,7 @@ namespace Mono.CSharp
 			var nested = MemberCache.FindNestedType (expr_type, Name, -System.Math.Max (1, \
Arity));  
 			if (nested != null) {
-				Error_TypeArgumentsCannotBeUsed (rc.Module.Compiler.Report, expr.Location, \
nested, Arity); +				Error_TypeArgumentsCannotBeUsed (rc, nested, Arity, \
expr.Location);  return;
 			}
 
@@ -8451,7 +8451,7 @@ namespace Mono.CSharp
 
 		public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
 		{
-			Error_TypeArgumentsCannotBeUsed (ec.Report, "indexer", GetSignatureForError (), \
loc); +			Error_TypeArgumentsCannotBeUsed (ec, "indexer", GetSignatureForError (), \
loc);  }
 
 		#region IBaseMembersProvider Members
Modified: mcs/mcs/ikvm.cs
===================================================================
--- a/mcs/mcs/ikvm.cs
+++ b/mcs/mcs/ikvm.cs
@@ -535,7 +535,7 @@ namespace Mono.CSharp
 					continue;
 
 				if (m.IsManifestModule) {
-					Error_FileCorrupted (moduleName);
+					Error_ModuleIsAssembly (moduleName);
 					continue;
 				}
 
Modified: mcs/mcs/namespace.cs
===================================================================
--- a/mcs/mcs/namespace.cs
+++ b/mcs/mcs/namespace.cs
@@ -163,13 +163,13 @@ namespace Mono.CSharp {
 		{
 			FullNamedExpression retval = Lookup (ctx, name, -System.Math.Max (1, arity), \
loc);  if (retval != null) {
-				Error_TypeArgumentsCannotBeUsed (ctx.Module.Compiler.Report, loc, retval.Type, \
arity); +				Error_TypeArgumentsCannotBeUsed (ctx, retval.Type, arity, loc);
 				return;
 			}
 
 			Namespace ns;
 			if (arity > 0 && namespaces.TryGetValue (name, out ns)) {
-				ns.Error_TypeArgumentsCannotBeUsed (ctx.Module.Compiler.Report, loc, null, \
arity); +				ns.Error_TypeArgumentsCannotBeUsed (ctx, null, arity, loc);
 				return;
 			}
 
Modified: mcs/tests/ver-il-net_4_0.xml
===================================================================
--- a/mcs/tests/ver-il-net_4_0.xml
+++ b/mcs/tests/ver-il-net_4_0.xml
@@ -46630,6 +46630,47 @@
       </method>
     </type>
   </test>
+  <test name="test-818.cs">
+    <type name="A.CAttribute">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="B.CAttribute">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Foo.Foo">
+      <method name="Void Main()">
+        <size>1</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-819.cs">
+    <type name="AAttribute">
+      <method name="Int32 Main()">
+        <size>19</size>
+      </method>
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+      <method name="Void .ctor(Int32)">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="AAttribute+BAttribute">
+      <method name="Void .ctor()">
+        <size>7</size>
+      </method>
+      <method name="Void .ctor(Int32)">
+        <size>8</size>
+      </method>
+    </type>
+  </test>
   <test name="test-82.cs">
     <type name="N1.N2.B">
       <method name="Void .ctor()">

Added: mcs/errors/cs0182-13.cs
===================================================================
--- /dev/null
+++ b/mcs/errors/cs0182-13.cs
@@ -0,0 +1,17 @@
+// CS0182: An attribute argument must be a constant expression, typeof expression or \
array creation expression +// Line: 6
+
+using System;
+
+[BAttribute (null)]
+public class BAttribute : Attribute
+{
+	public BAttribute (Attribute a)
+	{
+	}
+	
+	public static void Main ()
+	{
+	}
+}
+

Added: mcs/errors/cs0307-7.cs
===================================================================
--- /dev/null
+++ b/mcs/errors/cs0307-7.cs
@@ -0,0 +1,11 @@
+// CS0307: The type parameter `a' cannot be used with type arguments
+// Line: 9
+
+public class Tests<a>
+{
+	public static void Test ()
+	{
+		a<int> ();
+	}
+}
+

Added: mcs/errors/cs1540-18.cs
===================================================================
--- /dev/null
+++ b/mcs/errors/cs1540-18.cs
@@ -0,0 +1,22 @@
+// CS1540: Cannot access protected member `A.member' via a qualifier of type `A'. \
The qualifier must be of type `B' or derived from it +// Line: 17
+// NOTE: csc report simple inaccessible error which is less precise
+
+using System;
+
+class A
+{
+       protected event EventHandler member;
+}
+
+class B : A
+{
+       static void Main ()
+       {
+               A a = new A ();
+               a.member += Handler;
+       }
+       
+       static void Handler (object sender, EventArgs args) {}
+}
+

Added: mcs/errors/cs1540-19.cs
===================================================================
--- /dev/null
+++ b/mcs/errors/cs1540-19.cs
@@ -0,0 +1,28 @@
+// CS1540: Cannot access protected member `AAttribute.AAttribute(int)' via a \
qualifier of type `AAttribute'. The qualifier must be of type `BAttribute' or derived \
from it +// Line: 17
+
+using System;
+
+public class AAttribute : Attribute
+{
+	public AAttribute ()
+	{
+	}
+
+	protected AAttribute (int a)
+	{
+	}
+}
+
+[AAttribute (5)]
+public class BAttribute : AAttribute
+{
+	public BAttribute () : base ()
+	{
+	}
+	
+	public BAttribute (int a) : base (a)
+	{
+	}
+}
+

Added: mcs/tests/test-819.cs
===================================================================
--- /dev/null
+++ b/mcs/tests/test-819.cs
@@ -0,0 +1,33 @@
+using System;
+
+public class AAttribute : Attribute
+{
+	[AAttribute (1)]
+	public class BAttribute : AAttribute
+	{
+		public BAttribute ()
+			: base ()
+		{
+		}
+
+		public BAttribute (int a)
+			: base (a)
+		{
+		}
+	}
+
+	public AAttribute ()
+	{
+	}
+
+	protected AAttribute (int a)
+	{
+	}
+
+	public static int Main ()
+	{
+		typeof (BAttribute).GetCustomAttributes (true);
+		return 0;
+	}
+}
+



   Commit: 50150fec0bf49a646c9d8da9375ef8a7673cf1b7
   Author: Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
     Date: 03/31/2011 14:05:08
      URL: https://github.com/mono/mono/commit/50150fec0bf49a646c9d8da9375ef8a7673cf1b7


[eglib] Implement g_ptr_array_sort_with_data()

Changed paths:
 M eglib/src/gptrarray.c
 M eglib/test/ptrarray.c

Modified: eglib/src/gptrarray.c
===================================================================
--- a/eglib/src/gptrarray.c
+++ b/eglib/src/gptrarray.c
@@ -3,8 +3,9 @@
  *
  * Author:
  *   Aaron Bockover (abockover@novell.com)
+ *   Gonzalo Paniagua Javier (gonzalo@novell.com)
  *
- * (C) 2006 Novell, Inc.
+ * (C) 2006,2011 Novell, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -215,11 +216,45 @@ g_ptr_array_sort(GPtrArray *array, GCompareFunc compare_func)
 	qsort(array->pdata, array->len, sizeof(gpointer), compare_func);
 }
 
-void
-g_ptr_array_sort_with_data(GPtrArray *array, GCompareDataFunc compare_func, 
-	gpointer user_data)
+#define PTR_ADDR(n) (&g_ptr_array_index (array, n))
+#define SWAP_PTR(l,r) do { \
+		gpointer ptr; \
+		if (l != r) { \
+			ptr = array->pdata [l]; \
+			array->pdata [l] = array->pdata [r]; \
+			array->pdata [r] = ptr; \
+		} \
+	} while (0)
+
+static void
+qsort_with_data (GPtrArray *array, gint left, gint right, GCompareDataFunc \
compare_func, gpointer user_data)  {
-}
+	gint l = left + 1;
+	gint r = right;
+	if (right <= left + 1)
+		return;
 
+	while (l < r) {
+		if (compare_func (PTR_ADDR (l), PTR_ADDR (left), user_data) <= 0) {
+			l++;
+		} else {
+			r--;
+			SWAP_PTR (l, r);
+		}
+	}
+	l--;
+	SWAP_PTR (l, left);
+	qsort_with_data (array, left, l, compare_func, user_data);
+	qsort_with_data (array, r, right, compare_func, user_data);
+}
+#undef PTR_ADDR
+#undef SWAP_PTR
 
+void
+g_ptr_array_sort_with_data(GPtrArray *array, GCompareDataFunc compare_func, gpointer \
user_data) +{
+	g_return_if_fail (array != NULL);
+	g_return_if_fail (compare_func != NULL);
+	qsort_with_data (array, 0, array->len, compare_func, user_data);
+}
 
Modified: eglib/test/ptrarray.c
===================================================================
--- a/eglib/test/ptrarray.c
+++ b/eglib/test/ptrarray.c
@@ -243,8 +243,8 @@ RESULT ptrarray_sort()
 
 	for(i = 0; i < array->len; i++) {
 		if(array->pdata[i] != letters[i]) {
-			return FAILED("Array out of order, expected %s got %s", 
-				(gchar *)array->pdata[i], letters[i]);
+			return FAILED("Array out of order, expected %s got %s at position %d",
+				letters [i], (gchar *) array->pdata [i], i);
 		}
 	}
 
@@ -253,6 +253,43 @@ RESULT ptrarray_sort()
 	return OK;
 }
 
+static gint ptrarray_sort_compare_with_data (gconstpointer a, gconstpointer b, \
gpointer user_data) +{
+	gchar *stra = *(gchar **) a;
+	gchar *strb = *(gchar **) b;
+
+	if (strcmp (user_data, "this is the data for qsort") != 0)
+		fprintf (stderr, "oops at compare with_data\n");
+
+	return strcmp(stra, strb);
+}
+
+RESULT ptrarray_sort_with_data ()
+{
+	GPtrArray *array = g_ptr_array_new();
+	guint i;
+	gchar *letters [] = { "A", "B", "C", "D", "E" };
+
+	g_ptr_array_add(array, letters[4]);
+	g_ptr_array_add(array, letters[1]);
+	g_ptr_array_add(array, letters[2]);
+	g_ptr_array_add(array, letters[0]);
+	g_ptr_array_add(array, letters[3]);
+
+	g_ptr_array_sort_with_data(array, ptrarray_sort_compare_with_data, "this is the \
data for qsort"); +
+	for(i = 0; i < array->len; i++) {
+		if(array->pdata[i] != letters[i]) {
+			return FAILED("Array out of order, expected %s got %s at position %d",
+				letters [i], (gchar *) array->pdata [i], i);
+		}
+	}
+
+	g_ptr_array_free(array, TRUE);
+
+	return OK;
+}
+
 RESULT ptrarray_remove_fast()
 {
 	GPtrArray *array = g_ptr_array_new();
@@ -303,6 +340,7 @@ static Test ptrarray_tests [] = {
 	{"remove", ptrarray_remove},
 	{"sort", ptrarray_sort},
 	{"remove_fast", ptrarray_remove_fast},
+	{"sort_with_data", ptrarray_sort_with_data},
 	{NULL, NULL}
 };
 




_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic