예제 #1
0
        public SignatureInfoMatchTarget(TypeInfo interfaceTypeInfo, int functionIndex,
                                        ElemDesc elemDesc, int parameterIndex)
        {
            m_interfaceTypeInfo = interfaceTypeInfo;
            m_functionIndex     = functionIndex;
            m_funcDesc          = interfaceTypeInfo.GetFuncDesc(m_functionIndex);
            m_elemDesc          = elemDesc;
            m_parameterIndex    = parameterIndex;

            if (m_parameterIndex == 0)
            {
                m_name = "return";
            }
            else
            {
                // the name of the parameter.
                string[] signatureNames = m_interfaceTypeInfo.GetNames(m_funcDesc.memid,
                                                                       m_funcDesc.cParams + 1);
                m_name = signatureNames[m_parameterIndex];
                if (m_name == null || m_name.Trim().Equals(""))
                {
                    m_name = "_unnamed_arg_" + m_parameterIndex;
                }
            }
            // NativeParentFunctionName
            m_nativeParentFunctionName =
                m_interfaceTypeInfo.GetDocumentation(m_funcDesc.memid);

            // NativeSignature
            m_nativeSignature = (new TlbType2String(interfaceTypeInfo, m_elemDesc.tdesc)).GetTypeString();
        }
        private static void ProcessFuncParams(TypeInfo interfaceTypeInfo,
                                              int funcIndex, TreeNode parentTreeNode)
        {
            int      paramIndex  = 0;
            FuncDesc funcDesc    = interfaceTypeInfo.GetFuncDesc(funcIndex);
            ElemDesc retElemDesc = funcDesc.elemdescFunc;
            SignatureInfoMatchTarget retSignatureInfo = new SignatureInfoMatchTarget(interfaceTypeInfo,
                                                                                     funcIndex, retElemDesc, paramIndex);
            TreeNode retTreeNode = new TreeNode();
            string   typeString  =
                (new TlbType2String(interfaceTypeInfo, retElemDesc.tdesc)).GetTypeString();

            retTreeNode.Text = typeString + "  " + retSignatureInfo.Name +
                               ": " + retSignatureInfo.Type;
            retTreeNode.Tag = retSignatureInfo;
            SetTlbTreeNodeImage(retTreeNode);
            parentTreeNode.Nodes.Add(retTreeNode);
            ++paramIndex;
            // Parameters
            //string[] signatureNames = interfaceTypeInfo.GetNames(funcDesc.memid, funcDesc.cParams + 1);
            for (int i = 0; i < funcDesc.cParams; ++i)
            {
                ElemDesc paramElemDesc = funcDesc.GetElemDesc(i);

                typeString =
                    (new TlbType2String(interfaceTypeInfo, paramElemDesc.tdesc)).GetTypeString();

                //string signatureName = signatureNames[i + 1];
                //if (signatureName.Trim().Equals(""))
                //    signatureName = "_unnamed_arg_" + paramIndex;
                SignatureInfoMatchTarget paramSignatureInfo = new SignatureInfoMatchTarget(
                    interfaceTypeInfo, funcIndex, paramElemDesc, paramIndex);
                TreeNode paramTreeNode = new TreeNode();
                paramTreeNode.Text = typeString + "  " + paramSignatureInfo.Name +
                                     ": " + paramSignatureInfo.Type;
                ++paramIndex;
                paramTreeNode.Tag = paramSignatureInfo;
                SetTlbTreeNodeImage(paramTreeNode);
                parentTreeNode.Nodes.Add(paramTreeNode);
            }
        }
예제 #3
0
        public void BuildIDLInto(IDLFormatter ih, bool bAsDispatch)
        {
            EnterElement();
            var lprops = _data.Attributes;

            ih.AppendLine("[" + string.Join(", ", lprops.ToArray()) + "] ");
            // Prototype in a different line.
            var ed = _fd.elemdescFunc;

            Action <int> paramtextgen   = null;
            ElemDesc     elast          = null;
            var          bRetvalPresent = false;

            if (_fd.cParams > 0)
            {
                var names = _fd.GetNames(_ti);
                var edps  = _fd.elemdescParams;
                if (edps.Length > 0)
                {
                    elast = edps[edps.Length - 1];
                }
                if (bAsDispatch && elast != null && 0 != (elast.paramdesc.wParamFlags & ParamDesc.ParamFlags.PARAMFLG_FRETVAL))
                {
                    bRetvalPresent = true;
                }
                // ReSharper disable once UnusedVariable
                var maxCnt = (bAsDispatch && bRetvalPresent) ? _fd.cParams - 1 : _fd.cParams;

                paramtextgen = x =>
                {
                    var paramname = names[x + 1] ?? "rhs";
                    var edp       = edps[x];
                    ih.AddString(ParamFlagsDescription(edp.paramdesc) + " ");
                    edp.tdesc.ComTypeNameAsString(_ti, ih);
                    ih.AddString(" " + paramname);
                };
            }
            (bRetvalPresent ? elast : ed).tdesc.ComTypeNameAsString(_ti, ih);
            if (MemIdInSpecialRange)
            {
                ih.AddString(" " + _fd.callconv.ToString().Substring(2).ToLower());
            }
            ih.AddString($" {_data.Name}");
            switch (_fd.cParams)
            {
            case 0:
                ih.AppendLine("();");
                break;

            case 1:
                ih.AddString("(");
                paramtextgen?.Invoke(0);
                ih.AppendLine(");");
                break;

            default:
                ih.AppendLine("(");
                using (new IDLHelperTab(ih))
                {
                    for (var y = 0; y < _fd.cParams; ++y)
                    {
                        paramtextgen?.Invoke(y);
                        ih.AppendLine(y == _fd.cParams - 1 ? "" : ",");
                    }
                }
                ih.AppendLine(");");
                break;
            }
            ExitElement();
        }
예제 #4
0
        public void BuildIDLInto(IDLFormatter ih, bool bAsDispatch)
        {
            var memIdInSpecialRange = (_fd.memid >= 0x60000000 && _fd.memid < 0x60020000);
            var lprops = new List <string>();

            if (!memIdInSpecialRange)
            {
                lprops.Add("id(" + _fd.memid.PaddedHex() + ")");
            }
            switch (_fd.invkind)
            {
            case FuncDesc.InvokeKind.INVOKE_PROPERTYGET:
                lprops.Add("propget");
                break;

            case FuncDesc.InvokeKind.INVOKE_PROPERTYPUT:
                lprops.Add("propput");
                break;

            case FuncDesc.InvokeKind.INVOKE_PROPERTYPUTREF:
                lprops.Add("propputref");
                break;
            }
            var help = _ti.GetHelpDocumentationById(_fd.memid, out var context);

            if (0 != (_fd.wFuncFlags & FuncDesc.FuncFlags.FUNCFLAG_FRESTRICTED))
            {
                lprops.Add("restricted");
            }
            if (0 != (_fd.wFuncFlags & FuncDesc.FuncFlags.FUNCFLAG_FHIDDEN))
            {
                lprops.Add("hidden");
            }
            AddHelpStringAndContext(lprops, help, context);
            ih.AppendLine("[" + string.Join(", ", lprops.ToArray()) + "] ");
            // Prototype in a different line.
            var ed = _fd.elemdescFunc;

            Action <int> paramtextgen   = null;
            ElemDesc     elast          = null;
            var          bRetvalPresent = false;

            if (_fd.cParams > 0)
            {
                var names = _fd.GetNames(_ti);
                var edps  = _fd.elemdescParams;
                if (edps.Length > 0)
                {
                    elast = edps[edps.Length - 1];
                }
                if (bAsDispatch && elast != null && 0 != (elast.paramdesc.wParamFlags & ParamDesc.ParamFlags.PARAMFLG_FRETVAL))
                {
                    bRetvalPresent = true;
                }
                // ReSharper disable once UnusedVariable
                var maxCnt = (bAsDispatch && bRetvalPresent) ? _fd.cParams - 1 : _fd.cParams;

                paramtextgen = x =>
                {
                    var paramname = (names[x + 1] == null) ? "rhs" : names[x + 1];
                    var edp       = edps[x];
                    ih.AddString(ParamFlagsDescription(edp.paramdesc) + " ");
                    edp.tdesc.ComTypeNameAsString(_ti, ih);
                    ih.AddString(" " + paramname);
                };
            }
            (bRetvalPresent ? elast : ed).tdesc.ComTypeNameAsString(_ti, ih);
            if (memIdInSpecialRange)
            {
                ih.AddString(" " + _fd.callconv.ToString().Substring(2).ToLower());
            }
            ih.AddString($" {_name}");
            switch (_fd.cParams)
            {
            case 0:
                ih.AppendLine("();");
                break;

            case 1:
                ih.AddString("(");
                paramtextgen?.Invoke(0);
                ih.AppendLine(");");
                break;

            default:
                ih.AppendLine("(");
                using (new IDLHelperTab(ih))
                {
                    for (var y = 0; y < _fd.cParams; ++y)
                    {
                        paramtextgen?.Invoke(y);
                        ih.AppendLine(y == _fd.cParams - 1 ? "" : ",");
                    }
                }
                ih.AppendLine(");");
                break;
            }
        }