本文整理汇总了C#中Internal.TypeSystem.MethodDesc.GetPInvokeMethodMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDesc.GetPInvokeMethodMetadata方法的具体用法?C# MethodDesc.GetPInvokeMethodMetadata怎么用?C# MethodDesc.GetPInvokeMethodMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Internal.TypeSystem.MethodDesc
的用法示例。
在下文中一共展示了MethodDesc.GetPInvokeMethodMetadata方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsStubRequired
/// <summary>
/// Returns true if <paramref name="method"/> requires a stub to be generated.
/// </summary>
public static bool IsStubRequired(MethodDesc method)
{
Debug.Assert(method.IsPInvoke);
// TODO: true if there are any custom marshalling rules on the parameters
// TODO: true if SetLastError is true
TypeDesc returnType = method.Signature.ReturnType;
if (!IsBlittableType(returnType) && !returnType.IsVoid)
return true;
for (int i = 0; i < method.Signature.Length; i++)
{
if (!IsBlittableType(method.Signature[i]))
{
return true;
}
}
if (UseLazyResolution(method, method.GetPInvokeMethodMetadata().Module))
{
return true;
}
return false;
}
示例2: PInvokeMarshallingILEmitter
private PInvokeMarshallingILEmitter(MethodDesc targetMethod)
{
Debug.Assert(targetMethod.IsPInvoke);
Debug.Assert(RequiresMarshalling(targetMethod));
_targetMethod = targetMethod;
_importMetadata = targetMethod.GetPInvokeMethodMetadata();
_emitter = null;
_marshallingCodeStream = null;
}
示例3: PInvokeILEmitter
private PInvokeILEmitter(MethodDesc targetMethod)
{
Debug.Assert(targetMethod.IsPInvoke);
_targetMethod = targetMethod;
_context = _targetMethod.Context;
_importMetadata = targetMethod.GetPInvokeMethodMetadata();
_emitter = null;
_marshallingCodeStream = null;
_returnValueMarshallingCodeStream = null;
_unmarshallingCodestream = null;
}
示例4: CompileSpecialMethod
private string CompileSpecialMethod(MethodDesc method, SpecialMethodKind kind)
{
StringBuilder builder = new StringBuilder();
switch (kind)
{
case SpecialMethodKind.PInvoke:
case SpecialMethodKind.RuntimeImport:
{
EcmaMethod ecmaMethod = method as EcmaMethod;
string importName = kind == SpecialMethodKind.PInvoke ?
method.GetPInvokeMethodMetadata().Name : ecmaMethod.GetAttributeStringValue("System.Runtime", "RuntimeImportAttribute");
if (importName == null)
importName = method.Name;
MethodSignature methodSignature = method.Signature;
bool slotCastRequired = false;
MethodSignature externCSignature;
if (_externCSignatureMap.TryGetValue(importName, out externCSignature))
{
slotCastRequired = !externCSignature.Equals(method.Signature);
}
else
{
_externCSignatureMap.Add(importName, methodSignature);
externCSignature = methodSignature;
}
builder.AppendLine(GetCppMethodDeclaration(method, true));
builder.AppendLine("{");
if (slotCastRequired)
{
AppendSlotTypeDef(builder, method);
}
if (!method.Signature.ReturnType.IsVoid)
{
builder.Append("return ");
}
if (slotCastRequired)
builder.Append("((__slot__" + GetCppMethodName(method) + ")");
builder.Append("::");
builder.Append(importName);
if (slotCastRequired)
builder.Append(")");
builder.Append("(");
builder.Append(GetCppMethodCallParamList(method));
builder.AppendLine(");");
builder.AppendLine("}");
return builder.ToString();
}
default:
return GetCppMethodDeclaration(method, true) + " { throw 0xC000C000; }" + Environment.NewLine;
}
}
示例5: CompileSpecialMethod
private string CompileSpecialMethod(MethodDesc method, SpecialMethodKind kind)
{
StringBuilder builder = new StringBuilder();
switch (kind)
{
case SpecialMethodKind.PInvoke:
case SpecialMethodKind.RuntimeImport:
{
EcmaMethod ecmaMethod = method as EcmaMethod;
string importName = kind == SpecialMethodKind.PInvoke ?
method.GetPInvokeMethodMetadata().Name : ecmaMethod.GetAttributeStringValue("System.Runtime", "RuntimeImportAttribute");
if (importName == null)
importName = method.Name;
// TODO: hacky special-case
if (importName != "memmove" && importName != "malloc") // some methods are already declared by the CRT headers
{
builder.AppendLine(GetCppMethodDeclaration(method, false, importName));
}
builder.AppendLine(GetCppMethodDeclaration(method, true));
builder.AppendLine("{");
builder.Append(" ");
if (GetCppSignatureTypeName(method.Signature.ReturnType) != "void")
{
builder.Append("return ");
}
builder.AppendLine("::" + importName + "(" + GetCppMethodCallParamList(method) + ");");
builder.AppendLine("}");
return builder.ToString();
}
default:
// TODO: hacky special-case
if (method.Name == "BlockCopy")
return null;
return GetCppMethodDeclaration(method, true) + " { throw 0xC000C000; }" + Environment.NewLine;
}
}