예제 #1
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            EnterElement();
            ih.AppendLine("[");
            var lprops = _data.Attributes;

            for (var i = 0; i < lprops.Count; ++i)
            {
                ih.AppendLine("  " + lprops[i] + (i < (lprops.Count - 1) ? "," : ""));
            }
            ih.AppendLine("]");
            ih.AppendLine(_data.Name + " {");
            using (new IDLHelperTab(ih))
            {
                for (var x = 0; x < _ta.cImplTypes; ++x)
                {
                    _ti.GetRefTypeOfImplType(x, out var href);
                    _ti.GetRefTypeInfo(href, out var ti2);
                    _ti.GetImplTypeFlags(x, out var itypflags);

                    var memInterface = new OWCoClassInterface(this, ti2, itypflags);
                    memInterface.BuildIDLInto(ih);
                }
            }
            ih.AppendLine("};");
            ExitElement();
        }
        private IEnumerable <string> GetImplementedInterfaceNames(TYPEATTR typeAttr, ITypeInfo info)
        {
            var output = new List <string>();

            for (var implIndex = 0; implIndex < typeAttr.cImplTypes; implIndex++)
            {
                int href;
                info.GetRefTypeOfImplType(implIndex, out href);

                ITypeInfo implTypeInfo;
                info.GetRefTypeInfo(href, out implTypeInfo);

                IntPtr typeAttributesPointer;
                implTypeInfo.GetTypeAttr(out typeAttributesPointer);

                var typeAttributes = (TYPEATTR)Marshal.PtrToStructure(typeAttributesPointer, typeof(TYPEATTR));

                IMPLTYPEFLAGS flags = 0;
                try
                {
                    info.GetImplTypeFlags(implIndex, out flags);
                }
                catch (COMException) { }

                var implTypeName = GetTypeName(implTypeInfo);
                if (implTypeName != "IDispatch" && implTypeName != "IUnknown")
                {
                    // skip IDispatch.. just about everything implements it and RD doesn't need to care about it; don't care about IUnknown either
                    output.Add(implTypeName);
                }

                if (flags != 0)
                {
                    ComInformation comInfo;
                    if (_comInformation.TryGetValue(typeAttributes.guid, out comInfo))
                    {
                        _comInformation[typeAttributes.guid].ImplTypeFlags =
                            _comInformation[typeAttributes.guid].ImplTypeFlags | flags;
                    }
                    else
                    {
                        _comInformation.Add(typeAttributes.guid,
                                            new ComInformation(typeAttributes, flags, implTypeInfo, implTypeName, new QualifiedModuleName(), null, 0));
                    }
                }

                info.ReleaseTypeAttr(typeAttributesPointer);
            }
            return(output);
        }
예제 #3
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            ih.AppendLine("[");
            var lprops = new List <string> {
                $"uuid({_ta.guid})"
            };
            var help = _ti.GetHelpDocumentationById(-1, out var context);

            AddHelpStringAndContext(lprops, help, context);
            for (var i = 0; i < lprops.Count; ++i)
            {
                ih.AppendLine("  " + lprops[i] + (i < (lprops.Count - 1) ? "," : ""));
            }
            ih.AppendLine("]");
            ih.AppendLine("coclass " + _name + " {");
            using (new IDLHelperTab(ih))
            {
                for (var x = 0; x < _ta.cImplTypes; ++x)
                {
                    _ti.GetRefTypeOfImplType(x, out var href);
                    _ti.GetRefTypeInfo(href, out var ti2);
                    _ti.GetImplTypeFlags(x, out var itypflags);
                    var res = new List <string>();
                    if (0 != (itypflags & IMPLTYPEFLAGS.IMPLTYPEFLAG_FDEFAULT))
                    {
                        res.Add("default");
                    }
                    if (0 != (itypflags & IMPLTYPEFLAGS.IMPLTYPEFLAG_FSOURCE))
                    {
                        res.Add("source");
                    }

                    if (res.Count > 0)
                    {
                        ih.AddString("[" + string.Join(", ", res.ToArray()) + "] ");
                    }
                    ih.AddString("interface ");
                    ih.AddLink(ti2.GetName(), "i");
                    ih.AppendLine(";");
                }
            }
            ih.AppendLine("};");
        }
예제 #4
0
        private void GetImplementedInterfaces(ITypeInfo info, TYPEATTR typeAttr)
        {
            for (var implIndex = 0; implIndex < typeAttr.cImplTypes; implIndex++)
            {
                info.GetRefTypeOfImplType(implIndex, out int href);
                info.GetRefTypeInfo(href, out ITypeInfo implemented);

                implemented.GetTypeAttr(out IntPtr attribPtr);
                using (DisposalActionContainer.Create(attribPtr, info.ReleaseTypeAttr))
                {
                    var attribs = Marshal.PtrToStructure <TYPEATTR>(attribPtr);

                    ComProject.KnownTypes.TryGetValue(attribs.guid, out ComType inherited);
                    var intface = inherited as ComInterface ?? new ComInterface(Project, implemented, attribs);

                    ComProject.KnownTypes.TryAdd(attribs.guid, intface);

                    IMPLTYPEFLAGS flags = 0;
                    try
                    {
                        info.GetImplTypeFlags(implIndex, out flags);
                    }
                    catch (COMException) { }

                    if (flags.HasFlag(IMPLTYPEFLAGS.IMPLTYPEFLAG_FSOURCE))
                    {
                        _events.Add(intface);
                    }
                    else
                    {
                        DefaultInterface = flags.HasFlag(IMPLTYPEFLAGS.IMPLTYPEFLAG_FDEFAULT) ? intface : DefaultInterface;
                    }
                    _interfaces.Add(intface, flags.HasFlag(IMPLTYPEFLAGS.IMPLTYPEFLAG_FRESTRICTED));
                }
            }

            if (DefaultInterface == null)
            {
                DefaultInterface = VisibleInterfaces.FirstOrDefault();
            }
        }
예제 #5
0
        private void GetImplementedInterfaces(ITypeInfo info, TYPEATTR typeAttr)
        {
            for (var implIndex = 0; implIndex < typeAttr.cImplTypes; implIndex++)
            {
                int href;
                info.GetRefTypeOfImplType(implIndex, out href);

                ITypeInfo implemented;
                info.GetRefTypeInfo(href, out implemented);

                IntPtr attribPtr;
                implemented.GetTypeAttr(out attribPtr);
                var attribs = (TYPEATTR)Marshal.PtrToStructure(attribPtr, typeof(TYPEATTR));

                ComType inherited;
                ComProject.KnownTypes.TryGetValue(attribs.guid, out inherited);
                var intface = inherited as ComInterface ?? new ComInterface(implemented, attribs);
                ComProject.KnownTypes.TryAdd(attribs.guid, intface);

                IMPLTYPEFLAGS flags = 0;
                try
                {
                    info.GetImplTypeFlags(implIndex, out flags);
                }
                catch (COMException) { }

                if (flags.HasFlag(IMPLTYPEFLAGS.IMPLTYPEFLAG_FSOURCE))
                {
                    _events.Add(intface);
                }
                else
                {
                    DefaultInterface = flags.HasFlag(IMPLTYPEFLAGS.IMPLTYPEFLAG_FDEFAULT) ? intface : DefaultInterface;
                }
                _interfaces.Add(intface, flags.HasFlag(IMPLTYPEFLAGS.IMPLTYPEFLAG_FRESTRICTED));
                info.ReleaseTypeAttr(attribPtr);
            }
        }