本文整理汇总了C#中CallingConventions类的典型用法代码示例。如果您正苦于以下问题:C# CallingConventions类的具体用法?C# CallingConventions怎么用?C# CallingConventions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallingConventions类属于命名空间,在下文中一共展示了CallingConventions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConstructParameters
internal static string ConstructParameters(Type[] parameters, CallingConventions callingConvention)
{
StringBuilder builder = new StringBuilder();
string str = "";
for (int i = 0; i < parameters.Length; i++)
{
Type type = parameters[i];
builder.Append(str);
string str2 = type.SigToString();
if (type.IsByRef)
{
builder.Append(str2.TrimEnd(new char[] { '&' }));
builder.Append(" ByRef");
}
else
{
builder.Append(str2);
}
str = ", ";
}
if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
{
builder.Append(str);
builder.Append("...");
}
return builder.ToString();
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:MethodBase.cs
示例2: PropertySignature
private PropertySignature(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
{
this.callingConvention = callingConvention;
this.propertyType = propertyType;
this.parameterTypes = parameterTypes;
this.customModifiers = customModifiers;
}
开发者ID:nestalk,项目名称:mono,代码行数:7,代码来源:PropertySignature.cs
示例3: MonoArrayMethod
#pragma warning restore 649
internal MonoArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
name = methodName;
parent = arrayClass;
ret = returnType;
parameters = (Type[])parameterTypes.Clone();
call_conv = callingConvention;
}
开发者ID:rabink,项目名称:mono,代码行数:9,代码来源:MonoArrayMethod.cs
示例4: GetArrayMethod_ValidArrayValues_ReferenceParameterType
public void GetArrayMethod_ValidArrayValues_ReferenceParameterType(CallingConventions callingConvention)
{
ModuleBuilder module = Helpers.DynamicModule();
VerifyGetArrayMethod(module, typeof(ModuleBuilderGetArrayMethod[]), callingConvention.ToString() + "1", callingConvention, typeof(int), new Type[] { typeof(object) });
VerifyGetArrayMethod(module, typeof(ModuleBuilderGetArrayMethod[]), callingConvention.ToString() + "2", callingConvention, typeof(int), new Type[] { typeof(object), typeof(string), typeof(ModuleBuilderGetArrayMethod) });
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:ModuleBuilderGetArrayMethod.cs
示例5: GetArrayMethod_MultiDimensionalArray
public void GetArrayMethod_MultiDimensionalArray(CallingConventions callingConvention)
{
ModuleBuilder module = Helpers.DynamicModule();
VerifyGetArrayMethod(module, typeof(ModuleBuilderGetArrayMethod[,]), callingConvention.ToString() + "1", callingConvention, typeof(int), new Type[] { typeof(object) });
VerifyGetArrayMethod(module, typeof(ModuleBuilderGetArrayMethod[,]), callingConvention.ToString() + "2", callingConvention, typeof(int), new Type[] { typeof(object), typeof(int), typeof(ModuleBuilderGetArrayMethod) });
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:ModuleBuilderGetArrayMethod.cs
示例6: DefineConstructor
public void DefineConstructor(MethodAttributes methodAttributes, Type[] parameterTypes, CallingConventions callingConvention, BindingFlags bindingFlags)
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
FieldBuilder fieldBuilderA = type.DefineField("TestField", typeof(int), FieldAttributes.Private);
FieldBuilder fieldBuilderB = type.DefineField("TestField", typeof(int), FieldAttributes.Private);
ConstructorBuilder ctorBuilder = type.DefineConstructor(methodAttributes, callingConvention, parameterTypes);
ILGenerator ctorIlGenerator = ctorBuilder.GetILGenerator();
if (parameterTypes.Length != 0)
{
//Calling base class constructor
ctorIlGenerator.Emit(OpCodes.Ldarg_0);
ctorIlGenerator.Emit(OpCodes.Call, typeof(object).GetConstructor(new Type[0]));
ctorIlGenerator.Emit(OpCodes.Ldarg_0);
ctorIlGenerator.Emit(OpCodes.Ldarg_1);
ctorIlGenerator.Emit(OpCodes.Stfld, fieldBuilderA);
ctorIlGenerator.Emit(OpCodes.Ldarg_0);
ctorIlGenerator.Emit(OpCodes.Ldarg_2);
ctorIlGenerator.Emit(OpCodes.Stfld, fieldBuilderB);
}
ctorIlGenerator.Emit(OpCodes.Ret);
Type createdType = type.CreateTypeInfo().AsType();
Assert.NotNull(createdType.GetConstructors(bindingFlags).FirstOrDefault());
}
开发者ID:ESgarbi,项目名称:corefx,代码行数:30,代码来源:TypeBuilderDefineConstructor.cs
示例7: SymbolMethod
//***********************************************
//
// Constructor
//
//***********************************************
internal SymbolMethod(
ModuleBuilder mod,
MethodToken token,
Type arrayClass,
String methodName,
CallingConventions callingConvention,
Type returnType,
Type[] parameterTypes)
{
m_module = mod;
m_containingType = arrayClass;
m_name = methodName;
m_callingConvention = callingConvention;
m_returnType = returnType;
m_mdMethod = token;
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
Array.Copy(parameterTypes, m_parameterTypes, parameterTypes.Length);
}
else
m_parameterTypes = null;
m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention, returnType, parameterTypes);
}
开发者ID:ArildF,项目名称:masters,代码行数:30,代码来源:symbolmethod.cs
示例8: DefineMethod
public void DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
{
bool defaultReturnTypeAndParameters = returnType == null && parameterTypes == null;
if (callingConvention == CallingConventions.Standard)
{
if (defaultReturnTypeAndParameters)
{
// Use DefineMethod(string, MethodAttributes)
TypeBuilder type1 = Helpers.DynamicType(TypeAttributes.Public);
MethodBuilder method1 = type1.DefineMethod(name, attributes);
VerifyMethod(type1, method1, name, attributes, callingConvention, returnType, parameterTypes);
}
// Use DefineMethod(string, MethodAttributes, Type, Type[])
TypeBuilder type2 = Helpers.DynamicType(TypeAttributes.Public);
MethodBuilder method2 = type2.DefineMethod(name, attributes, returnType, parameterTypes);
VerifyMethod(type2, method2, name, attributes, callingConvention, returnType, parameterTypes);
}
if (defaultReturnTypeAndParameters)
{
// Use DefineMethod(string, MethodAttributes, CallingConventions)
TypeBuilder type3 = Helpers.DynamicType(TypeAttributes.Public);
MethodBuilder method3 = type3.DefineMethod(name, attributes, callingConvention);
VerifyMethod(type3, method3, name, attributes, callingConvention, returnType, parameterTypes);
}
// Use DefineMethod(string, MethodAttributes, CallingConventions, Type, Type[])
TypeBuilder type4 = Helpers.DynamicType(TypeAttributes.Public);
MethodBuilder method4 = type4.DefineMethod(name, attributes, callingConvention, returnType, parameterTypes);
VerifyMethod(type4, method4, name, attributes, callingConvention, returnType, parameterTypes);
}
开发者ID:dotnet,项目名称:corefx,代码行数:29,代码来源:TypeBuilderDefineMethod.cs
示例9: DefineConstructor
/// <summary>
/// Defines a constructor.
/// </summary>
/// <param name="typeBuilder">The type builder.</param>
/// <param name="methodAttributes">The method attributes.</param>
/// <param name="callingConvention">The calling convention.</param>
/// <param name="parameterTypes">The parameter types.</param>
/// <param name="parameterNames">The parameter names.</param>
/// <returns>The constructor builder.</returns>
public static ConstructorBuilder DefineConstructor(this TypeBuilder typeBuilder,
MethodAttributes methodAttributes,
CallingConventions callingConvention,
Type[] parameterTypes,
string[] parameterNames)
{
if (typeBuilder == null)
throw new ArgumentNullException("typeBuilder");
if (parameterTypes == null)
throw new ArgumentNullException("parameterTypes");
if (parameterNames == null)
throw new ArgumentNullException("parameterNames");
if (parameterTypes.Length != parameterNames.Length)
throw new ArgumentException(Resources.NumberOfParameterTypesAndNamesMustBeEqual);
// Define constructor.
var constructorBuilder = typeBuilder.DefineConstructor(
methodAttributes,
callingConvention,
parameterTypes);
// Define constructor parameters.
constructorBuilder.DefineParameters(parameterNames);
return constructorBuilder;
}
开发者ID:Kostassoid,项目名称:NProxy,代码行数:38,代码来源:TypeBuilderExtensions.cs
示例10: DefineConstructor
public void DefineConstructor(MethodAttributes attributes, Type[] parameterTypes, CallingConventions callingConvention)
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
FieldBuilder fieldBuilderA = type.DefineField("TestField", typeof(int), FieldAttributes.Private);
FieldBuilder fieldBuilderB = type.DefineField("TestField", typeof(int), FieldAttributes.Private);
ConstructorBuilder constructor = type.DefineConstructor(attributes, callingConvention, parameterTypes);
ILGenerator ctorIlGenerator = constructor.GetILGenerator();
if (parameterTypes.Length != 0)
{
// Calling base class constructor
ctorIlGenerator.Emit(OpCodes.Ldarg_0);
ctorIlGenerator.Emit(OpCodes.Call, typeof(object).GetConstructor(new Type[0]));
ctorIlGenerator.Emit(OpCodes.Ldarg_0);
ctorIlGenerator.Emit(OpCodes.Ldarg_1);
ctorIlGenerator.Emit(OpCodes.Stfld, fieldBuilderA);
ctorIlGenerator.Emit(OpCodes.Ldarg_0);
ctorIlGenerator.Emit(OpCodes.Ldarg_2);
ctorIlGenerator.Emit(OpCodes.Stfld, fieldBuilderB);
}
ctorIlGenerator.Emit(OpCodes.Ret);
Helpers.VerifyConstructor(constructor, type, attributes, callingConvention, parameterTypes);
}
开发者ID:dotnet,项目名称:corefx,代码行数:26,代码来源:TypeBuilderDefineConstructor.cs
示例11: ConstructorBuilder
/// <summary>
/// Constructor
/// </summary>
/// <param name="typeBuilder">Type builder</param>
/// <param name="attributes">Attributes for the constructor (public, private, etc.)</param>
/// <param name="parameters">Parameter types for the constructor</param>
/// <param name="callingConventions">Calling convention for the constructor</param>
public ConstructorBuilder(TypeBuilder typeBuilder, MethodAttributes attributes,
IEnumerable<Type> parameters, CallingConventions callingConventions)
{
if (typeBuilder == null)
throw new ArgumentNullException("typeBuilder");
Type = typeBuilder;
Attributes = attributes;
Parameters = new List<ParameterBuilder>();
Parameters.Add(new ParameterBuilder(null, 0));
if (parameters != null)
{
int x = 1;
foreach (var parameterType in parameters)
{
Parameters.Add(new ParameterBuilder(parameterType, x));
++x;
}
}
CallingConventions = callingConventions;
Builder = Type.Builder.DefineConstructor(attributes, callingConventions,
(parameters != null && parameters.Count() > 0)
? parameters.ToArray()
: System.Type.EmptyTypes);
Generator = Builder.GetILGenerator();
}
开发者ID:OxPatient,项目名称:Rule-Engine,代码行数:32,代码来源:ConstructorBuilder.cs
示例12: CreateConstructor
/// <summary>
/// 타입의 생성자를 생성합니다.
/// </summary>
/// <param name="methodAttributes"> 생성자 메서드인 .ctor 의 메서드 특성입니다. </param>
/// <param name="callingConventions"> 메서드의 유효한 호출 규칙입니다. </param>
/// <param name="parameterCriteriaMetadataInfos"> 매개 변수의 표준적인 메타데이터 정보입니다. </param>
/// <returns>
/// 생성자를 생성할 때 사용하는 <see cref="ConstructorBuilder"/> 객체를 반환합니다.
/// </returns>
public ConstructorBuilder CreateConstructor(MethodAttributes methodAttributes, CallingConventions callingConventions, IEnumerable<ParameterCriteriaMetadataInfo> parameterCriteriaMetadataInfos)
{
if (isStaticMethod(methodAttributes))
{
methodAttributes = MethodAttributes.Static | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | MethodAttributes.Private | MethodAttributes.HideBySig;
callingConventions = CallingConventions.Standard;
}
else
{
callingConventions = CallingConventions.HasThis;
}
var constructorBuilder = this.TypeBuilder.DefineConstructor(methodAttributes, callingConventions, parameterCriteriaMetadataInfos.Select( o => o.Type).ToArray());
int iSeqence = 0;
foreach (var parameter in parameterCriteriaMetadataInfos)
{
iSeqence++;
constructorBuilder.DefineParameter(iSeqence, parameter.ParameterAttribute, parameter.Name);
}
var il = constructorBuilder.GetILGenerator();
if (isStaticMethod(methodAttributes)) // 정적 생성자는 Object 개체 파생이 아니므로 Object 생성을 하지 않음
{
il.Emit(OpCodes.Nop);
}
else
{
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Call, this.TypeBuilder.BaseType.GetConstructors()[0]);
}
return constructorBuilder;
}
开发者ID:powerumc,项目名称:UmcCore,代码行数:44,代码来源:TypeBuilderExtension.cs
示例13: GetMethodImpl
protected sealed override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
Debug.Assert(name != null);
// GetMethodImpl() is a funnel for two groups of api. We can distinguish by comparing "types" to null.
if (types == null)
{
// Group #1: This group of api accept only a name and BindingFlags. The other parameters are hard-wired by the non-virtual api entrypoints.
Debug.Assert(binder == null);
Debug.Assert(callConvention == CallingConventions.Any);
Debug.Assert(modifiers == null);
return LowLevelTypeExtensions.GetMethod(this, name, bindingAttr);
}
else
{
if (!OnlySearchRelatedBitsSet(bindingAttr)) // We don't yet have proper handling for BindingFlags not related to search so throw rather return a wrong result.
throw new NotImplementedException();
// Group #2: This group of api takes a set of parameter types and an optional binder.
if (callConvention != CallingConventions.Any)
throw new NotImplementedException();
if (binder == null)
binder = Type.DefaultBinder;
MethodInfo[] candidates = LowLevelTypeExtensions.GetMethods(this, name, bindingAttr);
return (MethodInfo)binder.SelectMethod(bindingAttr, candidates, types, modifiers);
}
}
开发者ID:adityamandaleeka,项目名称:corert,代码行数:27,代码来源:RuntimeTypeInfo.BindingFlags.cs
示例14: SymbolMethod
internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
{
// This is a kind of MethodInfo to represent methods for array type of unbaked type
// Another way to look at this class is as a glorified MethodToken wrapper. At the time of this comment
// this class is only constructed inside ModuleBuilder.GetArrayMethod and the only interesting thing
// passed into it is this MethodToken. The MethodToken was forged using a TypeSpec for an Array type and
// the name of the method on Array.
// As none of the methods on Array have CustomModifiers their is no need to pass those around in here.
m_mdMethod = token;
// The ParameterTypes are also a bit interesting in that they may be unbaked TypeBuilders.
m_returnType = returnType;
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
Array.Copy(parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length);
}
else
{
m_parameterTypes = EmptyArray<Type>.Value;
}
m_module = mod;
m_containingType = arrayClass;
m_name = methodName;
m_callingConvention = callingConvention;
m_signature = SignatureHelper.GetMethodSigHelper(
mod, callingConvention, returnType, null, null, parameterTypes, null, null);
}
开发者ID:kouvel,项目名称:coreclr,代码行数:32,代码来源:SymbolMethod.cs
示例15: FormatParameters
internal static void FormatParameters (StringBuilder sb, ParameterInfo[] p, CallingConventions callingConvention, bool serialization)
{
for (int i = 0; i < p.Length; ++i) {
if (i > 0)
sb.Append (", ");
Type t = p[i].ParameterType;
string typeName = t.FormatTypeName (serialization);
// Legacy: Why use "ByRef" for by ref parameters? What language is this?
// VB uses "ByRef" but it should precede (not follow) the parameter name.
// Why don't we just use "&"?
if (t.IsByRef && !serialization) {
sb.Append (typeName.TrimEnd (new char[] { '&' }));
sb.Append (" ByRef");
} else {
sb.Append (typeName);
}
}
if ((callingConvention & CallingConventions.VarArgs) != 0) {
if (p.Length > 0)
sb.Append (", ");
sb.Append ("...");
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:27,代码来源:ParameterInfo.cs
示例16: MethodBuilder
#pragma warning restore 169, 414
internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnModReq, Type[] returnModOpt, Type[] parameterTypes, Type[][] paramModReq, Type[][] paramModOpt)
{
this.name = name;
this.attrs = attributes;
this.call_conv = callingConvention;
this.rtype = returnType;
this.returnModReq = returnModReq;
this.returnModOpt = returnModOpt;
this.paramModReq = paramModReq;
this.paramModOpt = paramModOpt;
// The MSDN docs does not specify this, but the MS MethodBuilder
// appends a HasThis flag if the method is not static
if ((attributes & MethodAttributes.Static) == 0)
this.call_conv |= CallingConventions.HasThis;
if (parameterTypes != null) {
for (int i = 0; i < parameterTypes.Length; ++i)
if (parameterTypes [i] == null)
throw new ArgumentException ("Elements of the parameterTypes array cannot be null", "parameterTypes");
this.parameters = new Type [parameterTypes.Length];
System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
}
type = tb;
table_idx = get_next_table_index (this, 0x06, true);
((ModuleBuilder)tb.Module).RegisterToken (this, GetToken ().Token);
}
开发者ID:stabbylambda,项目名称:mono,代码行数:29,代码来源:MethodBuilder.cs
示例17: DefineConstructor
public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes)
{
var cb = _typeBuilder.DefineConstructor(attributes, callingConvention, parameterTypes);
_members.Add(cb);
_paramsByMember.Add(cb, parameterTypes);
return cb;
}
开发者ID:davidvmckay,项目名称:ProxyFoo,代码行数:7,代码来源:FooTypeFromTypeBuilder.cs
示例18: GetMethodSigHelper
internal static SignatureHelper GetMethodSigHelper(
Module scope, CallingConventions callingConvention, int cGenericParam,
Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
SignatureHelper sigHelp;
MdSigCallingConvention intCall;
if (returnType == null)
{
returnType = typeof(void);
}
intCall = MdSigCallingConvention.Default;
if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
intCall = MdSigCallingConvention.Vararg;
if (cGenericParam > 0)
{
intCall |= MdSigCallingConvention.Generic;
}
if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
intCall |= MdSigCallingConvention.HasThis;
sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType,
requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
return sigHelp;
}
开发者ID:kouvel,项目名称:coreclr,代码行数:32,代码来源:SignatureHelper.cs
示例19: DefineConstructor_NullRequiredAndOptionalCustomModifiers
public void DefineConstructor_NullRequiredAndOptionalCustomModifiers(MethodAttributes attributes, Type[] parameterTypes, CallingConventions callingConvention)
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
ConstructorBuilder constructor = type.DefineConstructor(attributes, callingConvention, parameterTypes);
constructor.GetILGenerator().Emit(OpCodes.Ret);
Helpers.VerifyConstructor(constructor, type, attributes, callingConvention, parameterTypes);
}
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:TypeBuilderDefineConstructor.cs
示例20: ManagedCalliDescriptor
internal ManagedCalliDescriptor(CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes)
: base()
{
this.Value = string.Format(CultureInfo.CurrentCulture, "{0} {1}({2})",
ManagedCalliDescriptor.GetConventions(callingConvention),
new TypeDescriptor(returnType).Value,
ManagedCalliDescriptor.GetArguments(callingConvention, parameterTypes, optionalParameterTypes));
}
开发者ID:JasonBock,项目名称:EmitDebugging,代码行数:8,代码来源:ManagedCalliDescriptor.cs
注:本文中的CallingConventions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论