зеркало из https://github.com/mono/ikvm-fork.git
- Added support for defining extension methods in the core class library assembly (without taking a System.Core.dll dependency).
- Added the first two extension methods.
This commit is contained in:
Родитель
8f8dcc3084
Коммит
b5c5f18679
Двоичный файл не отображается.
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Copyright (C) 2008 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
package ikvm.extensions;
|
||||
|
||||
import cli.System.Runtime.CompilerServices.ExtensionAttribute;
|
||||
|
||||
@ExtensionAttribute.Annotation
|
||||
public final class ExtensionMethods
|
||||
{
|
||||
private ExtensionMethods() { }
|
||||
|
||||
@ExtensionAttribute.Annotation
|
||||
@cli.IKVM.Attributes.HideFromJavaAttribute.Annotation
|
||||
public static void printStackTrace(Throwable t)
|
||||
{
|
||||
ikvm.runtime.Util.mapException(t).printStackTrace();
|
||||
}
|
||||
|
||||
@ExtensionAttribute.Annotation
|
||||
public static Class getClass(Object obj)
|
||||
{
|
||||
return obj.getClass();
|
||||
}
|
||||
}
|
|
@ -1009,6 +1009,7 @@
|
|||
../classpath/gnu/java/awt/peer/ClasspathDesktopPeer.java
|
||||
../classpath/gnu/java/awt/peer/gtk/CairoSurface.java
|
||||
../classpath/gnu/java/net/protocol/ikvmres/Handler.java
|
||||
../classpath/ikvm/extensions/ExtensionMethods.java
|
||||
../classpath/ikvm/internal/__unspecified.java
|
||||
../classpath/ikvm/internal/AssemblyClassLoader.java
|
||||
../classpath/ikvm/internal/EnumEnum.java
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
</replacetokens>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<exec program="javac" commandline="-J-Xmx1024M -g -nowarn -bootclasspath ../classpath/mscorlib.jar${pathsep}../classpath/System.jar @allsources.lst" useruntimeengine="false" />
|
||||
<exec program="javac" commandline="-J-Xmx1024M -g -nowarn -bootclasspath ../classpath/mscorlib.jar${pathsep}../classpath/System.jar${pathsep}../classpath/IKVM.Runtime.jar @allsources.lst" useruntimeengine="false" />
|
||||
</target>
|
||||
|
||||
<target name="vfs">
|
||||
|
|
|
@ -46,6 +46,18 @@ using jlrConstructor = java.lang.reflect.Constructor;
|
|||
using jlrField = java.lang.reflect.Field;
|
||||
#endif
|
||||
|
||||
// HACK we have our own version of ExtensionAttribute to avoid a System.Core.dll (i.e. .NET 3.5) dependency
|
||||
// it turns out that the C# compiler will honor the attribute, even if it's from a different assembly
|
||||
// (note that it's internal because it should only be used by the core class library assembly and it will
|
||||
// go away at some point in the future (when taking a .NET 3.5 dependency is acceptable))
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
sealed class ExtensionAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
|
||||
{
|
||||
static class Handler
|
||||
|
|
Загрузка…
Ссылка в новой задаче