genStub.tcl erroneusly parses function declaration
Closed / Wont Fix1471633fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2006-04-17 08:50:03
In procedure genStubs::parseDecl the first regular expression ^(.*)\((.*)\)$ should be replaced with either ^([^(]*)\((.*)\)$ or ^(.*?)\((.*)\)$, otherwise procedure declarations such as int privKey_create(pthread_key_t *key, void (*destr_function) (void *) are erroneously broken into prefix and args. József Németh NJG on wiki.tcl.tk
dkfplain2006-04-17 20:59:04
Logged In: YES
user_id=79902
I don't quite understand the exact problem yet (your example
isn't quite complete as far as I can see) but it is
recommended (i.e. all Tcl APIs work this way) that all API
functions that take a function pointer typed argument should
name that type in their main header file, like this:
typedef void (*FreeFuncPtr)(void *ptr);
with that, you'd be parsing a declaration like this instead:
void *privKey_create(
pthread_key_t *key,
FreeFuncPtr destr_function);
Which should be perfectly OK from the stub generator's PoV.
This applies doubly when the function parameter takes
multiple arguments, of course...
Workaround exists; lowering priority.
dgpplain2006-04-17 23:38:15
Logged In: YES user_id=80530 jenglish has done the most work adapting genStubs utilities to work on source code other than Tcl and Tk.
jenglishplain2006-04-18 12:51:00
Logged In: YES user_id=68433 Agree with dkf's assessment -- genStubs.tcl isn't intended to parse arbitrary C function declarations, only a restricted subset of the syntax is supported. It's always possible to rewrite declarations in a form acceptable to genStubs.tcl by introducing intermediate typedefs (which is good style anyway...) [ As an aside: if you're generating a stubs table for your own extension, you might want to look at Tile's modified version of genStubs.tcl, in tile/tools/genStubs.tcl. This attempts to address some of the historical problems encountered with the core stubs tables. ]
dkf Ticket [1471633fff]: 1 change
[History diff]2006-04-18 15:01:15
Log in (anonymous is fine) to add a comment.