[Mono-list] NUnit and Reflection
Sean MacIsaac
macisaac@ximian.com
10 Nov 2001 15:24:47 -0500
--=-nGAQxlz/P3+RTvNoj+lu
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Helllo,
This is the first increment in my work to get NUnit running in Linux
Attached are diffs of my changes to mcs and mono, and two sample files.
HelloWorld.cs should be compiled into a dll
test1.cs should be compiled into an executable.
test1 loads an assembly from disk, and uses reflection to load one of
the types from the assembly, and then prints it's name. It's not too
much yet, but it is the first couple of steps that NUnit takes when
loading a set of tests. I still need to add the loading and executing
of methods.
One question I have deals with field positions inside of objects. The
spec says that the runtime is allowed to shuffle fields inside of
objects, but for some types there seem to be C structs which coorespond
to the C# classes. Is it that these types are handled specially by the
runtime/jit (I've seen check_corlib in interp.c). If so I'll change my
code to remove the mono_class_get_field_from_name calls and add structs
in reflection.h before I commit.
Sean
--=-nGAQxlz/P3+RTvNoj+lu
Content-Disposition: attachment; filename=mcs.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
Index: class/corlib/corlib.build
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/corlib.build,v
retrieving revision 1.8
diff -u -r1.8 corlib.build
--- class/corlib/corlib.build 2001/11/08 06:14:03 1.8
+++ class/corlib/corlib.build 2001/11/10 16:39:13
@@ -74,6 +74,7 @@
<excludes name=3D"System/Object.cs"/>
<excludes name=3D"System/ValueType.cs"/>
<excludes name=3D"System/Type.cs"/>
+ <excludes name=3D"System/MonoType.cs"/>
<excludes name=3D"System/Array.cs"/>
<excludes name=3D"System/String.cs"/>
<excludes name=3D"System/Console.cs"/>
Index: class/corlib/Linux/Linux.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/Linux/Linux.cs,v
retrieving revision 1.4
diff -u -r1.4 Linux.cs
--- class/corlib/Linux/Linux.cs 2001/10/17 17:36:03 1.4
+++ class/corlib/Linux/Linux.cs 2001/11/10 16:39:13
@@ -285,8 +285,10 @@
=20=0D
public string GetCurrentDirectory()=0D
{=0D
- System.Diagnostics.Debug.WriteLine("Linux:GetCurrentDirectory(): Stub M=
ethod");=0D
- return null;=0D
+ IntPtr p =3D GetCwd(new IntPtr(0), new IntPtr(0));=09
+ string str =3D Marshal.PtrToStringAuto (p);
+ Free(p);
+ return str;
}=0D
=20=0D
public string[] GetDirectories(string path, string searchPattern)=0D
@@ -603,6 +605,10 @@
[ DllImport("libm", EntryPoint=3D"tanh") ]
public extern static double Tanh(double d);
=20
+ [ DllImport("libc", EntryPoint=3D"free") ]
+ private extern static void Free(IntPtr p);
=20
+ [ DllImport("libc", EntryPoint=3D"getcwd") ]
+ private extern static IntPtr GetCwd(IntPtr p, IntPtr size);
}=0D
}=0D
Index: class/corlib/System/AttributeUsage.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/AttributeUsage.cs,v
retrieving revision 1.1
diff -u -r1.1 AttributeUsage.cs
--- class/corlib/System/AttributeUsage.cs 2001/09/29 16:57:38 1.1
+++ class/corlib/System/AttributeUsage.cs 2001/11/10 16:39:13
@@ -10,11 +10,11 @@
namespace System {=0D
=20=0D
[AttributeUsage(AttributeTargets.All)]=0D
- public class AttributeUsage : Attribute {=0D
+ public class AttributeUsageAttribute : Attribute {=0D
AttributeTargets valid_on;=0D
bool allow_multiple, inherited;=0D
=09=0D
- public AttributeUsage (AttributeTargets validOn)=0D
+ public AttributeUsageAttribute (AttributeTargets validOn)=0D
{=0D
valid_on =3D validOn;=0D
}=0D
Index: class/corlib/System/CLSCompliantAttribute.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/CLSCompliantAttribute.cs,v
retrieving revision 1.1
diff -u -r1.1 CLSCompliantAttribute.cs
--- class/corlib/System/CLSCompliantAttribute.cs 2001/08/19 22:59:11 1.1
+++ class/corlib/System/CLSCompliantAttribute.cs 2001/11/10 16:39:13
@@ -15,6 +15,7 @@
///
/// <remarks>
/// </remarks>
+ [AttributeUsage(AttributeTargets.All)]
public class CLSCompliant : Attribute {
=20
bool is_compliant;
Index: class/corlib/System/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/ChangeLog,v
retrieving revision 1.72
diff -u -r1.72 ChangeLog
--- class/corlib/System/ChangeLog 2001/11/06 06:50:13 1.72
+++ class/corlib/System/ChangeLog 2001/11/10 16:39:13
@@ -1,3 +1,19 @@
+2001-11-10 Sean MacIsaac <macisaac@ximian.com>
+
+ * AttributeUseage.cs: Should define AttributeUsageAttribute.
+
+ * CLSCompliant.cs: Marked with AttributeUsage attribute.
+
+ * Decimal.cs: Fixed CLSCompliant attributes.
+
+ * Type.cs: changed _impl to internal (needs to be accessable by
+ subclasses).
+
+ (TypeHandle): Marked as abstract, implementation removed.
+
+ (IsNotPublic, IsPublic, GetMethods, GetPropery, GetConstructor,
+ GetMethod): Added stub implementations so NUnit would link against
+ corlib
=20
Tue Nov 6 09:11:43 CET 2001 Paolo Molaro <lupus@ximian.com>
=20
Index: class/corlib/System/Decimal.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/Decimal.cs,v
retrieving revision 1.2
diff -u -r1.2 Decimal.cs
--- class/corlib/System/Decimal.cs 2001/10/20 17:00:59 1.2
+++ class/corlib/System/Decimal.cs 2001/11/10 16:39:19
@@ -92,7 +92,7 @@
}=0D
}=0D
=20=0D
- [CLSCompliantAttribute(false)]=0D
+ [CLSCompliant(false)]=0D
public Decimal(uint val)=20=0D
{=0D
lo32 =3D val;=0D
@@ -121,7 +121,7 @@
}=0D
}=0D
=20=0D
- [CLSCompliantAttribute(false)]=0D
+ [CLSCompliant(false)]=0D
public Decimal(ulong uval)=20=0D
{=0D
unchecked=20=0D
Index: class/corlib/System/RuntimeTypeHandle.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/RuntimeTypeHandle.cs,v
retrieving revision 1.4
diff -u -r1.4 RuntimeTypeHandle.cs
--- class/corlib/System/RuntimeTypeHandle.cs 2001/08/10 07:03:40 1.4
+++ class/corlib/System/RuntimeTypeHandle.cs 2001/11/10 16:39:19
@@ -21,11 +21,10 @@
}
}
=09
- // This is from ISerializable
- public void GetObjectData (SerializationInfo info, Streami=
ngContext context)
- {
- // TODO: IMPLEMENT ME.
- }
-
+ // This is from ISerializable
+ public void GetObjectData (SerializationInfo info, StreamingContext cont=
ext)
+ {
+ // TODO: IMPLEMENT ME.
+ }
}
}
Index: class/corlib/System/Type.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System/Type.cs,v
retrieving revision 1.12
diff -u -r1.12 Type.cs
--- class/corlib/System/Type.cs 2001/11/05 06:18:33 1.12
+++ class/corlib/System/Type.cs 2001/11/10 16:39:19
@@ -19,7 +19,8 @@
//
=09
public abstract class Type : MemberInfo /* IReflect */ {
- private RuntimeTypeHandle _impl;
+ =09
+ internal RuntimeTypeHandle _impl;
=20
/// <summary>
/// The assembly where the type is defined.
@@ -98,16 +99,18 @@
return internal_from_name (typeName);
}
=20
+ public static Type GetType(string typeName, bool throwOnError)
+ {
+ // LAMESPEC: what kinds of errors cause exception to be thrown?
+ return internal_from_name (typeName);
+ }
+
public static Type GetTypeFromHandle (RuntimeTypeHandle handle)
{=20
return internal_from_handle (handle);
}
=20
- public RuntimeTypeHandle TypeHandle {
- get {
- return _impl;
- }
- }
+ public abstract RuntimeTypeHandle TypeHandle { get; }
=09
public bool IsValueType {
get {
@@ -183,6 +186,50 @@
get {
return typeof (ContextBoundObject).IsAssignableFrom (this);
}
+ }
+
+ public bool IsNotPublic {
+ get {
+ // FIXME
+ return false;
+ }
+ }
+
+ public bool IsPublic {
+ get {
+ // FIXME
+ return false;
+ }
+ }
+
+ public MethodInfo[] GetMethods ()
+ {
+ // FIXME
+ return null;
+ }
+
+ public MethodInfo[] GetMethods (BindingFlags bindingAttr)
+ {
+ // FIXME
+ return null;
+ }
+
+ public PropertyInfo GetProperty (string name, Type[] types)
+ {
+ // FIXME
+ return null;
+ }
+
+ public ConstructorInfo GetConstructor (Type[] types)
+ {
+ // FIXME
+ return null;
+ }
+
+ public MethodInfo GetMethod (string name, Type[] types)
+ {
+ // FIXME
+ return null;
}
}
}
Index: class/corlib/System.IO/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.IO/ChangeLog,v
retrieving revision 1.10
diff -u -r1.10 ChangeLog
--- class/corlib/System.IO/ChangeLog 2001/11/05 06:18:33 1.10
+++ class/corlib/System.IO/ChangeLog 2001/11/10 16:39:19
@@ -1,3 +1,8 @@
+2001-11-10 Sean MacIsaac <macisaac@ximian.com>
+
+ * FileNotFoundException.cs: Added some constructors
+
+ * Path.cs (GetFullPath): Fixed implementation
=20
Fri Nov 2 18:27:58 CET 2001 Paolo Molaro <lupus@ximian.com>
=20
Index: class/corlib/System.IO/FileNotFoundException.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.IO/FileNotFoundException.cs,v
retrieving revision 1.2
diff -u -r1.2 FileNotFoundException.cs
--- class/corlib/System.IO/FileNotFoundException.cs 2001/10/17 03:54:00 1.2
+++ class/corlib/System.IO/FileNotFoundException.cs 2001/11/10 16:39:19
@@ -10,6 +10,8 @@
namespace System.IO {
=20
public class FileNotFoundException : SystemException {
+ private string _fileName;
+
// Constructors
public FileNotFoundException ()
: base ("File not found")
@@ -24,6 +26,18 @@
public FileNotFoundException (string message, Exception inner)
: base (message, inner)
{
+ }
+
+ public FileNotFoundException (string message, string fileName)
+ : base (message)
+ {
+ _fileName =3D fileName;
+ }
+
+ public string FileName {
+ get {
+ return _fileName;
+ }
}
=20
public string FusionLog {
Index: class/corlib/System.IO/Path.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.IO/Path.cs,v
retrieving revision 1.5
diff -u -r1.5 Path.cs
--- class/corlib/System.IO/Path.cs 2001/09/26 09:11:28 1.5
+++ class/corlib/System.IO/Path.cs 2001/11/10 16:39:19
@@ -165,12 +165,14 @@
=20
public static string GetFullPath(string path)
{
- if(path !=3D null)
- {
- //TODO: Implement this correctly
+ if (path =3D=3D null)
+ throw(new ArgumentNullException("path", "You must specify a path when =
calling System.IO.Path.GetFullPath"));
+
+ if (path.StartsWith(new string(DirectorySeparatorChar, 1)) ||
+ path.StartsWith(new string(AltDirectorySeparatorChar, 1)))
return path;
- }
- return null;
+
+ return _os.GetCurrentDirectory() + new string(DirectorySeparatorChar, 1=
) + path;
}
=20
public static string GetPathRoot(string path)
Index: class/corlib/System.Reflection/Assembly.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.Reflection/Assembly.cs,v
retrieving revision 1.5
diff -u -r1.5 Assembly.cs
--- class/corlib/System.Reflection/Assembly.cs 2001/11/05 06:18:33 1.5
+++ class/corlib/System.Reflection/Assembly.cs 2001/11/10 16:39:19
@@ -13,12 +13,13 @@
using System.Reflection.Emit;
using System.IO;
using System.Globalization;
+using System.Runtime.CompilerServices;
=20
namespace System.Reflection {
=20
public class Assembly : System.Reflection.ICustomAttributeProvider,
System.Security.IEvidenceFactory, System.Runtime.Serialization.ISerializ=
able {
- private IntPtr mono_assembly;
+ private IntPtr _mono_assembly;
=20
public virtual string CodeBase { get {return null;} }
=20
@@ -124,12 +125,20 @@
=20
public virtual Type GetType(String name, Boolean throwOnError)
{
- return null;
+ return GetType (name, throwOnError, false);
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern virtual Type GetType(String name);
+/*
+ {
+ return GetType (name, true, false);
}
+*/
=20
- public virtual Type GetType(String name)
+ public Type GetType(String name, Boolean throwOnError, Boolean ignoreCas=
e)
{
- return GetType (name, true);
+ return null;
}
=09
public virtual AssemblyName GetName(Boolean copiedName)
@@ -162,11 +171,6 @@
return null;
}
=20
- public Type GetType(String name, Boolean throwOnError, Boolean ignoreCas=
e)
- {
- return null;
- }
-
public Assembly GetSatelliteAssembly(CultureInfo culture)
{
return null;
@@ -174,13 +178,11 @@
=20
public static Assembly LoadFrom(String assemblyFile)
{
- return null;
+ return LoadFrom (assemblyFile, new Evidence());
}
=20
- public static Assembly LoadFrom(String assemblyFile, Evidence securityEv=
idence)
- {
- return null;
- }
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public static extern Assembly LoadFrom(String assemblyFile, Evidence sec=
urityEvidence);
=20
public static Assembly Load(String assemblyString)
{
Index: class/corlib/System.Reflection/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.Reflection/ChangeLog,v
retrieving revision 1.5
diff -u -r1.5 ChangeLog
--- class/corlib/System.Reflection/ChangeLog 2001/11/05 06:18:33 1.5
+++ class/corlib/System.Reflection/ChangeLog 2001/11/10 16:39:19
@@ -1,3 +1,8 @@
+2001-11-10 Sean MacIsaac <macisaac@ximian.com>=0D
+=0D
+ * Assembly.cs: Filled in some stub implementations=0D
+=0D
+ * ConstructorInfo.cs: Added some stub functions for NUnit=0D
=20=0D
Fri Nov 2 18:29:36 CET 2001 Paolo Molaro <lupus@ximian.com>=0D
=20=0D
Index: class/corlib/System.Reflection/ConstructorInfo.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.Reflection/ConstructorInfo.cs=
,v
retrieving revision 1.2
diff -u -r1.2 ConstructorInfo.cs
--- class/corlib/System.Reflection/ConstructorInfo.cs 2001/10/08 12:02:19 1=
.2
+++ class/corlib/System.Reflection/ConstructorInfo.cs 2001/11/10 16:39:19
@@ -15,5 +15,11 @@
public override MemberTypes MemberType {
get {return MemberTypes.Constructor;}
}
+
+ public object Invoke (object[] parameters)
+ {
+ //FIXME
+ return null;
+ }
}
}
Index: class/corlib/System.Reflection.Emit/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.Reflection.Emit/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- class/corlib/System.Reflection.Emit/ChangeLog 2001/11/06 06:50:13 1.4
+++ class/corlib/System.Reflection.Emit/ChangeLog 2001/11/10 16:39:19
@@ -1,3 +1,6 @@
+2001-11-10 Sean MacIsaac <macisaac@ximian.com>
+
+ * TypeBuilder.cs: Added implementation for TypeHandle.
=20
Tue Nov 6 09:13:45 CET 2001 Paolo Molaro <lupus@ximian.com>
=20
Index: class/corlib/System.Reflection.Emit/TypeBuilder.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.c=
s,v
retrieving revision 1.6
diff -u -r1.6 TypeBuilder.cs
--- class/corlib/System.Reflection.Emit/TypeBuilder.cs 2001/11/05 06:18:33 =
1.6
+++ class/corlib/System.Reflection.Emit/TypeBuilder.cs 2001/11/10 16:39:19
@@ -129,5 +129,7 @@
public override Type GetElementType () { return null; }
=20
public override Type[] GetInterfaces () { return null; }
+
+ public override RuntimeTypeHandle TypeHandle { get { return _impl; } }
}
}
Index: mcs/.cvsignore
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mcs/mcs/.cvsignore,v
retrieving revision 1.2
diff -u -r1.2 .cvsignore
--- mcs/.cvsignore 2001/07/15 04:21:26 1.2
+++ mcs/.cvsignore 2001/11/10 16:39:19
@@ -2,3 +2,4 @@
compiler.exe
cs-parser.cs
y.output
+*.pdb
--=-nGAQxlz/P3+RTvNoj+lu
Content-Disposition: attachment; filename=mono.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
Index: mono/metadata/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/metadata/ChangeLog,v
retrieving revision 1.87
diff -u -r1.87 ChangeLog
--- mono/metadata/ChangeLog 2001/11/09 22:20:33 1.87
+++ mono/metadata/ChangeLog 2001/11/10 16:22:08
@@ -1,3 +1,28 @@
+2001-11-10 Sean MacIsaac <macisaac@ximian.com>
+
+ * loader.h: Removed type class from MonoDefaults, added monotype
+
+ * loader.c: Loaded MonoType, removed loading of Type
+
+ * icall.c (my_mono_new_object): Now returns a System.MonoType,
+ and fills in System.Type._impl with a RuntimeTypeHandle rather
+ than the actual MonoClass *
+
+ (ves_icall_type_from_handle): change from type_class to
+ monotype_class
+
+ (ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr):
+ implemented
+
+ (ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto):
+ implemented
+
+ (ves_icall_System_Reflection_Assembly_LoadFrom): implemented
+
+ (ves_icall_System_Reflection_Assembly_GetType): implemented
+
+ (ves_icall_System_MonoType_assQualifiedName): implemented
+
2001-11-09 Miguel de Icaza <miguel@ximian.com>
=20
* assembly.c (mono_assembly_open): Implement a cache for the
Index: mono/metadata/icall.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/metadata/icall.c,v
retrieving revision 1.24
diff -u -r1.24 icall.c
--- mono/metadata/icall.c 2001/11/09 10:53:55 1.24
+++ mono/metadata/icall.c 2001/11/10 16:22:08
@@ -15,6 +15,7 @@
#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/reflection.h>
+#include <mono/metadata/assembly.h>
#include "decimal.h"
=20
static MonoObject *
@@ -146,11 +147,16 @@
{
MonoClassField *field;
MonoObject *res =3D mono_object_new (klass);
+ MonoObject *typehandle =3D mono_object_new (mono_defaults.typehandle_clas=
s);
gpointer *slot;
=20
- field =3D mono_class_get_field_from_name (klass, "_impl");
- slot =3D (gpointer*)((char*)res + field->offset);
+ field =3D mono_class_get_field_from_name (mono_defaults.typehandle_class,=
"value");
+ slot =3D (gpointer*)((char*)typehandle + field->offset);
*slot =3D data;
+
+ field =3D mono_class_get_field_from_name (klass->parent, "_impl");
+ slot =3D (gpointer*)((char*)res + field->offset);
+ *slot =3D typehandle;
return res;
}
=20
@@ -184,8 +190,111 @@
=20
static MonoObject*
ves_icall_type_from_handle (gpointer handle)
+{
+ return my_mono_new_object (mono_defaults.monotype_class, handle);
+}
+
+static gpointer
+ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr (gpointer ptr)
+{
+ return (gpointer)(*(int *)ptr);
+}
+
+static MonoString*
+ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto (gpointer=
ptr)
+{
+ return mono_string_new ((char *)ptr);
+}
+
+static MonoObject*
+ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *assName, MonoOb=
ject *evidence)
+{
+ /* FIXME : examine evidence? */
+ char *name =3D mono_string_to_utf8 (assName);
+ enum MonoImageOpenStatus status =3D MONO_IMAGE_OK;
+ MonoClass *klass =3D mono_class_from_name (mono_defaults.corlib, "System.=
Reflection", "Assembly");
+ MonoAssembly *ass =3D mono_assembly_open (name, NULL, &status);
+ MonoObject *res;
+ MonoClassField *field;
+ gpointer *slot;
+
+ g_assert (ass !=3D NULL);
+ g_assert (status =3D=3D MONO_IMAGE_OK);
+
+ res =3D mono_object_new (klass);
+
+ field =3D mono_class_get_field_from_name (klass, "_mono_assembly");
+ slot =3D (gpointer*)((char*)res + field->offset);
+ *slot =3D ass;
+
+ g_free (name);
+
+ return res;
+}
+
+static MonoObject*
+ves_icall_System_Reflection_Assembly_GetType (MonoObject *assembly, MonoSt=
ring *type) /* , guint8 throwOnError, guint8 ignoreCase) */
+{
+ /* FIXME : use throwOnError and ignoreCase */
+ MonoClassField *field;
+ gpointer *slot;
+ MonoAssembly *ass;
+ gchar *name, *namespace, **parts;
+ MonoClass *klass;
+ int j =3D 0;
+
+ field =3D mono_class_get_field_from_name (assembly->klass, "_mono_assembl=
y");
+ slot =3D (gpointer*)((char*)assembly + field->offset);
+ ass =3D *slot;
+ name =3D mono_string_to_utf8 (type);
+
+ parts =3D g_strsplit (name, ".", 0);
+ g_free (name);
+
+ while (parts[j])
+ j++;
+
+ name =3D parts[j-1];
+ parts[j-1] =3D NULL;
+ namespace =3D g_strjoinv (".", parts);
+ g_strfreev (parts);
+
+ klass =3D mono_class_from_name (ass->image, namespace, name);
+ if (!klass->metadata_inited)
+ mono_class_metadata_init (klass);
+
+ g_free (name);
+ g_free (namespace);
+
+ return my_mono_new_object (mono_defaults.monotype_class, klass);
+}
+
+static MonoString *
+ves_icall_System_MonoType_assQualifiedName (MonoObject *object)
{
- return my_mono_new_object (mono_defaults.type_class, handle);
+ /* FIXME : real rules are more complicated (internal classes,
+ reference types, array types, etc. */
+
+
+ MonoString *res;
+ gchar *fullname;
+ MonoObject *typehandle;
+ MonoClassField *field;
+ MonoClass *klass;
+
+ field =3D mono_class_get_field_from_name (object->klass->parent, "_impl")=
;
+ typehandle =3D *(gpointer *)((char *)object + field->offset);
+
+ field =3D mono_class_get_field_from_name (typehandle->klass, "value");
+ klass =3D *(gpointer *)((char *)typehandle + field->offset);
+
+ fullname =3D g_strconcat (klass->name_space, ".",
+ klass->name, ",",
+ klass->image->assembly_name);
+ res =3D mono_string_new (fullname);
+ g_free (fullname);
+
+ return res;
}
=20
static gpointer icall_map [] =3D {
@@ -284,6 +393,13 @@
"System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading=
_Monitor_Monitor_try_enter,
"System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Moni=
tor_Monitor_wait,
=20
+ "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Ru=
ntime_InteropServices_Marshal_ReadIntPtr,
+ "System.Runtime.InteropServices.Marshal::PtrToStringAuto", ves_icall_Syst=
em_Runtime_InteropServices_Marshal_PtrToStringAuto,
+
+ "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assem=
bly_LoadFrom,
+ "System.Reflection.Assembly::GetType", ves_icall_System_Reflection_Assemb=
ly_GetType,
+
+ "System.MonoType::assQualifiedName", ves_icall_System_MonoType_assQualifi=
edName,
/*
* add other internal calls here
*/
Index: mono/metadata/loader.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/metadata/loader.c,v
retrieving revision 1.43
diff -u -r1.43 loader.c
--- mono/metadata/loader.c 2001/11/07 11:02:31 1.43
+++ mono/metadata/loader.c 2001/11/10 16:22:08
@@ -166,10 +166,9 @@
mono_defaults.corlib, "System", "RuntimeFieldHandle");
g_assert (mono_defaults.fieldhandle_class !=3D 0);
=20
- mono_defaults.type_class =3D mono_class_from_name (
- mono_defaults.corlib, "System", "Type");
- g_assert (mono_defaults.type_class !=3D 0);
-
+ mono_defaults.monotype_class =3D mono_class_from_name (
+ mono_defaults.corlib, "System", "MonoType");
+ g_assert (mono_defaults.monotype_class !=3D 0);
}
=20
static GHashTable *icall_hash =3D NULL;
Index: mono/metadata/loader.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/metadata/loader.h,v
retrieving revision 1.12
diff -u -r1.12 loader.h
--- mono/metadata/loader.h 2001/10/10 07:47:05 1.12
+++ mono/metadata/loader.h 2001/11/10 16:22:08
@@ -51,7 +51,7 @@
MonoClass *typehandle_class;
MonoClass *fieldhandle_class;
MonoClass *methodhandle_class;
- MonoClass *type_class;
+ MonoClass *monotype_class;
} MonoDefaults;
=20
extern MonoDefaults mono_defaults;
--=-nGAQxlz/P3+RTvNoj+lu
Content-Disposition: attachment; filename=HelloWorld.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
namespace Test
{
public class HelloWorld
{
private string _name;
public HelloWorld() : this("Mono")
{
}
public HelloWorld(string name)
{
_name =3D name;
}
public void PrintIt()
{
System.Console.WriteLine("Hello " + _name + ".\n");
}
}
}
--=-nGAQxlz/P3+RTvNoj+lu
Content-Disposition: attachment; filename=test1.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
using System;
using System.IO;
using System.Reflection;
public class RefletionTest
{
public static void Main()
{
FileInfo dll =3D new FileInfo("HelloWorld.dll");
Assembly a =3D Assembly.LoadFrom(dll.FullName);
Type testClass =3D a.GetType("Test.HelloWorld");
System.Console.WriteLine(testClass.FullName);
}
}
--=-nGAQxlz/P3+RTvNoj+lu--