public FunctionInfoMatchTarget(TypeInfo parentTypeInfo, int index) { m_interfaceTypeInfo = parentTypeInfo; m_index = index; m_funcDesc = parentTypeInfo.GetFuncDesc(m_index); m_nativeParentTypeName = m_interfaceTypeInfo.GetDocumentation(); }
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(); }
public static string[] GetNames(this FuncDesc fd, ITypeInfo ti) { var names = new string[fd.cParams + 1]; ti.GetNames(fd.memid, names, fd.cParams + 1, out _); return(names); }
public OWModule(ITlibNode parent, ITypeInfo ti, TypeAttr ta) { Parent = parent; _ti = ti; _ta = ta; _name = _ti.GetName(); if (_ta.cVars <= 0 && _ta.cFuncs <= 0) { return; } var tix = new olewoo_interop.ITypeInfoXtra(); if (_ta.cFuncs > 0) { var fd = new FuncDesc(_ti, 0); var invkind = fd.invkind; var memid = fd.memid; _dllname = tix.GetDllEntry(ti, invkind, memid); } else { _dllname = null; } _data = new IDLData(this); }
public OWMethod(ITlibNode parent, ITypeInfo ti, FuncDesc fd) { Parent = parent; _ti = ti; _fd = fd; var names = fd.GetNames(ti); _name = names[0]; }
private List <ITlibNode> GenFuncChildren() { var res = new List <ITlibNode>(); for (var x = 0; x < _ta.cFuncs; ++x) { var fd = new FuncDesc(_ti, x); res.Add(new OWMethod(this, _ti, fd)); } return(res); }
public List <ITlibNode> MethodChildren() { var res = new List <ITlibNode>(); var nfuncs = _ta.cFuncs; for (var idx = 0; idx < nfuncs; ++idx) { var fd = new FuncDesc(_ti, idx); // if (0 == (fd.wFuncFlags & FuncDesc.FuncFlags.FUNCFLAG_FRESTRICTED)) res.Add(new OWMethod(this, _ti, fd)); } return(res); }
public override List <ITlibNode> GenChildren() { var res = new List <ITlibNode>(); // First add a child for every method / property, then an inherited interfaces // child (if applicable). var nfuncs = _ta.cFuncs; for (var idx = 0; idx < nfuncs; ++idx) { var fd = new FuncDesc(_ti, idx); res.Add(new OWMethod(this, _ti, fd)); } if (_ta.cImplTypes > 0) { res.Add(new OWInheritedInterfaces(this, _ti, _ta)); } return(res); }
/// <summary> /// This function is used to workaround around the fact that the TypeInfo might return IUnknown/IDispatch methods (in the case of dual interfaces) /// So we should always call this function to get the first index for different TypeInfo and never save the id /// </summary> static public int GetIndexOfFirstMethod(TypeInfo type, TypeAttr attr) { if (attr.typekind != TypeLibTypes.Interop.TYPEKIND.TKIND_DISPATCH) { return(0); } int nIndex = 0; if (attr.cFuncs >= 3) { // Check for IUnknown first using (FuncDesc func = type.GetFuncDesc(0)) { if (func.memid == 0x60000000 && func.elemdescFunc.tdesc.vt == (int)VarEnum.VT_VOID && func.cParams == 2 && func.GetElemDesc(0).tdesc.vt == (int)VarEnum.VT_PTR && func.GetElemDesc(1).tdesc.vt == (int)VarEnum.VT_PTR && "QueryInterface" == type.GetDocumentation(func.memid)) { nIndex = 3; } } if (attr.cFuncs >= 7) { using (FuncDesc func = type.GetFuncDesc(3)) { // Check IDispatch if (func.memid == 0x60010000 && func.elemdescFunc.tdesc.vt == (int)VarEnum.VT_VOID && func.cParams == 1 && func.GetElemDesc(0).tdesc.vt == (int)VarEnum.VT_PTR && "GetTypeInfoCount" == type.GetDocumentation(func.memid)) { nIndex = 7; } } } } return(nIndex); }
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); } }