private Declaration CreateMemberDeclaration(FUNCDESC memberDescriptor, TYPEKIND typeKind, ITypeInfo info, IMPLTYPEFLAGS parentImplFlags, QualifiedModuleName typeQualifiedModuleName, Declaration moduleDeclaration, out string[] memberNames) { if (memberDescriptor.callconv != CALLCONV.CC_STDCALL) { memberNames = new string[] { }; return(null); } memberNames = new string[255]; int namesArrayLength; info.GetNames(memberDescriptor.memid, memberNames, 255, out namesArrayLength); var memberName = memberNames[0]; var funcValueType = (VarEnum)memberDescriptor.elemdescFunc.tdesc.vt; var memberDeclarationType = GetDeclarationType(memberName, memberDescriptor, funcValueType, typeKind, parentImplFlags); if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED) && IgnoredInterfaceMembers.Contains(memberName)) // Ignore IDispatch and IUnknown members - quick-and-dirty for beta { return(null); } var asTypeName = new ComParameter(string.Empty, false); if (memberDeclarationType != DeclarationType.Procedure) { asTypeName = GetParameterInfo(memberDescriptor.elemdescFunc.tdesc, info); } var attributes = new Attributes(); if (memberName == "_NewEnum" && ((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FNONBROWSABLE)) { attributes.AddEnumeratorMemberAttribute(memberName); } else if (memberDescriptor.memid == 0) { attributes.AddDefaultMemberAttribute(memberName); } else if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN)) { attributes.AddHiddenMemberAttribute(memberName); } switch (memberDeclarationType) { case DeclarationType.Procedure: return(new SubroutineDeclaration( new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName.Name, Accessibility.Global, null, Selection.Home, true, null, attributes)); case DeclarationType.Function: return(new FunctionDeclaration( new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName.Name, null, null, Accessibility.Global, null, Selection.Home, asTypeName.IsArray, true, null, attributes)); case DeclarationType.PropertyGet: return(new PropertyGetDeclaration( new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName.Name, null, null, Accessibility.Global, null, Selection.Home, asTypeName.IsArray, true, null, attributes)); case DeclarationType.PropertySet: return(new PropertySetDeclaration( new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName.Name, Accessibility.Global, null, Selection.Home, true, null, attributes)); case DeclarationType.PropertyLet: return(new PropertyLetDeclaration( new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName.Name, Accessibility.Global, null, Selection.Home, true, null, attributes)); default: return(new Declaration( new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName.Name, null, false, false, Accessibility.Global, memberDeclarationType, null, Selection.Home, false, null, true, null, attributes)); } }
private Declaration CreateMemberDeclaration(out FUNCDESC memberDescriptor, TYPEKIND typeKind, ITypeInfo info, int memberIndex, QualifiedModuleName typeQualifiedModuleName, Declaration moduleDeclaration, out string[] memberNames) { IntPtr memberDescriptorPointer; info.GetFuncDesc(memberIndex, out memberDescriptorPointer); memberDescriptor = (FUNCDESC)Marshal.PtrToStructure(memberDescriptorPointer, typeof(FUNCDESC)); if (memberDescriptor.callconv != CALLCONV.CC_STDCALL) { memberDescriptor = new FUNCDESC(); memberNames = new string[] {}; return(null); } memberNames = new string[255]; int namesArrayLength; info.GetNames(memberDescriptor.memid, memberNames, 255, out namesArrayLength); var memberName = memberNames[0]; var funcValueType = (VarEnum)memberDescriptor.elemdescFunc.tdesc.vt; var memberDeclarationType = GetDeclarationType(memberDescriptor, funcValueType, typeKind); var asTypeName = string.Empty; if (memberDeclarationType != DeclarationType.Procedure && !TypeNames.TryGetValue(funcValueType, out asTypeName)) { if (funcValueType == VarEnum.VT_PTR) { try { var asTypeDesc = (TYPEDESC)Marshal.PtrToStructure(memberDescriptor.elemdescFunc.tdesc.lpValue, typeof(TYPEDESC)); asTypeName = GetTypeName(asTypeDesc, info); } catch { asTypeName = funcValueType.ToString(); //TypeNames[VarEnum.VT_VARIANT]; } } else { asTypeName = funcValueType.ToString(); //TypeNames[VarEnum.VT_VARIANT]; } } var attributes = new Attributes(); if (memberName == "_NewEnum" && ((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FNONBROWSABLE)) { attributes.AddEnumeratorMemberAttribute(memberName); } else if (memberDescriptor.memid == 0) { attributes.AddDefaultMemberAttribute(memberName); //Debug.WriteLine("Default member found: {0}.{1} ({2} / {3})", moduleDeclaration.IdentifierName, memberName, memberDeclarationType, (VarEnum)memberDescriptor.elemdescFunc.tdesc.vt); } else if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN)) { attributes.AddHiddenMemberAttribute(memberName); } return(new Declaration(new QualifiedMemberName(typeQualifiedModuleName, memberName), moduleDeclaration, moduleDeclaration, asTypeName, false, false, Accessibility.Global, memberDeclarationType, null, Selection.Home, true, null, attributes)); }