[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection ClrMethod.c
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection ClrMethod.cs, 1.6, 1.7 MethodInfo.cs, 1.6, 1.7 |
Date: |
Fri, 08 Aug 2003 03:44:59 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection
In directory subversions:/tmp/cvs-serv4913/runtime/System/Reflection
Modified Files:
ClrMethod.cs MethodInfo.cs
Log Message:
Add internalcalls for method generics.
Index: ClrMethod.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/ClrMethod.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ClrMethod.cs 15 Apr 2003 11:22:32 -0000 1.6
--- ClrMethod.cs 8 Aug 2003 07:44:57 -0000 1.7
***************
*** 200,203 ****
--- 200,281 ----
}
+ // Determine if this method has generic arguments.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern protected override bool HasGenericArgumentsImpl();
+
+ // Determine if this method has uninstantiated generic parameters.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern protected override bool HasGenericParametersImpl();
+
+ // Get the arguments for this generic method instantiation.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern private Type[] GetGenericArgumentsImpl();
+ public override Type[] GetGenericArguments()
+ {
+ if(!HasGenericArgumentsImpl())
+ {
+ return new Type [0];
+ }
+ else
+ {
+ return GetGenericArgumentsImpl();
+ }
+ }
+
+ // Get the generic base method upon this instantiation was based.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern private ClrMethod GetGenericMethodDefinitionImpl();
+ public override MethodInfo GetGenericMethodDefinition()
+ {
+ if(HasGenericArgumentsImpl())
+ {
+ return GetGenericMethodDefinitionImpl();
+ }
+ else if(HasGenericParametersImpl())
+ {
+ // Not instantiated, so the base method
is itself.
+ return this;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ // Get the arity of an uninstantiated generic method.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern private int GetArity();
+
+ // Bind arguments to this generic method to instantiate it.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern private MethodInfo BindGenericParametersImpl(Type[] typeArgs);
+ public override MethodInfo BindGenericParameters(Type[] typeArgs)
+ {
+ if(typeArgs == null)
+ {
+ throw new
ArgumentNullException("typeArgs");
+ }
+ ClrMethod method = this;
+ if(HasGenericArgumentsImpl())
+ {
+ // Use the base method, not the
instantiated form.
+ method =
GetGenericMethodDefinitionImpl();
+ }
+ if(!method.HasGenericParametersImpl())
+ {
+ throw new ArgumentException
+ (_("Arg_NotGenericMethod"));
+ }
+ else if(method.GetArity() != typeArgs.Length)
+ {
+ throw new ArgumentException
+
(_("Arg_GenericParameterCount"));
+ }
+ else
+ {
+ return
method.BindGenericParametersImpl(typeArgs);
+ }
+ }
+
}; // class ClrMethod
Index: MethodInfo.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/MethodInfo.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** MethodInfo.cs 29 May 2003 01:22:40 -0000 1.6
--- MethodInfo.cs 8 Aug 2003 07:44:57 -0000 1.7
***************
*** 58,61 ****
--- 58,105 ----
#endif // !ECMA_COMPAT
+ // Determine if this method has generic arguments.
+ protected virtual bool HasGenericArgumentsImpl()
+ {
+ return false;
+ }
+ public bool HasGenericArguments
+ {
+ get
+ {
+ return HasGenericArgumentsImpl();
+ }
+ }
+
+ // Determine if this method has uninstantiated generic parameters.
+ protected virtual bool HasGenericParametersImpl()
+ {
+ return false;
+ }
+ public bool HasGenericParameters
+ {
+ get
+ {
+ return HasGenericParametersImpl();
+ }
+ }
+
+ // Get the arguments for this generic method instantiation.
+ public virtual Type[] GetGenericArguments()
+ {
+ throw new
NotSupportedException(_("NotSupp_NotGenericType"));
+ }
+
+ // Get the generic base method upon this instantiation was based.
+ public virtual MethodInfo GetGenericMethodDefinition()
+ {
+ throw new
NotSupportedException(_("NotSupp_NotGenericType"));
+ }
+
+ // Bind arguments to this generic method to instantiate it.
+ public virtual MethodInfo BindGenericParameters(Type[] typeArgs)
+ {
+ throw new
NotSupportedException(_("NotSupp_NotGenericType"));
+ }
+
}; // class MethodInfo
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection ClrMethod.cs, 1.6, 1.7 MethodInfo.cs, 1.6, 1.7,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h, 1.72, 1.73 int_table.c, 1.75, 1.76 lib_type.c, 1.40, 1.41
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/runtime Arg.txt, 1.40, 1.41
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h, 1.72, 1.73 int_table.c, 1.75, 1.76 lib_type.c, 1.40, 1.41
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/runtime Arg.txt, 1.40, 1.41
- Index(es):