-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2009-07-02 Marek Safar <marek.safar@gmail.com>
* Initial import, revision 25679. svn path=/trunk/mcs/; revision=137277
- Loading branch information
1 parent
6833026
commit 340222f
Showing
183 changed files
with
52,759 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<html> | ||
|
||
<head> | ||
<title>Microsoft Public License (Ms-PL)</title> | ||
</head> | ||
|
||
<body> | ||
|
||
<p><b>This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.</b></p> | ||
|
||
<h2>1. Definitions</h2> | ||
<p>The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the same meaning here as under U.S. copyright law.</p> | ||
<p>A “contribution” is the original software, or any additions or changes to the software.</p> | ||
<p>A “contributor” is any person that distributes its contribution under this license.</p> | ||
<p> “Licensed patents” are a contributor’s patent claims that read directly on its contribution.</p> | ||
<h2>2. Grant of Rights</h2> | ||
<p>(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright | ||
license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.</p> | ||
|
||
<p>(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, | ||
royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative | ||
works of the contribution in the software.</p> | ||
|
||
<h2>3. Conditions and Limitations</h2><p>(A) No Trademark License- This license does not grant you rights to use any contributors’ name, logo, or trademarks.</p> | ||
<p>(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.</p> | ||
<p>(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.</p> | ||
<p>(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. | ||
If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.</p> | ||
|
||
<p>(E) The software is licensed “as-is.” You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional | ||
consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, | ||
fitness for a particular purpose and non-infringement.</p> | ||
|
||
</body> | ||
|
||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* **************************************************************************** | ||
* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* This source code is subject to terms and conditions of the Microsoft Public License. A | ||
* copy of the license can be found in the License.html file at the root of this distribution. If | ||
* you cannot locate the Microsoft Public License, please send an email to | ||
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | ||
* by the terms of the Microsoft Public License. | ||
* | ||
* You must not remove this notice, or any other, from this software. | ||
* | ||
* | ||
* ***************************************************************************/ | ||
using System; using Microsoft; | ||
|
||
|
||
#if !SILVERLIGHT | ||
|
||
#if CODEPLEX_40 | ||
using System.Linq.Expressions; | ||
#else | ||
using Microsoft.Linq.Expressions; | ||
#endif | ||
|
||
#if CODEPLEX_40 | ||
namespace System.Dynamic { | ||
#else | ||
namespace Microsoft.Scripting { | ||
#endif | ||
/// <summary> | ||
/// ArgBuilder provides an argument value used by the MethodBinder. One ArgBuilder exists for each | ||
/// physical parameter defined on a method. | ||
/// | ||
/// Contrast this with ParameterWrapper which represents the logical argument passed to the method. | ||
/// </summary> | ||
internal abstract class ArgBuilder { | ||
/// <summary> | ||
/// Provides the Expression which provides the value to be passed to the argument. | ||
/// </summary> | ||
internal abstract Expression Marshal(Expression parameter); | ||
|
||
/// <summary> | ||
/// Provides the Expression which provides the value to be passed to the argument. | ||
/// This method is called when result is intended to be used ByRef. | ||
/// </summary> | ||
internal virtual Expression MarshalToRef(Expression parameter) { | ||
return Marshal(parameter); | ||
} | ||
|
||
/// <summary> | ||
/// Provides an Expression which will update the provided value after a call to the method. | ||
/// May return null if no update is required. | ||
/// </summary> | ||
internal virtual Expression UnmarshalFromRef(Expression newValue) { | ||
return newValue; | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* **************************************************************************** | ||
* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* This source code is subject to terms and conditions of the Microsoft Public License. A | ||
* copy of the license can be found in the License.html file at the root of this distribution. If | ||
* you cannot locate the Microsoft Public License, please send an email to | ||
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | ||
* by the terms of the Microsoft Public License. | ||
* | ||
* You must not remove this notice, or any other, from this software. | ||
* | ||
* | ||
* ***************************************************************************/ | ||
|
||
#define DEBUG | ||
using System; using Microsoft; | ||
|
||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
#if CODEPLEX_40 | ||
namespace System.Dynamic { | ||
#else | ||
namespace Microsoft.Scripting { | ||
#endif | ||
internal static class Assert { | ||
|
||
internal static Exception Unreachable { | ||
get { | ||
Debug.Assert(false, "Unreachable"); | ||
return new InvalidOperationException("Code supposed to be unreachable"); | ||
} | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void NotNull(object var) { | ||
Debug.Assert(var != null); | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void NotNull(object var1, object var2) { | ||
Debug.Assert(var1 != null && var2 != null); | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void NotNull(object var1, object var2, object var3) { | ||
Debug.Assert(var1 != null && var2 != null && var3 != null); | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1025:ReplaceRepetitiveArgumentsWithParamsArray")] | ||
internal static void NotNull(object var1, object var2, object var3, object var4) { | ||
Debug.Assert(var1 != null && var2 != null && var3 != null && var4 != null); | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void NotEmpty(string str) { | ||
Debug.Assert(!String.IsNullOrEmpty(str)); | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void NotEmpty<T>(ICollection<T> array) { | ||
Debug.Assert(array != null && array.Count > 0); | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void NotNullItems<T>(IEnumerable<T> items) where T : class { | ||
Debug.Assert(items != null); | ||
foreach (object item in items) { | ||
Debug.Assert(item != null); | ||
} | ||
} | ||
|
||
[Conditional("DEBUG")] | ||
internal static void IsTrue(Func<bool> predicate) { | ||
ContractUtils.RequiresNotNull(predicate, "predicate"); | ||
Debug.Assert(predicate()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* **************************************************************************** | ||
* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* This source code is subject to terms and conditions of the Microsoft Public License. A | ||
* copy of the license can be found in the License.html file at the root of this distribution. If | ||
* you cannot locate the Microsoft Public License, please send an email to | ||
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | ||
* by the terms of the Microsoft Public License. | ||
* | ||
* You must not remove this notice, or any other, from this software. | ||
* | ||
* | ||
* ***************************************************************************/ | ||
using System; using Microsoft; | ||
|
||
|
||
#if !SILVERLIGHT // ComObject | ||
|
||
using System.Collections.Generic; | ||
|
||
using System.Diagnostics; | ||
#if CODEPLEX_40 | ||
using System.Linq.Expressions; | ||
#else | ||
using Microsoft.Linq.Expressions; | ||
#endif | ||
using System.Runtime.CompilerServices; | ||
#if !CODEPLEX_40 | ||
using Microsoft.Runtime.CompilerServices; | ||
#endif | ||
|
||
using System.Runtime.InteropServices; | ||
#if CODEPLEX_40 | ||
using System.Dynamic.Utils; | ||
#else | ||
using Microsoft.Scripting.Utils; | ||
#endif | ||
|
||
#if CODEPLEX_40 | ||
namespace System.Dynamic { | ||
#else | ||
namespace Microsoft.Scripting { | ||
#endif | ||
internal sealed class BoolArgBuilder : SimpleArgBuilder { | ||
internal BoolArgBuilder(Type parameterType) | ||
: base(parameterType) { | ||
Debug.Assert(parameterType == typeof(bool)); | ||
} | ||
|
||
internal override Expression MarshalToRef(Expression parameter) { | ||
// parameter ? -1 : 0 | ||
return Expression.Condition( | ||
Marshal(parameter), | ||
Expression.Constant((Int16)(-1)), | ||
Expression.Constant((Int16)0) | ||
); | ||
} | ||
|
||
internal override Expression UnmarshalFromRef(Expression value) { | ||
//parameter = temp != 0 | ||
return base.UnmarshalFromRef( | ||
Expression.NotEqual( | ||
value, | ||
Expression.Constant((Int16)0) | ||
) | ||
); | ||
} | ||
} | ||
} | ||
|
||
#endif |
138 changes: 138 additions & 0 deletions
138
mcs/class/dlr/Runtime/Microsoft.Dynamic/BoundDispEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* **************************************************************************** | ||
* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* This source code is subject to terms and conditions of the Microsoft Public License. A | ||
* copy of the license can be found in the License.html file at the root of this distribution. If | ||
* you cannot locate the Microsoft Public License, please send an email to | ||
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | ||
* by the terms of the Microsoft Public License. | ||
* | ||
* You must not remove this notice, or any other, from this software. | ||
* | ||
* | ||
* ***************************************************************************/ | ||
using System; using Microsoft; | ||
|
||
|
||
#if !SILVERLIGHT // ComObject | ||
|
||
#if CODEPLEX_40 | ||
using System.Linq.Expressions; | ||
#else | ||
using Microsoft.Linq.Expressions; | ||
#endif | ||
using System.Runtime.CompilerServices; | ||
#if !CODEPLEX_40 | ||
using Microsoft.Runtime.CompilerServices; | ||
#endif | ||
|
||
using System.Security; | ||
using System.Security.Permissions; | ||
|
||
#if CODEPLEX_40 | ||
namespace System.Dynamic { | ||
#else | ||
namespace Microsoft.Scripting { | ||
#endif | ||
internal sealed class BoundDispEvent : DynamicObject { | ||
private object _rcw; | ||
private Guid _sourceIid; | ||
private int _dispid; | ||
|
||
internal BoundDispEvent(object rcw, Guid sourceIid, int dispid) { | ||
_rcw = rcw; | ||
_sourceIid = sourceIid; | ||
_dispid = dispid; | ||
} | ||
|
||
/// <summary> | ||
/// Provides the implementation of performing AddAssign and SubtractAssign binary operations. | ||
/// </summary> | ||
/// <param name="binder">The binder provided by the call site.</param> | ||
/// <param name="handler">The handler for the operation.</param> | ||
/// <param name="result">The result of the operation.</param> | ||
/// <returns>true if the operation is complete, false if the call site should determine behavior.</returns> | ||
public override bool TryBinaryOperation(BinaryOperationBinder binder, object handler, out object result) { | ||
if (binder.Operation == ExpressionType.AddAssign) { | ||
result = InPlaceAdd(handler); | ||
return true; | ||
} | ||
|
||
if (binder.Operation == ExpressionType.SubtractAssign) { | ||
result = InPlaceSubtract(handler); | ||
return true; | ||
} | ||
|
||
result = null; | ||
return false; | ||
} | ||
|
||
private static void VerifyHandler(object handler) { | ||
if (handler is Delegate && handler.GetType() != typeof(Delegate)) { | ||
return; // delegate | ||
} | ||
|
||
if (handler is IDynamicMetaObjectProvider) { | ||
return; // IDMOP | ||
} | ||
|
||
throw Error.UnsupportedHandlerType(); | ||
} | ||
|
||
/// <summary> | ||
/// Adds a handler to an event. | ||
/// </summary> | ||
/// <param name="handler">The handler to be added.</param> | ||
/// <returns>The original event with handler added.</returns> | ||
#if MICROSOFT_DYNAMIC | ||
[SecurityCritical, SecurityTreatAsSafe] | ||
#else | ||
[SecuritySafeCritical] | ||
#endif | ||
private object InPlaceAdd(object handler) { | ||
ContractUtils.RequiresNotNull(handler, "handler"); | ||
VerifyHandler(handler); | ||
|
||
// | ||
// Demand Full Trust to proceed with the operation. | ||
// | ||
|
||
new PermissionSet(PermissionState.Unrestricted).Demand(); | ||
|
||
ComEventSink comEventSink = ComEventSink.FromRuntimeCallableWrapper(_rcw, _sourceIid, true); | ||
comEventSink.AddHandler(_dispid, handler); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Removes handler from the event. | ||
/// </summary> | ||
/// <param name="handler">The handler to be removed.</param> | ||
/// <returns>The original event with handler removed.</returns> | ||
#if MICROSOFT_DYNAMIC | ||
[SecurityCritical, SecurityTreatAsSafe] | ||
#else | ||
[SecuritySafeCritical] | ||
#endif | ||
private object InPlaceSubtract(object handler) { | ||
ContractUtils.RequiresNotNull(handler, "handler"); | ||
VerifyHandler(handler); | ||
|
||
// | ||
// Demand Full Trust to proceed with the operation. | ||
// | ||
|
||
new PermissionSet(PermissionState.Unrestricted).Demand(); | ||
|
||
ComEventSink comEventSink = ComEventSink.FromRuntimeCallableWrapper(_rcw, _sourceIid, false); | ||
if (comEventSink != null) { | ||
comEventSink.RemoveHandler(_dispid, handler); | ||
} | ||
|
||
return this; | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.