コード例 #1
0
        static string VarianttoManaged(VarTypeInfo v)
        {
            switch (v.VarType)
            {
            case TliVarType.VT_BOOL:
                return("bool");

            case TliVarType.VT_I1:
                return("sbyte");

            case TliVarType.VT_UI1:
                return("byte");

            case TliVarType.VT_I2:
                return("short");

            case TliVarType.VT_UI2:
                return("ushort");

            case TliVarType.VT_I4:
                return("int");

            case TliVarType.VT_UI4:
                return("uint");

            case TliVarType.VT_I8:
                return("long");

            case TliVarType.VT_UI8:
                return("ulong");

            case TliVarType.VT_R4:
                return("float");

            case TliVarType.VT_R8:
                return("double");

            case TliVarType.VT_DATE:
                return("DateTime");

            case TliVarType.VT_BSTR:
                return("string");

            case TliVarType.VT_VOID:
                return("Void");

            default:
                return("object");
            }
        }
コード例 #2
0
 private static void DetectMembers(TLIApplication typeLibApplication, string fileName, XmlDocument returnDocument, Members members)
 {
     foreach (MemberInfo itemMember in members)
     {
         VarTypeInfo typeInfo = itemMember.ReturnType;
         if ((typeInfo != null) && (true == typeInfo.IsExternalType))
         {
             XmlNode fileNode = null;
             foreach (XmlNode itemNode in returnDocument.FirstChild.ChildNodes)
             {
                 if (itemNode.Attributes["File"].InnerText == typeInfo.TypeLibInfoExternal.ContainingFile)
                 {
                     fileNode = itemNode;
                     break;
                 }
             }
             if (null == fileNode)
             {
                 fileNode = returnDocument.CreateElement("Component");
                 XmlAttribute attribute = returnDocument.CreateAttribute("File");
                 attribute.InnerText = typeInfo.TypeLibInfoExternal.ContainingFile;
                 fileNode.Attributes.Append(attribute);
                 attribute           = returnDocument.CreateAttribute("Name");
                 attribute.InnerText = typeInfo.TypeLibInfoExternal.Name;
                 fileNode.Attributes.Append(attribute);
                 returnDocument.FirstChild.AppendChild(fileNode);
                 AddDependencyComponentNode(fileNode, fileName);
                 DetectDependencies(typeLibApplication, typeInfo.TypeLibInfoExternal.ContainingFile, returnDocument);
             }
             else
             {
                 AddDependencyComponentNode(fileNode, fileName);
             }
         }
         if (null != typeInfo)
         {
             Marshal.ReleaseComObject(typeInfo);
         }
     }
 }
コード例 #3
0
        //unhandled values for VarType

        /*
         * VT_RESERVED	32768
         * VT_BYREF	16384
         * VT_CLSID	72
         * VT_CF	71
         * VT_BLOB_OBJECT	70
         * VT_STORED_OBJECT	69
         * VT_STREAMED_OBJECT	68
         * VT_STORAGE	67
         * VT_STREAM	66
         * VT_BLOB	65
         * VT_FILETIME	64
         * VT_RECORD	36
         * VT_USERDEFINED	29
         * VT_CARRAY	28
         * VT_SAFEARRAY	27
         * VT_PTR	26
         * VT_UNKNOWN	13
         * VT_ERROR	10
         * VT_NULL	1
         */

        private ITSType GetTypeName(VarTypeInfo vti, bool replaceVoidWithUndefined = false, bool isRest = false)
        {
            TSSimpleType ret;
            var          splitValues = vti.VarType.SplitValues();

            if (splitValues.SequenceEqual(new[] { VT_EMPTY }) && vti.TypeInfo.TypeKind == TKIND_ALIAS && !vti.IsExternalType)
            {
                splitValues = vti.TypeInfo.ResolvedType.VarType.SplitValues();
            }
            var isArray = splitValues.ContainsAny(VT_VECTOR, VT_ARRAY);

            if (splitValues.ContainsAny(VT_I1, VT_I2, VT_I4, VT_I8, VT_R4, VT_R8, VT_UI1, VT_UI2, VT_UI4, VT_UI8, VT_CY, VT_DECIMAL, VT_INT, VT_UINT))
            {
                ret = "number";
            }
            else if (splitValues.ContainsAny(VT_BSTR, VT_LPSTR, VT_LPWSTR))
            {
                ret = "string";
            }
            else if (splitValues.ContainsAny(VT_BOOL))
            {
                ret = "boolean";
            }
            else if (splitValues.ContainsAny(VT_VOID, VT_HRESULT))
            {
                ret = replaceVoidWithUndefined ? "undefined" : "void";
            }
            else if (splitValues.ContainsAny(VT_DATE))
            {
                ret = "VarDate";
            }
            else if (splitValues.ContainsAny(VT_EMPTY))
            {
                var ti = vti.TypeInfo;
                ret = $"{ti.Parent.Name}.{ti.Name}";
                if (vti.IsExternalType && ResolveExternal)
                {
                    AddTLI(vti.TypeLibInfoExternal, true);
                }
                interfaceToCoClassMapping.IfContainsKey(ret.FullName, val => ret = val.FirstOrDefault());
            }
            else if (splitValues.ContainsAny(VT_VARIANT, VT_DISPATCH, VT_UNKNOWN))
            {
                ret = "any";
            }
            else
            {
                ret = "any";
            }
            if (!isArray)
            {
                return(ret);
            }

            var safeArray = new TSGenericType()
            {
                Name = isRest ? "Array" : "SafeArray"
            };

            safeArray.Parameters.Add(ret);
            return(safeArray);
        }