Exemple #1
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            EnterElement();
            var tde = "typedef ";

            // If the enum has a uuid, or a version associate with it, we provide that information on the same line.
            if (_data.Attributes.Count > 0)
            {
                var lprops = _data.Attributes;
                if (_ta.guid == Guid.Empty)
                {
                    var rs = lprops.Where(p => p.StartsWith("uuid")).ToList();
                    foreach (var s in rs)
                    {
                        lprops.Remove(s);
                    }
                }
                tde += "[" + string.Join(",", lprops) + "]";
                ih.AppendLine(tde);
                tde = string.Empty;
            }

            ih.AppendLine(tde + "enum " + _data.ShortName + "{");
            using (new IDLHelperTab(ih))
            {
                var idx = 0;
                Children.ForEach(x => ((OWEnumValue)x).BuildIDLInto(ih, true, ++idx == _ta.cVars));
            }
            // Redundant but necessary to ensure MIDL will compile enum correctly without making up fake names that'll confuse object browsers
            ih.AppendLine("} " + _data.ShortName + ";");
            ExitElement();
        }
Exemple #2
0
        public void BuildIDLInto(IDLFormatter ih, bool embedded)
        {
            var memIdInSpecialRange = (_vd.memid >= 0x60000000 && _vd.memid < 0x60020000);
            var lprops = new List <string>();

            if (!memIdInSpecialRange)
            {
                lprops.Add("id(" + _vd.memid.PaddedHex() + ")");
            }
            var help = _ti.GetHelpDocumentationById(_vd.memid, out var context);

//            if (0 != (_vd.wFuncFlags & FuncDesc.FuncFlags.FUNCFLAG_FRESTRICTED)) lprops.Add("restricted");
//            if (0 != (_vd.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 = _vd.elemDescVar;

            ed.tdesc.ComTypeNameAsString(_ti, ih);
//            if (memIdInSpecialRange)
//            {
//                ih.AddString(" " + _fd.callconv.ToString().Substring(2).ToLower());
//            }
            ih.AppendLine(" " + _name + ";");
        }
Exemple #3
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 + " {");

            //if (_ta.cFuncs > 0 || _ta.cVars > 0)
            //{
            // Naughty, but rely on side effect of verifying children.
            using (new IDLHelperTab(ih))
            {
                _propChildren.BuildIDLInto(ih);
                _methodChildren.BuildIDLInto(ih);
            }
            //}
            ih.AppendLine("};");
            ExitElement();
        }
Exemple #4
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();
        }
Exemple #5
0
 public override void BuildIDLInto(IDLFormatter ih)
 {
     ih.AppendLine("typedef struct tag" + _name + " {");
     using (new IDLHelperTab(ih))
     {
         Children.ForEach(x => x.BuildIDLInto(ih));
     }
     ih.AppendLine("} " + _name + ";");
 }
Exemple #6
0
 public override void BuildIDLInto(IDLFormatter ih)
 {
     EnterElement();
     ih.AppendLine(_data.Name + " {");
     using (new IDLHelperTab(ih))
     {
         Children.ForEach(x => x.BuildIDLInto(ih));
     }
     ih.AppendLine("} " + _data.ShortName + ";");
     ExitElement();
 }
Exemple #7
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);
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FHIDDEN))
            {
                lprops.Add("hidden");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FDUAL))
            {
                lprops.Add("dual");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FRESTRICTED))
            {
                lprops.Add("restricted");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FNONEXTENSIBLE))
            {
                lprops.Add("nonextensible");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FOLEAUTOMATION))
            {
                lprops.Add("oleautomation");
            }
            for (var i = 0; i < lprops.Count; ++i)
            {
                ih.AppendLine("  " + lprops[i] + (i < (lprops.Count - 1) ? "," : ""));
            }
            ih.AppendLine("]");

            ih.AppendLine("dispinterface " + _name + " {");

            if (_ta.cFuncs > 0 || _ta.cVars > 0)
            {
                // Naughty, but rely on side effect of verifying children.
                using (new IDLHelperTab(ih))
                {
                    _propChildren?.BuildIDLInto(ih);
                    _methodChildren?.BuildIDLInto(ih);
                }
            }
            ih.AppendLine("};");
        }
Exemple #8
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            EnterElement();
            var lprops = _data.Attributes;

            if (lprops.Count > 0)
            {
                ih.AddString("[" + string.Join(", ", lprops.ToArray()) + "] ");
            }
            var attr = _ti.GetTypeAttr();

            if (TypeAttr.TypeFlags.TYPEFLAG_FDUAL != (attr.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FDUAL) &&
                TypeAttr.TypeKind.TKIND_DISPATCH == (attr.typekind & TypeAttr.TypeKind.TKIND_DISPATCH))
            {
                ih.AddString("dispinterface ");
                ih.AddLink(_data.ShortName, "di");
            }
            else
            {
                ih.AddString("interface ");
                ih.AddLink(_data.ShortName, "i");
            }
            ih.AppendLine(";");

            ExitElement();
        }
Exemple #9
0
        public void BuildIDLInto(IDLFormatter ih, bool embedded)
        {
            EnterElement();
            var lprops = _data.Attributes;

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

            ed.tdesc.ComTypeNameAsString(_ti, ih);
//            if (memIdInSpecialRange)
//            {
//                ih.AddString(" " + _fd.callconv.ToString().Substring(2).ToLower());
//            }
            ih.AppendLine(" " + _data.Name + ";");
            ExitElement();
        }
Exemple #10
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            EnterElement();
            var lprops = _data.Attributes;

            ih.AppendLine("typedef [" + string.Join(", ", lprops.ToArray()) + "] " + _data.ShortName + ";");
            ExitElement();
        }
Exemple #11
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            var meths = Children.Select(x => x as OWMethod).ToList();

            ih.AppendLine("methods:");
            if (meths.Count > 0)
            {
                using (new IDLHelperTab(ih)) meths.ForEach(x => x.BuildIDLInto(ih, true));
            }
        }
Exemple #12
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            var props = Children.ToList().ConvertAll(x => x as OWDispProperty);

            ih.AppendLine("properties:");
            if (props.Count > 0)
            {
                using (new IDLHelperTab(ih)) props.ForEach(x => x.BuildIDLInto(ih, true));
            }
        }
Exemple #13
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            var tde = "typedef ";

            // If the enum has a uuid, or a version associate with it, we provide that information on the same line.

            if (!_ta.guid.Equals(Guid.Empty))
            {
                tde += "[uuid(" + _ta.guid + "), version(" + _ta.wMajorVerNum + "." + _ta.wMinorVerNum + ")]";
                ih.AppendLine(tde);
                tde = "";
            }
            ih.AppendLine(tde + "enum {");
            using (new IDLHelperTab(ih))
            {
                var idx = 0;
                Children.ForEach(x => ((OWEnumValue)x).BuildIDLInto(ih, true, ++idx == _ta.cVars));
            }
            ih.AppendLine("} " + _name + ";");
        }
Exemple #14
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("]");

            if (_ta.cImplTypes > 0)
            {
                _ti.GetRefTypeOfImplType(0, out var href);
                _ti.GetRefTypeInfo(href, out var ti2);
                ih.AddString($"{_data.Name} : ");
                ih.AddLink(ti2.GetName(), "i");
                ih.AppendLine(" {");
            }
            else
            {
                ih.AppendLine("interface " + _data.Name + " {");
            }
            using (new IDLHelperTab(ih))
            {
                Children.ForEach(x => x.BuildIDLInto(ih));
            }
            ih.AppendLine("};");
            ExitElement();
        }
Exemple #15
0
        public void BuildIDLInto(IDLFormatter ih, bool embedded, bool islast)
        {
            var desc = "";

            //int cnt = 0;
            //String help = _ti.GetHelpDocumentationById(_idx, out cnt);
            //List<String> props = new List<string>();
            //AddHelpStringAndContext(props, help, cnt);
            //if (props.Count > 0)
            //{
            //    desc += "[" + String.Join(",", props.ToArray()) + "] ";
            //}
            desc += _val is int i?negStr(i) : _val.ToString();

            ih.AppendLine("const " + _name + " = " + desc + (embedded ? (islast ? "" : ",") : ";"));
        }
Exemple #16
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);
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FHIDDEN))
            {
                lprops.Add("hidden");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FDUAL))
            {
                lprops.Add("dual");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FRESTRICTED))
            {
                lprops.Add("restricted");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FNONEXTENSIBLE))
            {
                lprops.Add("nonextensible");
            }
            if (0 != (_ta.wTypeFlags & TypeAttr.TypeFlags.TYPEFLAG_FOLEAUTOMATION))
            {
                lprops.Add("oleautomation");
            }
            for (var i = 0; i < lprops.Count; ++i)
            {
                ih.AppendLine("  " + lprops[i] + (i < (lprops.Count - 1) ? "," : ""));
            }
            ih.AppendLine("]");

            if (_ta.cImplTypes > 0)
            {
                _ti.GetRefTypeOfImplType(0, out var href);
                _ti.GetRefTypeInfo(href, out var ti2);
                ih.AddString($"interface {_name} : ");
                ih.AddLink(ti2.GetName(), "i");
                ih.AppendLine(" {");
            }
            else
            {
                ih.AppendLine("interface " + _name + " {");
            }
            using (new IDLHelperTab(ih))
            {
                Children.ForEach(x => x.BuildIDLInto(ih));
            }
            ih.AppendLine("};");
        }
Exemple #17
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            if (_ta.cFuncs == 0)
            {
                ih.AppendLine("// NOTE: This module has no entry points. There is no way to");
                ih.AppendLine("//       extract the dllname of a module with no entry points!");
                ih.AppendLine("// ");
            }
            ih.AppendLine("[");
            var liba = new List <string>
            {
                "dllname(\"" + (string.IsNullOrEmpty(_dllname) ? "<no entry points>" : _dllname) + "\")"
            };

            if (_ta.guid != Guid.Empty)
            {
                liba.Add("uuid(" + _ta.guid + ")");
            }
            var help = _ti.GetHelpDocumentationById(-1, out var cnt);

            if (!string.IsNullOrEmpty(help))
            {
                liba.Add("helpstring(\"" + help + "\")");
            }
            if (cnt != 0)
            {
                liba.Add("helpcontext(" + cnt.PaddedHex() + ")");
            }

            cnt = 0;
            liba.ForEach(x => ih.AppendLine("  " + x + (++cnt == liba.Count ? "" : ",")));
            ih.AppendLine("]");
            ih.AppendLine("module " + _name + " {");
            using (new IDLHelperTab(ih))
            {
                Children.ForEach(x => x.BuildIDLInto(ih));
            }
            ih.AppendLine("};");
        }
Exemple #18
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            EnterElement();
            if (_ta.cFuncs == 0)
            {
                ih.AppendLine("// NOTE: This module has no entry points. There is no way to");
                ih.AppendLine("//       extract the dllname of a module with no entry points!");
                ih.AppendLine("// ");
            }
            ih.AppendLine("[");
            var liba = _data.Attributes;
            var cnt  = 0;

            liba.ForEach(x => ih.AppendLine("  " + x + (++cnt == liba.Count ? "" : ",")));
            ih.AppendLine("]");
            ih.AppendLine(_data.Name + " {");
            using (new IDLHelperTab(ih))
            {
                Children.ForEach(x => x.BuildIDLInto(ih));
            }
            ih.AppendLine("};");
            ExitElement();
        }
Exemple #19
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("};");
        }
Exemple #20
0
 public void BuildIDLInto(IDLFormatter ih, bool embedded, bool islast)
 {
     EnterElement();
     ih.AppendLine(_data.Name + (embedded ? (islast ? "" : ",") : ";"));
     ExitElement();
 }
Exemple #21
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;
            }
        }
Exemple #22
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            // Header for type library, followed by a first pass to pre-declare
            // interfaces.
            // dispinterfaces aren't shown seperately.

            EnterElement();

            ih.AppendLine("// Generated .IDL file (by OleWoo)");
            ih.AppendLine("[");

            var liba = _data.Attributes;
            var cnt  = 0;

            liba.ForEach(x => ih.AppendLine("  " + x + (++cnt == liba.Count ? "" : ",")));
            ih.AppendLine("]");
            ih.AppendLine("library " + _data.ShortName);
            ih.AppendLine("{");
            using (new IDLHelperTab(ih))
            {
                var lmd = new TypeLibMetadata();
                var l   = lmd.GetDependentLibraries(_tlib);
                foreach (var dl in l)
                {
                    var attr     = new TypeLibAttr(dl);
                    var hive     = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Default);
                    var libKey   = hive.OpenSubKey($"TypeLib\\{{{attr.guid}}}\\{attr.wMajorVerNum}.{attr.wMinorVerNum}");
                    var longName = libKey?.GetValue(null);
                    if (longName != null)
                    {
                        longName = string.Concat(", ", longName);
                    }
                    var tlbKey = libKey?.OpenSubKey($"{attr.lcid}\\win32") ?? libKey?.OpenSubKey($"{attr.lcid}\\win64");
                    var path   = tlbKey?.GetValue(null) as string;
                    ih.AppendLine($"// Tlib : {dl.GetName()}{longName} : {{{attr.guid}}}");
                    ih.AppendLine($"importlib(\"{path ?? dl.GetName()}\");");
                }
                ih.AppendLine(string.Empty);

                //Identify all interfaces & dispinterfaces to be listed
                var interfaceNames = Children.Aggregate <ITlibNode, ICollection <string> >(new HashSet <string>(),
                                                                                           (x, y) =>
                {
                    if ((y as OWInterface) != null)
                    {
                        x.Add(y.ShortName);
                    }
                    return(x);
                });

                // Forward declare all interfaces.
                ih.AppendLine("// Forward declare all types defined in this typelib");

                Children.FindAll(x => (x as OWCoClass) != null).ForEach(
                    x => ih.AppendLine(string.Concat(x.Name, ";"))
                    );

                /*
                 * Need to collect all dumpable interface names, in case we have dispinterfaces which don't have
                 * top level interfaces.  In THIS case, we'd dump the dispinterface.
                 */
                var fwdDeclarations = new Dictionary <string, string>();
                Children.FindAll(x =>
                                 (x as OWInterface) != null).ForEach(
                    x => fwdDeclarations.Add(x.ShortName, string.Concat(x.Name, ";"))
                    );
                Children.FindAll(x =>
                                 (x as OWDispInterface) != null).ForEach(
                    x =>
                {
                    if (!fwdDeclarations.ContainsKey(x.ShortName))
                    {
                        fwdDeclarations.Add(x.ShortName, string.Concat(x.Name, ";"));
                    }
                }
                    );
                foreach (var fwdDeclaration in fwdDeclarations)
                {
                    ih.AppendLine(fwdDeclaration.Value);
                }
                ih.AppendLine(string.Empty);
                Children.FindAll(x => (x as OWEnum) != null).ForEach(
                    x =>
                {
                    x.BuildIDLInto(ih);
                    ih.AppendLine(string.Empty);
                });
                ih.AppendLine(string.Empty);
                Children.FindAll(x => (x as OWRecord) != null).ForEach(x =>
                {
                    x.BuildIDLInto(ih);
                    ih.AppendLine(string.Empty);
                });

                Children.FindAll(x => x.DisplayAtTLBLevel(interfaceNames)).ForEach(
                    x =>
                {
                    x.BuildIDLInto(ih);
                    ih.AppendLine("");
                }
                    );
            }
            ih.AppendLine("};");

            ExitElement();
        }
Exemple #23
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();
        }
Exemple #24
0
        public override void BuildIDLInto(IDLFormatter ih)
        {
            // Header for type library, followed by a first pass to pre-declare
            // interfaces.
            // dispinterfaces aren't shown seperately.

            ih.AppendLine("// Generated .IDL file (by OleWoo)");
            ih.AppendLine("[");
            var liba = new List <string>();

            using (var tla = new TypeLibAttr(_tlib))
            {
                liba.Add($"uuid({tla.guid})");
                liba.Add($"version({tla.wMajorVerNum}.{tla.wMinorVerNum})");
            }
            var cds = new CustomDatas(_tlib as ITypeLib2);
            {
                foreach (var cd in cds.Items)
                {
                    liba.Add("custom(" + cd.guid + ", " + ITypeInfoXtra.QuoteString(cd.varValue) + ")");
                }
            }
            var help = _tlib.GetHelpDocumentation(out var cnt);

            if (!string.IsNullOrEmpty(help))
            {
                liba.Add($"helpstring(\"{help}\")");
            }
            if (cnt != 0)
            {
                liba.Add($"helpcontext({cnt.PaddedHex()})");
            }

            cnt = 0;
            liba.ForEach(x => ih.AppendLine("  " + x + (++cnt == liba.Count ? "" : ",")));
            ih.AppendLine("]");
            ih.AppendLine("library " + ShortName);
            ih.AppendLine("{");
            using (new IDLHelperTab(ih))
            {
                // How do I know I'm importing stdole2??!
                // Forward declare all interfaces.
                ih.AppendLine("// Forward declare all types defined in this typelib");

                /*
                 * Need to collect all dumpable interface names, in case we have dispinterfaces which don't have
                 * top level interfaces.  In THIS case, we'd dump the dispinterface.
                 */
                var interfaceNames = Children.Aggregate <ITlibNode, ICollection <string> >(new HashSet <string>(),
                                                                                           (x, y) =>
                {
                    if ((y as OWInterface) != null)
                    {
                        x.Add(y.ShortName);
                    }
                    return(x);
                });
                Children.FindAll(x => ((x as OWInterface) != null || (x as OWDispInterface) != null)).ForEach(
                    x => ih.AppendLine(x.Name)
                    );
                Children.FindAll(x => x.DisplayAtTLBLevel(interfaceNames)).ForEach(
                    x => { x.BuildIDLInto(ih); ih.AppendLine(""); }
                    );
            }
            ih.AppendLine("};");
        }
 public override void BuildIDLInto(IDLFormatter ih)
 {
     ih.AppendLine("");
 }
Exemple #26
0
 public override void BuildIDLInto(IDLFormatter ih)
 {
     ih.AppendLine("typedef [public] " + _name + ";");
 }
Exemple #27
0
 public override void BuildIDLInto(IDLFormatter ih)
 {
     EnterElement();
     ih.AppendLine("");
     ExitElement();
 }
Exemple #28
0
 public void BuildIDLInto(IDLFormatter ih, bool embedded, bool islast)
 {
     ih.AppendLine("const int " + _ti.GetDocumentationById(_vd.memid) + " = " + negStr(_val) + (embedded ? (islast ? "" : ",") : ";"));
 }