3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
14 * The maximum number of sub-expressions that may appear in a single struct
17 const int typeInfoMaxExpr
= 5;
22 TypeInfo(const QString
& displayString
);
26 * The number of sub-expressions that need to be evaluated to get the
31 * This array contains the various parts which glue together the
32 * sub-expressions. The entries in this array are the parts that appear
33 * between the percent signs '%' of the display expression; hence,
34 * there is one part more than there are sub-expressions.
36 QString m_displayString
[typeInfoMaxExpr
+1];
38 * This is a list of partial expressions. Each contains exactly one %s,
39 * which will be replaced by the parent expression. The results are
40 * substituted for the percent signs in m_displayString.
42 QString m_exprStrings
[typeInfoMaxExpr
];
44 * This is a list of guard expressions. Each contains exactly one %s,
45 * which will be replaced by the parent expression, or is empty. If the
46 * evaluation of the resulting expression returns an error, the
47 * corresponding expression from m_exprStrings is not evaluated. (This
48 * is used to guard function calls.)
50 QString m_guardStrings
[typeInfoMaxExpr
];
52 * Gets a pointer to a TypeInfo that means: "I don't know the type"
54 static TypeInfo
* unknownType() { return &m_unknownType
; }
57 static TypeInfo m_unknownType
;
67 * Load all known type libraries.
69 static void initTypeLibraries();
72 * Copy type infos to the specified dictionary.
74 void copyTypes(QDict
<TypeInfo
>& dict
);
77 * Does the file name match this library?
79 bool matchFileName(const char* fileName
) {
80 return m_shlibNameRE
.match(fileName
) >= 0;
84 * Is the specified builtin feature enabled in this type library?
86 bool isEnabledBuiltin(const char* feature
);
90 * Loads the structure type information from the configuration files.
92 static void loadTypeTables();
93 void loadFromFile(const QString
& fileName
);
94 void readType(KConfigBase
& cf
, const char* type
);
95 QDict
<TypeInfo
> m_typeDict
;
96 QDict
<TypeInfo
> m_aliasDict
;
97 QString m_displayName
;
98 QRegExp m_shlibNameRE
;
99 QStrList m_enabledBuiltins
;
104 * This table keeps only references to the global type table. It is set up
107 class ProgramTypeTable
114 * Load types belonging to the specified libraries.
116 void loadLibTypes(const QStrList
& libs
);
119 * Load types belonging to the specified type table
121 void loadTypeTable(TypeTable
* table
);
124 * Clears that types and starts over (e.g. for a new program).
129 * Lookup a structure type.
131 * A type is looked up in the following manner:
133 * - If the type is unknown, 0 is returned.
135 * - If the type is known and it belongs to a shared library and that
136 * shared library was loaded, the type is returned such that isNew()
139 * - Otherwise the type is returned such that isNew() returns true.
141 TypeInfo
* lookup(const char* type
);
144 * Adds a new alias for a type name.
146 void registerAlias(const QString
& name
, TypeInfo
* type
);
149 * Tells whether we use built-in support to understand QStrings.
151 bool parseQt2QStrings() const { return m_parseQt2QStrings
; }
154 QDict
<TypeInfo
> m_types
;
155 QDict
<TypeInfo
> m_aliasDict
;
156 bool m_parseQt2QStrings
;