Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Is it possible for the parser to support newlib prototypes?
Huki:
Today I was about to submit my patch for function calltips, and coincidentally found this post. :) My patch adds calltips support for some complex macro functions, and variables of function pointer typedefs. Both are required to support the glew functions.
1) Advanced macro functions: supported cases,
- Preprocosser token defined to function name, macro name or variable of typedef'd function pointer.
- Nested cases of the above (defines and macro calls are expanded).
--- Code: ---void FUNC(...);
#define DEFINE FUNC
DEFINE( // show calltip for FUNC()
#define MACRO(..) ...
#define DEFINE MACRO
DEFINE( // show calltip for MACRO()
MACRO( // same
#define WRAPPER(_x) FUNC
#define DEFINE WRAPPER(x)
DEFINE( // show calltip for FUNC()
--- End code ---
2) Fixed the support for typedef'd function pointer (there was already some non-working code for it).
--- Code: ---typedef void (* t_pfnMyProc) (int a);
t_pfnMyProc myProc;
myProc( // show calltip
--- End code ---
Also combinations of 1) and 2) are supported (like your glew test code).
3) Some improvement and notes for GetMacroExpendedText() which is used for above features.
I'm attaching the patch file.
ollydbg:
I'm sleep now, will look into it tomorrow, thanks.
ollydbg:
I try to test this code with your patch:
--- Code: ---void my_f(int b);
void (*foo)(int a);
foo = &my_f;
foo(5);
--- End code ---
But I don't have tip info if the mouse hover on the "foo(5)".
Find declaration of "foo(5)" gives nothing.
Huki:
--- Quote from: ollydbg on September 06, 2014, 08:02:14 am ---I try to test this code with your patch:
--- Code: ---void my_f(int b);
void (*foo)(int a);
foo = &my_f;
foo(5);
--- End code ---
But I don't have tip info if the mouse hover on the "foo(5)".
Find declaration of "foo(5)" gives nothing.
--- End quote ---
I think normal function pointer variables parsing require another patch (I will send it next, but it requires some cleanup before). This patch supports typedef'd function pointers only (and it's a patch for function calltips, not tooltips).
Try this:
--- Code: ---void my_f(int b);
typedef void (*t_foo)(int a);
t_foo foo;
foo = my_f; // I think we should assign function directly, not &my_f
// EDIT: Ok, in fact both my_f and &my_f are correct...
foo( // shows calltip for void t_foo(int a)
--- End code ---
ollydbg:
Hi, Huki, thanks for the explanation, when testing and reviewing your patch, I see this comment which I'm not clear:
--- Code: --- // NOTE: ReplaceFunctionLikeMacro will recursively expand all defines and macro calls,
// but will not expand macro names, which is what we want
smallTokenizer.ReplaceFunctionLikeMacro(tk);
tk = tree->at(tree->TokenExists(smallTokenizer.GetToken(), -1, tkFunction|tkMacroDef|tkVariable));
if (tk && smallTokenizer.PeekToken().empty()) // only if the expanded result is a single token
token = tk;
--- End code ---
What does the "will not expand macro names" in comments means? as I see, ReplaceFunctionLikeMacro() did a full expansion until nothing is expanded.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version