- 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:
jfrijters 2008-02-10 11:20:52 +00:00
Родитель 8f8dcc3084
Коммит b5c5f18679
5 изменённых файлов: 59 добавлений и 1 удалений

Двоичные данные
classpath/IKVM.Runtime.jar Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -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/ClasspathDesktopPeer.java
../classpath/gnu/java/awt/peer/gtk/CairoSurface.java ../classpath/gnu/java/awt/peer/gtk/CairoSurface.java
../classpath/gnu/java/net/protocol/ikvmres/Handler.java ../classpath/gnu/java/net/protocol/ikvmres/Handler.java
../classpath/ikvm/extensions/ExtensionMethods.java
../classpath/ikvm/internal/__unspecified.java ../classpath/ikvm/internal/__unspecified.java
../classpath/ikvm/internal/AssemblyClassLoader.java ../classpath/ikvm/internal/AssemblyClassLoader.java
../classpath/ikvm/internal/EnumEnum.java ../classpath/ikvm/internal/EnumEnum.java

Просмотреть файл

@ -41,7 +41,7 @@
</replacetokens> </replacetokens>
</filterchain> </filterchain>
</copy> </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>
<target name="vfs"> <target name="vfs">

Просмотреть файл

@ -46,6 +46,18 @@ using jlrConstructor = java.lang.reflect.Constructor;
using jlrField = java.lang.reflect.Field; using jlrField = java.lang.reflect.Field;
#endif #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 namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
{ {
static class Handler static class Handler