[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit Assemb
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit AssemblyBuilder.cs,1.3,1.4 EventBuilder.cs,1.2,1.3 FieldBuilder.cs,1.2,1.3 ModuleBuilder.cs,1.4,1.5 PropertyBuilder.cs,1.2,1.3 TypeBuilder.cs,1.3,1.4 UnmanagedMarshal.cs,1.2,1.3 |
Date: |
Thu, 20 Mar 2003 01:23:01 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit
In directory subversions:/tmp/cvs-serv950/runtime/System/Reflection/Emit
Modified Files:
AssemblyBuilder.cs EventBuilder.cs FieldBuilder.cs
ModuleBuilder.cs PropertyBuilder.cs TypeBuilder.cs
UnmanagedMarshal.cs
Log Message:
Continue implementation of Reflection.Emit; events, fields,
properties, and marshalling.
Index: AssemblyBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/AssemblyBuilder.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** AssemblyBuilder.cs 18 Mar 2003 10:53:15 -0000 1.3
--- AssemblyBuilder.cs 20 Mar 2003 06:22:59 -0000 1.4
***************
*** 283,296 ****
}
! [TODO]
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
! throw new
NotImplementedException("SetCustomAttribute");
}
-
- [TODO]
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
{
! throw new
NotImplementedException("SetCustomAttribute");
}
--- 283,320 ----
}
! // Set a custom attribute on this assembly.
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
! try
! {
! StartSync();
! if(saved)
! {
! throw new
InvalidOperationException
!
(_("Emit_AlreadySaved"));
! }
! SetCustomAttribute(this, customBuilder);
! }
! finally
! {
! EndSync();
! }
}
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
{
! try
! {
! StartSync();
! if(saved)
! {
! throw new
InvalidOperationException
!
(_("Emit_AlreadySaved"));
! }
! SetCustomAttribute(this, con,
binaryAttribute);
! }
! finally
! {
! EndSync();
! }
}
***************
*** 318,321 ****
--- 342,360 ----
}
+ // Set custom attributes on a program item in this assembly.
+ [TODO]
+ internal void SetCustomAttribute
+ (IClrProgramItem item, CustomAttributeBuilder
customBuilder)
+ {
+ throw new
NotImplementedException("SetCustomAttribute");
+ }
+ [TODO]
+ internal void SetCustomAttribute
+ (IClrProgramItem item, ConstructorInfo con,
+ byte[] binaryAttribute)
+ {
+ throw new
NotImplementedException("SetCustomAttribute");
+ }
+
// Create a new assembly.
[MethodImpl(MethodImplOptions.InternalCall)]
***************
*** 328,331 ****
--- 367,374 ----
extern private void ClrSetEntryPoint(IntPtr clrMethod,
PEFileKinds fileKind);
+
+ // Get the token associated with a particular program item.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern internal static int ClrGetItemToken(IntPtr item);
}; // class AssemblyBuilder
Index: EventBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/EventBuilder.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** EventBuilder.cs 1 Mar 2003 20:26:31 -0000 1.2
--- EventBuilder.cs 20 Mar 2003 06:22:59 -0000 1.3
***************
*** 30,79 ****
using System.Runtime.CompilerServices;
! [TODO]
! public sealed class EventBuilder
{
! [TODO]
public void AddOtherMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("AddOtherMethod");
! }
! [TODO]
public EventToken GetEventToken()
! {
! throw new NotImplementedException("GetEventToken");
! }
! [TODO]
public void SetAddOnMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("SetAddOnMethod");
! }
! [TODO]
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
! {
! throw new NotImplementedException("SetCustomAttribute");
! }
!
! [TODO]
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
! {
! throw new NotImplementedException("SetCustomAttribute");
! }
! [TODO]
public void SetRaiseMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("SetRaiseMethod");
! }
! [TODO]
public void SetRemoveOnMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("SetRemoveOnMethod");
! }
!
! // TODO
}; // class EventBuilder
--- 30,160 ----
using System.Runtime.CompilerServices;
! public sealed class EventBuilder : IClrProgramItem
{
! // Internal state.
! private TypeBuilder type;
! private IntPtr privateData;
!
! // Constructor.
! internal EventBuilder(TypeBuilder type, String name,
! EventAttributes attributes,
Type eventType)
! {
! // Validate the parameters.
! if(name == null)
! {
! throw new ArgumentNullException("name");
! }
! else if(eventType == null)
! {
! throw new
ArgumentNullException("eventType");
! }
!
! // Create the event.
! this.type = type;
! this.privateData = ClrEventCreate
! (((IClrProgramItem)type).ClrHandle,
name,
! eventType, attributes);
! }
!
! // Add method semantics to this event.
! private void AddSemantics(MethodSemanticsAttributes attr,
! MethodBuilder
mdBuilder)
! {
! try
! {
! type.StartSync();
! if(mdBuilder == null)
! {
! throw new
ArgumentNullException("mdBuilder");
! }
! ClrEventAddSemantics
! (privateData, attr,
!
type.module.GetMethodToken(mdBuilder));
! }
! finally
! {
! type.EndSync();
! }
! }
!
! // Add an "other" method to this event.
public void AddOtherMethod(MethodBuilder mdBuilder)
! {
! AddSemantics(MethodSemanticsAttributes.Other,
mdBuilder);
! }
! // Get the token code for this event.
public EventToken GetEventToken()
! {
! return new EventToken
!
(AssemblyBuilder.ClrGetItemToken(privateData));
! }
! // Set the "add on" method for this event.
public void SetAddOnMethod(MethodBuilder mdBuilder)
! {
! AddSemantics(MethodSemanticsAttributes.AddOn,
mdBuilder);
! }
! // Set custom attributes for this event.
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
! {
! try
! {
! type.StartSync();
! type.module.assembly.SetCustomAttribute
! (this, customBuilder);
! }
! finally
! {
! type.EndSync();
! }
! }
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
! {
! try
! {
! type.StartSync();
! type.module.assembly.SetCustomAttribute
! (this, con, binaryAttribute);
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the "raise" method for this event.
public void SetRaiseMethod(MethodBuilder mdBuilder)
! {
! AddSemantics(MethodSemanticsAttributes.Fire,
mdBuilder);
! }
! // Set the "remove on" method for this event.
public void SetRemoveOnMethod(MethodBuilder mdBuilder)
! {
!
AddSemantics(MethodSemanticsAttributes.RemoveOn, mdBuilder);
! }
!
! // Get the CLR handle for this object.
! IntPtr IClrProgramItem.ClrHandle
! {
! get
! {
! return privateData;
! }
! }
!
! // Create a new event and attach it to a particular class.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static IntPtr ClrEventCreate
! (IntPtr classInfo, String name, Type type,
! EventAttributes attributes);
!
! // Add semantic information to this event.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrEventAddSemantics
! (IntPtr eventInfo, MethodSemanticsAttributes attr,
! MethodToken token);
}; // class EventBuilder
Index: FieldBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/FieldBuilder.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** FieldBuilder.cs 28 Feb 2003 14:52:04 -0000 1.2
--- FieldBuilder.cs 20 Mar 2003 06:22:59 -0000 1.3
***************
*** 30,161 ****
using System.Runtime.CompilerServices;
! [TODO]
! public sealed class FieldBuilder : FieldInfo
{
! [TODO]
! public override Object[] GetCustomAttributes(bool inherit)
! {
! throw new NotImplementedException("GetCustomAttributes");
! }
! [TODO]
public override Object[] GetCustomAttributes(Type attributeType,
bool inherit)
! {
! throw new NotImplementedException("GetCustomAttributes");
! }
! [TODO]
public FieldToken GetToken()
! {
! throw new NotImplementedException("GetToken");
! }
! [TODO]
public override Object GetValue(Object obj)
! {
! throw new NotImplementedException("GetValue");
! }
! [TODO]
public override bool IsDefined(Type attributeType, bool inherit)
! {
! throw new NotImplementedException("IsDefined");
! }
! [TODO]
public void SetConstant(Object defaultValue)
! {
! throw new NotImplementedException("SetConstant");
! }
! [TODO]
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
! {
! throw new NotImplementedException("SetCustomAttribute");
! }
!
! [TODO]
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
! {
! throw new NotImplementedException("SetCustomAttribute");
! }
! [TODO]
public void SetMarshal(UnmanagedMarshal unmanagedMarshal)
! {
! throw new NotImplementedException("SetMarshal");
! }
! [TODO]
public void SetOffset(int iOffset)
! {
! throw new NotImplementedException("SetOffset");
! }
! [TODO]
public override void SetValue(Object obj, Object val,
BindingFlags
invokeAttr,
Binder
binder,
CultureInfo
culture)
! {
! throw new NotImplementedException("SetValue");
! }
! [TODO]
public override FieldAttributes Attributes
! {
! get
! {
! throw new NotImplementedException("Attributes");
! }
! }
! [TODO]
public override Type DeclaringType
! {
! get
! {
! throw new NotImplementedException("DeclaringType");
! }
! }
! [TODO]
public override RuntimeFieldHandle FieldHandle
! {
! get
! {
! throw new NotImplementedException("FieldHandle");
! }
! }
! [TODO]
public override Type FieldType
! {
! get
! {
! throw new NotImplementedException("FieldType");
! }
! }
! [TODO]
public override String Name
! {
! get
! {
! throw new NotImplementedException("Name");
! }
! }
! [TODO]
public override Type ReflectedType
! {
! get
! {
! throw new NotImplementedException("ReflectedType");
! }
! }
!
! // TODO
}; // class FieldBuilder
--- 30,287 ----
using System.Runtime.CompilerServices;
! public sealed class FieldBuilder : FieldInfo, IClrProgramItem
{
! // Internal state.
! private TypeBuilder type;
! private IntPtr privateData;
!
! // Constructor.
! internal FieldBuilder(TypeBuilder type, String name, Type fieldType,
! FieldAttributes attributes)
! {
! this.type = type;
! this.privateData = ClrFieldCreate
! (((IClrProgramItem)type).ClrHandle,
! name, fieldType, attributes);
! }
! // Get the custom attributes associated with this field.
! public override Object[] GetCustomAttributes(bool inherit)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
public override Object[] GetCustomAttributes(Type attributeType,
bool inherit)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Get the token code for this field.
public FieldToken GetToken()
! {
! return new FieldToken
!
(AssemblyBuilder.ClrGetItemToken(privateData));
! }
! // Get the value associated with this field on an object.
public override Object GetValue(Object obj)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Determine if a custom attribute is defined on this field.
public override bool IsDefined(Type attributeType, bool inherit)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Set the constant value on this field.
public void SetConstant(Object defaultValue)
! {
! try
! {
! type.StartSync();
! ValidateConstant(FieldType,
defaultValue);
! ClrFieldSetConstant(privateData,
defaultValue);
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set a custom attribute on this field.
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
! {
! try
! {
! type.StartSync();
! type.module.assembly.SetCustomAttribute
! (this, customBuilder);
! }
! finally
! {
! type.EndSync();
! }
! }
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
! {
! try
! {
! type.StartSync();
! type.module.assembly.SetCustomAttribute
! (this, con, binaryAttribute);
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the marshalling information for this field.
public void SetMarshal(UnmanagedMarshal unmanagedMarshal)
! {
! try
! {
! type.StartSync();
! if(unmanagedMarshal == null)
! {
! throw new
ArgumentNullException("unmanagedMarshal");
! }
! ClrFieldSetMarshal(privateData,
unmanagedMarshal.ToBytes());
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the offset of this field in an explicitly laid out class.
public void SetOffset(int iOffset)
! {
! try
! {
! type.StartSync();
! ClrFieldSetOffset(privateData, iOffset);
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the value of this field on an object.
public override void SetValue(Object obj, Object val,
BindingFlags
invokeAttr,
Binder
binder,
CultureInfo
culture)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Get the attributes for this field.
public override FieldAttributes Attributes
! {
! get
! {
! return (FieldAttributes)
!
ClrHelpers.GetMemberAttrs(privateData);
! }
! }
! // Get the type that declares this field
public override Type DeclaringType
! {
! get
! {
! return type;
! }
! }
! // Get the handle associated with this field.
public override RuntimeFieldHandle FieldHandle
! {
! get
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! }
! // Get the field type.
public override Type FieldType
! {
! get
! {
! return
ClrField.GetFieldType(privateData);
! }
! }
! // Get the name of this field.
public override String Name
! {
! get
! {
! return ClrHelpers.GetName(this);
! }
! }
! // Get the reflected type for this field.
public override Type ReflectedType
! {
! get
! {
! return type;
! }
! }
!
! // Get the CLR handle for this field.
! IntPtr IClrProgramItem.ClrHandle
! {
! get
! {
! return privateData;
! }
! }
!
! // Validate a constant value against a type.
! internal static void ValidateConstant(Type type, Object value)
! {
! if(value == null)
! {
! // Cannot be null if a value type.
! if(type.IsValueType)
! {
! throw new
ArgumentException(_("Emit_InvalidConstant"));
! }
! }
! else if(type.IsEnum)
! {
! // Process enumerated type values.
! if(type != value.GetType() &&
! type.UnderlyingSystemType !=
value.GetType())
! {
! throw new
ArgumentException(_("Emit_InvalidConstant"));
! }
! }
! else if(value is IConvertible)
! {
! // Determine if it is a simple
recognised constant.
! TypeCode code =
((IConvertible)value).GetTypeCode();
! if(code == TypeCode.Empty || code ==
TypeCode.Object ||
! code == TypeCode.DBNull || code ==
TypeCode.DateTime)
! {
! throw new
ArgumentException(_("Emit_InvalidConstant"));
! }
!
! // Check the types.
! if(type != value.GetType())
! {
! throw new
ArgumentException(_("Emit_InvalidConstant"));
! }
! }
! else
! {
! // Not a useful constant value.
! throw new
ArgumentException(_("Emit_InvalidConstant"));
! }
! }
!
! // Create a new field and attach it to a particular class.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static IntPtr ClrFieldCreate
! (IntPtr classInfo, String name, Type type,
! FieldAttributes attributes);
!
! // Internal version of "SetOffset".
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrFieldSetOffset(IntPtr item, int offset);
!
! // Internal version of "SetMarshal".
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrFieldSetMarshal(IntPtr item, byte[] data);
!
! // Internal version of "SetConstant".
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrFieldSetConstant(IntPtr item, Object
value);
}; // class FieldBuilder
Index: ModuleBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/ModuleBuilder.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ModuleBuilder.cs 18 Mar 2003 10:53:15 -0000 1.4
--- ModuleBuilder.cs 20 Mar 2003 06:22:59 -0000 1.5
***************
*** 37,41 ****
{
// Internal state.
! private AssemblyBuilder assembly;
private String name;
private bool transient;
--- 37,41 ----
{
// Internal state.
! internal AssemblyBuilder assembly;
private String name;
private bool transient;
Index: PropertyBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/PropertyBuilder.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PropertyBuilder.cs 1 Mar 2003 19:32:28 -0000 1.2
--- PropertyBuilder.cs 20 Mar 2003 06:22:59 -0000 1.3
***************
*** 30,217 ****
using System.Runtime.CompilerServices;
! [TODO]
! public sealed class PropertyBuilder : PropertyInfo
{
! [TODO]
public void AddOtherMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("AddOtherMethod");
! }
! [TODO]
public override MethodInfo[] GetAccessors(bool nonPublic)
! {
! throw new NotImplementedException("GetAccessors");
! }
! [TODO]
public override Object[] GetCustomAttributes(bool inherit)
! {
! throw new NotImplementedException("GetCustomAttributes");
! }
!
! [TODO]
public override Object[] GetCustomAttributes(Type attributeType,
bool inherit)
! {
! throw new NotImplementedException("GetCustomAttributes");
! }
! [TODO]
public override MethodInfo GetGetMethod(bool nonPublic)
! {
! throw new NotImplementedException("GetGetMethod");
! }
! [TODO]
public override ParameterInfo[] GetIndexParameters()
! {
! throw new NotImplementedException("GetIndexParameters");
! }
! [TODO]
public override MethodInfo GetSetMethod(bool nonPublic)
! {
! throw new NotImplementedException("GetSetMethod");
! }
! [TODO]
public override Object GetValue(Object obj, Object[] index)
! {
! throw new NotImplementedException("GetValue");
! }
!
! [TODO]
public override Object GetValue(Object obj, BindingFlags invokeAttr,
Binder
binder, Object[] index,
CultureInfo culture)
! {
! throw new NotImplementedException("GetValue");
! }
! [TODO]
public override bool IsDefined(Type attributeType, bool inherit)
! {
! throw new NotImplementedException("IsDefined");
! }
! [TODO]
public void SetConstant(Object defaultValue)
! {
! throw new NotImplementedException("SetConstant");
! }
! [TODO]
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
! {
! throw new NotImplementedException("SetCustomAttribute");
! }
!
! [TODO]
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
! {
! throw new NotImplementedException("SetCustomAttribute");
! }
! [TODO]
public void SetGetMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("SetGetMethod");
! }
! [TODO]
public void SetSetMethod(MethodBuilder mdBuilder)
! {
! throw new NotImplementedException("SetSetMethod");
! }
! [TODO]
public override void SetValue(Object obj, Object value, Object[] index)
! {
! throw new NotImplementedException("SetValue");
! }
!
! [TODO]
public override void SetValue(Object obj, Object value,
BindingFlags
invokeAttr,
Binder
binder, Object[] index,
CultureInfo
culture)
! {
! throw new NotImplementedException("SetValue");
! }
! [TODO]
public override PropertyAttributes Attributes
! {
! get
! {
! throw new NotImplementedException("Attributes");
! }
! }
! [TODO]
public override bool CanRead
! {
! get
! {
! throw new NotImplementedException("CanRead");
! }
! }
! [TODO]
public override bool CanWrite
! {
! get
! {
! throw new NotImplementedException("CanWrite");
! }
! }
! [TODO]
public override Type DeclaringType
! {
! get
! {
! throw new NotImplementedException("DeclaringType");
! }
! }
! [TODO]
public override String Name
! {
! get
! {
! throw new NotImplementedException("Name");
! }
! }
! [TODO]
public PropertyToken PropertyToken
! {
! get
! {
! throw new NotImplementedException("PropertyToken");
! }
! }
! [TODO]
public override Type PropertyType
! {
! get
! {
! throw new NotImplementedException("PropertyType");
! }
! }
! [TODO]
public override Type ReflectedType
! {
! get
! {
! throw new NotImplementedException("ReflectedType");
! }
! }
!
! // TODO
}; // class PropertyBuilder
--- 30,376 ----
using System.Runtime.CompilerServices;
! public sealed class PropertyBuilder : PropertyInfo, IClrProgramItem
{
! // Internal state.
! private TypeBuilder type;
! private Type returnType;
! private MethodInfo getMethod;
! private MethodInfo setMethod;
! private IntPtr privateData;
!
! // Constructor.
! internal PropertyBuilder(TypeBuilder type, String name,
! PropertyAttributes
attributes,
! Type returnType,
Type[] parameterTypes)
! {
! // Validate the parameters.
! if(name == null)
! {
! throw new ArgumentNullException("name");
! }
! else if(returnType == null)
! {
! throw new
ArgumentNullException("returnType");
! }
!
! // Initialize this object's internal state.
! this.type = type;
! this.returnType = returnType;
! this.getMethod = null;
! this.setMethod = null;
!
! // Create the property.
! this.privateData = ClrPropertyCreate
! (((IClrProgramItem)type).ClrHandle,
name,
! attributes, returnType,
parameterTypes);
! }
!
! // Add an "other" method to this property.
public void AddOtherMethod(MethodBuilder mdBuilder)
! {
! try
! {
! type.StartSync();
! if(mdBuilder == null)
! {
! throw new
ArgumentNullException("mdBuilder");
! }
! ClrPropertyAddSemantics
! (privateData,
MethodSemanticsAttributes.Other,
!
type.module.GetMethodToken(mdBuilder));
! }
! finally
! {
! type.EndSync();
! }
! }
! // Get the accessor methods for this property.
public override MethodInfo[] GetAccessors(bool nonPublic)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Get custom attributes form this property.
public override Object[] GetCustomAttributes(bool inherit)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
public override Object[] GetCustomAttributes(Type attributeType,
bool inherit)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Get the "get" method for this property.
public override MethodInfo GetGetMethod(bool nonPublic)
! {
! if(getMethod == null || nonPublic)
! {
! return getMethod;
! }
! else if((getMethod.Attributes &
!
MethodAttributes.MemberAccessMask) ==
! MethodAttributes.Public)
! {
! return getMethod;
! }
! else
! {
! return null;
! }
! }
! // Get the index parameters for this property.
public override ParameterInfo[] GetIndexParameters()
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Get the "set" method for this property.
public override MethodInfo GetSetMethod(bool nonPublic)
! {
! if(setMethod == null || nonPublic)
! {
! return setMethod;
! }
! else if((setMethod.Attributes &
!
MethodAttributes.MemberAccessMask) ==
! MethodAttributes.Public)
! {
! return setMethod;
! }
! else
! {
! return null;
! }
! }
! // Get the value of this property on an object.
public override Object GetValue(Object obj, Object[] index)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
public override Object GetValue(Object obj, BindingFlags invokeAttr,
Binder
binder, Object[] index,
CultureInfo culture)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Determine if a particular custom attribute is defined on this
property.
public override bool IsDefined(Type attributeType, bool inherit)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Set the constant value on this property.
public void SetConstant(Object defaultValue)
! {
! try
! {
! type.StartSync();
!
FieldBuilder.ValidateConstant(returnType, defaultValue);
! ClrPropertySetConstant(privateData,
defaultValue);
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set a custom attribute on this property.
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
! {
! try
! {
! type.StartSync();
! type.module.assembly.SetCustomAttribute
! (this, customBuilder);
! }
! finally
! {
! type.EndSync();
! }
! }
public void SetCustomAttribute(ConstructorInfo con, byte[]
binaryAttribute)
! {
! try
! {
! type.StartSync();
! type.module.assembly.SetCustomAttribute
! (this, con, binaryAttribute);
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the "get" method on this property.
public void SetGetMethod(MethodBuilder mdBuilder)
! {
! try
! {
! type.StartSync();
! if(mdBuilder == null)
! {
! throw new
ArgumentNullException("mdBuilder");
! }
! else if(getMethod != null)
! {
! throw new ArgumentException
!
(_("Emit_GetAlreadyDefined"));
! }
! ClrPropertyAddSemantics
! (privateData,
MethodSemanticsAttributes.Getter,
!
type.module.GetMethodToken(mdBuilder));
! getMethod = mdBuilder;
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the "set" method on this property.
public void SetSetMethod(MethodBuilder mdBuilder)
! {
! try
! {
! type.StartSync();
! if(mdBuilder == null)
! {
! throw new
ArgumentNullException("mdBuilder");
! }
! else if(setMethod != null)
! {
! throw new ArgumentException
!
(_("Emit_SetAlreadyDefined"));
! }
! ClrPropertyAddSemantics
! (privateData,
MethodSemanticsAttributes.Setter,
!
type.module.GetMethodToken(mdBuilder));
! setMethod = mdBuilder;
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set the value of this property on an object.
public override void SetValue(Object obj, Object value, Object[] index)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
public override void SetValue(Object obj, Object value,
BindingFlags
invokeAttr,
Binder
binder, Object[] index,
CultureInfo
culture)
! {
! throw new
NotSupportedException(_("NotSupp_Builder"));
! }
! // Get the attributes for this property.
public override PropertyAttributes Attributes
! {
! get
! {
! return (PropertyAttributes)
!
ClrHelpers.GetMemberAttrs(privateData);
! }
! }
! // Determine if we can read from this property.
public override bool CanRead
! {
! get
! {
! return (getMethod != null);
! }
! }
! // Determine if we can write to this property.
public override bool CanWrite
! {
! get
! {
! return (setMethod != null);
! }
! }
! // Get the type that this property is declared within.
public override Type DeclaringType
! {
! get
! {
! return type;
! }
! }
! // Get the name of this property.
public override String Name
! {
! get
! {
! return ClrHelpers.GetName(this);
! }
! }
! // Get the token associated with this property.
public PropertyToken PropertyToken
! {
! get
! {
! return new PropertyToken
!
(AssemblyBuilder.ClrGetItemToken(privateData));
! }
! }
! // Get the type associated with this property.
public override Type PropertyType
! {
! get
! {
! return returnType;
! }
! }
! // Get the reflected type that this property exists within.
public override Type ReflectedType
! {
! get
! {
! return type;
! }
! }
!
! // Get the CLR handle for this property.
! IntPtr IClrProgramItem.ClrHandle
! {
! get
! {
! return privateData;
! }
! }
!
! // Create a new event and attach it to a particular class.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static IntPtr ClrPropertyCreate
! (IntPtr classInfo, String name,
! PropertyAttributes attributes,
! Type returnType, Type[] parameterTypes);
!
! // Add semantic information to this property.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrPropertyAddSemantics
! (IntPtr item, MethodSemanticsAttributes attr,
! MethodToken token);
!
! // Internal version of "SetConstant".
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrPropertySetConstant
! (IntPtr item, Object value);
}; // class PropertyBuilder
Index: TypeBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/TypeBuilder.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** TypeBuilder.cs 18 Mar 2003 09:54:50 -0000 1.3
--- TypeBuilder.cs 20 Mar 2003 06:22:59 -0000 1.4
***************
*** 26,29 ****
--- 26,30 ----
using System;
+ using System.Collections;
using System.Globalization;
using System.Reflection;
***************
*** 35,39 ****
{
// Internal state.
! private ModuleBuilder module;
private String name;
private String nspace;
--- 36,41 ----
{
// Internal state.
! private IntPtr privateData; // Must be the first
field.
! internal ModuleBuilder module;
private String name;
private String nspace;
***************
*** 46,51 ****
private ClrType type;
private TypeToken token;
- private IntPtr privateData;
private Type underlyingSystemType;
// Constants.
--- 48,53 ----
private ClrType type;
private TypeToken token;
private Type underlyingSystemType;
+ private ArrayList methods;
// Constants.
***************
*** 89,92 ****
--- 91,95 ----
this.underlyingSystemType = null;
this.token = new TypeToken(0); // TODO
+ this.methods = new ArrayList();
}
***************
*** 261,265 ****
// Check that the type has not yet been created.
! private void CheckNotCreated()
{
if(type != null)
--- 264,268 ----
// Check that the type has not yet been created.
! internal void CheckNotCreated()
{
if(type != null)
***************
*** 270,274 ****
// Check that the type has been created.
! private void CheckCreated()
{
if(type == null)
--- 273,277 ----
// Check that the type has been created.
! internal void CheckCreated()
{
if(type == null)
***************
*** 280,284 ****
// Start a synchronized type builder operation.
! private void StartSync()
{
module.StartSync();
--- 283,287 ----
// Start a synchronized type builder operation.
! internal void StartSync()
{
module.StartSync();
***************
*** 290,294 ****
// End a synchronized type builder operation.
! private void EndSync()
{
module.EndSync();
--- 293,297 ----
// End a synchronized type builder operation.
! internal void EndSync()
{
module.EndSync();
***************
*** 411,415 ****
// Define an event for this class.
- [TODO]
public EventBuilder DefineEvent
(String name, EventAttributes attributes, Type
eventType)
--- 414,417 ----
***************
*** 418,423 ****
{
StartSync();
! // TODO
! return null;
}
finally
--- 420,424 ----
{
StartSync();
! return new EventBuilder(this, name,
attributes, eventType);
}
finally
***************
*** 428,432 ****
// Define a field for this class.
- [TODO]
public FieldBuilder DefineField
(String name, Type type, FieldAttributes
attributes)
--- 429,432 ----
***************
*** 435,439 ****
{
StartSync();
- // TODO
if(IsEnum && underlyingSystemType ==
null &&
(attributes &
FieldAttributes.Static) == 0)
--- 435,438 ----
***************
*** 441,445 ****
underlyingSystemType = type;
}
! return null;
}
finally
--- 440,444 ----
underlyingSystemType = type;
}
! return new FieldBuilder(this, name,
type, attributes);
}
finally
***************
*** 652,657 ****
{
StartSync();
! // TODO
! return null;
}
finally
--- 651,656 ----
{
StartSync();
! return new PropertyBuilder
! (this, name, attributes,
returnType, parameterTypes);
}
finally
***************
*** 961,965 ****
// Set a custom attribute on this type builder.
- [TODO]
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
--- 960,963 ----
***************
*** 967,971 ****
{
StartSync();
! // TODO
}
finally
--- 965,969 ----
{
StartSync();
!
module.assembly.SetCustomAttribute(this, customBuilder);
}
finally
***************
*** 974,978 ****
}
}
- [TODO]
public void SetCustomAttribute(ConstructorInfo con,
byte[]
binaryAttribute)
--- 972,975 ----
***************
*** 981,985 ****
{
StartSync();
! // TODO
}
finally
--- 978,983 ----
{
StartSync();
! module.assembly.SetCustomAttribute
! (this, con, binaryAttribute);
}
finally
***************
*** 1020,1023 ****
--- 1018,1027 ----
return privateData;
}
+ }
+
+ // Add a method to this type for later processing during "CreateType".
+ internal void AddMethod(MethodBase method)
+ {
+ methods.Add(method);
}
Index: UnmanagedMarshal.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/UnmanagedMarshal.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** UnmanagedMarshal.cs 22 Dec 2002 10:50:17 -0000 1.2
--- UnmanagedMarshal.cs 20 Mar 2003 06:22:59 -0000 1.3
***************
*** 1,8 ****
/*
! * UnmanagedMarshal.cs - Implementation of
"System.Reflection.Emit.UnmanagedMarshal"
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
! * Contributed by Gopal.V <address@hidden>
*
* This program is free software; you can redistribute it and/or modify
--- 1,10 ----
/*
! * UnmanagedMarshal.cs - Implementation of the
! * "System.Reflection.Emit.UnmanagedMarshal" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
! * Contributions from by Gopal.V <address@hidden>
! * Rhys Weatherley <address@hidden>
*
* This program is free software; you can redistribute it and/or modify
***************
*** 21,101 ****
*/
! using System;
! using System.Runtime.InteropServices;
#if !ECMA_COMPAT
! namespace System.Reflection.Emit
{
! public sealed class UnmanagedMarshal
! {
! [TODO]
! public static UnmanagedMarshal DefineByValArray(int elemCount)
! {
! throw new NotImplementedException("DefineByValArray");
! }
!
! [TODO]
! public static UnmanagedMarshal DefineByValTStr(int elemCount)
! {
! throw new NotImplementedException("DefineByValTStr");
! }
!
! [TODO]
! public static UnmanagedMarshal DefineLPArray(UnmanagedType
elemType)
! {
! throw new NotImplementedException("DefineLPArray");
! }
!
! [TODO]
! public static UnmanagedMarshal DefineSafeArray(UnmanagedType
elemType)
! {
! throw new NotImplementedException("DefineSafeArray");
! }
!
! [TODO]
! public static UnmanagedMarshal
DefineUnmanagedMarshal(UnmanagedType unmanagedType)
! {
! throw new
NotImplementedException("DefineUnmanagedMarshal");
! }
!
! [TODO]
! public UnmanagedType BaseType
! {
! get
! {
! throw new NotImplementedException("BaseType");
! }
! }
!
! [TODO]
! public int ElementCount
! {
! get
! {
! throw new
NotImplementedException("ElementCount");
! }
! }
!
! [TODO]
! public UnmanagedType GetUnmanagedType
! {
! get
! {
! throw new
NotImplementedException("GetUnmanagedType");
! }
! }
!
! [TODO]
! public Guid IIDGuid
! {
! get
{
! throw new NotImplementedException("IIDGuid");
}
- }
! }
! }//namespace
! #endif
--- 23,220 ----
*/
! namespace System.Reflection.Emit
! {
#if !ECMA_COMPAT
! using System;
! using System.Runtime.InteropServices;
!
! public sealed class UnmanagedMarshal
{
! // Internal state.
! private UnmanagedType type;
! private UnmanagedType baseType;
! private int elemCount;
!
! // Constructor.
! private UnmanagedMarshal(UnmanagedType type)
! {
! this.type = type;
! }
! private UnmanagedMarshal(UnmanagedType type, int elemCount)
! {
! this.type = type;
! this.elemCount = elemCount;
! }
! private UnmanagedMarshal(UnmanagedType type, UnmanagedType baseType)
! {
! this.type = type;
! this.elemCount = elemCount;
! }
!
! // Define a by-value array type.
! public static UnmanagedMarshal DefineByValArray(int elemCount)
! {
! return new UnmanagedMarshal
! (UnmanagedType.ByValArray, elemCount);
! }
!
! // Define a by-value TSTR type.
! public static UnmanagedMarshal DefineByValTStr(int elemCount)
! {
! return new UnmanagedMarshal
! (UnmanagedType.ByValTStr, elemCount);
! }
!
! // Define an LP array type.
! public static UnmanagedMarshal DefineLPArray(UnmanagedType elemType)
{
! return new
UnmanagedMarshal(UnmanagedType.LPArray, elemType);
}
! // Define a safe array.
! public static UnmanagedMarshal DefineSafeArray(UnmanagedType elemType)
! {
! return new
UnmanagedMarshal(UnmanagedType.SafeArray, elemType);
! }
!
! // Define a simple unmanaged marshalling behaviour.
! public static UnmanagedMarshal DefineUnmanagedMarshal
! (UnmanagedType unmanagedType)
! {
! // Must be a simple unmanaged type.
! if(unmanagedType == UnmanagedType.ByValArray ||
! unmanagedType == UnmanagedType.ByValTStr ||
! unmanagedType == UnmanagedType.LPArray ||
! unmanagedType == UnmanagedType.SafeArray ||
! unmanagedType ==
UnmanagedType.CustomMarshaler)
! {
! throw new ArgumentException
!
(_("Emit_NotSimpleUnmanagedType"));
! }
! return new UnmanagedMarshal(unmanagedType);
! }
!
! // Get the base type for marshalling behaviour.
! public UnmanagedType BaseType
! {
! get
! {
! if(type == UnmanagedType.LPArray ||
! type == UnmanagedType.SafeArray)
! {
! return baseType;
! }
! else
! {
! throw new ArgumentException
!
(_("Emit_NoUnmanagedBaseType"));
! }
! }
! }
!
! // Get the number of elements in an array type.
! public int ElementCount
! {
! get
! {
! if(type == UnmanagedType.ByValArray ||
! type == UnmanagedType.ByValTStr)
! {
! return elemCount;
! }
! else
! {
! throw new ArgumentException
!
(_("Emit_NoUnmanagedElementCount"));
! }
! }
! }
!
! // Get the primary unmanaged type code for marshalling behaviour.
! public UnmanagedType GetUnmanagedType
! {
! get
! {
! return type;
! }
! }
!
! // Get the GUID information for custom marshalling.
! public Guid IIDGuid
! {
! get
! {
! if(type ==
UnmanagedType.CustomMarshaler)
! {
! // It is not actually possible
to set the GUID
! // through any of the API's, so
it will always
! // be the empty GUID.
! return Guid.Empty;
! }
! else
! {
! throw new
ArgumentException(_("Emit_NotCustom"));
! }
! }
! }
!
! // Convert this object into an array of marshalling bytes.
! internal byte[] ToBytes()
! {
! byte[] bytes;
! switch(type)
! {
! case UnmanagedType.ByValArray:
! case UnmanagedType.ByValTStr:
! {
! if(elemCount < 0x80)
! {
! bytes = new byte [1];
! bytes[0] = (byte)type;
! bytes[1] =
(byte)elemCount;
! }
! else if(elemCount < 0x4000)
! {
! bytes = new byte [2];
! bytes[0] = (byte)type;
! bytes[1] =
(byte)((elemCount >> 8) | 0x80);
! bytes[2] =
(byte)(elemCount & 0xFF);
! }
! else
! {
! bytes = new byte [5];
! bytes[0] = (byte)type;
! bytes[1] =
(byte)((elemCount >> 24) | 0x80);
! bytes[2] =
(byte)((elemCount >> 16) | 0x80);
! bytes[3] =
(byte)((elemCount >> 8) | 0x80);
! bytes[4] =
(byte)(elemCount & 0xFF);
! }
! }
! break;
!
! case UnmanagedType.LPArray:
! case UnmanagedType.SafeArray:
! {
! bytes = new byte [2];
! bytes[0] = (byte)type;
! bytes[1] = (byte)baseType;
! }
! break;
!
! default:
! {
! bytes = new byte [1];
! bytes[0] = (byte)type;
! }
! break;
! }
! return bytes;
! }
!
! }; // class UnmanagedMarshal
!
! #endif // !ECMA_COMPAT
! }; // namespace System.Reflection.Emit
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit AssemblyBuilder.cs,1.3,1.4 EventBuilder.cs,1.2,1.3 FieldBuilder.cs,1.2,1.3 ModuleBuilder.cs,1.4,1.5 PropertyBuilder.cs,1.2,1.3 TypeBuilder.cs,1.3,1.4 UnmanagedMarshal.cs,1.2,1.3,
Rhys Weatherley <address@hidden> <=
- Re: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit AssemblyBuilder.cs,1.3,1.4 EventBuilder.cs,1.2,1.3 FieldBuilder.cs,1.2,1.3 ModuleBuilder.cs,1.4,1.5 PropertyBuilder.cs,1.2,1.3 TypeBuilder.cs,1.3,1.4 UnmanagedMarshal.cs,1.2,1.3, James Michael DuPont, 2003/03/20
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.755,1.756
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h,1.47,1.48 int_table.c,1.49,1.50 lib_emit.c,1.3,1.4
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.755,1.756
- Next by thread:
Re: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit AssemblyBuilder.cs,1.3,1.4 EventBuilder.cs,1.2,1.3 FieldBuilder.cs,1.2,1.3 ModuleBuilder.cs,1.4,1.5 PropertyBuilder.cs,1.2,1.3 TypeBuilder.cs,1.3,1.4 UnmanagedMarshal.cs,1.2,1.3
- Index(es):