当前位置: 首页>>代码示例>>C#>>正文


C# MethodDesc.GetPInvokeMethodMetadata方法代码示例

本文整理汇总了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;
        }
开发者ID:shahid-pk,项目名称:corert,代码行数:29,代码来源:PInvokeILEmitter.cs

示例2: PInvokeMarshallingILEmitter

        private PInvokeMarshallingILEmitter(MethodDesc targetMethod)
        {
            Debug.Assert(targetMethod.IsPInvoke);
            Debug.Assert(RequiresMarshalling(targetMethod));

            _targetMethod = targetMethod;
            _importMetadata = targetMethod.GetPInvokeMethodMetadata();

            _emitter = null;
            _marshallingCodeStream = null;
        }
开发者ID:niemyjski,项目名称:corert,代码行数:11,代码来源:PInvokeMarshallingILEmitter.cs

示例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;
        }
开发者ID:shahid-pk,项目名称:corert,代码行数:13,代码来源:PInvokeILEmitter.cs

示例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;
            }
        }
开发者ID:xier2012,项目名称:corert,代码行数:62,代码来源:CppWriter.cs

示例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;
            }
        }
开发者ID:morganbr,项目名称:corert,代码行数:43,代码来源:CppWriter.cs


注:本文中的Internal.TypeSystem.MethodDesc.GetPInvokeMethodMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。