For example, if the following was declared:
AL_FUNC(int, drawpixel, (int x,int y, int color));
Then the final format of the argument when the preprocessor execution is finished looks like:
int drawpixel (int x,int y, int color);
Unfortunately our "Replacement tokens" do not facilitate the arguments in question. Do you by any chance have a suggestion or idea how the CC could handle such Macro arguments?
Best regards,
Ok, I understand your request.
First, I would say the "macro replacement" is really hard for the current CC, because there is not preprocessor in the current design. Although someone else is designing a preprocessor or there are several preprocessors on the net, but using preprocessor in CC will rapidly *slow* down the performance.
What's it offered is the "replacement token" functionality. say, if you have these code
AL_FUNC(int, drawpixel, (int x,int y, int color));
Then you have a replacement token "AL_FUNC" --> "xxxxx", then these code will regard as
xxxxx(int, drawpixel, (int x,int y, int color));
This is done by the Tokenizer class, you can see some details in the wiki page:
http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#Return_a_correct_token.2C_Macro_replacementTill now, Nothing more, but seems this can't solve your problem.
Some days ago, I have write a post to suggest a more sophisticated replacement in Tokenizer. That is what I have seen from source code of CTAGES. In these code, they have a more complex replacement function. This is something like Ctags' replacement options "−I identifier−list". see:
http://ctags.sourceforge.net/ctags.html#OPERATIONAL%20DETAILSSo, you can define the replacement token map like below:
"AL_FUNC" --> "+xxxxx"
"AL_FUNC1" --> "-yyyyy"
"AL_FUNC2" --> "*zzzzz"
......
Note, the first character of the map value can give the different macro extension method. For example, the "minus sign" suggest remove some string in the next string.
Back to your problem, I think the best way to write a custom replacement method.
when Tokenizer meets AL_FUNC, it should first return the token "int", next "drawpixel" , then "(int x,int y, int color)", so the high level lexer should give the right token sequence, and recognize them as a function declaration.
Another way, you can manual replace the m_Buffer in Tokenizer class, and remove the "," in AL_FUNC(int
, drawpixel
, (int x,int y, int color)); but that's more tricky.
EditI have changed a lot in that wiki page:
http://wiki.codeblocks.org/index.php?title=Code_Completion_Design