Downloads
Wiki
Build CodeLite
Devs
|
Main /
MacrosHandling101On this page... (hide) GeneralFirst let me begin by saying that codelite does not parse macros, nor it does not attempt to resolve them. So... what DOES codelite do? codelite manages an internal 'Token' replacement table which helps it during the parsing stage to perform simple string replacements. The 'Token' replacement table is accessible from the main menu: Note that codelite's default installation comes with a populated 'Token' table which manages most of the commonly used macros in the STL, wxWidgets and QT. Also, each time you add / remove entries to this table you need to re-tag your workspace (full) from the main menu: Various types of token entriesType 1: X=Y entryLets say that you have the following code snippet: CLASS myClass { public: void foo(){}; }; The example above uses This can be easily fixed by adding the following entry to the 'Token' table: CLASS=class Type 2: Ignore entryMany APIs are using functions / class decorators which can also confuse the parser, take for example the following code: class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl; By parsing the above line, codelite will mistakenly count wxRichTextCtrl as a variable of type WXDLLIMPEXP_FWD_RICHTEXT By adding this entry to the 'Tokens' table codelite knows that whenever it "sees" this token, he can safely ignore it so it will actually sees the above code snippt like this class wxRichTextCtrl; Which can be parsed easily by the parser. Type 3: Complex replacement macros (since codelite revision 4080)Some macros are too complex and can not be resolved by using the simple X=Y or the 'ignore' entries. These kind of macros require the third type of macros: complex macros An example: Most of the Python C API methods looks like this: PyAPI_FUNC(void*) PySomeFunctionName(PyObject*); By reading it we know that the API is: void* PySomeFunctionName(PyObject*); The problem is that codelite does not know that... We could use the naive solution of adding an X=Y entry like this: PyAPI_FUNC(void*)=void* But there are many variations in the code for the PyAPI_FUNC with different types, like: PyAPI_FUNC(PyObject*), PyAPI_FUNC(int) etc. What we need is a search pattern that will match ALL the variations of PyAPI_FUNC: PyAPI_FUNC(%0)=%0 In the above example
A more complex example: wxWidgets uses the following macro: #define wxConstCast(t, x) const_cast<t>(x) Simply add the following entry: wxConstCast(%0, %1)=const_cast<%0>(%1) to fix this |