Esempio n. 1
0
 protected ComBase(IComBase parent, ITypeInfo info)
 {
     Parent = parent;
     info.GetContainingTypeLib(out ITypeLib typeLib, out int index);
     Index = index;
     Debug.Assert(typeLib != null);
     Documentation = new ComDocumentation(typeLib, index);
 }
Esempio n. 2
0
        public ComAlias(ITypeLib typeLib, ITypeInfo info, int index, TYPEATTR attributes) : base(typeLib, index)
        {
            Index         = index;
            Documentation = new ComDocumentation(typeLib, index);
            Guid          = attributes.guid;
            IsHidden      = attributes.wTypeFlags.HasFlag(TYPEFLAGS.TYPEFLAG_FHIDDEN);
            IsRestricted  = attributes.wTypeFlags.HasFlag(TYPEFLAGS.TYPEFLAG_FRESTRICTED);

            if (Name.Equals("LONG_PTR"))
            {
                TypeName = "LongPtr";
                return;
            }

            var aliased = new ComParameter(attributes, info);

            TypeName = aliased.TypeName;
        }
Esempio n. 3
0
        private void GetParameterType(TYPEDESC desc, ITypeInfo info)
        {
            var      vt = (VarEnum)desc.vt;
            TYPEDESC tdesc;

            if (vt == VarEnum.VT_PTR)
            {
                tdesc = Marshal.PtrToStructure <TYPEDESC>(desc.lpValue);
                GetParameterType(tdesc, info);
                IsByRef = true;
            }
            else if (vt == VarEnum.VT_USERDEFINED)
            {
                int href;
                unchecked
                {
                    href = (int)(desc.lpValue.ToInt64() & 0xFFFFFFFF);
                }

                try
                {
                    info.GetRefTypeInfo(href, out ITypeInfo refTypeInfo);
                    refTypeInfo.GetTypeAttr(out IntPtr attribPtr);
                    using (DisposalActionContainer.Create(attribPtr, refTypeInfo.ReleaseTypeAttr))
                    {
                        var attribs = Marshal.PtrToStructure <TYPEATTR>(attribPtr);
                        var type    = new ComDocumentation(refTypeInfo, ComDocumentation.LibraryIndex).Name;
                        if (attribs.typekind == TYPEKIND.TKIND_ENUM)
                        {
                            _typeName = new ComTypeName(Project, type, attribs.guid, Guid.Empty);
                        }
                        else if (attribs.typekind == TYPEKIND.TKIND_ALIAS)
                        {
                            _typeName = new ComTypeName(Project, type, Guid.Empty, attribs.guid);
                        }
                        else
                        {
                            _typeName = new ComTypeName(Project, type);
                        }
                    }
                }
                catch (COMException)
                {
                    _typeName = new ComTypeName(Project, Tokens.Object);
                }
            }
            else if (vt == VarEnum.VT_SAFEARRAY || vt == VarEnum.VT_CARRAY || vt.HasFlag(VarEnum.VT_ARRAY))
            {
                tdesc = Marshal.PtrToStructure <TYPEDESC>(desc.lpValue);
                GetParameterType(tdesc, info);
                IsArray = true;
            }
            else if (vt == VarEnum.VT_HRESULT)
            {
                _typeName = new ComTypeName(Project, Tokens.Long);
            }
            else
            {
                _typeName = new ComTypeName(Project, (ComVariant.TypeNames.TryGetValue(vt, out string result)) ? result : Tokens.Object);
            }
        }
Esempio n. 4
0
 protected ComBase(ITypeInfo info, FUNCDESC funcDesc)
 {
     Index         = funcDesc.memid;
     Documentation = new ComDocumentation(info, funcDesc.memid);
 }
Esempio n. 5
0
 protected ComBase(ITypeLib typeLib, int index)
 {
     Index         = index;
     Documentation = new ComDocumentation(typeLib, index);
 }
Esempio n. 6
0
 protected ComBase(IComBase parent, ITypeInfo info, FUNCDESC funcDesc)
 {
     Parent        = parent;
     Index         = funcDesc.memid;
     Documentation = new ComDocumentation(info, funcDesc.memid);
 }
Esempio n. 7
0
 protected ComBase(IComBase parent, ITypeLib typeLib, int index)
 {
     Parent        = parent;
     Index         = index;
     Documentation = new ComDocumentation(typeLib, index);
 }