[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit Constr
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit ConstructorBuilder.cs,1.5,1.6 FieldBuilder.cs,1.6,1.7 ILGenerator.cs,1.8,1.9 LocalBuilder.cs,1.4,1.5 MethodBuilder.cs,1.5,1.6 ModuleBuilder.cs,1.7,1.8 ParameterBuilder.cs,1.3,1.4 PropertyBuilder.cs,1.6,1.7 TypeBuilder.cs,1.7,1.8 |
Date: |
Thu, 27 Mar 2003 20:04:18 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit
In directory subversions:/tmp/cvs-serv1632/runtime/System/Reflection/Emit
Modified Files:
ConstructorBuilder.cs FieldBuilder.cs ILGenerator.cs
LocalBuilder.cs MethodBuilder.cs ModuleBuilder.cs
ParameterBuilder.cs PropertyBuilder.cs TypeBuilder.cs
Log Message:
Continue implementation of the Reflection.Emit API.
Index: ConstructorBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/ConstructorBuilder.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ConstructorBuilder.cs 22 Mar 2003 05:55:13 -0000 1.5
--- ConstructorBuilder.cs 28 Mar 2003 01:04:15 -0000 1.6
***************
*** 26,29 ****
--- 26,30 ----
using System;
+ using System.Text;
using System.Security;
using System.Reflection;
***************
*** 108,112 ****
}
return new ParameterBuilder
! (this, iSequence, attributes,
strParamName);
}
finally
--- 109,113 ----
}
return new ParameterBuilder
! (type, this, iSequence,
attributes, strParamName);
}
finally
***************
*** 251,259 ****
// Convert this constructor into a string.
- [TODO]
public override String ToString()
{
! // TODO
! return String.Empty;
}
--- 252,269 ----
// Convert this constructor into a string.
public override String ToString()
{
! StringBuilder builder = new StringBuilder();
! builder.Append("Name: ");
! builder.Append(Name);
! builder.Append(Environment.NewLine);
! builder.Append("Attributes: ");
! builder.Append(Attributes.ToString());
! builder.Append(Environment.NewLine);
! builder.Append("Method Signature: ");
! builder.Append(helper.ToString());
! builder.Append(Environment.NewLine);
! builder.Append(Environment.NewLine);
! return builder.ToString();
}
***************
*** 353,357 ****
internal void FinalizeConstructor()
{
! // TODO
}
--- 363,379 ----
internal void FinalizeConstructor()
{
! int rva;
! if(ilGenerator != null)
! {
! rva = ilGenerator.WriteCode(initLocals);
! }
! else
! {
! rva = 0;
! }
! lock(typeof(AssemblyBuilder))
! {
!
MethodBuilder.ClrMethodSetRVA(privateData, rva);
! }
}
Index: FieldBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/FieldBuilder.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** FieldBuilder.cs 22 Mar 2003 05:55:13 -0000 1.6
--- FieldBuilder.cs 28 Mar 2003 01:04:15 -0000 1.7
***************
*** 303,306 ****
--- 303,326 ----
}
+ // Set data on this field within the ".sdata" section of the binary.
+ internal void SetData(byte[] data, int size)
+ {
+ int rva;
+ lock(typeof(AssemblyBuilder))
+ {
+ if(data != null)
+ {
+ rva =
ModuleBuilder.ClrModuleWriteData
+
(type.module.privateData, data);
+ }
+ else
+ {
+ rva =
ModuleBuilder.ClrModuleWriteGap
+
(type.module.privateData, size);
+ }
+ ClrFieldSetRVA(privateData, rva);
+ }
+ }
+
// Create a new field and attach it to a particular class.
[MethodImpl(MethodImplOptions.InternalCall)]
***************
*** 313,323 ****
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
--- 333,348 ----
extern private static void ClrFieldSetOffset(IntPtr item, int offset);
! // Internal version of "SetMarshal" (used by ParameterBuilder also).
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern internal static void ClrFieldSetMarshal(IntPtr item, byte[]
data);
!
! // Internal version of "SetConstant" (used by ParameterBuilder and
! // PropertyBuilder also).
[MethodImpl(MethodImplOptions.InternalCall)]
! extern internal static void ClrFieldSetConstant(IntPtr item, Object
value);
! // Set the RVA on a field.
[MethodImpl(MethodImplOptions.InternalCall)]
! extern private static void ClrFieldSetRVA(IntPtr item, int rva);
}; // class FieldBuilder
Index: ILGenerator.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/ILGenerator.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** ILGenerator.cs 22 Mar 2003 05:55:13 -0000 1.8
--- ILGenerator.cs 28 Mar 2003 01:04:15 -0000 1.9
***************
*** 126,129 ****
--- 126,135 ----
module.assembly.AddDetach(this);
}
+ private ILGenerator(ModuleBuilder module, byte[] explicitBody)
+ : this(module, explicitBody.Length)
+ {
+ Array.Copy(explicitBody, 0, code, 0,
explicitBody.Length);
+ maxHeight = 8;
+ }
// Terminate the previous exception clause.
***************
*** 1223,1226 ****
--- 1229,1249 ----
{
tokenFixups = null;
+ }
+
+ // Write the contents of this generator to the code section
+ // and return the RVA that corresponds to it.
+ internal int WriteCode(bool initLocals)
+ {
+ // TODO
+ return 0;
+ }
+
+ // Write an explicit method body to the code section and
+ // return the RVA that corresponds to it.
+ internal static int WriteExplicitCode
+ (ModuleBuilder module, byte[] explicitBody,
bool initLocals)
+ {
+ ILGenerator ilgen = new ILGenerator(module,
explicitBody);
+ return ilgen.WriteCode(initLocals);
}
Index: LocalBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/LocalBuilder.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** LocalBuilder.cs 22 Mar 2003 01:33:16 -0000 1.4
--- LocalBuilder.cs 28 Mar 2003 01:04:15 -0000 1.5
***************
*** 45,54 ****
}
! // Set the symbol information for a local variable.
! [TODO]
public void SetLocalSymInfo(String lname, int startOffset, int
endOffset)
{
name = lname;
- // TODO: write debug information about the
local variable
}
public void SetLocalSymInfo(String lname)
--- 45,52 ----
}
! // Set the symbol information for a local variable. Not used here.
public void SetLocalSymInfo(String lname, int startOffset, int
endOffset)
{
name = lname;
}
public void SetLocalSymInfo(String lname)
Index: MethodBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/MethodBuilder.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** MethodBuilder.cs 22 Mar 2003 05:55:13 -0000 1.5
--- MethodBuilder.cs 28 Mar 2003 01:04:15 -0000 1.6
***************
*** 27,30 ****
--- 27,31 ----
using System;
using System.Security;
+ using System.Text;
using System.Reflection;
using System.Globalization;
***************
*** 66,70 ****
returnType = typeof(void);
}
! // TODO
// Set the local state.
--- 67,92 ----
returnType = typeof(void);
}
! if((attributes & MethodAttributes.Static) == 0)
! {
! callingConvention |=
CallingConventions.HasThis;
! }
! else if((attributes & MethodAttributes.Virtual)
!= 0)
! {
! throw new ArgumentException
!
(_("Emit_BothStaticAndVirtual"));
! }
! if((type.Attributes &
TypeAttributes.ClassSemanticsMask)
! == TypeAttributes.Interface &&
! (attributes & MethodAttributes.SpecialName)
== 0)
! {
! if((attributes &
(MethodAttributes.Virtual |
!
MethodAttributes.Abstract))
! != (MethodAttributes.Virtual |
!
MethodAttributes.Abstract))
! {
! throw new ArgumentException
!
(_("Emit_InterfaceMethodAttrs"));
! }
! }
// Set the local state.
***************
*** 163,167 ****
}
return new ParameterBuilder
! (this, position, attributes,
strParamName);
}
finally
--- 185,189 ----
}
return new ParameterBuilder
! (type, this, position,
attributes, strParamName);
}
finally
***************
*** 321,325 ****
{
returnBuilder = new
ParameterBuilder
! (this, 0,
ParameterAttributes.None, null);
}
returnBuilder.SetMarshal(unmanagedMarshal);
--- 343,347 ----
{
returnBuilder = new
ParameterBuilder
! (type, this, 0,
ParameterAttributes.None, null);
}
returnBuilder.SetMarshal(unmanagedMarshal);
***************
*** 384,392 ****
// Convert this method into a string.
- [TODO]
public override String ToString()
{
! // TODO
! return String.Empty;
}
--- 406,423 ----
// Convert this method into a string.
public override String ToString()
{
! StringBuilder builder = new StringBuilder();
! builder.Append("Name: ");
! builder.Append(Name);
! builder.Append(Environment.NewLine);
! builder.Append("Attributes: ");
! builder.Append(Attributes.ToString());
! builder.Append(Environment.NewLine);
! builder.Append("Method Signature: ");
! builder.Append(helper.ToString());
! builder.Append(Environment.NewLine);
! builder.Append(Environment.NewLine);
! return builder.ToString();
}
***************
*** 508,512 ****
internal void FinalizeMethod()
{
! // TODO
}
--- 539,567 ----
internal void FinalizeMethod()
{
! int rva;
! if(bodySet)
! {
! if(explicitBody == null)
! {
! rva = 0;
! }
! else
! {
! rva =
ILGenerator.WriteExplicitCode
! (type.module,
explicitBody, initLocals);
! }
! }
! else if(ilGenerator != null)
! {
! rva = ilGenerator.WriteCode(initLocals);
! }
! else
! {
! rva = 0;
! }
! lock(typeof(AssemblyBuilder))
! {
! ClrMethodSetRVA(privateData, rva);
! }
}
***************
*** 532,535 ****
--- 587,599 ----
extern internal static int ClrMethodCreateVarArgRef
(IntPtr module, int methodToken, IntPtr signature);
+
+ // Set the RVA for a method's code.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern internal static void ClrMethodSetRVA(IntPtr method, int rva);
+
+ // Add a PInvoke declaration to a method.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern internal static void ClrMethodAddPInvoke
+ (IntPtr method, int pinvAttrs, String dllName, String
entryName);
}; // class MethodBuilder
Index: ModuleBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/ModuleBuilder.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** ModuleBuilder.cs 22 Mar 2003 05:55:13 -0000 1.7
--- ModuleBuilder.cs 28 Mar 2003 01:04:15 -0000 1.8
***************
*** 691,694 ****
--- 691,702 ----
extern private static int ClrModuleCreateString(IntPtr module, String
str);
+ // Write data directly to the ".sdata" section of a module.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern internal static int ClrModuleWriteData(IntPtr module, byte[]
data);
+
+ // Write zero data directly to the ".sdata" section of a module.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern internal static int ClrModuleWriteGap(IntPtr module, int size);
+
}; // class ModuleBuilder
Index: ParameterBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/ParameterBuilder.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ParameterBuilder.cs 22 Mar 2003 01:33:16 -0000 1.3
--- ParameterBuilder.cs 28 Mar 2003 01:04:15 -0000 1.4
***************
*** 1,4 ****
/*
! * ParameterBuilder.cs - Implementation of
"System.Reflection.Emit.ParameterBuilder"
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
--- 1,5 ----
/*
! * ParameterBuilder.cs - Implementation of the
! * "System.Reflection.Emit.ParameterBuilder" class.
*
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
***************
*** 21,127 ****
*/
! using System;
#if !ECMA_COMPAT
! namespace System.Reflection.Emit
{
! public class ParameterBuilder
! {
! // Constructor.
! internal ParameterBuilder(MethodBase method, int position,
!
ParameterAttributes attributes,
! String
strParamName)
{
! // TODO
}
! [TODO]
! public virtual ParameterToken GetToken()
! {
! throw new NotImplementedException("GetToken");
! }
! [TODO]
! public virtual 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 virtual void SetMarshal(UnmanagedMarshal
unmanagedMarshal)
! {
! throw new NotImplementedException("SetMarshal");
! }
! [TODO]
! public virtual int Attributes
! {
! get
{
! throw new NotImplementedException("Attributes");
}
- }
! [TODO]
! public bool IsIn
! {
! get
{
! throw new NotImplementedException("IsIn");
}
- }
! [TODO]
! public bool IsOptional
! {
! get
{
! throw new NotImplementedException("IsOptional");
}
- }
! [TODO]
! public bool IsOut
! {
! get
{
! throw new NotImplementedException("IsOut");
}
- }
! [TODO]
! public virtual String Name
! {
! get
{
! throw new NotImplementedException("Name");
}
- }
! [TODO]
! public virtual int Position
! {
! get
{
! throw new NotImplementedException("Position");
}
- }
! }
! }//namespace
! #endif
--- 22,258 ----
*/
! namespace System.Reflection.Emit
! {
#if !ECMA_COMPAT
! using System;
! using System.Runtime.CompilerServices;
!
! public class ParameterBuilder : IClrProgramItem, IDetachItem
{
! // Internal state.
! private TypeBuilder type;
! private MethodBase method;
! private IntPtr privateData;
!
! // Constructor.
! internal ParameterBuilder(TypeBuilder type, MethodBase method,
! int position,
ParameterAttributes attributes,
! String strParamName)
! {
! // Initialize the internal state.
! this.type = type;
! this.method = method;
!
! // Register this item to be detached later.
! type.module.assembly.AddDetach(this);
! // Create the parameter.
! lock(typeof(AssemblyBuilder))
{
! this.privateData = ClrParameterCreate
!
(((IClrProgramItem)method).ClrHandle,
! position, attributes,
strParamName);
}
+ }
! // Get the token for this parameter.
! public virtual ParameterToken GetToken()
! {
! lock(typeof(AssemblyBuilder))
! {
! return new ParameterToken
!
(AssemblyBuilder.ClrGetItemToken(privateData));
! }
! }
!
! // Set a default constant value for this parameter.
! public virtual void SetConstant(Object defaultValue)
! {
! Type paramType;
! int position;
! try
! {
! type.StartSync();
! position = Position;
! if(position == 0)
! {
! if(method is MethodInfo)
! {
! paramType =
((MethodInfo)method).ReturnType;
! }
! else
! {
! paramType =
typeof(void);
! }
! }
! else
! {
! paramType =
((method.GetParameters())[position - 1])
!
.ParameterType;
! }
!
FieldBuilder.ValidateConstant(paramType, defaultValue);
! lock(typeof(AssemblyBuilder))
! {
! FieldBuilder.ClrFieldSetConstant
! (privateData,
defaultValue);
! }
! }
! finally
! {
! type.EndSync();
! }
! }
! // Set a custom attribute on this parameter.
! 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 parameter.
! public virtual void SetMarshal(UnmanagedMarshal unmanagedMarshal)
! {
! try
! {
! type.StartSync();
! if(unmanagedMarshal == null)
! {
! throw new
ArgumentNullException("unmanagedMarshal");
! }
! lock(typeof(AssemblyBuilder))
! {
! FieldBuilder.ClrFieldSetMarshal
! (privateData,
unmanagedMarshal.ToBytes());
! }
! }
! finally
! {
! type.EndSync();
! }
! }
! // Get the attributes for this parameter.
! public virtual int Attributes
! {
! get
! {
! lock(typeof(AssemblyBuilder))
! {
! return
ClrParameterGetAttrs(privateData);
! }
! }
! }
! // Determine if this is an "in" parameter.
! public bool IsIn
! {
! get
! {
! return ((Attributes & 0x0001) != 0);
! }
! }
! // Determine if this is an "optional" parameter.
! public bool IsOptional
{
! get
! {
! return ((Attributes & 0x0004) != 0);
! }
}
! // Determine if this is an "out" parameter.
! public bool IsOut
{
! get
! {
! return ((Attributes & 0x0002) != 0);
! }
}
! // Get the name that is associated with this parameter.
! public virtual String Name
{
! get
! {
! lock(typeof(AssemblyBuilder))
! {
! return
ClrParameterGetName(privateData);
! }
! }
}
! // Get the position associated with this parameter.
! public virtual int Position
{
! get
! {
! lock(typeof(AssemblyBuilder))
! {
! return
ClrParameterGetPosition(privateData);
! }
! }
}
! // Get the CLR handle for this program item.
! IntPtr IClrProgramItem.ClrHandle
{
! get
! {
! return privateData;
! }
}
! // Detach this program item.
! void IDetachItem.Detach()
{
! privateData = IntPtr.Zero;
}
! // Create a new parameter and attach it to a particular method.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern internal static IntPtr ClrParameterCreate
! (IntPtr method, int position,
! ParameterAttributes attributes, String name);
!
! // Get the attributes associated with a parameter.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern internal static int ClrParameterGetAttrs(IntPtr parameter);
!
! // Get the name associated with a parameter.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern internal static String ClrParameterGetName(IntPtr parameter);
!
! // Get the position associated with a parameter.
! [MethodImpl(MethodImplOptions.InternalCall)]
! extern internal static int ClrParameterGetPosition(IntPtr parameter);
!
! }; // class ParameterBuilder
!
! #endif // !ECMA_COMPAT
! }; // namespace System.Reflection.Emit
Index: PropertyBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/PropertyBuilder.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** PropertyBuilder.cs 22 Mar 2003 05:55:13 -0000 1.6
--- PropertyBuilder.cs 28 Mar 2003 01:04:15 -0000 1.7
***************
*** 189,193 ****
lock(typeof(AssemblyBuilder))
{
!
ClrPropertySetConstant(privateData, defaultValue);
}
}
--- 189,194 ----
lock(typeof(AssemblyBuilder))
{
! FieldBuilder.ClrFieldSetConstant
! (privateData,
defaultValue);
}
}
***************
*** 406,414 ****
(IntPtr item, MethodSemanticsAttributes attr,
MethodToken token);
-
- // Internal version of "SetConstant".
- [MethodImpl(MethodImplOptions.InternalCall)]
- extern private static void ClrPropertySetConstant
- (IntPtr item, Object value);
}; // class PropertyBuilder
--- 407,410 ----
Index: TypeBuilder.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Reflection/Emit/TypeBuilder.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** TypeBuilder.cs 22 Mar 2003 05:55:13 -0000 1.7
--- TypeBuilder.cs 28 Mar 2003 01:04:15 -0000 1.8
***************
*** 72,79 ****
nspace = String.Empty;
}
- // TODO
-
- // Check for an existing type with this name.
- // TODO
// Initialize the internal state.
--- 72,75 ----
***************
*** 90,105 ****
this.needsDefaultConstructor = true;
! // Register this item to be detached later.
! module.assembly.AddDetach(this);
!
! // Create the type.
lock(typeof(AssemblyBuilder))
{
privateData = ClrTypeCreate
!
(((IClrProgramItem)module).ClrHandle, name,
(nspace == String.Empty ? null
: nspace), attr,
(parent == null
? new
System.Reflection.Emit.TypeToken(0)
:
module.GetTypeToken(parent)));
if(packingSize !=
PackingSize.Unspecified)
{
--- 86,116 ----
this.needsDefaultConstructor = true;
! // We need the AssemblyBuilder lock for the
next part.
lock(typeof(AssemblyBuilder))
{
+ // Determine the scope to use to
declare the type.
+ IntPtr scope;
+ if(declaringType == null)
+ {
+ scope = IntPtr.Zero;
+ }
+ else
+ {
+ scope =
((IClrProgramItem)declaringType).ClrHandle;
+ }
+
+ // Create the type.
privateData = ClrTypeCreate
!
(((IClrProgramItem)module).ClrHandle, scope, name,
(nspace == String.Empty ? null
: nspace), attr,
(parent == null
? new
System.Reflection.Emit.TypeToken(0)
:
module.GetTypeToken(parent)));
+ if(privateData == IntPtr.Zero)
+ {
+ throw new ArgumentException
+
(_("Emit_TypeAlreadyExists"));
+ }
+ module.assembly.AddDetach(this);
if(packingSize !=
PackingSize.Unspecified)
{
***************
*** 607,611 ****
FieldBuilder field = DefineField
(name, type, attributes |
FieldAttributes.Static);
! // TODO: set the data
return field;
}
--- 618,622 ----
FieldBuilder field = DefineField
(name, type, attributes |
FieldAttributes.Static);
! field.SetData(data, size);
return field;
}
***************
*** 658,662 ****
// Define a method override declaration for this class.
- [TODO]
public void DefineMethodOverride
(MethodInfo methodInfoBody, MethodInfo
methodInfoDeclaration)
--- 669,672 ----
***************
*** 665,669 ****
{
StartSync();
! // TODO
}
finally
--- 675,704 ----
{
StartSync();
!
! // Validate the parameters.
! if(methodInfoBody == null)
! {
! throw new
ArgumentNullException("methodInfoBody");
! }
! if(methodInfoDeclaration == null)
! {
! throw new ArgumentNullException
!
("methodInfoDeclaration");
! }
! if(methodInfoBody.DeclaringType != this)
! {
! throw new ArgumentException
!
(_("Emit_OverrideBodyNotInType"));
! }
! MethodToken bodyToken =
module.GetMethodToken
! (methodInfoBody);
! MethodToken declToken =
module.GetMethodToken
! (methodInfoDeclaration);
! lock(typeof(AssemblyBuilder))
! {
! ClrTypeAddOverride
! (module.privateData,
! bodyToken.Token,
declToken.Token);
! }
}
finally
***************
*** 728,732 ****
// Define a PInvoke method for this class.
- [TODO]
public MethodBuilder DefinePInvokeMethod
(String name, String dllName, String entryName,
--- 763,766 ----
***************
*** 739,745 ****
try
{
StartSync();
! // TODO
! return null;
}
finally
--- 773,846 ----
try
{
+ // Lock down the assembly while we do
this.
StartSync();
!
! // Validate the parameters.
! if(name == null)
! {
! throw new
ArgumentNullException("name");
! }
! if(name == String.Empty)
! {
! throw new
ArgumentException(_("Emit_NameEmpty"));
! }
! if(dllName == null)
! {
! throw new
ArgumentNullException("dllName");
! }
! if(dllName == String.Empty)
! {
! throw new
ArgumentException(_("Emit_NameEmpty"));
! }
! if(entryName == null)
! {
! throw new
ArgumentNullException("entryName");
! }
! if(entryName == String.Empty)
! {
! throw new
ArgumentException(_("Emit_NameEmpty"));
! }
! if((type.Attributes &
TypeAttributes.ClassSemanticsMask)
! ==
TypeAttributes.Interface)
! {
! throw new ArgumentException
!
(_("Emit_PInvokeInInterface"));
! }
! if((attributes &
MethodAttributes.Abstract) != 0)
! {
! throw new ArgumentException
!
(_("Emit_PInvokeAbstract"));
! }
!
! // Create the underlying method.
! MethodBuilder method = new MethodBuilder
! (this, name,
! attributes |
MethodAttributes.PinvokeImpl,
! callingConvention,
returnType, parameterTypes);
!
! // Build the attributes for the PInvoke
declaration.
! int pinvAttrs = (((int)nativeCallConv)
<< 8);
! switch(nativeCharSet)
! {
! case CharSet.Ansi:
pinvAttrs |= 0x0002; break;
! case CharSet.Unicode:
pinvAttrs |= 0x0004; break;
! case CharSet.Auto:
pinvAttrs |= 0x0006; break;
! default:
break;
! }
!
! // Create the PInvoke declaration on
the method.
! if(entryName == name)
! {
! entryName = null;
! }
! lock(typeof(AssemblyBuilder))
! {
!
MethodBuilder.ClrMethodAddPInvoke
!
(((IClrProgramItem)method).ClrHandle,
! pinvAttrs, dllName,
entryName);
! }
!
! // Return the method to the caller.
! return method;
}
finally
***************
*** 782,795 ****
public ConstructorBuilder DefineTypeInitializer()
{
! try
! {
! StartSync();
! // TODO
! return null;
! }
! finally
! {
! EndSync();
! }
}
--- 883,891 ----
public ConstructorBuilder DefineTypeInitializer()
{
! return
DefineConstructor(MethodAttributes.Private |
!
MethodAttributes.Static |
!
MethodAttributes.SpecialName,
!
CallingConventions.Standard,
!
null);
}
***************
*** 1166,1170 ****
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static IntPtr ClrTypeCreate
! (IntPtr module, String name, String nspace,
TypeAttributes attr, TypeToken parent);
--- 1262,1266 ----
[MethodImpl(MethodImplOptions.InternalCall)]
extern private static IntPtr ClrTypeCreate
! (IntPtr module, IntPtr nestedParent, String name,
String nspace,
TypeAttributes attr, TypeToken parent);
***************
*** 1206,1209 ****
--- 1302,1310 ----
extern internal static int ClrTypeImportMember
(IntPtr module, IntPtr memberInfo);
+
+ // Add an override declaration.
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ extern private static void ClrTypeAddOverride
+ (IntPtr module, int bodyToken, int declToken);
}; // class TypeBuilder
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Reflection/Emit ConstructorBuilder.cs,1.5,1.6 FieldBuilder.cs,1.6,1.7 ILGenerator.cs,1.8,1.9 LocalBuilder.cs,1.4,1.5 MethodBuilder.cs,1.5,1.6 ModuleBuilder.cs,1.7,1.8 ParameterBuilder.cs,1.3,1.4 PropertyBuilder.cs,1.6,1.7 TypeBuilder.cs,1.7,1.8,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h,1.50,1.51 int_table.c,1.52,1.53 lib_emit.c,1.6,1.7
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet ChangeLog,1.2262,1.2263
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h,1.50,1.51 int_table.c,1.52,1.53 lib_emit.c,1.6,1.7
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet ChangeLog,1.2262,1.2263
- Index(es):